-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanualmode.js
42 lines (41 loc) · 1.71 KB
/
manualmode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Javascript for printing OpenSprinkler homepage (manual mode)
// Firmware v1.8
// All content is published under:
// Creative Commons Attribution ShareAlike 3.0 License
// Sep 2012, Rayshobby.net
function id(s) {return document.getElementById(s);}
function snf(sid,sbit) {
if(sbit==1) window.location="/sn"+(sid+1)+"=0"; // turn off station
else {
var strmm=id("mm"+sid).value, strss=id("ss"+sid).value;
var mm=(strmm=="")?0:parseInt(strmm);
var ss=(strss=="")?0:parseInt(strss);
if(!(mm>=0&&ss>=0&&ss<60)) {alert("Timer values wrong: "+strmm+":"+strss);return;}
window.location="/sn"+(sid+1)+"=1"+"&t="+(mm*60+ss); // turn it off with timer
}
}
w("<b>手动控制:</b> (timer is optional)<p></p>");
w("<table border=1>");
var bid,s,sid,sn,rem,remm,rems,sbit;
for(bid=0;bid<nbrd;bid++){
for(s=0;s<8;s++){
w("<tr><td bgcolor=\"#E4E4E4\">");
sid=bid*8+s;
sn=sid+1;
//w("Station "+(sn/10>>0)+(sn%10)+": ");
w(snames[sid]+": </td><td>");
if(sn==mas) {w(((sbits[bid]>>s)&1?("<b>On</b>").fontcolor("green"):("Off").fontcolor("black"))+" (<b>Master</b>)");}
else {
rem=ps[sid][1];
if(rem>65536) rem=0;
remm=rem/60>>0;rems=rem%60;sbit=(sbits[bid]>>s)&1;
var bg=(sbit?"#FFCCCC":"CCFFCC"),tx=(sbit?"off":"on"),dis=(sbit?"disabled":"");
w("<button style=\"width:100px;height:32px;background-color:"+bg+";border-radius:8px;\" id=bb"+sid+" onclick=\"snf("+sid+","+sbit+")\">Turn "+tx+"</button>");
w(sbit?" in ":" with timer ");
w("<input type=text id=mm"+sid+" size=2 maxlength=3 value="+remm+" "+dis+" />:");
w("<input type=text id=ss"+sid+" size=2 maxlength=2 value="+rems+" "+dis+" /> (mm:ss)");
}
w("</td>");
}
}
w("</table>");