From 696c3f97a17612c436f558efbd212ff7627b21a2 Mon Sep 17 00:00:00 2001 From: maru21 Date: Sun, 1 Oct 2023 18:50:46 +0200 Subject: [PATCH] implemented lineBreak default 200 --- index.html | 2 +- js/{9.7 => 9.8}/buildForm.js | 0 js/{9.7 => 9.8}/createTemplate.js | 0 js/{9.7 => 9.8}/evts.js | 0 js/{9.7 => 9.8}/files.js | 0 js/{9.7 => 9.8}/form.js | 0 js/{9.7 => 9.8}/identify.js | 0 js/{9.7 => 9.8}/init.js | 2 +- js/{9.7 => 9.8}/main.js | 0 js/{9.7 => 9.8}/parseForm.js | 40 +++++++++++++++++--- js/{9.7 => 9.8}/parseTemplate.js | 0 js/{9.7 => 9.8}/scripts.js | 0 js/{9.7 => 9.8}/sha256.min.js | 0 js/{9.7 => 9.8}/storage.js | 0 js/{9.7 => 9.8}/web.js | 0 js/{9.7 => 9.8}/xorc.js | 0 template/Sozialanamnese.txt | 63 ++++++++++++++++--------------- template/testing-form.txt | 2 +- 18 files changed, 69 insertions(+), 40 deletions(-) rename js/{9.7 => 9.8}/buildForm.js (100%) rename js/{9.7 => 9.8}/createTemplate.js (100%) rename js/{9.7 => 9.8}/evts.js (100%) rename js/{9.7 => 9.8}/files.js (100%) rename js/{9.7 => 9.8}/form.js (100%) rename js/{9.7 => 9.8}/identify.js (100%) rename js/{9.7 => 9.8}/init.js (95%) rename js/{9.7 => 9.8}/main.js (100%) rename js/{9.7 => 9.8}/parseForm.js (87%) rename js/{9.7 => 9.8}/parseTemplate.js (100%) rename js/{9.7 => 9.8}/scripts.js (100%) rename js/{9.7 => 9.8}/sha256.min.js (100%) rename js/{9.7 => 9.8}/storage.js (100%) rename js/{9.7 => 9.8}/web.js (100%) rename js/{9.7 => 9.8}/xorc.js (100%) mode change 100755 => 100644 template/Sozialanamnese.txt diff --git a/index.html b/index.html index c61f5c7..5fbe507 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,7 @@ - + diff --git a/js/9.7/buildForm.js b/js/9.8/buildForm.js similarity index 100% rename from js/9.7/buildForm.js rename to js/9.8/buildForm.js diff --git a/js/9.7/createTemplate.js b/js/9.8/createTemplate.js similarity index 100% rename from js/9.7/createTemplate.js rename to js/9.8/createTemplate.js diff --git a/js/9.7/evts.js b/js/9.8/evts.js similarity index 100% rename from js/9.7/evts.js rename to js/9.8/evts.js diff --git a/js/9.7/files.js b/js/9.8/files.js similarity index 100% rename from js/9.7/files.js rename to js/9.8/files.js diff --git a/js/9.7/form.js b/js/9.8/form.js similarity index 100% rename from js/9.7/form.js rename to js/9.8/form.js diff --git a/js/9.7/identify.js b/js/9.8/identify.js similarity index 100% rename from js/9.7/identify.js rename to js/9.8/identify.js diff --git a/js/9.7/init.js b/js/9.8/init.js similarity index 95% rename from js/9.7/init.js rename to js/9.8/init.js index e1cb74f..9535408 100644 --- a/js/9.7/init.js +++ b/js/9.8/init.js @@ -16,7 +16,7 @@ window.activeState = { fileName: "", lastElement: "", serverFilesTs: "", - lineBreak: 80, + lineBreak: 200, templates: [], templateFieldTypes: [ "simpleInput", diff --git a/js/9.7/main.js b/js/9.8/main.js similarity index 100% rename from js/9.7/main.js rename to js/9.8/main.js diff --git a/js/9.7/parseForm.js b/js/9.8/parseForm.js similarity index 87% rename from js/9.7/parseForm.js rename to js/9.8/parseForm.js index 8265443..dfb46f7 100644 --- a/js/9.7/parseForm.js +++ b/js/9.8/parseForm.js @@ -173,7 +173,6 @@ function parseFormOnSubmit(returnJSON = false, parseOnly = false) { value = obj.placeholder + "\n" + value; } } - //Plugin TextBlock Insertion according to file _textblocks.txt value = parseTextBlocks(value); @@ -182,6 +181,9 @@ function parseFormOnSubmit(returnJSON = false, parseOnly = false) { //handle placeholders like !l or !n and set it to final interpreted string for object value = parseTextMarkups(value); + //parse global linebreak after marked text was already fixed + value = parseGlobalLineBreak(value); + return value; } @@ -317,20 +319,46 @@ function parseFormOnSubmit(returnJSON = false, parseOnly = false) { return data; } + function parseGlobalLineBreak(data) { + let parsedData = ''; + for (let line of data.split('\n')) { + let parsedLine = parseLineBreak(line); + if (parsedData != '') { + parsedData = parsedData + '\n' + parsedLine; + } else { + parsedData = parsedLine; + } + } + return parsedData + } + function parseLineBreak(line, intendation = 0) { - return line; //very much in development no idea yet let lines; if (line.length > activeState.lineBreak) { + let correctedLineBreak; + let newLineStart; + let cLBt = activeState.lineBreak-(intendation*2) + correctedLineBreak = line.substring(0, cLBt).lastIndexOf(" "); + newLineStart = correctedLineBreak+1; + lines = line.substring(0, correctedLineBreak); + line = line.substring(newLineStart); + while(line.length > activeState.lineBreak) { let intendationSpaces = ''; - if (intendation != 0) intendationSpaces = ' '.repeat(intendation); - - lines = lines + "\n" + intendationSpaces + line.substring(0, activeState.lineBreak-intendation); - line = line.substring(activeState.lineBreak-intendation); + if (intendation != 0) intendationSpaces = ' '.repeat(intendation+1); + let cLBt = activeState.lineBreak-(intendation*2) + correctedLineBreak = line.substring(0, cLBt).lastIndexOf(" "); + newLineStart = correctedLineBreak+1; + lines += "\n" + intendationSpaces + line.substring(0, correctedLineBreak); + line = line.substring(newLineStart); + break; } + let intendationSpaces = ''; + if (intendation != 0) intendationSpaces = ' '.repeat(intendation+1); + lines += "\n" + intendationSpaces + line; } else { lines = line; } diff --git a/js/9.7/parseTemplate.js b/js/9.8/parseTemplate.js similarity index 100% rename from js/9.7/parseTemplate.js rename to js/9.8/parseTemplate.js diff --git a/js/9.7/scripts.js b/js/9.8/scripts.js similarity index 100% rename from js/9.7/scripts.js rename to js/9.8/scripts.js diff --git a/js/9.7/sha256.min.js b/js/9.8/sha256.min.js similarity index 100% rename from js/9.7/sha256.min.js rename to js/9.8/sha256.min.js diff --git a/js/9.7/storage.js b/js/9.8/storage.js similarity index 100% rename from js/9.7/storage.js rename to js/9.8/storage.js diff --git a/js/9.7/web.js b/js/9.8/web.js similarity index 100% rename from js/9.7/web.js rename to js/9.8/web.js diff --git a/js/9.7/xorc.js b/js/9.8/xorc.js similarity index 100% rename from js/9.7/xorc.js rename to js/9.8/xorc.js diff --git a/template/Sozialanamnese.txt b/template/Sozialanamnese.txt old mode 100755 new mode 100644 index 590e314..f7c428c --- a/template/Sozialanamnese.txt +++ b/template/Sozialanamnese.txt @@ -1,31 +1,32 @@ -# -# Erzeuge das Wohnenfeld an erster Stelle und generiere ein Eingabefeld in Listenformat -Wohnen: -!l Lebensmittelpunkt: %Lebensmittelpunkt%10 -!l Mietzins: %Mietzins CHF%11 -!l Wohnhaft seit %Wohnhaft seit%12 -!l Wohnhaft mit %Wohnpartner%13 -%Weitere Angaben zum Wohnen=longText:!l%15 - -Finanzen: -%Finanzielle Situation=longText:!l%20 - -Arbeit: -%Arbeitssituation und IV=longText:!l%30 - -Tagesstruktur: -%Tagesstruktur=longText:!l%40 - -Soziales Umfeld: -%Soziales Umfeld=longText:!l%50 - -Externe Fachpersonen: -%Externe Fachpersonen=longText:!l%60 - -Beistandschaft: -%Berufsbeistandschaft vorhanden=simpleInput:!l%70 - -Sozialarbeiter:in: Karim Muhrer - -Verlauf: -Der Patient wurde durch den internen Sozialdienst beraten. %Verlauf Patient=longText%80 +# +# Erzeuge das Wohnenfeld an erster Stelle und generiere ein Eingabefeld in Listenformat +Wohnen: +!l Lebensmittelpunkt: %Lebensmittelpunkt%10 +!l Mietzins: %Mietzins CHF%11 +!l Wohnhaft seit %Wohnhaft seit%12 +!l Wohnhaft mit %Wohnpartner%13 +%Weitere Angaben zum Wohnen=longText:!l%15 + +Finanzen: +%Finanzielle Situation=longText:!l%20 + +Arbeit: +%Arbeitssituation und IV=longText:!l%30 + +Tagesstruktur: +%Tagesstruktur=longText:!l%40 + +Soziales Umfeld: +%Soziales Umfeld=longText:!l%50 + +Externe Fachpersonen: +%Externe Fachpersonen=longText:!l%60 + +Beistandschaft: +%Berufsbeistandschaft vorhanden=simpleInput:!l%70 + +Sozialarbeiter:in: Karim Muhrer + +Verlauf: +Der Patient wurde durch den internen Sozialdienst beraten. +%Verlauf Patient=longText%80 diff --git a/template/testing-form.txt b/template/testing-form.txt index dc9af9e..37f6be0 100644 --- a/template/testing-form.txt +++ b/template/testing-form.txt @@ -1 +1 @@ -[{"value":"!none","name":"Con_List_Selection"},{"value":"","name":"cl-Die_Patientin_ist_erwerbstätig","placeholder":"!ls"},{"value":"Firma: \nFunktion: \nPensum: \nAngestellt seit: \n","name":"cl-Der_Patient_ist_erwerbstätig_auf_dem_2._AM","placeholder":"!ls"},{"value":"AUF seit: \nAktueller Stand IV: ","name":"cl-_Der_Patient_ist_nicht_erwerbstätig","placeholder":"!ls"},{"value":"","name":"cl-Andere","placeholder":"!ls"},{"value":"Lebensmittelpunkt","name":"Con_List_Button"},{"value":"","name":"cl-Lebensmittelpunkt","placeholder":"!ls"}] \ No newline at end of file +[{"value":"!none","name":"Con_List_Selection"},{"value":"","name":"cl-Die_Patientin_ist_erwerbstätig","placeholder":"!ls"},{"value":"Firma: \nFunktion: \nPensum: \nAngestellt seit: \n","name":"cl-Der_Patient_ist_erwerbstätig_auf_dem_2._AM","placeholder":"!ls"},{"value":"AUF seit: \nAktueller Stand IV: ","name":"cl-_Der_Patient_ist_nicht_erwerbstätig","placeholder":"!ls"},{"value":"","name":"cl-Andere","placeholder":"!ls"},{"value":"Lebensmittelpunkt","name":"Con_List_Button"},{"value":"!ls\n!kbs","name":"cl-Lebensmittelpunkt","placeholder":"!ls"}] \ No newline at end of file