crypto error solve : RV
This commit is contained in:
parent
87a9e1eb42
commit
59b93e5c5c
@ -463,36 +463,97 @@ color: #1d3557 !important;
|
||||
//Preview edit button
|
||||
document.getElementById("editlink").href = "addform.html?filename=" + xmlFileName;
|
||||
|
||||
// Function to load XML from a file
|
||||
function loadXML(xmlFileName) {
|
||||
//XmlPath get from .env
|
||||
|
||||
// const decode = require('./decode');
|
||||
|
||||
//XmlPath get from .env
|
||||
const xmlPathenv=configObject.XML_FILE_PATH.trim();
|
||||
// Function to load XML from a file
|
||||
function loadXML(xmlFileName) {
|
||||
|
||||
// const xmlPathenv=process.env.XML_FILE_PATH;
|
||||
const xmlPath =path.join(__dirname,xmlPathenv);
|
||||
// console.log(xmlFileName)
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(`${xmlPath}`+xmlFileName, 'utf8', (error, data) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
if (isEncrypted === 'YES') {
|
||||
var decodeData = decode(data);
|
||||
resolve(decodeData);
|
||||
xml2json(decodeData);
|
||||
} else {
|
||||
resolve(data);
|
||||
xml2json(data);
|
||||
}
|
||||
MathJax.typeset();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
const xmlPathenv=configObject.XML_FILE_PATH.trim();
|
||||
const xmlPath =path.join(__dirname,xmlPathenv);
|
||||
|
||||
// console.log('xmlFileName', xmlFileName);
|
||||
|
||||
var decodeData ="";
|
||||
var encodedXmlFilePath = `${xmlPath}${xmlFileName}`;
|
||||
|
||||
var jsonDecodeData = "";
|
||||
var jsonFileName = xmlFileName.split('.xml');
|
||||
var encodedJsonFilePath = `${xmlPath}${jsonFileName[0]}_answer.json`;
|
||||
|
||||
// console.log('encodedJsonFilePath', encodedJsonFilePath);
|
||||
|
||||
var filelist = findFile(encodedJsonFilePath);
|
||||
const decode = require('./decode');
|
||||
if(filelist !== false)
|
||||
{
|
||||
//JSON File Read Function
|
||||
fs.readFile(encodedJsonFilePath, 'utf8', (error, data) => {
|
||||
if (error) {
|
||||
console.error('Error reading file:', error);
|
||||
} else {
|
||||
if (isEncrypted === 'YES') {
|
||||
|
||||
jsonDecodeData = decode(encodedJsonFilePath);
|
||||
localStorage.setItem('json_Decode_Data_For_Mcq_Crt_Ans', jsonDecodeData);
|
||||
|
||||
} else{
|
||||
jsonDecodeData = data;
|
||||
localStorage.setItem('json_Decode_Data_For_Mcq_Crt_Ans', jsonDecodeData);
|
||||
console.log('jsonDecodeData', jsonDecodeData);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
setTimeout(function() {
|
||||
|
||||
fs.readFile(`${xmlPath}${xmlFileName}`, 'utf8', (error, data) => {
|
||||
if (error) {
|
||||
console.error('Error reading file:', error);
|
||||
} else {
|
||||
if (isEncrypted === 'YES') {
|
||||
// decrypt function call go to decode.js
|
||||
decodeData = decode(encodedXmlFilePath);
|
||||
|
||||
} else{
|
||||
decodeData = data;
|
||||
}
|
||||
console.log('jsonDecodeData : ', jsonDecodeData);
|
||||
xml2json(decodeData);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
|
||||
console.log()
|
||||
|
||||
|
||||
|
||||
// Function for Finding the JSON File in the folder
|
||||
function findFile(filePath) {
|
||||
try {
|
||||
const stats = fs.statSync(filePath);
|
||||
|
||||
if (stats.isFile()) {
|
||||
|
||||
// File exists
|
||||
// console.log(`File found at: ${filePath}`);
|
||||
return true;
|
||||
} else {
|
||||
// console.error(`Path is not a file: ${filePath}`);
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
// console.error(`File not found: ${filePath}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
164
addform.html
164
addform.html
@ -1284,41 +1284,43 @@ $('#workarea_math').click(function(){
|
||||
console.log('called');
|
||||
$('#workarea_math').css('margin-bottom', '240px');
|
||||
localStorage.setItem('workAreaMath', true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(document).on("click", function (event) {
|
||||
|
||||
// console.log('Clicked element id:', event.target.id);
|
||||
// console.log('Clicked element:', event.target);
|
||||
// console.log('Clicked element id:', event.target.id);
|
||||
// console.log('Clicked element:', event.target);
|
||||
|
||||
const targetElement = event.target;
|
||||
var tragetedId = event.target.id.startsWith("ML");
|
||||
const classList = Array.from(event.target.classList);
|
||||
const hasMLKClass = classList.some(className => className.startsWith("MLK") || className.startsWith("row") || className.startsWith("left") || className.startsWith("ML") || className.startsWith("action"));
|
||||
const isSvgElement = targetElement.closest('svg') || targetElement.closest('i');
|
||||
// console.log('svg',isSvgElement);
|
||||
// console.log(hasMLKClass);
|
||||
const targetElement = event.target;
|
||||
var tragetedId = event.target.id.startsWith("ML");
|
||||
const classList = Array.from(event.target.classList);
|
||||
const hasMLKClass = classList.some(className => className.startsWith("MLK") || className.startsWith("row") || className.startsWith("left") || className.startsWith("ML") || className.startsWith("action"));
|
||||
const isSvgElement = targetElement.closest('svg') || targetElement.closest('i');
|
||||
// console.log('svg',isSvgElement);
|
||||
// console.log(hasMLKClass);
|
||||
|
||||
if (event.target.id !== 'workarea_math' && tragetedId == false && hasMLKClass == false && isSvgElement == null) {
|
||||
// console.log('Inside if');
|
||||
var value = localStorage.getItem('workAreaMath');
|
||||
if (event.target.id !== 'workarea_math' && tragetedId == false && hasMLKClass == false && isSvgElement == null) {
|
||||
// console.log('Inside if');
|
||||
var value = localStorage.getItem('workAreaMath');
|
||||
|
||||
if (value === 'true') {
|
||||
// console.log('Value:', value);
|
||||
$('#workarea_math').css('margin-bottom', '0px');
|
||||
localStorage.removeItem('workAreaMath');
|
||||
} else {
|
||||
// $('#workarea_math').css('margin-bottom', '190px');
|
||||
// console.log('Value is not true');
|
||||
if (value === 'true') {
|
||||
// console.log('Value:', value);
|
||||
$('#workarea_math').css('margin-bottom', '0px');
|
||||
localStorage.removeItem('workAreaMath');
|
||||
} else {
|
||||
// $('#workarea_math').css('margin-bottom', '190px');
|
||||
// console.log('Value is not true');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var ids = document.getElementById('workarea_math');
|
||||
|
||||
|
||||
//clear the string from the workarea and a fileds
|
||||
function clearMessage() {
|
||||
var val = document.getElementById('messages') ;
|
||||
if(val !== null){
|
||||
@ -1437,69 +1439,73 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
|
||||
//EditPreview and Create Preview
|
||||
var previewbutton = document.getElementById("editPreview");
|
||||
previewbutton.addEventListener("click", async () => {
|
||||
if (FileName) {
|
||||
const saveButton = document.getElementById('SaveButton');
|
||||
if (saveButton) {
|
||||
saveButton.click();
|
||||
setTimeout(function() {
|
||||
var popupInput = document.getElementById("swal2-input");
|
||||
var submitButton = document.querySelector(".swal2-confirm.swal2-styled");
|
||||
submitButton.addEventListener("click", function() {
|
||||
FileName = popupInput.value;
|
||||
FileName += ".xml"
|
||||
if(FileName){
|
||||
var anchorElement = document.getElementById("editPreview");
|
||||
if (anchorElement) {
|
||||
anchorElement.click();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 3000);
|
||||
}
|
||||
previewbutton.href = "QuestionPreview.html?filename=" + FileName;
|
||||
} else {
|
||||
var previewbutton = document.getElementById("editPreview");
|
||||
previewbutton.addEventListener("click", async () => {
|
||||
if (FileName)
|
||||
{
|
||||
const saveButton = document.getElementById('SaveButton');
|
||||
if (saveButton) {
|
||||
saveButton.click();
|
||||
setTimeout(function() {
|
||||
var popupInput = document.getElementById("swal2-input");
|
||||
var submitButton = document.querySelector(".swal2-confirm.swal2-styled");
|
||||
submitButton.addEventListener("click", function() {
|
||||
FileName = popupInput.value;
|
||||
FileName += ".xml"
|
||||
if(FileName){
|
||||
var anchorElement = document.getElementById("editPreview");
|
||||
if (anchorElement) {
|
||||
anchorElement.click();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 3000);
|
||||
}
|
||||
previewbutton.href = "QuestionPreview.html?filename=" + FileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
const saveButton = document.getElementById('SaveButton');
|
||||
if (saveButton) {
|
||||
saveButton.click();
|
||||
setTimeout(function() {
|
||||
var popupInput = document.getElementById("swal2-input");
|
||||
var submitButton = document.querySelector(".swal2-confirm.swal2-styled");
|
||||
submitButton.addEventListener("click", function() {
|
||||
FileName = popupInput.value;
|
||||
FileName += ".xml"
|
||||
if(FileName){
|
||||
var anchorElement = document.getElementById("editPreview");
|
||||
if (anchorElement) {
|
||||
anchorElement.click();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const saveButton = document.getElementById('SaveButton');
|
||||
if (saveButton) {
|
||||
saveButton.click();
|
||||
setTimeout(function() {
|
||||
var popupInput = document.getElementById("swal2-input");
|
||||
var submitButton = document.querySelector(".swal2-confirm.swal2-styled");
|
||||
submitButton.addEventListener("click", function() {
|
||||
FileName = popupInput.value;
|
||||
FileName += ".xml"
|
||||
if(FileName){
|
||||
var anchorElement = document.getElementById("editPreview");
|
||||
if (anchorElement) {
|
||||
anchorElement.click();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Function for Finding the JSON File in the folder
|
||||
function findFile(filePath) {
|
||||
try {
|
||||
const stats = fs.statSync(filePath);
|
||||
try {
|
||||
const stats = fs.statSync(filePath);
|
||||
|
||||
if (stats.isFile()) {
|
||||
if (stats.isFile()) {
|
||||
|
||||
// File exists
|
||||
// console.log(`File found at: ${filePath}`);
|
||||
return true;
|
||||
} else {
|
||||
// console.error(`Path is not a file: ${filePath}`);
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
// console.error(`File not found: ${filePath}`);
|
||||
return false;
|
||||
}
|
||||
// File exists
|
||||
// console.log(`File found at: ${filePath}`);
|
||||
return true;
|
||||
} else {
|
||||
// console.error(`Path is not a file: ${filePath}`);
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
// console.error(`File not found: ${filePath}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1521,7 +1527,7 @@ function loadXML(xmlFileName) {
|
||||
// console.log('encodedJsonFilePath', encodedJsonFilePath);
|
||||
|
||||
var filelist = findFile(encodedJsonFilePath);
|
||||
|
||||
const decode = require('./decode');
|
||||
if(filelist !== false)
|
||||
{
|
||||
//JSON File Read Function
|
||||
|
||||
@ -432,9 +432,9 @@ function validateFile(input) {
|
||||
const allowedExtensions = ["xml"];
|
||||
const fileExtension = file.name.split(".").pop().toLowerCase();
|
||||
if (!allowedExtensions.includes(fileExtension)) {
|
||||
alert('Invalid file type. Only xml files are allowed.')
|
||||
input.value = "";
|
||||
return;
|
||||
alert('Invalid file type. Only xml files are allowed.')
|
||||
input.value = "";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -460,19 +460,19 @@ function validateFile(input) {
|
||||
|
||||
function downloadFile(filename) {
|
||||
|
||||
console.log(xmlPath);
|
||||
// console.log(xmlPath);
|
||||
const xmlFilePath = `${xmlPath}${filename}`;
|
||||
console.log(xmlFilePath)
|
||||
// console.log(xmlFilePath)
|
||||
|
||||
const xmlFileNameParts = filename.split('.xml');
|
||||
const xmlBaseName = xmlFileNameParts[0];
|
||||
const jsonFileName = `${xmlBaseName}_answer.json`;
|
||||
const jsonFilePath = `${xmlPath}${jsonFileName}`;
|
||||
console.log(jsonFilePath);
|
||||
// console.log(jsonFilePath);
|
||||
|
||||
|
||||
var fileList = findFile(jsonFilePath);
|
||||
console.log(fileList)
|
||||
// console.log(fileList)
|
||||
|
||||
|
||||
// const downloadsPath = process.env.DOWNLOAD_XML_FILE_PATH;
|
||||
@ -480,18 +480,18 @@ console.log(fileList)
|
||||
// const isEncrypted = process.env.ENCRYPTED;
|
||||
|
||||
const downloadsPath = configObject.DOWNLOAD_XML_FILE_PATH.trim();
|
||||
console.log(downloadsPath,'downloadpath');
|
||||
// console.log(downloadsPath,'downloadpath');
|
||||
const isEncrypted = configObject.ENCRYPTED.trim();
|
||||
|
||||
const filePathToSave = path.join(downloadsPath, filename);
|
||||
const jsonFilePathToSave = path.join(downloadsPath, jsonFileName);
|
||||
console.log(filePathToSave);
|
||||
console.log(jsonFilePathToSave);
|
||||
// console.log(filePathToSave);
|
||||
// console.log(jsonFilePathToSave);
|
||||
|
||||
|
||||
if(isEncrypted == 'YES'){
|
||||
|
||||
console.log('isEncrypted');
|
||||
// console.log('isEncrypted');
|
||||
|
||||
// XML File
|
||||
|
||||
@ -510,7 +510,7 @@ if(fileList !== false)
|
||||
}
|
||||
else{
|
||||
|
||||
console.log('isEncrypted NOT');
|
||||
// console.log('isEncrypted NOT');
|
||||
|
||||
// //Download XML FIle
|
||||
// console.log(xmlFilePath);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user