update extended cron editor
This commit is contained in:
parent
7a30d25181
commit
308fe79602
|
|
@ -1,30 +1,30 @@
|
||||||
adapters.html
|
adapters.html
|
||||||
api
|
api
|
||||||
api/dbg.json
|
api/dbg.json
|
||||||
api/dbg2.json
|
api/dbg2.json
|
||||||
api/gendata.json
|
api/gendata.json
|
||||||
api/mem.json
|
api/mem.json
|
||||||
api/set1.json
|
api/set1.json
|
||||||
api/set2.json
|
api/set2.json
|
||||||
api/set3.json
|
api/set3.json
|
||||||
api/stat.json
|
api/stat.json
|
||||||
api/status.json
|
api/status.json
|
||||||
api/tmr.json
|
api/tmr.json
|
||||||
api/wifiscan.json
|
api/wifiscan.json
|
||||||
application.html
|
application.html
|
||||||
favicon.ico
|
favicon.ico
|
||||||
index.html
|
index.html
|
||||||
info.html
|
info.html
|
||||||
reboot.html
|
reboot.html
|
||||||
res
|
res
|
||||||
res/appstyles.css
|
res/appstyles.css
|
||||||
res/ca_cert.pem
|
res/ca_cert.pem
|
||||||
res/cron.js
|
res/cron.js
|
||||||
res/iconsfont.css
|
res/iconsfont.css
|
||||||
res/iconsfont.woff2
|
res/iconsfont.woff2
|
||||||
res/logo.png
|
res/logo.png
|
||||||
res/main.js
|
res/main.js
|
||||||
res/res.js
|
res/res.js
|
||||||
res/styles.css
|
res/styles.css
|
||||||
services.html
|
services.html
|
||||||
system.html
|
system.html
|
||||||
368
HTML/res/cron.js
368
HTML/res/cron.js
|
|
@ -1,148 +1,226 @@
|
||||||
objects_test = ["scene_1", "scene_2", "scene_3", "scene_4", "scene_5", "scene_6", "scene_7", "scene_8", "scene_9", "scene_10", "scene_11", "scene_12", "scene_13", "scene_14", "scene_15", "scene_16"];
|
objects_test = ["scene_1", "scene_2", "scene_3", "scene_4", "scene_5", "scene_6", "scene_7", "scene_8", "scene_9", "scene_10", "scene_11", "scene_12", "scene_13", "scene_14", "scene_15", "scene_16"];
|
||||||
actions_test = ["start", "stop"];
|
actions_test = ["start", "stop"];
|
||||||
timarr_test = [{ 'num': 1, 'obj': 2, 'act': 0, 'start': 1000000000, 'cron': '*/2 * * * * *' },
|
timarr_test = [{ 'num': 1, 'obj': 2, 'act': 0, 'start': 1000000000, 'cron': '*/2 * * * * *' },
|
||||||
{ 'num': 2, 'obj': 12, 'act': 1, 'start': 1622222222, 'cron': '6 0 12 * * *' },
|
{ 'num': 2, 'obj': 12, 'act': 1, 'start': 1622222222, 'cron': '6 0 12 * * *' },
|
||||||
{ 'num': 3, 'obj': 8, 'act': 0, 'start': 1675757575, 'cron': '* * * * * *' }];
|
{ 'num': 3, 'obj': 8, 'act': 0, 'start': 1675757575, 'cron': '* * * * * *' }];
|
||||||
function savetm(n) {
|
function savetm(n) {
|
||||||
|
|
||||||
}
|
}
|
||||||
function set_cron_string(tnum, s, m, h, d, mm, w) {
|
function extractSelectArr(select)
|
||||||
var c = (document.getElementById("cron" + tnum).value).split(" ");
|
{
|
||||||
if (c.length == 6) {
|
var result = [];
|
||||||
if (s != null)
|
var options = select && select.options;
|
||||||
c[0] = s;
|
var opt;
|
||||||
if (m != null)
|
for (var i=0, iLen=options.length; i<iLen; i++) {
|
||||||
c[1] = m;
|
opt = options[i];
|
||||||
if (h != null)
|
if (opt.selected) {
|
||||||
c[2] = h;
|
if(isNaN(opt.value))
|
||||||
if (d != null)
|
{
|
||||||
c[3] = d;
|
return opt.value;
|
||||||
if (mm != null)
|
}
|
||||||
c[4] = mm;
|
result.push(opt.value);
|
||||||
if (w != null)
|
}}
|
||||||
c[5] = w;
|
|
||||||
document.getElementById("cron" + tnum).value = c[0] + " " + c[1] + " " + c[2] + " " + c[3] + " " + c[4] + " " + c[5];
|
var grouped = "";
|
||||||
}
|
var intbeg;
|
||||||
}
|
var inside = false;
|
||||||
function getSecondSelect(n) {
|
for ( i=0; i <result.length;i++)
|
||||||
var sel = document.getElementsByName("selectSeconds" + n + "[]")[0];
|
{
|
||||||
var opts = [],
|
if(parseInt(result[i+1]) == (parseInt(result[i]) + 1))
|
||||||
opt;
|
{
|
||||||
var len = sel.options.length;
|
if(!inside)
|
||||||
for (var i = 0; i < len; i++) {
|
intbeg = result[i];
|
||||||
opt = sel.options[i];
|
inside = true;
|
||||||
|
}
|
||||||
if (opt.selected) {
|
else
|
||||||
opts.push(opt);
|
{
|
||||||
|
if(inside)
|
||||||
}
|
{
|
||||||
}
|
inside=false;
|
||||||
console.log(opts);
|
if((parseInt(result[i]) - parseInt(intbeg)) > 1 )
|
||||||
return opts;
|
grouped+=intbeg+"-"+result[i];
|
||||||
//var s = document.getElementsByName("selectSeconds" + n + "[]")[0].value;
|
else
|
||||||
//set_cron_string(n, s, null, null, null, null, null);
|
grouped+=intbeg+","+result[i];
|
||||||
}
|
}
|
||||||
function getMinutesSelect(n) {
|
else
|
||||||
var m = document.getElementById("minutes").value;
|
grouped+=result[i];
|
||||||
set_cron_string(n, null, m, null, null, null, null);
|
}
|
||||||
}
|
if(i < result.length -1 && !inside)
|
||||||
function getHoursSelect(n) {
|
grouped+=",";
|
||||||
var h = document.getElementById("hours").value;
|
}
|
||||||
set_cron_string(n, null, null, h, null, null, null);
|
return grouped;
|
||||||
}
|
}
|
||||||
|
function handleSelect(tnum, type)
|
||||||
function deltm(n) {
|
{
|
||||||
alert("Delete timer " + n);
|
var cinp = document.getElementById("cron" + tnum);
|
||||||
timarr_test.splice(n - 1, 1);
|
var c = (cinp.value).split(" ");
|
||||||
drawtimers(timarr_test);
|
if(c.length != 6)
|
||||||
}
|
{
|
||||||
function closecron(n) {
|
alert("Cron string was edited and not valid");
|
||||||
var target = document.getElementById("cronext"+n);
|
return;
|
||||||
var content = "";
|
}
|
||||||
target.innerHTML = content;
|
switch(type)
|
||||||
}
|
{
|
||||||
function setcron(n) {
|
case 1:
|
||||||
var target = document.getElementById("cronext" + n);
|
var s = extractSelectArr(document.getElementById("seconds"));
|
||||||
var content = "";
|
if (s != null) c[0] = s;
|
||||||
content += ("<select multiple size=\"10\" class=\"crselect\" name=\"selectSeconds" + n + "[]\" id=\"seconds\" onchange=\"getSecondSelect("+n+")\">");
|
break;
|
||||||
content += ("<option value=\"*\">Every Second</option>");
|
case 2:
|
||||||
content += ("<option value=\"*/2\">Even Second</option>");
|
var m = extractSelectArr(document.getElementById("minutes"));
|
||||||
content += ("<option value=\"1-59/2\">Odd Second</option>");
|
if (m != null) c[1] = m;
|
||||||
content += ("<option value=\"*/5\">Every 5 Second</option>");
|
break;
|
||||||
content += ("<option value=\"*/15\">Every 15 Second</option>");
|
case 3:
|
||||||
content += ("<option value=\"*/30\">Every 30 Second</option>");
|
var h = extractSelectArr(document.getElementById("hours"));
|
||||||
for (s = 0; s < 60; s++) { content += ("<option value=\"" + s + "\">" + s + "</option>"); }
|
if (h != null) c[2] = h;
|
||||||
content += ("</select>");
|
break;
|
||||||
|
case 4:
|
||||||
content += ("<select multiple size=\"10\" class=\"crselect\" name=\"selectMinutes" + n + "[]\" id=\"minutes\" onchange=\"getMinutesSelect("+n+")\">");
|
var d = extractSelectArr(document.getElementById("days"));
|
||||||
content += ("<option value=\"*\">Every Minute</option>");
|
if (d != null) c[3] = d;
|
||||||
content += ("<option value=\"*/2\">Even Minutes</option>");
|
break;
|
||||||
content += ("<option value=\"1-59/2\">Odd Minute</option>");
|
case 5:
|
||||||
content += ("<option value=\"*/5\">Every 5 Minutes</option>");
|
var mm = extractSelectArr(document.getElementById("months"));
|
||||||
content += ("<option value=\"*/15\">Every 15 Minutes</option>");
|
if (mm != null) c[4] = mm;
|
||||||
content += ("<option value=\"*/30\">Every 30 Minutes</option>");
|
break;
|
||||||
for (s = 0; s < 60; s++) { content += ("<option value=\"" + s + "\">" + s + "</option>"); }
|
case 6:
|
||||||
content += ("</select>");
|
var w = extractSelectArr(document.getElementById("weekdays"));
|
||||||
|
if (w != null) c[5] = w;
|
||||||
content += ("<select multiple size=\"10\" class=\"crselect\" name=\"selectHours" + n + "[]\" id=\"hours\" onchange=\"getHoursSelect("+n+")\">");
|
break;
|
||||||
content += ("<option value=\"*\">Every Hour</option>");
|
}
|
||||||
content += ("<option value=\"*/2\">Even Hours</option>");
|
cinp.value = c[0] + " " + c[1] + " " + c[2] + " " + c[3] + " " + c[4] + " " + c[5];
|
||||||
content += ("<option value=\"1-23/2\">Odd Hours</option>");
|
}
|
||||||
content += ("<option value=\"*/2\">Every 2 Hours</option>");
|
function deltm(n) {
|
||||||
content += ("<option value=\"*/3\">Every 3 Hours</option>");
|
alert("Delete timer " + n);
|
||||||
content += ("<option value=\"*/4\">Every 4 Hours</option>");
|
timarr_test.splice(n - 1, 1);
|
||||||
for (s = 0; s < 24; s++) { content += ("<option value=\"" + s + "\">" + s + "</option>"); }
|
drawtimers(timarr_test);
|
||||||
content += ("</select>");
|
}
|
||||||
|
function closecron(n) {
|
||||||
|
var target = document.getElementById("cronext"+n);
|
||||||
|
var content = "";
|
||||||
content += ("<div><button class=\"btn\" type=\"button\" onclick=\"closecron(" + n + ")\">Ready</button></div>");
|
target.innerHTML = content;
|
||||||
target.innerHTML = content;
|
}
|
||||||
}
|
function setcron(n) {
|
||||||
function drawtimers(tarr) {
|
var target = document.getElementById("cronext" + n);
|
||||||
var num = tarr.length;
|
var content = "";
|
||||||
var target = document.getElementById("timer");
|
content += ("<select multiple class=\"crselect\" name=\"selectSeconds" + n + "[]\" id=\"seconds\" onchange=\"handleSelect("+n+", 1)\">");
|
||||||
var content = "";
|
content += ("<option value=\"*\">Every Sec</option>");
|
||||||
for (i = 1; i <= num; i++) {
|
content += ("<option value=\"*/2\">Even Sec</option>");
|
||||||
content += ("<div class=\"timer\">");
|
content += ("<option value=\"1-59/2\">Odd Sec</option>");
|
||||||
content += ("<label class=\"tmlab\">Timer " + i + "</label>");
|
content += ("<option value=\"*/5\">Every 5 Sec</option>");
|
||||||
content += ("<div class=\"timerrec\">");
|
content += ("<option value=\"*/15\">Every 15 Sec</option>");
|
||||||
|
content += ("<option value=\"*/30\">Every 30 Sec</option>");
|
||||||
content += ("<div class=\"nowrap\">");
|
for (s = 0; s < 60; s++) { content += ("<option value=\"" + s + "\">" + s + "</option>"); }
|
||||||
//content +=("<label for=\"cron"+i+"\">Cron string:</label>");
|
content += ("</select>");
|
||||||
content += ("<input type=\"text\" id=\"cron" + i + "\" value=\"" + tarr[i - 1].cron + "\"></input>");
|
|
||||||
content += ("<button class=\"tmbtn btn\" type=\"button\" onclick=\"setcron(" + i + ")\">Set cron</button></div></div>")
|
content += ("<select multiple class=\"crselect\" name=\"selectMinutes" + n + "[]\" id=\"minutes\" onchange=\"handleSelect("+n+", 2)\">");
|
||||||
|
content += ("<option value=\"*\">Every Min</option>");
|
||||||
content += ("<div id=\"cronext" + i + "\"></div>");
|
content += ("<option value=\"*/2\">Even Min</option>");
|
||||||
|
content += ("<option value=\"1-59/2\">Odd Min</option>");
|
||||||
content += ("<input class=\"tmpick\" type=\"datetime-local\" value=\"" + UnixToStr(tarr[i - 1].start, 10, 1) + "\"></input>");
|
content += ("<option value=\"*/5\">Every 5 Min</option>");
|
||||||
content += ("<select id=\"action\">");
|
content += ("<option value=\"*/15\">Every 15 Min</option>");
|
||||||
for (k = 0; k < actions_test.length; k++) {
|
content += ("<option value=\"*/30\">Every 30 Min</option>");
|
||||||
var selected = (tarr[i - 1].act == k) ? "selected" : "";
|
for (s = 0; s < 60; s++) { content += ("<option value=\"" + s + "\">" + s + "</option>"); }
|
||||||
|
content += ("</select>");
|
||||||
|
|
||||||
|
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=\"*/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>");
|
||||||
|
target.innerHTML = content;
|
||||||
|
}
|
||||||
|
function drawtimers(tarr) {
|
||||||
|
var num = tarr.length;
|
||||||
|
var target = document.getElementById("timer");
|
||||||
|
var content = "";
|
||||||
|
for (i = 1; i <= num; i++) {
|
||||||
|
content += ("<div class=\"timer\">");
|
||||||
|
content += ("<label class=\"tmlab\">Timer " + i + "</label>");
|
||||||
|
content += ("<div class=\"timerrec\">");
|
||||||
|
|
||||||
|
content += ("<div class=\"nowrap\">");
|
||||||
|
//content +=("<label for=\"cron"+i+"\">Cron string:</label>");
|
||||||
|
content += ("<input type=\"text\" id=\"cron" + i + "\" value=\"" + tarr[i - 1].cron + "\"></input>");
|
||||||
|
content += ("<button class=\"tmbtn btn\" type=\"button\" onclick=\"setcron(" + i + ")\">Set cron</button></div></div>")
|
||||||
|
|
||||||
|
content += ("<div id=\"cronext" + i + "\"></div>");
|
||||||
|
|
||||||
|
content += ("<input class=\"tmpick\" type=\"datetime-local\" value=\"" + UnixToStr(tarr[i - 1].start, 10, 1) + "\"></input>");
|
||||||
|
content += ("<select id=\"action\">");
|
||||||
|
for (k = 0; k < actions_test.length; k++) {
|
||||||
|
var selected = (tarr[i - 1].act == k) ? "selected" : "";
|
||||||
content += ("<option value=\"" + (k + 1) + "\" " + selected + ">" + actions_test[k] + "</option>");
|
content += ("<option value=\"" + (k + 1) + "\" " + selected + ">" + actions_test[k] + "</option>");
|
||||||
}
|
}
|
||||||
content += ("</select>");
|
content += ("</select>");
|
||||||
|
|
||||||
content += ("<select id=\"object\">");
|
content += ("<select id=\"object\">");
|
||||||
for (k = 0; k < objects_test.length; k++) {
|
for (k = 0; k < objects_test.length; k++) {
|
||||||
var selected = (tarr[i - 1].obj == k) ? "selected" : "";
|
var selected = (tarr[i - 1].obj == k) ? "selected" : "";
|
||||||
content += ("<option value=\"" + (k + 1) + "\" " + selected + ">" + objects_test[k] + "</option>");
|
content += ("<option value=\"" + (k + 1) + "\" " + selected + ">" + objects_test[k] + "</option>");
|
||||||
}
|
}
|
||||||
content += ("</select>");
|
content += ("</select>");
|
||||||
|
|
||||||
|
|
||||||
content += ("<button class=\"btn\" type=\"button\" onclick=\"savetm(" + i + ")\">Save</button>");
|
content += ("<button class=\"btn\" type=\"button\" onclick=\"savetm(" + i + ")\">Save</button>");
|
||||||
content += ("<button class=\"btn\" type=\"button\" onclick=\"deltm(" + i + ")\">Delete</button>");
|
content += ("<button class=\"btn\" type=\"button\" onclick=\"deltm(" + i + ")\">Delete</button>");
|
||||||
|
|
||||||
content += ("</div>");
|
content += ("</div>");
|
||||||
target.innerHTML = content;
|
target.innerHTML = content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function applytm() {
|
function applytm() {
|
||||||
|
|
||||||
}
|
}
|
||||||
function addtm() {
|
function addtm() {
|
||||||
var num = timarr_test.length + 1;
|
var num = timarr_test.length + 1;
|
||||||
timarr_test.push({ 'num': num, 'start': 1500000000, 'cron': '* * * * * *' });
|
timarr_test.push({ 'num': num, 'start': 1500000000, 'cron': '* * * * * *' });
|
||||||
drawtimers(timarr_test);
|
drawtimers(timarr_test);
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
idf:
|
idf:
|
||||||
component_hash: null
|
component_hash: null
|
||||||
source:
|
source:
|
||||||
type: idf
|
type: idf
|
||||||
version: 4.4.4
|
version: 4.4.4
|
||||||
manifest_hash: f9b3d78d7d56685d1c543701158a0fab7a56c908117ed70644f77e4247c831ae
|
manifest_hash: 31dd4ec84ade1450fc168388f4adce2efacd1516170670735140bc772e9d72bd
|
||||||
target: esp32
|
target: esp32
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user