CRYPTO AUTO CLOSE PREVIEW: AADHAVAN
This commit is contained in:
parent
eef226bda5
commit
630d9da5db
@ -35,6 +35,7 @@ function CheakQnType(question, questionIndex, depth) {
|
||||
}
|
||||
|
||||
}
|
||||
let count =0
|
||||
function processQuestion(question, questionIndex, depth) {
|
||||
const questionText = question.question;
|
||||
const questionDescription = question.question_description;
|
||||
@ -42,7 +43,8 @@ function processQuestion(question, questionIndex, depth) {
|
||||
|
||||
// Add appropriate indentation for nested questions
|
||||
const questionIndentation = " ".repeat(depth + 1);
|
||||
questionPaper += `<div class="text-qus-align">${questionIndentation}${questionIndex + 1}) ${convertToLatex(questionText, mathstatus)}${questionIndentation}</div><div class="text-des">${convertToLatex(questionDescription, mathstatus)}</div>`;
|
||||
count++
|
||||
questionPaper += `<div class="text-qus-align">${questionIndentation}${count}) ${convertToLatex(questionText, mathstatus)}${questionIndentation}</div><div class="text-des">${convertToLatex(questionDescription, mathstatus)}</div>`;
|
||||
|
||||
// If it's an MCQ question, add choices
|
||||
if (question.question_type === "group") {
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
.MathJax.CtxtMenu_Attached_0{
|
||||
display: contents !important;
|
||||
}
|
||||
.text-qus-align{ display:flex;margin-left: -19px; }
|
||||
.text-qus-align{ display:flex;margin-left: -10px; }
|
||||
.text-qus-align p{ margin:0; }
|
||||
.text-des{ margin-left: 20px;margin-top: 6px;}
|
||||
.text-option-align{display:flex;margin-top: 10px;}
|
||||
@ -136,7 +136,7 @@
|
||||
<div class="heder-menu">
|
||||
<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="addform.html"><i class="fa fa-pencil-square-o" aria-hidden="true" style="font-size: 24px;"></i> Edit</a></li>
|
||||
<li><a id="editlink" href=""><i class="fa fa-pencil-square-o" aria-hidden="true" style="font-size: 24px;"></i> Edit</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -177,8 +177,9 @@
|
||||
|
||||
<!-- jquery js -->
|
||||
<script src="./node_modules/jquery/dist/jquery.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-chtml.min.js" integrity="sha512-T8xxpazDtODy3WOP/c6hvQI2O9UPdARlDWE0CvH1Cfqc0TXZF6GZcEKL7tIR8VbfS/7s/J6C+VOqrD6hIo++vQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<!-- bootstrap js -->
|
||||
<!-- mathjax -->
|
||||
<script src="./node_modules/mathjax/es5/tex-chtml-full.js"></script>
|
||||
<!-- bootstrap js -->
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
<!-- carousel js -->
|
||||
<script src="assets/js/owl.carousel.min.js"></script>
|
||||
@ -214,17 +215,22 @@
|
||||
|
||||
<script src="xml2json_for_Questionpaper_preview.js"></script>
|
||||
<script src="QuestionPaperPreview.js"></script>
|
||||
|
||||
<script src="decode.js"></script>
|
||||
|
||||
|
||||
<script>
|
||||
const fs = require('fs');
|
||||
require('dotenv').config();
|
||||
const isEncrypted = process.env.ENCRYPTED;
|
||||
|
||||
const url = new URL(window.location.href);// Get the URL of the current page for JSON
|
||||
const params = new URLSearchParams(url.search);// Create a URLSearchParams object from the query string
|
||||
const xmlFileName = params.get('filename');// Get the value of a specific parameter
|
||||
loadXML(xmlFileName)
|
||||
|
||||
//Preview edit button
|
||||
document.getElementById("editlink").href = "addform.html?filename=" + xmlFileName;
|
||||
|
||||
// Function to load XML from a file
|
||||
function loadXML(xmlFileName) {
|
||||
console.log(xmlFileName)
|
||||
@ -233,9 +239,15 @@
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(data);
|
||||
xml2json(data);
|
||||
console.log(data)
|
||||
if (isEncrypted === 'YES') {
|
||||
var decodeData = decode(data);
|
||||
resolve(decodeData);
|
||||
xml2json(decodeData);
|
||||
} else {
|
||||
resolve(data);
|
||||
xml2json(data);
|
||||
}
|
||||
MathJax.typeset();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
13
addform.html
13
addform.html
@ -198,6 +198,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>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -369,7 +370,7 @@
|
||||
|
||||
<!-- RTC Hide and Show Script -->
|
||||
<script src="rtc_hide_and_show.js"></script>
|
||||
|
||||
<script src="decode.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
@ -416,6 +417,9 @@ 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
|
||||
|
||||
//EditPreview
|
||||
document.getElementById("editpreview").href = "QuestionPreview.html?filename=" + FileName;
|
||||
|
||||
// Function to load XML from a file
|
||||
function loadXML(xmlFileName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -423,8 +427,10 @@ function loadXML(xmlFileName) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(data);
|
||||
xml2json(data);
|
||||
// decrypt function call
|
||||
var decodeData = decode(data);
|
||||
resolve(decodeData);
|
||||
xml2json(decodeData);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -437,7 +443,6 @@ function saveFile() {
|
||||
json2xml();
|
||||
|
||||
if(FileName == "" || FileName == null ){
|
||||
|
||||
setTimeout(promptBox, 1000);
|
||||
|
||||
}else{
|
||||
|
||||
23
decode.js
Normal file
23
decode.js
Normal file
@ -0,0 +1,23 @@
|
||||
const crypto = require('crypto');
|
||||
|
||||
function decode(encryptedData) {
|
||||
try {
|
||||
const algorithm = 'aes-256-cbc';
|
||||
const iv = Buffer.from(encryptedData.slice(0, 24), 'base64');
|
||||
const keyHex = 'd0ca711dc0c599de0847cb86f415cd34d602a322f0f07dc89bce9e1481f481b3';
|
||||
const derivedKey = Buffer.from(keyHex, 'hex');
|
||||
const encryptedText = encryptedData.slice(24);
|
||||
|
||||
const decipher = crypto.createDecipheriv(algorithm, derivedKey, iv);
|
||||
let decrypted = decipher.update(encryptedText, 'base64', 'utf8');
|
||||
decrypted += decipher.final('utf8');
|
||||
|
||||
console.log('Decrypted String:', decrypted);
|
||||
return decrypted;
|
||||
} catch (error) {
|
||||
console.error('Decryption failed:', error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = decode;
|
||||
23
encode.js
Normal file
23
encode.js
Normal file
@ -0,0 +1,23 @@
|
||||
const crypto = require('crypto');
|
||||
|
||||
function encode(inputString) {
|
||||
try {
|
||||
const algorithm = 'aes-256-cbc';
|
||||
const iv = crypto.randomBytes(16);
|
||||
const keyHex = 'd0ca711dc0c599de0847cb86f415cd34d602a322f0f07dc89bce9e1481f481b3';
|
||||
const derivedKey = Buffer.from(keyHex, 'hex');
|
||||
const cipher = crypto.createCipheriv(algorithm, derivedKey, iv);
|
||||
|
||||
let encrypted = cipher.update(inputString, 'utf8', 'base64');
|
||||
encrypted += cipher.final('base64');
|
||||
|
||||
const encryptedData = iv.toString('base64') + encrypted;
|
||||
console.log('Encrypted String:', encryptedData);
|
||||
return encryptedData;
|
||||
} catch (error) {
|
||||
console.error('Encryption failed:', error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = encode;
|
||||
44
main.js
44
main.js
@ -1,29 +1,61 @@
|
||||
// main.js
|
||||
// const { app, BrowserWindow} = require('electron');
|
||||
const { app, BrowserWindow, ipcMain} = require('electron');
|
||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const jquery = require('jquery');
|
||||
let onlineStatus = true;
|
||||
const { dialog } = require('electron');
|
||||
const saveFile = require('./savexml')
|
||||
|
||||
let mainWindow;
|
||||
|
||||
function createWindow() {
|
||||
async function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
contextIsolation: false,
|
||||
},
|
||||
});
|
||||
|
||||
mainWindow.loadFile('dashboard.html'); // Create an HTML file for your interface
|
||||
mainWindow.loadFile('dashboard.html'); // Create an HTML file for your interface
|
||||
|
||||
mainWindow.on('closed', function () {
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
setInterval(checkInternetConnection, 5000);
|
||||
}
|
||||
|
||||
async function checkInternetConnection() {
|
||||
try {
|
||||
const response = await fetch('https://www.google.com');
|
||||
if (response.ok && onlineStatus) {
|
||||
onlineStatus = false;
|
||||
|
||||
// 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);
|
||||
} else if (!response.ok && !onlineStatus) {
|
||||
onlineStatus = true;
|
||||
// mainWindow.webContents.send('offline');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error checking internet connection');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
app.on('ready', createWindow);
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
@ -37,5 +69,3 @@ app.on('activate', function () {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
22
package-lock.json
generated
22
package-lock.json
generated
@ -1,16 +1,17 @@
|
||||
{
|
||||
"name": "myapp",
|
||||
"name": "project-b",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "myapp",
|
||||
"name": "project-b",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"desandro-matches-selector": "^2.0.2",
|
||||
"dotenv": "^16.3.1",
|
||||
"ev-emitter": "^2.1.2",
|
||||
"fizzy-ui-utils": "^3.0.0",
|
||||
"formidable": "^3.5.1",
|
||||
@ -20,6 +21,7 @@
|
||||
"jquery": "^3.7.1",
|
||||
"jquery-ui": "^1.13.2",
|
||||
"jsdom": "^22.1.0",
|
||||
"mathjax": "^3.2.2",
|
||||
"mathlive": "^0.95.5",
|
||||
"quill": "^1.3.6",
|
||||
"sweetalert2": "^11.6.13",
|
||||
@ -606,6 +608,17 @@
|
||||
"url": "https://github.com/fb55/domutils?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.3.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
|
||||
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/motdotla/dotenv?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/electron": {
|
||||
"version": "26.2.1",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-26.2.1.tgz",
|
||||
@ -1420,6 +1433,11 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/mathjax": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/mathjax/-/mathjax-3.2.2.tgz",
|
||||
"integrity": "sha512-Bt+SSVU8eBG27zChVewOicYs7Xsdt40qm4+UpHyX7k0/O9NliPc+x77k1/FEsPsjKPZGJvtRZM1vO+geW0OhGw=="
|
||||
},
|
||||
"node_modules/mathlive": {
|
||||
"version": "0.95.5",
|
||||
"resolved": "https://registry.npmjs.org/mathlive/-/mathlive-0.95.5.tgz",
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
"dependencies": {
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"desandro-matches-selector": "^2.0.2",
|
||||
"dotenv": "^16.3.1",
|
||||
"ev-emitter": "^2.1.2",
|
||||
"fizzy-ui-utils": "^3.0.0",
|
||||
"formidable": "^3.5.1",
|
||||
@ -24,6 +25,7 @@
|
||||
"jquery": "^3.7.1",
|
||||
"jquery-ui": "^1.13.2",
|
||||
"jsdom": "^22.1.0",
|
||||
"mathjax": "^3.2.2",
|
||||
"mathlive": "^0.95.5",
|
||||
"quill": "^1.3.6",
|
||||
"sweetalert2": "^11.6.13",
|
||||
|
||||
18
savexml.js
18
savexml.js
@ -1,6 +1,9 @@
|
||||
const fs = require('fs');
|
||||
const cheerio = require('cheerio');
|
||||
const Swal = require('sweetalert2')
|
||||
const encode = require('./encode')
|
||||
require('dotenv').config();
|
||||
const isEncrypted = process.env.ENCRYPTED;
|
||||
|
||||
function saveXmlToFile(xmlData, filePath) {
|
||||
// Check if the file path is provided
|
||||
@ -10,7 +13,9 @@ function saveXmlToFile(xmlData, filePath) {
|
||||
}
|
||||
|
||||
// Write the XML data to the specified file path
|
||||
fs.writeFile(filePath, xmlData, 'utf8', (err) => {
|
||||
fs.writeFileSync(filePath, xmlData, 'utf8', (err) => {
|
||||
console.log("fs write inside ");
|
||||
alert("fs write inside")
|
||||
if (err) {
|
||||
console.error('Error writing XML file:', err);
|
||||
} else {
|
||||
@ -33,6 +38,15 @@ function savexml(UserFilename) {
|
||||
// Get the XML string from localStorage
|
||||
var xmlString = localStorage.getItem("xml");
|
||||
|
||||
//check Encrypted or not
|
||||
var enc = "";
|
||||
if (isEncrypted === 'YES') {
|
||||
// Encrypt
|
||||
enc = encode(xmlString);
|
||||
}else{
|
||||
enc = xmlString;
|
||||
}
|
||||
|
||||
// Get the json string from localStorage for set fileName
|
||||
var jsonData = localStorage.getItem("json");
|
||||
|
||||
@ -45,7 +59,7 @@ function savexml(UserFilename) {
|
||||
// const jsonfilePath = process.cwd() + '/xml/' + jsonfilename;
|
||||
|
||||
// Call the function to save the XML file
|
||||
saveXmlToFile(xmlString, xmlfilePath);
|
||||
saveXmlToFile(enc, xmlfilePath);
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user