mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Lots of bugfixes, improvements: Dinamyc QA, file uploading refactoring, file managing logging improvements ...
This commit is contained in:
parent
3250139c82
commit
b8c1a6ca97
14 changed files with 662 additions and 533 deletions
32
actions.js
32
actions.js
|
@ -22,7 +22,8 @@ module.exports = {
|
|||
ProcessIncomingRequest: ProcessIncomingRequest,
|
||||
CheckData: CheckData,
|
||||
NLoad: NLoad,
|
||||
LoadJSON: LoadJSON
|
||||
LoadJSON: LoadJSON,
|
||||
ProcessQA: ProcessQA
|
||||
};
|
||||
|
||||
var recievedFile = "stats/recieved";
|
||||
|
@ -31,6 +32,7 @@ var manFile = "public/man.html";
|
|||
var dataFile = "public/data.json";
|
||||
var motdFile = "public/motd";
|
||||
var versionFile = "public/currVersion";
|
||||
const qaFile = "public/qa";
|
||||
|
||||
var logger = require('./logger.js');
|
||||
var utils = require('./utils.js');
|
||||
|
@ -490,3 +492,31 @@ function LoadJSON(resource) {
|
|||
logger.Log("[LOAD]:Error loading sutff", logger.GetColor("redbg"), true);
|
||||
}
|
||||
}
|
||||
|
||||
function ProcessQA() {
|
||||
if (!utils.FileExists(qaFile))
|
||||
utils.WriteFile("", qaFile);
|
||||
|
||||
let a = utils.ReadFile(qaFile).split("\n");
|
||||
let r = [];
|
||||
let ind = 0;
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if ( a[i] == "#")
|
||||
ind ++;
|
||||
else {
|
||||
if (r[ind] == undefined)
|
||||
r[ind] = {};
|
||||
|
||||
if (r[ind].q == undefined) {
|
||||
r[ind].q = a[i];
|
||||
} else {
|
||||
if (r[ind].a == undefined)
|
||||
r[ind].a = [];
|
||||
|
||||
r[ind].a.push(a[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue