From 69bc96d7db3ba1b1e1a6e8f1278ee61266ea5bd9 Mon Sep 17 00:00:00 2001 From: aadhavan Date: Tue, 12 Dec 2023 13:01:25 +0530 Subject: [PATCH] SERIALNOCHECK : AADHAVAN --- addform.html | 155 ++++++++++++++++++++++++++++----------------------- decode.js | 4 +- encode.js | 9 ++- xml2json.js | 20 +++---- 4 files changed, 104 insertions(+), 84 deletions(-) diff --git a/addform.html b/addform.html index f2af17f..15d5f08 100644 --- a/addform.html +++ b/addform.html @@ -4,7 +4,7 @@ - Project-B + Project- @@ -1513,7 +1513,6 @@ var previewbutton = document.getElementById("editPreview"); } if (FileName) { - console.log("if"); const saveButton = document.getElementById('SaveButton'); if (saveButton) { // if (count != 0) { @@ -1526,7 +1525,6 @@ var previewbutton = document.getElementById("editPreview"); // }); // } saveButton.click(); - console.log(saveButton); if (count == 0) { setTimeout(function() { var popupInput = document.getElementById("swal2-input"); @@ -1539,7 +1537,6 @@ var previewbutton = document.getElementById("editPreview"); if (anchorElement) { anchorElement.click(); saveButton.click(); - console.log("ghj"); } } }); @@ -1638,7 +1635,7 @@ function loadXML(xmlFileName) { } else{ jsonDecodeData = data; localStorage.setItem('json_Decode_Data_For_Mcq_Crt_Ans', jsonDecodeData); - console.log('jsonDecodeData', jsonDecodeData); + // console.log('jsonDecodeData', jsonDecodeData); } @@ -1658,7 +1655,7 @@ function loadXML(xmlFileName) { } else{ decodeData = data; } - console.log('jsonDecodeData : ', jsonDecodeData); + // console.log('jsonDecodeData : ', jsonDecodeData); xml2json(decodeData); @@ -1671,8 +1668,8 @@ function loadXML(xmlFileName) { // Function for Save the XML File function saveFile(flag=0) { - console.log("flag = ", flag); - console.log("SaveFile"); + // console.log("flag = ", flag); + // console.log("SaveFile"); var title_id = localStorage.getItem('JSON_FOR_EMPTY_QUESTION'); var count = ""; @@ -1690,7 +1687,7 @@ function saveFile(flag=0) { if (count > 0) { check_Empty_Question() - console.log("check Empty"); + // console.log("check Empty"); } else { html2json(); json2xml(); @@ -2512,7 +2509,7 @@ function addQuestionGroup(idObj)
- +
${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.group_title : ""}
@@ -2978,7 +2975,7 @@ function groupQuestion(question_id = false, section_id = false , group_question_
- +
${questionTitle ? questionTitle : ''}
@@ -3797,7 +3794,7 @@ textQuestion +=
- +
${QuestionObj.hasOwnProperty('questionTitle') ? QuestionObj.questionTitle : ''}
@@ -4236,7 +4233,7 @@ function collect_Empty_Question_Id(arrayString, ID) { function check_Empty_Question() { - console.log("Check Empty Enter"); + // console.log("Check Empty Enter"); var title_id = localStorage.getItem('JSON_FOR_EMPTY_QUESTION'); if (title_id) { var parsedArray = JSON.parse(title_id); @@ -4245,7 +4242,8 @@ function check_Empty_Question() if (index === array.length - 1) { var idclass= document.getElementById(Id).className; - if ( idclass === 'QuestionTextIdSet' || idclass === 'QuestionsGroupIdset' || idclass === 'QuestionChoiceId' ) { + // console.log(idclass == "QuestionTextIdSet SerialNo"); + if ( idclass === 'QuestionTextIdSet SerialNo' || idclass === 'QuestionsGroupIdset' || idclass === 'QuestionChoiceId' ) { attrId = document.getElementById(Id).innerHTML }else if(idclass === 'multipleAnswerorNot'){ attrId =""; @@ -4256,17 +4254,17 @@ function check_Empty_Question() } if(attrId === '


') { - console.log("Check empty if"); + // console.log("Check empty if"); scrollToElementWithoutLink(Id); document.getElementById(Id).focus(); }else if(attrId == ''){ - console.log("Check empty else if"); + // console.log("Check empty else if"); scrollToElementWithoutLink(Id); document.getElementById(Id).focus(); } else{ - console.log("Check empty Last else"); + // console.log("Check empty Last else"); scrollToElementWithoutLink(Id); document.getElementById(Id).focus(); } @@ -4338,7 +4336,7 @@ function check_Remove_Empty_Question(IdToRemove , DeleteElement=0) { } }else if (DeleteElement) { - console.log("section"); + // console.log("section"); // console.log(parsedArray); if (Id === IdToRemove ) { @@ -4631,7 +4629,7 @@ function removeSection(RandomId, IndexValue) { var jsonData = JSON.parse(localStorage.getItem('JSON_FOR_NAV')); var count = jsonData.sections.length; - console.log(`Count of sections: ${count}`); + // console.log(`Count of sections: ${count}`); if(count > 1) { @@ -5178,41 +5176,41 @@ setInterval(imagebuttonidset,3000) - + - + @@ -5285,13 +5283,13 @@ function findInputByValue(value) { }) } setInterval(addTitleforTable,2000) - + - + - + + + - - - --> diff --git a/decode.js b/decode.js index 7a7bb97..216ff66 100644 --- a/decode.js +++ b/decode.js @@ -10,8 +10,10 @@ function decode(encryptedDataFilePath) { // console.log('encryptedDataFilePath :', encryptedDataFilePath); // const privateKeyPath = process.env.PRIVATE_KEY_PATH; - const privateKeyPath = configObject.PRIVATE_KEY_PATH; + const privateKeyPathTemp = configObject.PRIVATE_KEY_PATH; + const privateKeyPath = path.join(__dirname,privateKeyPathTemp); + const encryptedFileContent = fs.readFileSync(encryptedDataFilePath); // Extract the encrypted AES key, IV, and ciphertext diff --git a/encode.js b/encode.js index 993cb22..725a467 100644 --- a/encode.js +++ b/encode.js @@ -13,16 +13,21 @@ function encode(inputString, downloadFilePath = false) { var certificatePath = ''; + + if(downloadFilePath !== false) { // certificatePath = process.env.DOWNLOAD_PUBLIC_KEY_PATH; - certificatePath = configObject.DOWNLOAD_PUBLIC_KEY_PATH; + var certificatePathTemp = configObject.DOWNLOAD_PUBLIC_KEY_PATH; + certificatePath = path.join(__dirname,certificatePathTemp); } else{ // certificatePath = process.env.PUBLIC_KEY_PATH; - certificatePath = configObject.PUBLIC_KEY_PATH; + var certificatePathTemp = configObject.PUBLIC_KEY_PATH; + certificatePath = path.join(__dirname,certificatePathTemp); } + try { const aesKey = crypto.randomBytes(16); // Change the byte length for different key lengths diff --git a/xml2json.js b/xml2json.js index 0675d94..9afa587 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(jsonDecodeData); +// console.log(jsonDecodeData); function getAttributesOfXMLNode(node) { @@ -22,11 +22,11 @@ function getAttributesOfXMLNode(node) function getQuestionsNodes(questionNode,type) { - console.log(type); + // console.log(type); var questionObj = {}; if(type == 1) { - console.log(questionNode); + // console.log(questionNode); questionObj['question_id'] = questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "" ; questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue; questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : ""); @@ -54,7 +54,7 @@ function getQuestionsNodes(questionNode,type) questionObj['correct_answer'] = []; var choiceList = questionNode.childNodes[7].childNodes; - console.log(questionNode); + // console.log(questionNode); if(choiceList.length > 0) { for (let k = 0; k < choiceList.length ;k++) @@ -72,7 +72,7 @@ function getQuestionsNodes(questionNode,type) { var jsonParsedData = JSON.parse(jsonDecodeData); - console.log('jsonParsedData : ', jsonParsedData) + // console.log('jsonParsedData : ', jsonParsedData) // Iterate over each question for (const question of jsonParsedData.questions) { @@ -123,17 +123,17 @@ function getQuestionGroupNodes(questionGroup) var questionType = questionList[q].getAttribute("xsi:type"); if(questionType == 'DescriptiveQuestion') { - console.log(questionList[q]); + // console.log(questionList[q]); questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1)); } else if(questionType == 'MultiChoiceQuestion') { - console.log(questionList[q]); + // console.log(questionList[q]); questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],2)); } else { - console.log(questionList[q]); + // console.log(questionList[q]); questionGroupObj['questions'].push(getQuestionGroupNodes(questionList[q])); } @@ -146,7 +146,7 @@ function getQuestionGroupNodes(questionGroup) //busi logic start var xmlString = xmlData; -console.log(xmlString); +// console.log(xmlString); const parser = new DOMParser(); // Parse the XML string into an XML document @@ -207,7 +207,7 @@ jsonObj['sections'] = []; var jsonData = JSON.stringify(jsonObj); // console.log('Xml to Json Conversion '); // console.log('jsonData : ', jsonData); - console.log(jsonObj); + // console.log(jsonObj); jsonToHtml(jsonObj); // console.log(jsonToHtml(jsonObj)) // localStorage.removeItem('json_Decode_Data_For_Mcq_Crt_Ans');