From 7ec9adad268ce42b5be120c55a0d4a34d151a51d Mon Sep 17 00:00:00 2001 From: hbk01 <3243430237@qq.com> Date: Thu, 21 Jul 2022 16:26:49 +0800 Subject: [PATCH] =?UTF-8?q?+=20=E5=B9=B2=E7=87=A5=E5=A4=B1=E9=87=8D?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BF=9D=E5=AD=98=E5=8A=9F=E8=83=BD=EF=BC=88?= =?UTF-8?q?=E5=AE=9E=E9=AA=8C=E6=80=A7=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lod.html | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- theme.css | 2 ++ 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/lod.html b/lod.html index 11180cf..f8e700f 100644 --- a/lod.html +++ b/lod.html @@ -37,6 +37,8 @@ $(".msgbox").append(tip) + loadSavedContentsList(); + $("#ok").click(function () { var m0l = input_m0l.value; var m1l = input_m1l.value; @@ -92,6 +94,78 @@ window.open(window.location.href, "_blank"); }); + var timer; + var isSave = true; + $("#save_and_restore").bind("touchstart mousedown", event => { + event.preventDefault(); + timer = setTimeout(() => { + let save = $("#save"); + let restore = $("#restore"); + + if (isSave) { + save.removeAttr("style"); + restore.attr("style", "color: deepskyblue;"); + } else { + restore.removeAttr("style"); + save.attr("style", "color: deepskyblue;"); + } + isSave = !isSave; + }, 1000); + }); + + $("#save_and_restore").bind("touchmove mouseleave", event => { + event.preventDefault(); + clearTimeout(timer); + timer = null; + return false; + }); + + $("#save_and_restore").bind("touchend mouseup", event => { + event.preventDefault(); + clearTimeout(timer); + return false; + }); + + $("#save_and_restore").bind("click", event => { + event.preventDefault(); + let id = $("#lod-name").val(); + + if (id.length == 0) { + alert("请输入或选择样品批号!"); + return; + } + + if (isSave) { + // save data to localStorage + let m0l = input_m0l.value; + let m1l = input_m1l.value; + let m3l = input_m3l.value; + let m0r = input_m0r.value; + let m1r = input_m1r.value; + let m3r = input_m3r.value; + + let lod = { + "m0l": m0l, + "m1l": m1l, + "m3l": m3l, + "m0r": m0r, + "m1r": m1r, + "m3r": m3r + }; + localStorage.setItem(id, JSON.stringify(lod)); + loadSavedContentsList(); + } else { + let lod = JSON.parse(localStorage.getItem(id)); + input_m0l.value = lod.m0l; + input_m1l.value = lod.m1l; + input_m3l.value = lod.m3l; + input_m0r.value = lod.m0r; + input_m1r.value = lod.m1r; + input_m3r.value = lod.m3r; + } + + }) + if (debug) { document.getElementById("m0l").value = 18.34625; document.getElementById("m1l").value = 1.04213; @@ -99,6 +173,20 @@ } }); + function loadSavedContentsList() { + // load data from localStorage to input. + let keys = []; + $("#keys").empty(); + for (let i = 0; i < localStorage.length; i++) { + keys.push(localStorage.key(i)); + } + keys.forEach(key => { + let option = document.createElement("option"); + option.innerText = key; + $("#keys").append(option); + }); + } + function message(msg) { $(".msgbox").empty(); $(".msgbox").append(msg); @@ -135,7 +223,7 @@

干燥失重

-

+

第一组
@@ -156,10 +244,16 @@
+
+ diff --git a/theme.css b/theme.css index faeea46..b2faa37 100644 --- a/theme.css +++ b/theme.css @@ -53,6 +53,8 @@ input { button { height: 32px; width: 96px; + margin-top: 6px; + margin-left: 3px; text-align: center; background-color: #f6f8fa; color: #24292f;