Path: ${filePathToSave}`; - } - else if(err.code == 'ENOENT'){ +// Download XML File +try { - errorMessage = `No Such File Directory.
Path: ${filePathToSave}`; - } - else{ - errorMessage = `Unknown Error.
Path: ${filePathToSave}`; - } - - Swal.fire({ - title: "File Download Failed", - html: errorMessage, - icon: "error" - }); - } else { - Swal.fire({ - title: "File Downloaded", - icon: "success" - }); - } + const content = fs.readFileSync(xmlFilePath, 'utf-8'); + console.log('xml', content); + fs.writeFileSync(filePathToSave, content, 'utf-8'); + Swal.fire({ + title: "File Downloaded", + icon: "success" }); +} catch (err) { + let errorMessage = ""; + if (err.code === 'EACCES') { + errorMessage = `Permission Denied.
Path: ${filePathToSave}`; + } else if (err.code === 'ENOENT') { + errorMessage = `No Such File Directory.
Path: ${filePathToSave}`; + } else { + errorMessage = `Unknown Error.
Path: ${filePathToSave}`; + } - //Download JSON FIle - - if(fileList !== false) - { - - fs.writeFile(jsonFilePathToSave, jsonFilePath, 'utf-8', (err) => { - - var errorMessage = ""; - if (err) { - console.log(err.code); - if(err.code == 'EACCES'){ - errorMessage = `Permission Denied.
Path: ${jsonFilePathToSave}`; - console.log(errorMessage); - } - else if(err.code == 'ENOENT'){ - errorMessage = `No Such File Directory.
Path: ${jsonFilePathToSave}`; - console.log(errorMessage); - } - else{ - errorMessage = `Unknown Error.
Path: ${jsonFilePathToSave}`; - console.log(errorMessage); - } - - Swal.fire({ - title: "File Download Failed", - html: errorMessage, - icon: "error" - }); - } else { - Swal.fire({ - title: "File Downloaded", - icon: "success" - }); - } + Swal.fire({ + title: "File Download Failed", + html: errorMessage, + icon: "error" }); - } +// Download JSON File +if (fileList !== false) { + try { + const content = fs.readFileSync(jsonFilePath, 'utf-8'); + console.log('json', content); + fs.writeFileSync(jsonFilePathToSave, content, 'utf-8'); + Swal.fire({ + title: "File Downloaded", + icon: "success" + }); + } catch (err) { + let errorMessage = ""; + if (err.code === 'EACCES') { + errorMessage = `Permission Denied.
Path: ${jsonFilePathToSave}`; + } else if (err.code === 'ENOENT') { + errorMessage = `No Such File Directory.
Path: ${jsonFilePathToSave}`; + } else { + errorMessage = `Unknown Error.
Path: ${jsonFilePathToSave}`; + } + + Swal.fire({ + title: "File Download Failed", + html: errorMessage, + icon: "error" + }); + } +} + + } } @@ -583,6 +582,30 @@ function findFile(filePath) { } } +function copyFile(sourceFilePath, destinationFilePath) { + // Resolve absolute paths + const sourcePath = path.resolve(sourceFilePath); + const destinationPath = path.resolve(destinationFilePath); + + // Read the content of the source file + fs.readFile(sourcePath, 'utf8', (err, data) => { + if (err) { + console.error(`Error reading file: ${err.message}`); + return; + } + + // Write the content to the destination file + fs.writeFile(destinationPath, data, 'utf8', (err) => { + if (err) { + console.error(`Error writing file: ${err.message}`); + return; + } + + console.log(`File copied from ${sourcePath} to ${destinationPath}`); + }); + }); +} + diff --git a/html2json.js b/html2json.js index 5ab33e6..b4b454b 100644 --- a/html2json.js +++ b/html2json.js @@ -303,6 +303,6 @@ function html2json() { // console.log((formData)); // console.log(JSON.stringify(formData, null, 1)); localStorage.setItem("json", JSON.stringify((formData))); - // console.log(JSON.stringify(formData)); + console.log(JSON.stringify(formData)); // console.log(OBJtoXML(({'question_paper' : formData}))); } diff --git a/index.js b/index.js index 0f2fcbc..fdfa7a8 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,11 @@ const path = require('path'); const fs = require('fs'); const xml2js = require('xml2js'); - - - document.addEventListener('DOMContentLoaded', async () => { + $("#overlay").show(); + + document.addEventListener('DOMContentLoaded', async () => { + function getFilesInFolder(folderName) { const xmlFilePath = path.join(__dirname, folderName); @@ -98,10 +99,11 @@ async function loadMultipleXMLs() { + // Call the function to load and display XML files loadMultipleXMLs(); - +$("#overlay").hide(); }); diff --git a/json2html.js b/json2html.js index fff23e4..c70669f 100644 --- a/json2html.js +++ b/json2html.js @@ -87,6 +87,8 @@ function jsonToHtml(jsonData) { }) localStorage.removeItem('scroll'); localStorage.removeItem('EditNavExpend'); + $("#overlay").hide(); + } @@ -112,6 +114,8 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){ var questionUUID = Question.attributes.Id; var questionDisplayMarks = Question.display_marks; var Choice = Question.answers; + var CorrectAnswer = Question.correct_answer; + var QuestionObj = { @@ -138,7 +142,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){ } else if (questionType == 'group') { - groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,questionId); + groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,questionId, CorrectAnswer); // groupQuestion(QuestionObj); Choice = Choice.slice(1); @@ -157,6 +161,8 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){ } + // $("#overlay").hide(); + } @@ -174,3 +180,4 @@ function generateGroupQuestion(Question, questionAreaId, questionRandomNo) QuestionsForEach(GroupQuestions, questionGroupAreaId, QuestionGroupRandomNo); }); } + diff --git a/json2xml.js b/json2xml.js index 253df6c..7177743 100644 --- a/json2xml.js +++ b/json2xml.js @@ -1,144 +1,6 @@ function json2xml() { // console.clear(); var obj = localStorage.getItem("json"); - - // var obj = `{ - // "question_paper_title": "
0
", - // "section_description": "1
", - // "question_description": "2
", - // "question_description": "3
", - // "question_description": "/g, '').replace(/<\/p>/g, ''); + return html.replace(/
/g, '').replace(/<\/p>/g, '').replace(/ tags
+ const paragraphs = doc.getElementsByTagName('p');
+ for (let i = paragraphs.length - 1; i >= 0; i--) {
+ const paragraph = paragraphs[i];
+ paragraph.parentNode.replaceChild(document.createTextNode(paragraph.textContent), paragraph);
+ }
+
+ // Remove tag
+ function removeTagsAndTruncate(html, maxLength) {
+
+ const doc = new DOMParser().parseFromString(html, 'text/html');
+
+ // Remove
tags
+ const images = doc.getElementsByTagName('img');
+ for (let i = images.length - 1; i >= 0; i--) {
+ const image = images[i];
+ image.parentNode.removeChild(image);
+ }
+
+ // Get the text content
+ const textContent = doc.body.textContent;
+
+ // Truncate the content
+ var truncatedContent = "";
+ if(textContent.length > 20)
+ {
+ truncatedContent = textContent.substring(0, maxLength) + '...';
+ }
+ else{
+ truncatedContent = textContent;
+ }
+
+ return truncatedContent;
+ }
+
function createTreeWithHeading(data, container) {
const treeTitle = removeParagraphTags(data.question_paper_title);
const heading = document.createElement('a');
@@ -419,11 +454,11 @@ function navpane() {
nodeDiv.style.paddingLeft='0px';
currentlyHighlightedElement =null
});
- if (nodeData.question.length > 20) {
- questionLink.innerHTML = removeParagraphTags(nodeData.question.substring(0, 20) + '...');
- } else {
- questionLink.innerHTML = removeParagraphTags(nodeData.question);
- }
+
+ questionLink.innerHTML = removeTagsAndTruncate(nodeData.question, 20);
+
+
+ // console.log('questionLink : ', questionLink)
nodeDiv.appendChild(questionLink);
} else if (nodeData.group_title) {
diff --git a/style.css b/style.css
index d0855b6..223bd81 100644
--- a/style.css
+++ b/style.css
@@ -3046,7 +3046,7 @@ a.main_sticky {
/*Loader*/
-.loader-wrapper {
+/* .loader-wrapper {
position: fixed;
top: 0;
bottom: 0;
@@ -3056,8 +3056,8 @@ a.main_sticky {
height: 100%;
transition: 0.8s 1s ease;
z-index: 666;
-}
-.loader {
+} */
+/* .loader {
position: relative;
display: block;
z-index: 201;
@@ -3104,10 +3104,10 @@ a.main_sticky {
-moz-animation: spin 2.5s linear infinite;
-o-animation: spin 2.5s linear infinite;
animation: spin 2.5s linear infinite;
-}
+} */
/* Here comes the Magic */
-@-webkit-keyframes spin {
+/* @-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
@@ -3150,38 +3150,36 @@ a.main_sticky {
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
-}
+} */
-.loader-wrapper .loder-section {
+/* .loader-wrapper .loder-section {
position: fixed;
top: 0;
width: 55%;
height: 100%;
background: #111;
z-index: 2;
-}
-.loader-wrapper .loder-section.left-section {
- left: 0;
- transition: 1s 1.5s ease;
-}
-.loader-wrapper .loder-section.right-section {
- right: 0;
- transition: 1s 1.5s ease;
-}
-
-/* When page loaded */
-.loaded .loder-section {
+} */
+/* .loader-wrapper .loder-section.left-section {
+ left: 0;
+ transition: 15s 2s ease;
+ }
+ .loader-wrapper .loder-section.right-section {
+ right: 0;
+ transition: 15s 2s ease;
+ }
+
+ When page loaded
+ .loaded .loader-wrapper {
display: none;
- transition: 1s 1.5s ease;
-}
-.loaded .loader-wrapper {
- display: none;
- transition: 1s 1.5s ease;
-}
-.loaded .loader {
+ transition: 10s 1.5s ease;
+ } */
+ /* .loaded .loader {
top: -100%;
opacity: 0;
-}
+ } */
+
+
/* New Add CSS Class */
@@ -3780,3 +3778,36 @@ width:85px;
font-weight: 500;
font-size: 14px;
}
+
+
+#overlay{
+ position: fixed;
+ top: 0;
+ z-index: 100;
+ width: 100%;
+ height:100%;
+ display: none;
+ background: rgba(0,0,0,0.8);
+ }
+ .cv-spinner {
+ height: 100%;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
+ .spinner {
+ width: 120px;
+ height: 120px;
+ border: 16px #ddd solid;
+ border-top: 16px #2e93e6 solid;
+ border-radius: 50%;
+ animation: sp-anime 0.8s infinite linear;
+ }
+ @keyframes sp-anime {
+ 100% {
+ transform: rotate(360deg);
+ }
+ }
+ .is-hide{
+ display:none;
+ }
\ No newline at end of file
diff --git a/xml2json.js b/xml2json.js
index bc18ccb..f878d51 100644
--- a/xml2json.js
+++ b/xml2json.js
@@ -4,7 +4,7 @@ function xml2json(xmlData) {
// console.log(xmlData);
var jsonDecodeData = localStorage.getItem('json_Decode_Data_For_Mcq_Crt_Ans');
-// console.log(typeof jsonDecodeData);
+console.log(jsonDecodeData);
function getAttributesOfXMLNode(node)
{