

{"id":34,"date":"2024-05-09T10:35:18","date_gmt":"2024-05-09T10:35:18","guid":{"rendered":"https:\/\/test.uni-soft.in\/?page_id=34"},"modified":"2024-05-09T10:35:18","modified_gmt":"2024-05-09T10:35:18","slug":"test","status":"publish","type":"page","link":"https:\/\/test.uni-soft.in\/index.php\/test\/","title":{"rendered":"Test"},"content":{"rendered":"        <div class=\"wp-sjs-plugin\" id=\"surveyContainer-3\">\n            <div id=\"surveyElement-3\">Survey is loading&#8230;<\/div>\n            <div id=\"surveyResult-3\"><\/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: 3 },\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                    initSurvey3(json, theme);\n                }\n            });\n\n            function initSurvey3(json, theme) {\n                const survey3 = new Survey.Model(json);\n                if (!!theme) {\n                    survey3.applyTheme(theme);\n                }\n                window.survey3 = survey3;\n                survey3                    .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: '3', Json : JSON.stringify(result.data) },\n                            success: function (data) {}\n                        });\n                        \/\/document\n                        \/\/    .querySelector(\"#surveyResult-3\")\n                        \/\/    .innerHTML = \"result: \" + JSON.stringify(result.data);\n                    });\n\n                survey3.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                survey3.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-3\").Survey({model: survey3\/*, 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\/34"}],"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=34"}],"version-history":[{"count":1,"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/pages\/34\/revisions"}],"predecessor-version":[{"id":35,"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/pages\/34\/revisions\/35"}],"wp:attachment":[{"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/media?parent=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}