

{"id":5,"date":"2024-01-08T16:33:20","date_gmt":"2024-01-08T16:33:20","guid":{"rendered":"https:\/\/test.uni-soft.in\/?page_id=5"},"modified":"2024-08-24T07:24:06","modified_gmt":"2024-08-24T07:24:06","slug":"testimage","status":"publish","type":"page","link":"https:\/\/test.uni-soft.in\/index.php\/testimage\/","title":{"rendered":"testImage"},"content":{"rendered":"        <div class=\"wp-sjs-plugin\" id=\"surveyContainer-4\">\n            <div id=\"surveyElement-4\">Survey is loading&#8230;<\/div>\n            <div id=\"surveyResult-4\"><\/div>\n        <\/div>\n        <script>\n            jQuery.ajax({\n                url:  \"https:\/\/test.uni-soft.in\/wp-admin\/admin-ajax.php?action=SurveyJS_GetSurveyJson\",\n                type: \"POST\",\n                data: { Id: 4 },\n                success: function (data) {\n                    var json = {}\n                    let theme;\n                    if (data.json) {\n                        json = JSON.parse(data.json.replace(\/\\\\\\\"\/g, \"\\\"\").replace(\/\\\\\\\\\/g, \"\\\\\").replace(\/\\\\'\/g, \"'\"));\n                    }\n                    if (data.theme) {\n                        theme = JSON.parse(data.theme.replace(\/\\\\\\\"\/g, \"\\\"\").replace(\/\\\\\\\\\/g, \"\\\\\").replace(\/\\\\'\/g, \"'\"));\n                    } else {\n                        theme = null\n                    }\n                    initSurvey4(json, theme);\n                }\n            });\n\n            function initSurvey4(json, theme) {\n                const survey4 = new Survey.Model(json);\n                if (!!theme) {\n                    survey4.applyTheme(theme);\n                }\n                window.survey4 = survey4;\n                survey4                    .onComplete\n                    .add(function (result) {\n                        jQuery.ajax({\n                            url:  \"https:\/\/test.uni-soft.in\/wp-admin\/admin-ajax.php?action=SurveyJS_SaveResult\",\n                            type: \"POST\",\n                            data: { SurveyId: '4', Json : JSON.stringify(result.data) },\n                            success: function (data) {}\n                        });\n                        \/\/document\n                        \/\/    .querySelector(\"#surveyResult-4\")\n                        \/\/    .innerHTML = \"result: \" + JSON.stringify(result.data);\n                    });\n\n                survey4.onUploadFiles.add((_, options) => {\n                    const formData = new FormData();\n                    options.files.forEach((file) => {\n                        formData.append(file.name, file);\n                    });\n\n                    fetch(\"https:\/\/test.uni-soft.in\/wp-admin\/admin-ajax.php?action=SurveyJS_UploadFiles\", {\n                        method: \"POST\",\n                        body: formData\n                    })\n                        .then((response) => response.json())\n                        .then((data) => {\n                            options.callback(\n                                options.files.map((file) => {\n                                    return {\n                                        file: file,\n                                        content: data[file.name]\n                                    };\n                                })\n                            );\n                        })\n                        .catch((error) => {\n                            console.error(\"Error: \", error);\n                            options.callback([], [ 'An error occurred during file upload.' ]);\n                        });\n                });\n\n                function deleteFile(fileURL, options) {\n                    try {\n                        const apiUrl = `https:\/\/test.uni-soft.in\/wp-admin\/admin-ajax.php?action=SurveyJS_DeleteFile&name=${fileURL}`;\n                        fetch(apiUrl);\n                    } catch (error) {\n                        options.callback(\"error\");\n                    }\n                }\n\n                survey4.onClearFiles.add((_, options) => {\n                    if (!options.value || options.value.length === 0) {\n                        options.callback(\"success\");\n                        return;\n                    }\n\n                    if (!options.fileName && !!options.value) {\n                        for (const item of options.value) {\n                            deleteFile(item.content, options);\n                        }\n                    } else {\n                        const fileToRemove = options.value.find(\n                            (item) => item.name === options.fileName\n                        );\n                        if (fileToRemove) {\n                            deleteFile(fileToRemove.content, options);\n                        } else {\n                            console.error(`File with name ${options.fileName} is not found`);\n                        }\n                    }\n                    options.callback(\"success\");\n                });\n\n                jQuery(\"#surveyElement-4\").Survey({model: survey4\/*, css: customCss*\/});\n            }\n        <\/script>        \n        ","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/pages\/5"}],"collection":[{"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/comments?post=5"}],"version-history":[{"count":2,"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/pages\/5\/revisions"}],"predecessor-version":[{"id":46,"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/pages\/5\/revisions\/46"}],"wp:attachment":[{"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/media?parent=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}