diff --git a/addform.html b/addform.html index 02d8f44..2b3f03f 100644 --- a/addform.html +++ b/addform.html @@ -350,6 +350,94 @@ + + @@ -417,6 +505,8 @@
+ +
@@ -506,6 +596,21 @@
+ + +
+ +
@@ -581,6 +686,9 @@ @@ -2847,6 +2961,128 @@ function removeClonedQroupQuestion(index) } } + + diff --git a/savexml.js b/savexml.js index 4eb4e64..61ea50b 100644 --- a/savexml.js +++ b/savexml.js @@ -9,33 +9,33 @@ require('dotenv').config(); //Get the value from .env const isEncrypted = process.env.ENCRYPTED; - // start the Autosave filename take the names in xml folder //////// - function getFilesInFolder(folderName) { - const xmlFilePath = path.join(__dirname, folderName); - try { - const fileNames = fs.readdirSync(xmlFilePath); - const xmlFiles = fileNames.filter((file) => file.endsWith('.xml')); - return xmlFiles; - } catch (error) { - console.error('Error reading folder:', error); - return []; - } +function getFilesInFolder(folderName) { + const xmlFilePath = path.join(__dirname, folderName); + try { + const fileNames = fs.readdirSync(xmlFilePath); + const xmlFiles = fileNames.filter((file) => file.endsWith('.xml')); + return xmlFiles; + } catch (error) { + console.error('Error reading folder:', error); + return []; } - //XmlPath get from .env - const xmlPath_ = process.env.XML_FILE_PATH; - const folderName = `/${xmlPath_}`; - const filePaths = []; - const files = getFilesInFolder(folderName); - files.forEach((file) => { - const filePath = file; - filePaths.push(filePath); - }); +} +//XmlPath get from .env +const xmlPath_ = process.env.XML_FILE_PATH; +const folderName = `/${xmlPath_}`; +const filePaths = []; +const files = getFilesInFolder(folderName); +files.forEach((file) => { + const filePath = file; + filePaths.push(filePath); +}); //////// //end the autosave -function saveXmlToFile(xmlData, filePath) { +function saveXmlToFile(xmlData, filePath,reorder=false) { + console.log(filePath); // console.log(filePath); // Check if the file path is provided if (!filePath) { @@ -58,17 +58,19 @@ function saveXmlToFile(xmlData, filePath) { } }); localStorage.clear(); - - window.location.href = 'dashboard.html'; - -} + if(reorder){ + window.location.reload(); + }else{ + window.location.href = 'dashboard.html'; + } + + } -function savexml(UserFilename) { - +function savexml(UserFilename,reorder=false) { + console.log("reorder",reorder); // Get the XML string from localStorage var xmlString = localStorage.getItem("xml"); - //check Encrypted or not var enc = ""; if (isEncrypted === 'YES') { @@ -77,12 +79,11 @@ function savexml(UserFilename) { } else { enc = xmlString; } - //XmlPath get from .env - const xmlPathenv = process.env.XML_FILE_PATH; + const xmlPathenv=process.env.XML_FILE_PATH; const xmlPath = path.join(__dirname, xmlPathenv) // Get the json string from localStorage for set fileName - var jsonData = localStorage.getItem("json"); + var jsonData = localStorage.getItem("json"); // Create a filename using on the subtitle var xmlfilename = `${UserFilename}.xml`; @@ -94,11 +95,15 @@ function savexml(UserFilename) { const xmlfilePath = `${xmlPath}` + xmlfilename; // const jsonfilePath = process.cwd() + '/xml/' + jsonfilename; - // Call the function to save the XML file - saveXmlToFile(enc, xmlfilePath); - + if(reorder){ + saveXmlToFile(enc, xmlfilePath,reorder=true); + }else{ + // Call the function to save the XML file + saveXmlToFile(enc, xmlfilePath); + } } + function promptBox() { var jsonData = localStorage.getItem("json");