From cfe47f6633cdfd8b9ca97cc8c132eafe323578a0 Mon Sep 17 00:00:00 2001 From: hbk01 <3243430237@qq.com> Date: Mon, 8 Aug 2022 01:24:18 +0800 Subject: [PATCH] =?UTF-8?q?+=20=E5=B9=B2=E7=87=A5=E5=A4=B1=E9=87=8D?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=97=B6=E5=B0=86=E8=AE=B0=E5=BD=95=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E6=97=B6=E9=97=B4=EF=BC=8C=E5=B9=B6=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=9C=A8=E6=89=B9=E5=8F=B7=E7=9A=84=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E4=B8=AD=20+=20=E5=B9=B2=E7=87=A5=E5=A4=B1?= =?UTF-8?q?=E9=87=8D=E5=AF=B9=E6=89=B9=E5=8F=B7=E7=9A=84=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=BF=9B=E8=A1=8C=E6=8E=92=E5=BA=8F=EF=BC=88?= =?UTF-8?q?=E6=8C=89=E6=89=B9=E5=8F=B7=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lod.html | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lod.html b/lod.html index 75c29f2..2b6ad87 100644 --- a/lod.html +++ b/lod.html @@ -129,6 +129,7 @@ let m3r = input_m3r.value; let lod = { + "time": Date.now(), "m0l": m0l, "m1l": m1l, "m3l": m3l, @@ -183,9 +184,13 @@ for (let i = 0; i < localStorage.length; i++) { keys.push(localStorage.key(i)); } + keys.sort(); keys.forEach(key => { + let timestamp = JSON.parse(localStorage.getItem(key)).time; + let time = new Date(timestamp).format("yyyy-MM-dd hh:mm"); let option = document.createElement("option"); - option.innerText = key; + $(option).attr("value", key); + $(option).attr("label", `保存于 ${time}`); $("#keys").append(option); }); } @@ -247,6 +252,28 @@ return m0 == '' || m1 == '' || m3 == ''; } + // 为 Date 创建日期格式化方法 + Date.prototype.format = function (fmt) { + var o = { + "M+": this.getMonth() + 1, //月份 + "d+": this.getDate(), //日 + "h+": this.getHours(), //小时 + "m+": this.getMinutes(), //分 + "s+": this.getSeconds(), //秒 + "q+": Math.floor((this.getMonth() + 3) / 3), //季度 + "S": this.getMilliseconds() //毫秒 + }; + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); + } + for (var k in o) { + if (new RegExp("(" + k + ")").test(fmt)) { + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); + } + } + return fmt; + } +