dsg
INSERT INTO `cp_filehtml` (`id`,`modul`,`app`,`path`,`type`,`cat`,`file_name`,`content`) VALUES ('458','post','1','u2/creator','0','js','post-add.js--','$(document).on(\\\\\\\'click\\\\\\\', \\\\\\\'#submit-add-post-form\\\\\\\', async function (e) {\r\n var view = app.views.current\r\n\r\n const form = $(\\\\\\\'form#addPostForm\\\\\\\')\r\n\r\n const cover_image = form.find(\\\\\\\'input[name=\\\\\\\"post_image\\\\\\\"]\\\\\\\').prop(\\\\\\\'files\\\\\\\')[0]\r\n const description = $(\\\\\\\'#post_caption\\\\\\\').val();\r\n\r\n if (!cover_image) {\r\n showToast(\\\\\\\'Please upload a cover image\\\\\\\')\r\n return\r\n }\r\n\r\n let base64 = null\r\n\r\n if (cover_image) {\r\n // Wrap the FileReader in a Promise to wait for it to complete\r\n base64 = 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 const data = {\r\n caption: description,\r\n cover_photo: base64\r\n }\r\n\r\n try {\r\n app.preloader.show()\r\n\r\n const response = await addPost(data)\r\n\r\n app.preloader.hide()\r\n\r\n if (!response || response.error) {\r\n throw new Error(response.error);\r\n }\r\n\r\n showToast(\\\\\\\'Add post successfully\\\\\\\')\r\n /*\r\n // fine elem with data-post-id=\\\\\\\"52\\\\\\\" and update the .media-post-description .post-caption text\r\n var postElem = $(`[data-post-id=\\\\\\\"${postId}\\\\\\\"]`).find(\\\\\\\'.media-post-description\\\\\\\')\r\n\r\n const maxDescriptionLength = 200; // Set your character limit here\r\n const isLongDescription = description.length > maxDescriptionLength;\r\n const shortDescription = isLongDescription ? description.slice(0, maxDescriptionLength) : description;\r\n\r\n // for each postElem, loop through and update the .post-caption and .full-description hidden input\r\n postElem.each(function () {\r\n var postCaption = $(this).find(\\\\\\\'.post-caption\\\\\\\');\r\n var fullDescription = $(this).find(\\\\\\\'.full-description\\\\\\\');\r\n\r\n postCaption.text(shortDescription);\r\n fullDescription.val(description);\r\n });\r\n\r\n store.dispatch(\\\\\\\'addPost\\\\\\\', {\r\n caption: description\r\n })\r\n */\r\n\r\n\r\n //store.dispatch(\\\\\\\'getMyPosts\\\\\\\')\r\n //app.dialog.alert(\\\\\\\'Post added successfully\\\\\\\')\r\n\r\n // redirect to garage\r\n view.router.back(`/post-view/${response.id}`, {\r\n force: true\r\n })\r\n\r\n //view.router.back()\r\n } catch (error) {\r\n app.notification.create({\r\n titleRightText: \\\\\\\'now\\\\\\\',\r\n subtitle: \\\\\\\'Oops, something went wrong\\\\\\\',\r\n text: error.message || \\\\\\\'Failed to add post\\\\\\\',\r\n }).open()\r\n app.preloader.hide()\r\n }\r\n})');
Copy This

Warning: file_get_contents(/home/u340524018/domains/agniaga.com/public_html/sub/u2/creator/post-add.js--): Failed to open stream: No such file or directory in /home/u340524018/domains/agniaga.com/public_html/sub/u2/cp/inc.filehtml.php on line 319
$(document).on(\\\'click\\\', \\\'#submit-add-post-form\\\', async function (e) {
  var view = app.views.current

  const form = $(\\\'form#addPostForm\\\')

    const cover_image = form.find(\\\'input[name=\\\"post_image\\\"]\\\').prop(\\\'files\\\')[0]
    const description = $(\\\'#post_caption\\\').val();

    if (!cover_image) {
      showToast(\\\'Please upload a cover image\\\')
      return
    }

    let base64 = null

    if (cover_image) {
      // Wrap the FileReader in a Promise to wait for it to complete
      base64 = await new Promise((resolve, reject) => {
        const reader = new FileReader()
        reader.readAsDataURL(cover_image)

        reader.onload = () => resolve(reader.result)
        reader.onerror = () => reject(new Error(\\\'Failed to read image as base64\\\'))
      })
    }

    const data = {
        caption: description,
        cover_photo: base64
    }

    try {
        app.preloader.show()

        const response = await addPost(data)

        app.preloader.hide()

        if (!response || response.error) {
            throw new Error(response.error);
        }

        showToast(\\\'Add post successfully\\\')
        /*
        // fine elem with data-post-id=\\\"52\\\" and update the .media-post-description .post-caption text
        var postElem = $(`[data-post-id=\\\"${postId}\\\"]`).find(\\\'.media-post-description\\\')

        const maxDescriptionLength = 200; // Set your character limit here
        const isLongDescription = description.length > maxDescriptionLength;
        const shortDescription = isLongDescription ? description.slice(0, maxDescriptionLength) : description;

        // for each postElem, loop through and update the .post-caption and .full-description hidden input
        postElem.each(function () {
            var postCaption = $(this).find(\\\'.post-caption\\\');
            var fullDescription = $(this).find(\\\'.full-description\\\');

            postCaption.text(shortDescription);
            fullDescription.val(description);
        });

        store.dispatch(\\\'addPost\\\', {
            caption: description
        })
        */


        //store.dispatch(\\\'getMyPosts\\\')
        //app.dialog.alert(\\\'Post  added successfully\\\')

        // redirect to garage
        view.router.back(`/post-view/${response.id}`, {
          force: true
        })

        //view.router.back()
    } catch (error) {
        app.notification.create({
            titleRightText: \\\'now\\\',
            subtitle: \\\'Oops, something went wrong\\\',
            text: error.message || \\\'Failed to add post\\\',
        }).open()
        app.preloader.hide()
    }
})
Array
(
)
Add JS Function Name