From 5eb216f3958b0aa860e52784bc50ed9749018494 Mon Sep 17 00:00:00 2001 From: maru21 Date: Sat, 11 Nov 2023 15:52:25 +0100 Subject: [PATCH] started pell parsing on form import --- js/2.0.3/buildHtmlForm.js | 4 ++-- js/2.0.3/evts.js | 2 +- js/2.0.3/init.js | 12 +++++++----- js/2.0.3/parseForm.js | 4 ++-- js/2.0.3/scripts.js | 2 +- js/2.0.3/settings.js | 2 +- js/2.0.3/storage.js | 5 +++-- js/2.0.3/web.js | 20 ++++++++++++++++++++ 8 files changed, 37 insertions(+), 14 deletions(-) diff --git a/js/2.0.3/buildHtmlForm.js b/js/2.0.3/buildHtmlForm.js index e298240..21bb6ca 100644 --- a/js/2.0.3/buildHtmlForm.js +++ b/js/2.0.3/buildHtmlForm.js @@ -418,7 +418,7 @@ function buildSidebarList(obj, sidebarList) { function buildLongTextInput(source, textarea, label) { - if (activeState.settings.enablePell == "false") return; + if (!activeState.settings.enablePell) return; //hide default textarea textarea.style.display = "none"; label.style.display = "none"; @@ -440,7 +440,7 @@ function buildLongTextInput(source, textarea, label) { "heading2", { name: 'ulist', - icon: 'L' + icon: '' }, "olist" ], diff --git a/js/2.0.3/evts.js b/js/2.0.3/evts.js index f340440..339d0f7 100644 --- a/js/2.0.3/evts.js +++ b/js/2.0.3/evts.js @@ -129,7 +129,7 @@ function printVersion(msg = "") { } function clickImportFiles() { - if (activeState.settings.localOnly == "true") { + if (activeState.settings.localOnly) { createBookShelfDownload(); return; } diff --git a/js/2.0.3/init.js b/js/2.0.3/init.js index 8201bbe..56b0fa5 100644 --- a/js/2.0.3/init.js +++ b/js/2.0.3/init.js @@ -26,14 +26,14 @@ window.activeState = { lastElement: "", serverFilesTs: "", settings: { - localOnly: "true", + localOnly: true, lineBreak: 120, font: "Arial", fontSize: "10px", notifierPause: 1, - persistentStorage: "false", - enablePell: "false", - debug: "false" + persistentStorage: false, + enablePell: false, + debug: false }, templates: [], templateObjectsPurified: [], @@ -73,6 +73,8 @@ function init() { let settings = storeSettings("getInit", true); if (settings != null) { for (let setting of Object.entries(settings)) { + if (typeof(setting[1]) == "string" && setting[1].toLowerCase() === "true") setting[1] = true; + if (typeof(setting[1]) == "string" && setting[1].toLowerCase() === "false") setting[1] = false; activeState.settings[setting[0]] = setting[1]; } } @@ -87,7 +89,7 @@ function init() { eventListeners(); //print current version and storage mode to footer - let msg = (activeState.settings.persistentStorage == "false") ? "temporary" : "persistent"; + let msg = (!activeState.settings.persistentStorage) ? "temporary" : "persistent"; printVersion("storage mode: "+msg+" |"); //adjust title for mobile use diff --git a/js/2.0.3/parseForm.js b/js/2.0.3/parseForm.js index aa2e351..38f82aa 100644 --- a/js/2.0.3/parseForm.js +++ b/js/2.0.3/parseForm.js @@ -102,7 +102,7 @@ function parseForm(returnDIV = false) { bHtml = bHtml.replace(/<\/div>/g, '
'); bHtml = bHtml.replace(/
/g, ''); - if (activeState.settings.enablePell == "true") { + if (activeState.settings.enablePell) { bHtml = bHtml.replace(/!l /g, ""); bHtml = bHtml.replace(/!n /g, ""); bHtml = bHtml.replace(/!ls /g, ""); @@ -250,7 +250,7 @@ function parseForm(returnDIV = false) { if (listFlag && listIndicator == "") listIndicator = " • "; //exclude settings if pell is enabled - if (activeState.settings.enablePell == "true") listIndicator = ""; + if (activeState.settings.enablePell) listIndicator = ""; //handle global linebreak and fit according to indicator according to list indicator diff --git a/js/2.0.3/scripts.js b/js/2.0.3/scripts.js index f927498..31505c0 100644 --- a/js/2.0.3/scripts.js +++ b/js/2.0.3/scripts.js @@ -82,7 +82,7 @@ function setCookie(cname, cvalue, exdays) { const d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); let expires = "expires="+d.toUTCString(); - document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; + document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/;SameSite=Lax"; } function getCookie(cname) { diff --git a/js/2.0.3/settings.js b/js/2.0.3/settings.js index b1b5b97..15f46b4 100644 --- a/js/2.0.3/settings.js +++ b/js/2.0.3/settings.js @@ -184,7 +184,7 @@ function saveSettings() { //transfer tF if (tF != null) storeData("templateFiles", tF); - let msg = (activeState.settings.persistentStorage == "false") ? "temporary" : "persistent"; + let msg = (!activeState.settings.persistentStorage) ? "temporary" : "persistent"; printVersion("storage mode: "+msg+" |"); } diff --git a/js/2.0.3/storage.js b/js/2.0.3/storage.js index 21ade2e..834ce2f 100644 --- a/js/2.0.3/storage.js +++ b/js/2.0.3/storage.js @@ -34,7 +34,7 @@ const tempStore = { }; function getStor() { - if (window.activeState.settings.persistentStorage == "true") { + if (window.activeState.settings.persistentStorage) { return window.localStorage; } else { return tempStore; @@ -43,6 +43,7 @@ function getStor() { function debug(mode, key, data) { if (activeState.settings.debug == "false") return data; + if (activeState.settings.debug == false) return data; console.log({ mode: mode, key: key, @@ -165,7 +166,7 @@ function getFileName() { ts_copy: "", ts_edit: "", id: cyrb53(currentFileName), - editor: (activeState.settings.enablePell == "true") ? "pell": "textarea" + editor: (activeState.settings.enablePell) ? "pell": "textarea" }; if (tF.length != 0) { diff --git a/js/2.0.3/web.js b/js/2.0.3/web.js index d6f236a..ea06d5e 100644 --- a/js/2.0.3/web.js +++ b/js/2.0.3/web.js @@ -291,6 +291,7 @@ function retrieveForm(arr) { for (let i = 0; i < arr.length; i++) { + if (arr[i].name == "") continue; let e = document.getElementById(arr[i].name); if (e === null) { //parse connected list @@ -323,9 +324,28 @@ function retrieveForm(arr) { switch (e.nodeName) { case "TEXTAREA": + + arr[i].value = arr[i].value.replace(/
/g, ""); + arr[i].value = arr[i].value.replace(/<\/div>/g, "\n"); + arr[i].value = arr[i].value.replace(/<.{1,4}>/g, ""); + if (e.parentElement != undefined) { if (e.parentElement.getElementsByClassName("pell-content")[0] != undefined) { + let contentArray = arr[i].value.split("\n"); + let parsedContent = ""; + if (contentArray.length != 0) { + for (let contentLine of contentArray) { + if (contentLine != "") { + contentLine = "
" + contentLine + "
"; + } + parsedContent += contentLine; + } + } else { + parsedContent = arr[i].value; + } e.innerHTML = arr[i].value; + + arr[i].value = parsedContent; e = e.parentElement.getElementsByClassName("pell-content")[0]; } }