dsg
INSERT INTO `cp_filejs` (`id`,`app`,`path`,`modul`,`file_name`,`content`) VALUES ('169','1','u2/creator','post','js/post-edit.js-','import {\r\n updatePost\r\n} from \\\"./api/posts.js\\\";\r\nimport app, {\r\n showToast\r\n} from \\\"./app.js\\\";\r\nimport store from \\\"./store.js\\\";\r\n\r\nvar $ = Dom7;\r\n\r\n$(document).on(\\\'page:beforein\\\', \\\'.page[data-name=\\\"post-edit\\\"]\\\', async function (e) {\r\n var posts = store.getters.myPosts.value\r\n var postId = e.detail.route.params.id\r\n\r\n if (!postId || postId == -1) {\r\n return;\r\n }\r\n\r\n console.log(posts);\r\n const post = posts.data.find(p => p.id == postId)\r\n\r\n $(\\\'#edit_post_id\\\').val(postId);\r\n $(\\\'#post_content\\\').val(post.caption);\r\n\r\n});\r\n\r\n$(document).on(\\\'click\\\', \\\'#update-post\\\', async function (e) {\r\n var view = app.views.current\r\n\r\n const description = $(\\\'#post_content\\\').val();\r\n const postId = $(\\\'#edit_post_id\\\').val();\r\n\r\n const data = {\r\n post_id: postId,\r\n caption: description\r\n }\r\n\r\n try {\r\n app.preloader.show()\r\n\r\n const response = await updatePost(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(\\\'Post updated 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(\\\'updatePost\\\', {\r\n post_id: postId,\r\n caption: description\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 update 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/js/post-edit.js-): Failed to open stream: No such file or directory in /home/u340524018/domains/agniaga.com/public_html/sub/u2/cp/inc.filejs.php on line 190
import {
    updatePost
} from \"./api/posts.js\";
import app, {
    showToast
} from \"./app.js\";
import store from \"./store.js\";

var $ = Dom7;

$(document).on(\'page:beforein\', \'.page[data-name=\"post-edit\"]\', async function (e) {
    var posts = store.getters.myPosts.value
    var postId = e.detail.route.params.id

    if (!postId || postId == -1) {
        return;
    }

    console.log(posts);
    const post = posts.data.find(p => p.id == postId)

    $(\'#edit_post_id\').val(postId);
    $(\'#post_content\').val(post.caption);

});

$(document).on(\'click\', \'#update-post\', async function (e) {
    var view = app.views.current

    const description = $(\'#post_content\').val();
    const postId = $(\'#edit_post_id\').val();

    const data = {
        post_id: postId,
        caption: description
    }

    try {
        app.preloader.show()

        const response = await updatePost(data)

        app.preloader.hide()

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

        showToast(\'Post updated 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(\'updatePost\', {
            post_id: postId,
            caption: description
        })

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