diff --git a/index.html b/index.html index 17b8e96..1457009 100644 --- a/index.html +++ b/index.html @@ -126,7 +126,7 @@ var wordcloud = window.localStorage.getItem("wordcloud") || "true"; var scroll_y = window.localStorage.getItem("scroll_y"); //console.log("scroll_y read from cache is " + scroll_y); - + var inputHistory = window.localStorage.getItem("allHistory") || { "replace":{}, "checkbox":{} }; var cached_template = window.localStorage.getItem("template"); // try to get the saved templates from local storage var datepicker_list = []; // initialize a list to store DMP update reminder var toast_list; @@ -507,6 +507,7 @@ function load_dmp(callback = reload_answers, name = cached_template) { translatePage(name); + punctualReplaced = false; @@ -710,7 +711,7 @@ if (dmpLanguage[name] == dmpLanguage[doc_name]){ window["saved_a_"+dmpLanguage[name]]=saved_a; } - + window.localStorage.setItem("inputHistory", JSON.stringify(window.inputHistory)); dmpLanguage[name]=="en"? window.localStorage.setItem("saved_a", JSON.stringify(window.saved_a)): window.localStorage.setItem("saved_a_de", JSON.stringify(window.saved_a)) ; } @@ -722,8 +723,20 @@ */ function onchange_replace(child) { const before = child.name.toUpperCase(); - const after = child.value; + const after1 = child.value; + after = answerPunctual(after1) + child.value=after; saved_a["replace"][before] = after; + inputReplace = inputHistory["replace"]; + try{ + inputReplace[before][0]; + }catch(e){ + inputReplace[before]= []; + } + inputBefore = inputReplace[before] + singleInputContent = [after, saved_a["replace"][before], Date().toLocaleString().slice(0,15)].join(); + inputBefore.push(singleInputContent); + inputHistory["replace"][before] = inputBefore.filter((value, index, array) => array.indexOf(value) === index); //trim_saved_a(saved_a); eleName = before.split("_")[1]+"-to-"; @@ -802,10 +815,10 @@ */ // trim the "$_" to avoid infinite loops function trim_saved_a(saved_a) { - const replace = Object.entries(saved_a["replace"]); - for (const [key, value] of replace) { - saved_a["replace"][key] = value.replace("$_", "") - } + // const replace = Object.entries(saved_a["replace"]); + // for (const [key, value] of replace) { + // saved_a["replace"][key] = value.replace("$_", "") + // } } @@ -827,17 +840,17 @@ const selection = window.getSelection(); selection.removeAllRanges(); - trim_saved_a(saved_a); + //trim_saved_a(saved_a); saveToLocalStorage(name); - - const replace_input = Object.entries(saved_a["replace"]); - for (const [key, value] of replace_input) { + for (const [key, value1] of replace_input) { + value = answerPunctual(value1); if (key !== "$_VISUALIZATION") { let element = document.getElementsByName(key)[0]; //console.log(key + " "+value); try { + element.value = value; } catch (error) { console.error(error); @@ -1169,7 +1182,18 @@ } - + function answerPunctual(textall){ + textall= textall.replaceAll("and.", "."), + textall= textall.replaceAll(", .", "."), + textall= textall.replaceAll("..", "."), + textall= textall.replaceAll("..", ""), + textall= textall.replaceAll(". .", "."), + textall= textall.replaceAll(" ,", ","), + textall= textall.replaceAll(",,", ","), + textall= textall.replaceAll(",,", ""), + textall= textall.replaceAll(" .", "."); + return textall + } function punctual(){ let noDisplay = document.getElementById("doc3").querySelectorAll(".d-none"); noDisplay.forEach(e=>{ e.innerHTML= "" }); @@ -1177,9 +1201,11 @@ removeArtifact("and.", "."), removeArtifact(", .", "."), removeArtifact("..", "."), + removeArtifact("..", ""), removeArtifact(". .", "."), removeArtifact(" ,", ","), removeArtifact(",,", ","), + removeArtifact(",,", ""), removeArtifact(" .", "."); setTimeout(() => { removeComma("list-to-remove-comma", " and"), @@ -1205,6 +1231,7 @@ } function removeArtifact(text1, text2){ + while (window.find(text1, aCaseSensitive = 0, aBackwards = is_firefox, aWrapAround = 1, aWholeWord = 0, aSearchInFrames = is_firefox, aShowDialog = 0)) { let last_letter; @@ -1221,6 +1248,8 @@ } } + + // function get_option(this_element) { @@ -1788,7 +1817,7 @@ } - var cache_management = new bootstrap.Offcanvas(document.getElementById('cache_management')); + var upload_json1 = document.getElementById("upload"); upload_json1.addEventListener("change", open_storage_modal, false); var upload_json2 = document.getElementById("upload_menu"); @@ -2384,7 +2413,7 @@ const now = new Date(); saved_a["update"]["storage"][id]["answer"] = { "replace": JSON.parse(JSON.stringify(saved_a["replace"])), "checkbox": JSON.parse(JSON.stringify(saved_a["checkbox"])), "timestamp": now.toLocaleString() }; saved_a["update"]["storage"][id]["name"] = name; - trim_saved_a(saved_a); + //trim_saved_a(saved_a); saveToLocalStorage(doc_name); let update_element = document.querySelector("#load_from_cache_menu_" + id); update_element.innerHTML = now.toLocaleString(); @@ -2405,6 +2434,11 @@ } function dmp_update(saved_a) { + try { + saved_a["update"]["timeline"].length; + } catch (error) { + saved_a["update"]["timeline"] = []; + } if (saved_a["update"]["timeline"].length == 0) { clear_dmp_updates(); @@ -2428,7 +2462,6 @@ - } function clear_dmp_updates() { @@ -2569,11 +2602,9 @@ [].slice.call(document.querySelectorAll("#dmp-update-content li")).forEach((e) => datepicker_list.push({ "name": e.children[1].value, "date": e.children[2].value, })); const filtered_list = datepicker_list.filter(function (i) { return i != null; }); - - try { saved_a["update"]["timeline"] = filtered_list; } catch (e) { saved_a["update"]["timeline"] = [] } - trim_saved_a(saved_a); + //trim_saved_a(saved_a); saveToLocalStorage(doc_name); generate_vcal(saved_a); @@ -2805,7 +2836,12 @@ } function thisOnfocus(ele){ - const name1 = ele.name.split("_")[1]+"-to-";const elem1 = document.getElementsByName(name1); elem1.forEach(e => e.classList.add("border-highlight")); set_scrollbar_marker( scroll_marker,elem1 ) + const name1 = ele.name.split("_")[1]+"-to-";const elem1 = document.getElementsByName(name1); elem1.forEach(e => e.classList.add("border-highlight")); set_scrollbar_marker( scroll_marker,elem1 ); + try { + document.getElementById("historyContent").innerHTML = inputHistory.replace[ele.name]; + } catch (error) { + + } } function thisOnfocusout(ele){ const name1 = ele.name.split("_")[1]+"-to-";const elem1 = document.getElementsByName(name1);elem1.forEach(e => e.classList.remove("border-highlight")); document.querySelectorAll("[name=\"scroll-bar-span\"]").forEach(e => {e.remove()}) @@ -2954,6 +2990,11 @@ onchange="upload_image()" /> +