mirror of
https://github.com/s00500/ESPUI.git
synced 2024-11-21 22:50:55 +00:00
Use early return to tidy up logic
This commit is contained in:
parent
e3e5c34953
commit
eb21863e09
47
data/js/controls.js
vendored
47
data/js/controls.js
vendored
@ -650,29 +650,30 @@ function buttonclick(number, isdown) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function padclick(type, number, isdown) {
|
function padclick(type, number, isdown) {
|
||||||
if(!$("#id" + number + " nav").hasClass("disabled")) {
|
if($("#id" + number + " nav").hasClass("disabled")) {
|
||||||
switch (type) {
|
return;
|
||||||
case CENTER:
|
}
|
||||||
if (isdown) websock.send("pcdown:" + number);
|
switch (type) {
|
||||||
else websock.send("pcup:" + number);
|
case CENTER:
|
||||||
break;
|
if (isdown) websock.send("pcdown:" + number);
|
||||||
case UP:
|
else websock.send("pcup:" + number);
|
||||||
if (isdown) websock.send("pfdown:" + number);
|
break;
|
||||||
else websock.send("pfup:" + number);
|
case UP:
|
||||||
break;
|
if (isdown) websock.send("pfdown:" + number);
|
||||||
case DOWN:
|
else websock.send("pfup:" + number);
|
||||||
if (isdown) websock.send("pbdown:" + number);
|
break;
|
||||||
else websock.send("pbup:" + number);
|
case DOWN:
|
||||||
break;
|
if (isdown) websock.send("pbdown:" + number);
|
||||||
case LEFT:
|
else websock.send("pbup:" + number);
|
||||||
if (isdown) websock.send("pldown:" + number);
|
break;
|
||||||
else websock.send("plup:" + number);
|
case LEFT:
|
||||||
break;
|
if (isdown) websock.send("pldown:" + number);
|
||||||
case RIGHT:
|
else websock.send("plup:" + number);
|
||||||
if (isdown) websock.send("prdown:" + number);
|
break;
|
||||||
else websock.send("prup:" + number);
|
case RIGHT:
|
||||||
break;
|
if (isdown) websock.send("prdown:" + number);
|
||||||
}
|
else websock.send("prup:" + number);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
data/js/controls.min.js
vendored
3
data/js/controls.min.js
vendored
@ -54,7 +54,8 @@ function textchange(number){var val=$("#text"+number).val();websock.send("tvalue
|
|||||||
function tabclick(number){var val=$("#tab"+number).val();websock.send("tabvalue:"+val+":"+number);}
|
function tabclick(number){var val=$("#tab"+number).val();websock.send("tabvalue:"+val+":"+number);}
|
||||||
function selectchange(number){var val=$("#select"+number).val();websock.send("svalue:"+val+":"+number);}
|
function selectchange(number){var val=$("#select"+number).val();websock.send("svalue:"+val+":"+number);}
|
||||||
function buttonclick(number,isdown){if(isdown)websock.send("bdown:"+number);else websock.send("bup:"+number);}
|
function buttonclick(number,isdown){if(isdown)websock.send("bdown:"+number);else websock.send("bup:"+number);}
|
||||||
function padclick(type,number,isdown){if(!$("#id"+number+" nav").hasClass("disabled")){switch(type){case CENTER:if(isdown)websock.send("pcdown:"+number);else websock.send("pcup:"+number);break;case UP:if(isdown)websock.send("pfdown:"+number);else websock.send("pfup:"+number);break;case DOWN:if(isdown)websock.send("pbdown:"+number);else websock.send("pbup:"+number);break;case LEFT:if(isdown)websock.send("pldown:"+number);else websock.send("plup:"+number);break;case RIGHT:if(isdown)websock.send("prdown:"+number);else websock.send("prup:"+number);break;}}}
|
function padclick(type,number,isdown){if($("#id"+number+" nav").hasClass("disabled")){return;}
|
||||||
|
switch(type){case CENTER:if(isdown)websock.send("pcdown:"+number);else websock.send("pcup:"+number);break;case UP:if(isdown)websock.send("pfdown:"+number);else websock.send("pfup:"+number);break;case DOWN:if(isdown)websock.send("pbdown:"+number);else websock.send("pbup:"+number);break;case LEFT:if(isdown)websock.send("pldown:"+number);else websock.send("plup:"+number);break;case RIGHT:if(isdown)websock.send("prdown:"+number);else websock.send("prup:"+number);break;}}
|
||||||
function switcher(number,state){if(state==null){if(!$("#sl"+number).hasClass("checked")){websock.send("sactive:"+number);$("#sl"+number).addClass("checked");}else{websock.send("sinactive:"+number);$("#sl"+number).removeClass("checked");}}else if(state==1){$("#sl"+number).addClass("checked");$("#sl"+number).prop("checked",true);}else if(state==0){$("#sl"+number).removeClass("checked");$("#sl"+number).prop("checked",false);}}
|
function switcher(number,state){if(state==null){if(!$("#sl"+number).hasClass("checked")){websock.send("sactive:"+number);$("#sl"+number).addClass("checked");}else{websock.send("sinactive:"+number);$("#sl"+number).removeClass("checked");}}else if(state==1){$("#sl"+number).addClass("checked");$("#sl"+number).prop("checked",true);}else if(state==0){$("#sl"+number).removeClass("checked");$("#sl"+number).prop("checked",false);}}
|
||||||
var rangeSlider=function(isDiscrete){var range=$(".range-slider__range");var slidercb=function(){sliderchange($(this).attr("id").replace(/^\D+/g,""));};range.on({input:function(){$(this).next().html(this.value)}});range.each(function(){$(this).next().html(this.value);if($(this).attr("callbackSet")!="true"){if(!isDiscrete){$(this).on({input:slidercb});}else{$(this).on({change:slidercb});}
|
var rangeSlider=function(isDiscrete){var range=$(".range-slider__range");var slidercb=function(){sliderchange($(this).attr("id").replace(/^\D+/g,""));};range.on({input:function(){$(this).next().html(this.value)}});range.each(function(){$(this).next().html(this.value);if($(this).attr("callbackSet")!="true"){if(!isDiscrete){$(this).on({input:slidercb});}else{$(this).on({change:slidercb});}
|
||||||
$(this).attr("callbackSet","true");}});};var addToHTML=function(data){panelStyle=data.hasOwnProperty('panelStyle')?" style='"+data.panelStyle+"' ":"";panelwide=data.hasOwnProperty('wide')?"wide":"";if(!data.hasOwnProperty('parentControl')||$("#tab"+data.parentControl).length>0){var parent=data.hasOwnProperty('parentControl')?$("#tab"+data.parentControl):$("#row");var html="";switch(data.type){case UI_LABEL:case UI_BUTTON:case UI_SWITCHER:case UI_CPAD:case UI_PAD:case UI_SLIDER:case UI_NUMBER:case UI_TEXT_INPUT:case UI_SELECT:case UI_GRAPH:case UI_GAUGE:case UI_ACCEL:html="<div id='id"+data.id+"' "+panelStyle+" class='two columns "+panelwide+" card tcenter "+
|
$(this).attr("callbackSet","true");}});};var addToHTML=function(data){panelStyle=data.hasOwnProperty('panelStyle')?" style='"+data.panelStyle+"' ":"";panelwide=data.hasOwnProperty('wide')?"wide":"";if(!data.hasOwnProperty('parentControl')||$("#tab"+data.parentControl).length>0){var parent=data.hasOwnProperty('parentControl')?$("#tab"+data.parentControl):$("#row");var html="";switch(data.type){case UI_LABEL:case UI_BUTTON:case UI_SWITCHER:case UI_CPAD:case UI_PAD:case UI_SLIDER:case UI_NUMBER:case UI_TEXT_INPUT:case UI_SELECT:case UI_GRAPH:case UI_GAUGE:case UI_ACCEL:html="<div id='id"+data.id+"' "+panelStyle+" class='two columns "+panelwide+" card tcenter "+
|
||||||
|
Loading…
Reference in New Issue
Block a user