DISABLE_AUTO_CLOSE XML_FILE_PATH : AADHAVAN
This commit is contained in:
parent
ab940db256
commit
86ab9c54c9
@ -219,8 +219,10 @@
|
||||
|
||||
|
||||
<script>
|
||||
const fs = require('fs');
|
||||
const fs = require('fs');
|
||||
|
||||
require('dotenv').config();
|
||||
//get value from .env
|
||||
const isEncrypted = process.env.ENCRYPTED;
|
||||
|
||||
const url = new URL(window.location.href);// Get the URL of the current page for JSON
|
||||
@ -233,9 +235,12 @@
|
||||
|
||||
// Function to load XML from a file
|
||||
function loadXML(xmlFileName) {
|
||||
|
||||
//XmlPath get from .env
|
||||
const xmlPath=process.env.XML_FILE_PATH;
|
||||
console.log(xmlFileName)
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile('xml/'+xmlFileName, 'utf8', (error, data) => {
|
||||
fs.readFile(`${xmlPath}`+xmlFileName, 'utf8', (error, data) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
|
||||
38
addform.html
38
addform.html
@ -352,7 +352,7 @@
|
||||
<ul>
|
||||
<li><a href="dashboard.html"><i class="fa fa-home" aria-hidden="true" style="font-size: 24px;"></i> Home</a></li>
|
||||
<li><a href="#" class="myBtn" onclick="saveFile()" id="SaveButton"><i class="fa fa-floppy-o" aria-hidden="true" style="font-size: 20px;"></i> Save</a></li>
|
||||
<li><a id="editpreview" href=""><i class="fa fa-eye" aria-hidden="true" style="font-size: 24px;"></i> Preview</a></li>
|
||||
<li><a id="editPreview" href=""><i class="fa fa-eye" aria-hidden="true" style="font-size: 24px;"></i> Preview</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -535,8 +535,8 @@
|
||||
<!-- RTC Hide and Show Script -->
|
||||
<script src="rtc_hide_and_show.js"></script>
|
||||
|
||||
<!-- decrypt -->
|
||||
<script src="decode.js"></script>
|
||||
|
||||
|
||||
<!-- nave pane -->
|
||||
<script src="nav_pane.js"></script>
|
||||
@ -555,8 +555,16 @@ const url = new URL(window.location.href);// Get the URL of the current page for
|
||||
const params = new URLSearchParams(url.search);// Create a URLSearchParams object from the query string
|
||||
const FileName = params.get('filename');// Get the value of a specific parameter
|
||||
|
||||
var xmlPath ="" //get the xml filepath in .env file local variable
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
require('dotenv').config();
|
||||
//xmlPath added
|
||||
xmlPath=process.env.XML_FILE_PATH;
|
||||
// console.log(xmlPath);
|
||||
const isEncrypted = process.env.ENCRYPTED;
|
||||
// console.log(isEncrypted);
|
||||
|
||||
$('.ql-toolbar').hide(); // Hide the Quill Text Editor if PAge load
|
||||
|
||||
@ -564,7 +572,8 @@ $(document).ready(function() {
|
||||
var random_no = Date.now();
|
||||
addSection(false, false, random_no, false, false, false, false); //Call the Default section on the QUestion paper
|
||||
}else {
|
||||
loadXML(FileName); //send filename to read xml files to using this function
|
||||
loadXML(FileName); //send filename to read xml files to using this function
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
@ -583,8 +592,7 @@ $(document).on("click", function (event) {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const scrollToTopBtn = document.getElementById('SaveButton');
|
||||
const scrollToTopBtn2 = document.getElementById('SaveButton2');
|
||||
require('dotenv').config();
|
||||
const isEncrypted = process.env.ENCRYPTED;
|
||||
|
||||
|
||||
// Function to keep the cursor at its current position
|
||||
function keepCursorAtPosition(event) {
|
||||
@ -598,24 +606,26 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
|
||||
//EditPreview
|
||||
document.getElementById("editpreview").href = "QuestionPreview.html?filename=" + FileName;
|
||||
document.getElementById("editPreview").href = "QuestionPreview.html?filename=" + FileName;
|
||||
|
||||
// Function to load XML from a file
|
||||
function loadXML(xmlFileName) {
|
||||
var decodeData ="";
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile('xml/'+xmlFileName, 'utf8', (error, data) => {
|
||||
fs.readFile(`${xmlPath}${xmlFileName}`, 'utf8', (error, data) => {
|
||||
if (error) {
|
||||
console.error('Error reading file:', error);
|
||||
reject(error);
|
||||
} else {
|
||||
if (isEncrypted === 'YES') {
|
||||
// decrypt function call
|
||||
var decodeData = decode(data);
|
||||
resolve(decodeData);
|
||||
xml2json(decodeData);
|
||||
// decrypt function call go to decode.js
|
||||
decodeData = decode(data);
|
||||
} else {
|
||||
resolve(data)
|
||||
xml2json(data)
|
||||
}
|
||||
decodeData = data;
|
||||
}
|
||||
resolve(decodeData)
|
||||
xml2json(decodeData)
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
|
||||
@ -285,6 +285,9 @@ const Swal = require('sweetalert2')
|
||||
var msgDiv = document.getElementById('Message');
|
||||
var modal = document.getElementById('myModal');
|
||||
var fileInput = document.getElementById('fileInput');
|
||||
require('dotenv').config();
|
||||
//XmlPath get from .env
|
||||
const xmlPath=process.env.XML_FILE_PATH;
|
||||
|
||||
function fileupload(filePaths) {
|
||||
|
||||
@ -292,7 +295,7 @@ console.log('File path:', filePaths);
|
||||
|
||||
// Handle the selected folder path here
|
||||
// You can specify the destination folder path where you want to copy/move the files
|
||||
const destinationFolderPath = 'xml';
|
||||
const destinationFolderPath = `${xmlPath}`;
|
||||
|
||||
// Use fs to copy or move the file
|
||||
const fileName =filePaths.name;
|
||||
@ -384,6 +387,8 @@ sourceStream.on('error', (err) => {
|
||||
// Get the <span> element that closes the modal
|
||||
var span = document.getElementsByClassName("close")[0];
|
||||
|
||||
|
||||
|
||||
// When the user clicks the button, open the modal
|
||||
btn.onclick = function() {
|
||||
modal.style.display = "block";
|
||||
@ -406,21 +411,18 @@ sourceStream.on('error', (err) => {
|
||||
const file = input.files[0];
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Function to download a file by filename
|
||||
|
||||
// Function to download a file by filename
|
||||
function downloadFile(filename) {
|
||||
|
||||
// You can change the path to your server or specify a URL to download the file
|
||||
const fileURL = `xml/${filename}`;
|
||||
const fileURL = `${xmlPath}${filename}`;
|
||||
console.log(fileURL)
|
||||
// Create a hidden anchor element to trigger the download
|
||||
const a = document.createElement('a');
|
||||
|
||||
8
index.js
8
index.js
@ -19,7 +19,11 @@
|
||||
return [];
|
||||
}
|
||||
}
|
||||
const folderName = "/xml";
|
||||
require('dotenv').config();
|
||||
//XmlPath get from .env
|
||||
const xmlPath=process.env.XML_FILE_PATH;
|
||||
|
||||
const folderName = `/${xmlPath}`;
|
||||
const filePaths = [];
|
||||
const files = getFilesInFolder(folderName);
|
||||
files.forEach((file) => {
|
||||
@ -31,7 +35,7 @@ files.forEach((file) => {
|
||||
|
||||
// Function to load XML data and populate the list view
|
||||
function loadList(xmlFilePath) {
|
||||
return fetch('xml/'+xmlFilePath)
|
||||
return fetch(`${xmlPath}`+xmlFilePath)
|
||||
.then(response => response.text())
|
||||
.then(xmlContent => {
|
||||
const parser = new DOMParser();
|
||||
|
||||
25
main.js
25
main.js
@ -7,6 +7,9 @@ const jquery = require('jquery');
|
||||
let onlineStatus = true;
|
||||
const { dialog } = require('electron');
|
||||
const saveFile = require('./savexml')
|
||||
require('dotenv').config()
|
||||
|
||||
const auto_close= process.env.DISABLE_AUTO_CLOSE;
|
||||
|
||||
let mainWindow;
|
||||
|
||||
@ -37,15 +40,19 @@ async function checkInternetConnection() {
|
||||
|
||||
// mainWindow.webContents.send('online');
|
||||
|
||||
dialog.showMessageBox(mainWindow, {
|
||||
type: 'info',
|
||||
message: 'Internet is available. Click OK to close the app. Otherwise app will auto close in 10 seconds',
|
||||
buttons: ['OK'],
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
app.quit();
|
||||
}, 10000);
|
||||
|
||||
if (auto_close === 'TRUE') {
|
||||
|
||||
}else{
|
||||
dialog.showMessageBox(mainWindow, {
|
||||
type: 'info',
|
||||
message: 'Internet is available. Click OK to close the app. Otherwise app will auto close in 10 seconds',
|
||||
buttons: ['OK'],
|
||||
});
|
||||
setTimeout(() => {
|
||||
app.quit();
|
||||
}, 10000);
|
||||
}
|
||||
} else if (!response.ok && !onlineStatus) {
|
||||
onlineStatus = true;
|
||||
// mainWindow.webContents.send('offline');
|
||||
|
||||
@ -2,7 +2,9 @@ const fs = require('fs');
|
||||
const cheerio = require('cheerio');
|
||||
const Swal = require('sweetalert2')
|
||||
const encode = require('./encode')
|
||||
|
||||
require('dotenv').config();
|
||||
//Get the value from .env
|
||||
const isEncrypted = process.env.ENCRYPTED;
|
||||
|
||||
function saveXmlToFile(xmlData, filePath) {
|
||||
@ -47,6 +49,9 @@ function savexml(UserFilename) {
|
||||
enc = xmlString;
|
||||
}
|
||||
|
||||
//XmlPath get from .env
|
||||
const xmlPath=process.env.XML_FILE_PATH;
|
||||
|
||||
// Get the json string from localStorage for set fileName
|
||||
var jsonData = localStorage.getItem("json");
|
||||
|
||||
@ -55,7 +60,7 @@ function savexml(UserFilename) {
|
||||
// var jsonfilename = `${UserFilename}.json`;
|
||||
|
||||
// file path where you want to save the XML file
|
||||
const xmlfilePath = process.cwd() + '/xml/' + xmlfilename;
|
||||
const xmlfilePath = process.cwd() + `/${xmlPath}` + xmlfilename;
|
||||
// const jsonfilePath = process.cwd() + '/xml/' + jsonfilename;
|
||||
|
||||
// Call the function to save the XML file
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
xml2/Sample.xml
Normal file
2
xml2/Sample.xml
Normal file
File diff suppressed because one or more lines are too long
1
xml2/vf.xml
Normal file
1
xml2/vf.xml
Normal file
@ -0,0 +1 @@
|
||||
+cQcMhFlgMkbrF+i7iP25Q==7IbbJ+oG7KTi6Im1DLQqGsG/4bfBr32ec56wEKAZRfcvUCUe+BW1RUx+wB3KC9chpNkalv2i5yaTQWGnFxVB3i8jvnrJyDxdN2vhZCVOnAuyTMqLxrvRsCJ5rMJMsxVLZeRlYpi7d1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Nx3Mbv33LVG4DK3LMU21e631M/B1sQlLtccAXZpL6jalzaeChmbXqfMV
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
function xml2json(xmlData) {
|
||||
// console.clear();
|
||||
// console.log('xml to json converstion');
|
||||
// console.log(xmlData);
|
||||
console.log('xml to json converstion');
|
||||
console.log(xmlData);
|
||||
|
||||
function getAttributesOfXMLNode(node)
|
||||
{
|
||||
|
||||
@ -159,7 +159,6 @@ jsonObj['sections'] = [];
|
||||
|
||||
var jsonData = JSON.stringify(jsonObj);
|
||||
localStorage.setItem('pjsonData', jsonData );
|
||||
|
||||
QuestionPaperPreview(jsonObj);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user