From 487e233721c312de32932390cdaaca417afcb12b Mon Sep 17 00:00:00 2001 From: Bogdan Pilyugin Date: Wed, 12 Apr 2023 16:44:52 +0200 Subject: [PATCH] extended cron editor implemented, need testing --- HTML/espfs.paths | 58 ++++++------- HTML/res/appstyles.css | 3 +- HTML/res/cron.js | 184 ++++++++++++++++++++++++++++++----------- dependencies.lock | 18 ++-- 4 files changed, 178 insertions(+), 85 deletions(-) diff --git a/HTML/espfs.paths b/HTML/espfs.paths index b5a6c0d..0976c73 100644 --- a/HTML/espfs.paths +++ b/HTML/espfs.paths @@ -1,30 +1,30 @@ -adapters.html -api -api/dbg.json -api/dbg2.json -api/gendata.json -api/mem.json -api/set1.json -api/set2.json -api/set3.json -api/stat.json -api/status.json -api/tmr.json -api/wifiscan.json -application.html -favicon.ico -index.html -info.html -reboot.html -res -res/appstyles.css -res/ca_cert.pem -res/cron.js -res/iconsfont.css -res/iconsfont.woff2 -res/logo.png -res/main.js -res/res.js -res/styles.css -services.html +adapters.html +api +api/dbg.json +api/dbg2.json +api/gendata.json +api/mem.json +api/set1.json +api/set2.json +api/set3.json +api/stat.json +api/status.json +api/tmr.json +api/wifiscan.json +application.html +favicon.ico +index.html +info.html +reboot.html +res +res/appstyles.css +res/ca_cert.pem +res/cron.js +res/iconsfont.css +res/iconsfont.woff2 +res/logo.png +res/main.js +res/res.js +res/styles.css +services.html system.html \ No newline at end of file diff --git a/HTML/res/appstyles.css b/HTML/res/appstyles.css index 35ca562..17238b3 100644 --- a/HTML/res/appstyles.css +++ b/HTML/res/appstyles.css @@ -187,6 +187,7 @@ width:100%; .crselect { - height:120px; +height:120px; +overflow: hidden; } diff --git a/HTML/res/cron.js b/HTML/res/cron.js index 09062a5..942c828 100644 --- a/HTML/res/cron.js +++ b/HTML/res/cron.js @@ -6,37 +6,88 @@ timarr_test = [{ 'num': 1, 'obj': 2, 'act': 0, 'start': 1000000000, 'cron': '*/2 function savetm(n) { } -function set_cron_string(tnum, s, m, h, d, mm, w) { - var c = (document.getElementById("cron" + tnum).value).split(" "); - if (c.length == 6) { - if (s != null) - c[0] = s; - if (m != null) - c[1] = m; - if (h != null) - c[2] = h; - if (d != null) - c[3] = d; - if (mm != null) - c[4] = mm; - if (w != null) - c[5] = w; - document.getElementById("cron" + tnum).value = c[0] + " " + c[1] + " " + c[2] + " " + c[3] + " " + c[4] + " " + c[5]; +function extractSelectArr(select) +{ + var result = []; + var options = select && select.options; + var opt; + for (var i=0, iLen=options.length; i 1 ) + grouped+=intbeg+"-"+result[i]; + else + grouped+=intbeg+","+result[i]; + } + else + grouped+=result[i]; + } + if(i < result.length -1 && !inside) + grouped+=","; } + return grouped; } -function getSecondSelect(n) { - var s = document.getElementsByName("selectSeconds" + n + "[]")[0].value; - set_cron_string(n, s, null, null, null, null, null); +function handleSelect(tnum, type) +{ + var cinp = document.getElementById("cron" + tnum); + var c = (cinp.value).split(" "); + if(c.length != 6) + { + alert("Cron string was edited and not valid"); + return; + } + switch(type) + { + case 1: + var s = extractSelectArr(document.getElementById("seconds")); + if (s != null) c[0] = s; + break; + case 2: + var m = extractSelectArr(document.getElementById("minutes")); + if (m != null) c[1] = m; + break; + case 3: + var h = extractSelectArr(document.getElementById("hours")); + if (h != null) c[2] = h; + break; + case 4: + var d = extractSelectArr(document.getElementById("days")); + if (d != null) c[3] = d; + break; + case 5: + var mm = extractSelectArr(document.getElementById("months")); + if (mm != null) c[4] = mm; + break; + case 6: + var w = extractSelectArr(document.getElementById("weekdays")); + if (w != null) c[5] = w; + break; + } + cinp.value = c[0] + " " + c[1] + " " + c[2] + " " + c[3] + " " + c[4] + " " + c[5]; } -function getMinutesSelect(n) { - var m = document.getElementById("minutes").value; - set_cron_string(n, null, m, null, null, null, null); -} -function getHoursSelect(n) { - var h = document.getElementById("hours").value; - set_cron_string(n, null, null, h, null, null, null); -} - function deltm(n) { alert("Delete timer " + n); timarr_test.splice(n - 1, 1); @@ -50,36 +101,77 @@ function closecron(n) { function setcron(n) { var target = document.getElementById("cronext" + n); var content = ""; - content += (""); + content += (""); + content += (""); + content += (""); + content += (""); + content += (""); + content += (""); for (s = 0; s < 60; s++) { content += (""); } content += (""); - content += (""); + content += (""); + content += (""); + content += (""); + content += (""); + content += (""); + content += (""); for (s = 0; s < 60; s++) { content += (""); } content += (""); - content += (""); content += (""); content += (""); content += (""); - content += (""); - content += (""); - content += (""); + content += (""); + content += (""); for (s = 0; s < 24; s++) { content += (""); } content += (""); + content += (""); + + content += (""); + + content += (""); content += ("
"); diff --git a/dependencies.lock b/dependencies.lock index b34c22b..55ac77a 100644 --- a/dependencies.lock +++ b/dependencies.lock @@ -1,9 +1,9 @@ -dependencies: - idf: - component_hash: null - source: - type: idf - version: 4.4.4 -manifest_hash: 31dd4ec84ade1450fc168388f4adce2efacd1516170670735140bc772e9d72bd -target: esp32 -version: 1.0.0 +dependencies: + idf: + component_hash: null + source: + type: idf + version: 4.4.4 +manifest_hash: f9b3d78d7d56685d1c543701158a0fab7a56c908117ed70644f77e4247c831ae +target: esp32 +version: 1.0.0