

{"id":9,"date":"2024-03-27T07:58:32","date_gmt":"2024-03-27T07:58:32","guid":{"rendered":"https:\/\/test.uni-soft.in\/?page_id=9"},"modified":"2024-03-27T07:58:32","modified_gmt":"2024-03-27T07:58:32","slug":"9-2","status":"publish","type":"page","link":"https:\/\/test.uni-soft.in\/index.php\/9-2\/","title":{"rendered":""},"content":{"rendered":"        <div class=\"wp-sjs-plugin\" id=\"surveyContainer-1\">\r\n            <div id=\"surveyElement-1\">Checklist is loading&#8230;<\/div>\r\n            <div id=\"surveyResult-1\"><\/div>\r\n        <\/div>\r\n\r\n        \r\n\r\n        <script>\r\n            \/\/console.log(themeJSON);\r\n            jQuery.ajax({\r\n                url:  \"https:\/\/test.uni-soft.in\/wp-admin\/admin-ajax.php?action=SurveyJS_GetSurveyJson\",\r\n                type: \"POST\",\r\n                data: { Id: 1 },\r\n                success: function (data) {\r\n                    var json = {}\r\n                    let theme;\r\n                    if (data.json) {\r\n                        json = JSON.parse(data.json.replace(\/\\\\\\\"\/g, \"\\\"\").replace(\/\\\\\\\\\/g, \"\\\\\").replace(\/\\\\'\/g, \"'\"));\r\n                    }\r\n                    if (data.theme) {\r\n                        theme = JSON.parse(data.theme.replace(\/\\\\\\\"\/g, \"\\\"\").replace(\/\\\\\\\\\/g, \"\\\\\").replace(\/\\\\'\/g, \"'\"));\r\n                    } else {\r\n                        theme = null\r\n                    }\r\n                    initSurvey1(json, theme);\r\n                }\r\n            });\r\n\r\n            function initSurvey1(json, theme) {\r\n                const survey1 = new Survey.Model(json);\r\n                if (!!theme) {\r\n                    survey1.applyTheme(themeJSON);\r\n                    \/\/console.log(themeJSON);\r\n                    \/\/survey1.applyTheme(theme);\r\n                \r\n                }\r\n                window.survey1 = survey1;\r\n                survey1                    .onComplete\r\n                    .add(function (result) {\r\n                        jQuery.ajax({\r\n                            url:  \"https:\/\/test.uni-soft.in\/wp-admin\/admin-ajax.php?action=SurveyJS_SaveResult\",\r\n                            type: \"POST\",\r\n                            data: { SurveyId: '1', Json : JSON.stringify(result.data), variantid : '', serialid : '',dept : '',line : '', station : '' },\r\n                            success: function (data) {}\r\n                        });\r\n                        \r\n                        \r\n                        document.location = \"https:\/\/test.uni-soft.in\/wp-admin\/admin.php?page=enter_scan_data&dept=&line=&station=\";\r\n                        \/\/document\r\n                        \/\/    .querySelector(\"#surveyResult-1\")\r\n                        \/\/    .innerHTML = \"result: \" + JSON.stringify(result.data);\r\n                    });\r\n\r\n   \r\n\r\n\r\n\r\n                survey1.onUploadFiles.add((_, options) => {\r\n                    const formData = new FormData();\r\n                    options.files.forEach((file) => {\r\n                        formData.append(file.name, file);\r\n                    });\r\n\r\n                    fetch(\"https:\/\/test.uni-soft.in\/wp-admin\/admin-ajax.php?action=SurveyJS_UploadFiles\", {\r\n                        method: \"POST\",\r\n                        body: formData\r\n                    })\r\n                        .then((response) => response.json())\r\n                        .then((data) => {\r\n                            options.callback(\r\n                                options.files.map((file) => {\r\n                                    return {\r\n                                        file: file,\r\n                                        content: data[file.name]\r\n                                    };\r\n                                })\r\n                            );\r\n                        })\r\n                        .catch((error) => {\r\n                            console.error(\"Error: \", error);\r\n                            options.callback([], [ 'An error occurred during file upload.' ]);\r\n                        });\r\n                });\r\n\r\n                function deleteFile(fileURL, options) {\r\n                    try {\r\n                        const apiUrl = `https:\/\/test.uni-soft.in\/wp-admin\/admin-ajax.php?action=SurveyJS_DeleteFile&name=${fileURL}`;\r\n                        fetch(apiUrl);\r\n                    } catch (error) {\r\n                        options.callback(\"error\");\r\n                    }\r\n                }\r\n\r\n                survey1.onClearFiles.add((_, options) => {\r\n                    if (!options.value || options.value.length === 0) {\r\n                        options.callback(\"success\");\r\n                        return;\r\n                    }\r\n\r\n                    if (!options.fileName && !!options.value) {\r\n                        for (const item of options.value) {\r\n                            deleteFile(item.content, options);\r\n                        }\r\n                    } else {\r\n                        const fileToRemove = options.value.find(\r\n                            (item) => item.name === options.fileName\r\n                        );\r\n                        if (fileToRemove) {\r\n                            deleteFile(fileToRemove.content, options);\r\n                        } else {\r\n                            console.error(`File with name ${options.fileName} is not found`);\r\n                        }\r\n                    }\r\n                    options.callback(\"success\");\r\n                });\r\n\r\n                jQuery(\"#surveyElement-1\").Survey({model: survey1\/*, css: customCss*\/});\r\n            }\r\n        <\/script>        \r\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\/9"}],"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=9"}],"version-history":[{"count":1,"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/pages\/9\/revisions"}],"predecessor-version":[{"id":10,"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/pages\/9\/revisions\/10"}],"wp:attachment":[{"href":"https:\/\/test.uni-soft.in\/index.php\/wp-json\/wp\/v2\/media?parent=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}