This commit is contained in:
mynah
2018-08-14 19:28:16 -05:00
parent 8a99022caa
commit 471c05e7c9
4 changed files with 22 additions and 12 deletions

View File

@@ -5,8 +5,9 @@ d3.select("#clink").on("click",function(){
var ciface ="/json/candy/";
d3.json(ciface+"isOn" ,function(d){
if(d != undefined){
if (d.a==1) { on(); }
else if (d.a==0) { off(); }}
if (d.a=="1") { on(); }
else if (d.a=="0") { off(); }
else if (d.a=="connection error") { cerror(); }}
else {console.error(ciface+"isOn");}
});
@@ -17,9 +18,10 @@ d3.select("#myonoffswitch")
});
function on(){
d3.select("#clink").style("visibility","visible");
d3.select("#clink").style("visibility","visible");
d3.json(ciface+"on",function(d){
if (d.a==1){
if (d.a=="connection error"){ cerror();}
else if (d.a=="1"){
d3.select("#clink").style("visibility","visible");
d3.select("#myonoffswitch").property("checked","checked"); }
else {
@@ -27,15 +29,21 @@ function on(){
}}); }
function off(){
d3.select("#clink").style("visibility","hidden");
d3.select("#clink").style("visibility","hidden");
d3.json(ciface+"off",function(d){
if (d.a==1){
if (d.a=="connection error"){ cerror();}
else if (d.a=="1"){
d3.select("#clink").style("visibility","hidden");
d3.select("#myonoffswitch").property("checked",""); }
else {
d3.select("#myonoffswitch").property("checked","checked");
}}); }
function cerror(){
console.error("prosody connection error");
d3.select("#clink").style("visibility","hidden");
d3.select("#myonoffswitch").property("checked","");
}

View File

@@ -8,8 +8,10 @@ checkChat();
function checkChat(){
d3.json("/json/candy/isOn",function(d){
if(d != undefined){
if (d.a==1) { d3.select("#clink").style("visibility","visible");}
else if (d.a==0) { d3.select("#clink").style("visibility","hidden");}
if (d.a=="connection error"){
d3.select("#clink").style("visibility","hidden");}
else if (d.a=="1") { d3.select("#clink").style("visibility","visible");}
else if (d.a=="0") { d3.select("#clink").style("visibility","hidden");}
}
else {
d3.select("#clink").style("visibility","hidden");