INSERT INTO `cp_filehtml` (`id`,`modul`,`app`,`path`,`type`,`cat`,`file_name`,`content`) VALUES ('353','profile','1','u2/creator','0','js','profile-edit.js-','$(document).on(\\\'click\\\', \\\'#save-profile-images\\\', async function () {\r\n var view = app.views.current\r\n\r\n const cover_image = $(\\\'input[name=\\\"cover_image\\\"]\\\').prop(\\\'files\\\')[0]\r\n const profile_image = $(\\\'input[name=\\\"profile_image\\\"]\\\').prop(\\\'files\\\')[0]\r\n\r\n\r\n let coverBase64 = null\r\n let profileBase64 = null\r\n\r\n if (cover_image) {\r\n // Wrap the FileReader in a Promise to wait for it to complete\r\n coverBase64 = await new Promise((resolve, reject) => {\r\n const reader = new FileReader()\r\n reader.readAsDataURL(cover_image)\r\n\r\n reader.onload = () => resolve(reader.result)\r\n reader.onerror = () => reject(new Error(\\\'Failed to read image as base64\\\'))\r\n })\r\n }\r\n\r\n if (profile_image) {\r\n // Wrap the FileReader in a Promise to wait for it to complete\r\n profileBase64 = await new Promise((resolve, reject) => {\r\n const reader = new FileReader()\r\n reader.readAsDataURL(profile_image)\r\n\r\n reader.onload = () => resolve(reader.result)\r\n reader.onerror = () => reject(new Error(\\\'Failed to read image as base64\\\'))\r\n })\r\n }\r\n\r\n if (!coverBase64 && !profileBase64) {\r\n return\r\n }\r\n\r\n try {\r\n app.preloader.show()\r\n\r\n let promises = []\r\n\r\n if (profileBase64) {\r\n promises.push(updateProfileImage(profileBase64))\r\n }\r\n\r\n if (coverBase64) {\r\n promises.push(updateCoverImage(coverBase64))\r\n }\r\n\r\n const responses = await Promise.all(promises)\r\n app.preloader.hide()\r\n\r\n if (responses.every(response => response && response.success)) {\r\n showToast(\\\'Images updated successfully\\\', \\\'Success\\\')\r\n view.router.navigate(\\\'/profile/\\\')\r\n\r\n store.dispatch(\\\'updateUserDetails\\\')\r\n return\r\n }\r\n\r\n if (responses.some(response => response && !response.success)) {\r\n throw new Error(\\\'Failed to update images\\\')\r\n }\r\n } catch (error) {\r\n app.preloader.hide()\r\n\r\n app.notification.create({\r\n titleRightText: \\\'now\\\',\r\n subtitle: \\\'Oops, something went wrong\\\',\r\n text: error.message || \\\'Failed to update images\\\',\r\n }).open()\r\n }\r\n})');
Add JS Function Name
profile
pages/profile-edit-images.html
pages/profile-edit-images.html
- $(document).on('click', '#save-profile-images'
- $(document).on('page:init', '.page[data-name="profile-edit-images"]'
- $(document).on('click', '.user-follow-btn'
- $(document).on('infinite', '.profile-landing-page.infinite-scroll-content.view-page'
- $(document).on('page:beforein', '.page[data-name="profile-view"]'
- $(document).on('page:init', '.page[data-name="profile-view"]'
- $(document).on('ptr:refresh', '.profile-landing-page.view-page.ptr-content'
- async function renderProfileData(cachedData, userId)
- function populateUsersPosts(data)
- store.getters.getUserPathUpdated.onUpdated