update extended cron editor
This commit is contained in:
parent
7a30d25181
commit
308fe79602
196
HTML/res/cron.js
196
HTML/res/cron.js
|
|
@ -6,51 +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 getSecondSelect(n) {
|
||||
var sel = document.getElementsByName("selectSeconds" + n + "[]")[0];
|
||||
var opts = [],
|
||||
opt;
|
||||
var len = sel.options.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
opt = sel.options[i];
|
||||
|
||||
function extractSelectArr(select)
|
||||
{
|
||||
var result = [];
|
||||
var options = select && select.options;
|
||||
var opt;
|
||||
for (var i=0, iLen=options.length; i<iLen; i++) {
|
||||
opt = options[i];
|
||||
if (opt.selected) {
|
||||
opts.push(opt);
|
||||
if(isNaN(opt.value))
|
||||
{
|
||||
return opt.value;
|
||||
}
|
||||
result.push(opt.value);
|
||||
}}
|
||||
|
||||
}
|
||||
}
|
||||
console.log(opts);
|
||||
return opts;
|
||||
//var s = document.getElementsByName("selectSeconds" + n + "[]")[0].value;
|
||||
//set_cron_string(n, s, null, null, null, null, null);
|
||||
var grouped = "";
|
||||
var intbeg;
|
||||
var inside = false;
|
||||
for ( i=0; i <result.length;i++)
|
||||
{
|
||||
if(parseInt(result[i+1]) == (parseInt(result[i]) + 1))
|
||||
{
|
||||
if(!inside)
|
||||
intbeg = result[i];
|
||||
inside = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(inside)
|
||||
{
|
||||
inside=false;
|
||||
if((parseInt(result[i]) - parseInt(intbeg)) > 1 )
|
||||
grouped+=intbeg+"-"+result[i];
|
||||
else
|
||||
grouped+=intbeg+","+result[i];
|
||||
}
|
||||
else
|
||||
grouped+=result[i];
|
||||
}
|
||||
if(i < result.length -1 && !inside)
|
||||
grouped+=",";
|
||||
}
|
||||
return grouped;
|
||||
}
|
||||
function getMinutesSelect(n) {
|
||||
var m = document.getElementById("minutes").value;
|
||||
set_cron_string(n, null, m, 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 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);
|
||||
|
|
@ -64,36 +101,77 @@ function closecron(n) {
|
|||
function setcron(n) {
|
||||
var target = document.getElementById("cronext" + n);
|
||||
var content = "";
|
||||
content += ("<select multiple size=\"10\" class=\"crselect\" name=\"selectSeconds" + n + "[]\" id=\"seconds\" onchange=\"getSecondSelect("+n+")\">");
|
||||
content += ("<option value=\"*\">Every Second</option>");
|
||||
content += ("<option value=\"*/2\">Even Second</option>");
|
||||
content += ("<option value=\"1-59/2\">Odd Second</option>");
|
||||
content += ("<option value=\"*/5\">Every 5 Second</option>");
|
||||
content += ("<option value=\"*/15\">Every 15 Second</option>");
|
||||
content += ("<option value=\"*/30\">Every 30 Second</option>");
|
||||
content += ("<select multiple class=\"crselect\" name=\"selectSeconds" + n + "[]\" id=\"seconds\" onchange=\"handleSelect("+n+", 1)\">");
|
||||
content += ("<option value=\"*\">Every Sec</option>");
|
||||
content += ("<option value=\"*/2\">Even Sec</option>");
|
||||
content += ("<option value=\"1-59/2\">Odd Sec</option>");
|
||||
content += ("<option value=\"*/5\">Every 5 Sec</option>");
|
||||
content += ("<option value=\"*/15\">Every 15 Sec</option>");
|
||||
content += ("<option value=\"*/30\">Every 30 Sec</option>");
|
||||
for (s = 0; s < 60; s++) { content += ("<option value=\"" + s + "\">" + s + "</option>"); }
|
||||
content += ("</select>");
|
||||
|
||||
content += ("<select multiple size=\"10\" class=\"crselect\" name=\"selectMinutes" + n + "[]\" id=\"minutes\" onchange=\"getMinutesSelect("+n+")\">");
|
||||
content += ("<option value=\"*\">Every Minute</option>");
|
||||
content += ("<option value=\"*/2\">Even Minutes</option>");
|
||||
content += ("<option value=\"1-59/2\">Odd Minute</option>");
|
||||
content += ("<option value=\"*/5\">Every 5 Minutes</option>");
|
||||
content += ("<option value=\"*/15\">Every 15 Minutes</option>");
|
||||
content += ("<option value=\"*/30\">Every 30 Minutes</option>");
|
||||
content += ("<select multiple class=\"crselect\" name=\"selectMinutes" + n + "[]\" id=\"minutes\" onchange=\"handleSelect("+n+", 2)\">");
|
||||
content += ("<option value=\"*\">Every Min</option>");
|
||||
content += ("<option value=\"*/2\">Even Min</option>");
|
||||
content += ("<option value=\"1-59/2\">Odd Min</option>");
|
||||
content += ("<option value=\"*/5\">Every 5 Min</option>");
|
||||
content += ("<option value=\"*/15\">Every 15 Min</option>");
|
||||
content += ("<option value=\"*/30\">Every 30 Min</option>");
|
||||
for (s = 0; s < 60; s++) { content += ("<option value=\"" + s + "\">" + s + "</option>"); }
|
||||
content += ("</select>");
|
||||
|
||||
content += ("<select multiple size=\"10\" class=\"crselect\" name=\"selectHours" + n + "[]\" id=\"hours\" onchange=\"getHoursSelect("+n+")\">");
|
||||
content += ("<select multiple class=\"crselect\" name=\"selectHours" + n + "[]\" id=\"hours\" onchange=\"handleSelect("+n+", 3)\">");
|
||||
content += ("<option value=\"*\">Every Hour</option>");
|
||||
content += ("<option value=\"*/2\">Even Hours</option>");
|
||||
content += ("<option value=\"1-23/2\">Odd Hours</option>");
|
||||
content += ("<option value=\"*/2\">Every 2 Hours</option>");
|
||||
content += ("<option value=\"*/3\">Every 3 Hours</option>");
|
||||
content += ("<option value=\"*/4\">Every 4 Hours</option>");
|
||||
content += ("<option value=\"*/6\">Every 6 Hours</option>");
|
||||
content += ("<option value=\"*/12\">Every 12 Hours</option>");
|
||||
for (s = 0; s < 24; s++) { content += ("<option value=\"" + s + "\">" + s + "</option>"); }
|
||||
content += ("</select>");
|
||||
|
||||
content += ("<select multiple class=\"crselect\" name=\"selectDays" + n + "[]\" id=\"days\" onchange=\"handleSelect("+n+", 4)\">");
|
||||
content += ("<option value=\"*\">Every Day</option>");
|
||||
content += ("<option value=\"*/2\">Even Days</option>");
|
||||
content += ("<option value=\"1-31/2\">Odd Days</option>");
|
||||
content += ("<option value=\"*/5\">Every 5 Days</option>");
|
||||
content += ("<option value=\"*/10\">Every 10 Days</option>");
|
||||
content += ("<option value=\"*/15\">Every 15 Days</option>");
|
||||
for (s = 0; s < 32; s++) { content += ("<option value=\"" + s + "\">" + s + "</option>"); }
|
||||
content += ("</select>");
|
||||
|
||||
content += ("<select multiple class=\"crselect\" name=\"selectMonths" + n + "[]\" id=\"months\" onchange=\"handleSelect("+n+", 5)\">");
|
||||
content += ("<option value=\"*\">Every Month</option>");
|
||||
content += ("<option value=\"*/2\">Even Month</option>");
|
||||
content += ("<option value=\"1-11/2\">Odd Month</option>");
|
||||
content += ("<option value=\"*/4\">Every 4 Month</option>");
|
||||
content += ("<option value=\"*/6\">Every half Year</option>");
|
||||
content += ("<option value=\"1\">Jan</option>");
|
||||
content += ("<option value=\"2\">Feb</option>");
|
||||
content += ("<option value=\"3\">Mar</option>");
|
||||
content += ("<option value=\"4\">Apr</option>");
|
||||
content += ("<option value=\"5\">May</option>");
|
||||
content += ("<option value=\"6\">Jun</option>");
|
||||
content += ("<option value=\"7\">Jul</option>");
|
||||
content += ("<option value=\"8\">Aug</option>");
|
||||
content += ("<option value=\"9\">Sep</option>");
|
||||
content += ("<option value=\"10\">Oct</option>");
|
||||
content += ("<option value=\"11\">Nov</option>");
|
||||
content += ("<option value=\"12\">Dec</option>");
|
||||
content += ("</select>");
|
||||
|
||||
content += ("<select multiple class=\"crselect\" name=\"selectWeekday" + n + "[]\" id=\"weekdays\" onchange=\"handleSelect("+n+", 6)\">");
|
||||
content += ("<option value=\"*\">Every Weekday</option>");
|
||||
content += ("<option value=\"1-5\">Monday-Friday</option>");
|
||||
content += ("<option value=\"0,6\">Weekend Days</option>");
|
||||
content += ("<option value=\"0\">Sun</option>");
|
||||
content += ("<option value=\"1\">Mon</option>");
|
||||
content += ("<option value=\"2\">Tue</option>");
|
||||
content += ("<option value=\"3\">Wed</option>");
|
||||
content += ("<option value=\"4\">Thu</option>");
|
||||
content += ("<option value=\"5\">Fri</option>");
|
||||
content += ("<option value=\"6\">Sat</option>");
|
||||
content += ("</select>");
|
||||
|
||||
|
||||
content += ("<div><button class=\"btn\" type=\"button\" onclick=\"closecron(" + n + ")\">Ready</button></div>");
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ dependencies:
|
|||
source:
|
||||
type: idf
|
||||
version: 4.4.4
|
||||
manifest_hash: f9b3d78d7d56685d1c543701158a0fab7a56c908117ed70644f77e4247c831ae
|
||||
manifest_hash: 31dd4ec84ade1450fc168388f4adce2efacd1516170670735140bc772e9d72bd
|
||||
target: esp32
|
||||
version: 1.0.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user