diff --git a/QuestionPaperPreview.js b/QuestionPaperPreview.js index 5088d15..f902673 100644 --- a/QuestionPaperPreview.js +++ b/QuestionPaperPreview.js @@ -2,6 +2,7 @@ function QuestionPaperPreview(jsonData){ // The provided JSON data // console.log(jsonData) + // start Remove

tag var jsonDat = jsonData; @@ -305,10 +306,25 @@ function QuestionPaperPreview(jsonData){ const formattedQuestionPaper = convertJSONToQuestionPaper(jsonData, 0, 1, 1); const questionPaperElement = document.getElementById("questionPaper"); questionPaperElement.innerHTML = formattedQuestionPaper; // Use innerHTML here + + $("#overlay").hide(); + } + + + + + + + + + + + + function removeHtmlTags(inputString) { const cheerio = require('cheerio'); diff --git a/QuestionPreview.html b/QuestionPreview.html index 3e3b302..467d945 100644 --- a/QuestionPreview.html +++ b/QuestionPreview.html @@ -98,7 +98,7 @@ text-wrap: wrap; /* display: inline-flex; */ /* flex-direction: column; */ - text-decoration: underline; + /* text-decoration: underline; */ /* justify-content: flex-start; */ position: relative; top: -27px; @@ -320,11 +320,17 @@ color: #1d3557 !important; -

+ + +
+
+ +
+
@@ -409,6 +415,7 @@ color: #1d3557 !important; - - - - - - - - - - - - - - - - - - - + + + + -
+ +
+
+ +
+
@@ -913,6 +902,7 @@ h1.title{ $('#messageInput_rtc').hide(); } else { $(mathField).hide(); + $(mathField).css('margin-bottom', '0'); $(richText).show(); $('#messageInput_rtc').hide(); @@ -1023,7 +1013,7 @@ h1.title{ }); } - +
@@ -1263,12 +1252,27 @@ h1.title{ - + + @@ -288,7 +298,7 @@ margin-left: -16px; - + @@ -445,6 +455,7 @@ function validateFile(input) { function downloadFile(filename) { const xmlFilePath = `${xmlPath}${filename}`; +console.log(xmlFilePath) const xmlFileNameParts = filename.split('.xml'); const xmlBaseName = xmlFileNameParts[0]; @@ -488,75 +499,63 @@ if(fileList !== false) console.log('isEncrypted NOT'); - //Download XML FIle - fs.writeFile(filePathToSave, xmlFilePath, 'utf-8', (err) => { - - var errorMessage = ""; - if (err) { - // console.log(err.code); - if(err.code == 'EACCES'){ - errorMessage = `Permission Denied.
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": "


", - // "question_paper_description": "


", - // "max_marks": "", - // "course_ID": "", - // "course_Code": "", - // "subject_ID": "", - // "subject_Code": "", - // "paper_No": "", - // "subject_Name": "", - // "sub_Paper_Prefix": "", - // "question_Paper_uuid": "f676ad21-b0d2-4a80-8c77-6cd2b35f1b34", - // "sections": [ - // { - // "section_title": "

0

", - // "section_description": "


", - // "section_marks": "0", - // "section_uuid": "7c62e594-3b93-444f-9fa6-a05f87869db6", - // "section_display_marks": true, - // "section_attempt_any": "", - // "questions": [ - // { - // "question": "

1

", - // "question_description": "


", - // "question_type": "group", - // "question_sub_type": false, - // "is_math_enabled": false, - // "display_marks": true, - // "marks": "", - // "choice_question_uuid": "40f37294-e7cb-4f19-9166-72f7a04f6391", - // "answers": [ - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "387d9b85-4702-4e77-a8c3-29d713b7689e", - // "no": "a" - // }, - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "1a6be686-9e7c-4b07-bf15-b9e07a01fd62", - // "no": "b" - // }, - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "0640c05b-522e-422c-8050-0d5982aa3c74", - // "no": "c" - // }, - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "e59f90b0-79d5-413e-85a4-ee3c181230d8", - // "no": "d" - // } - // ], - // "correct_answer": ["1a6be686-9e7c-4b07-bf15-b9e07a01fd62"] - // }, - // { - // "question": "

2

", - // "question_description": "


", - // "question_type": "group", - // "question_sub_type": false, - // "is_math_enabled": false, - // "display_marks": true, - // "marks": "", - // "choice_question_uuid": "7a1c83e7-e9ae-4424-9336-6135eaa6b833", - // "answers": [ - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "0cbb8330-8ce9-4d69-b547-68cee529a636", - // "no": "a" - // }, - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "25dc4fdc-7bcf-4bea-aaa5-dc42a22c08b5", - // "no": "b" - // }, - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "5b0da327-076f-488c-a46e-0b8251c83283", - // "no": "c" - // }, - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "d3934305-d6fd-4601-8b1b-08067f47a8dd", - // "no": "d" - // } - // ], - // "correct_answer": ["d3934305-d6fd-4601-8b1b-08067f47a8dd"] - // }, - // { - // "question": "

3

", - // "question_description": "


", - // "question_type": "group", - // "question_sub_type": false, - // "is_math_enabled": false, - // "display_marks": true, - // "marks": "", - // "choice_question_uuid": "6f929b53-9ebc-40fb-800e-46c42b75f2d9", - // "answers": [ - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "f839312c-8de5-4cd5-8d6c-3ffd3b9efea6", - // "no": "a" - // }, - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "905db769-82b2-4240-af06-fe0b15ee1f73", - // "no": "b" - // }, - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "6a16126f-8100-49f8-ae33-71d4848030cf", - // "no": "c" - // }, - // { - // "choice_name": "


", - // "is_math_enabled": false, - // "choice_uuid": "143f648a-d52c-42ff-9428-1c080326e1c8", - // "no": "d" - // } - // ], - // "correct_answer": ["143f648a-d52c-42ff-9428-1c080326e1c8", "6a16126f-8100-49f8-ae33-71d4848030cf"] - // } - // ] - // } - // ] - // } - // ` // console.log(obj); // console.log('***********************************************************'); diff --git a/nav_pane.js b/nav_pane.js index 675cce1..7039636 100644 --- a/nav_pane.js +++ b/nav_pane.js @@ -19,9 +19,44 @@ function navpane() { function removeParagraphTags(html) { - return html.replace(/

/g, '').replace(/<\/p>/g, ''); + return html.replace(/

/g, '').replace(/<\/p>/g, '').replace(//g, ''); } + //function for remove tag + function removeTagsAndTruncate(html, maxLength) { + + const doc = new DOMParser().parseFromString(html, 'text/html'); + + // Remove

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 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) {