cleanup iforte index
This commit is contained in:
100
iforte/base.js
100
iforte/base.js
@@ -1,4 +1,10 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
// Sets the proper fixture name in the header and title
|
||||
var fixturename = "Robin iForte - Simulated";
|
||||
$('#pth').html(fixturename)
|
||||
$(document).prop('title', fixturename)
|
||||
|
||||
$('body').prepend(generateNavBar());
|
||||
var am = 0;
|
||||
var mip = 0;
|
||||
@@ -37,62 +43,11 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
//periodicly get status
|
||||
var bsy = false;
|
||||
var ebli = 0;
|
||||
var eblio = 255;
|
||||
|
||||
// handle RDM ident
|
||||
var idntb = $('#idnt img');
|
||||
function sta() {
|
||||
do_ajax('/serr',{},function (json) {
|
||||
// console.log(json);
|
||||
dmxsnf = '';
|
||||
if (json ) {
|
||||
if (json['err'] == 1) ebli = 0x80;
|
||||
else ebli = 0;
|
||||
if (json['dmxsnf'] == 1) dmxsnf = ' [sniffing DMX]';
|
||||
if (json['idnt'] == 1) idntb.addClass('a');
|
||||
else idntb.removeClass('a');
|
||||
if (json['dls'] && json['dls'] == 1) {
|
||||
$('.snz').show();
|
||||
}
|
||||
} else if (json == undefined) {
|
||||
ebli = 0x40;
|
||||
} else ebli = 0;
|
||||
bsy = false;
|
||||
});
|
||||
}
|
||||
setInterval(function() {
|
||||
if (!bsy) {
|
||||
bsy = true;
|
||||
sta();
|
||||
}
|
||||
},3000);
|
||||
sta();
|
||||
setInterval(function() {
|
||||
if (ebli == eblio) return;
|
||||
var opre = pre;
|
||||
if (ebli & 0x80) {
|
||||
ebli ^= 0x01;
|
||||
if (ebli & 0x01) pre = '(!) ';
|
||||
$('#pth').removeClass('stou');
|
||||
$('#pth').addClass('serr');
|
||||
} else if (ebli & 0x40) {
|
||||
ebli ^= 0x01;
|
||||
if (ebli & 0x01) pre = '(?) ';
|
||||
$('#pth').removeClass('serr');
|
||||
$('#pth').addClass('stou');
|
||||
} else {
|
||||
ebli = 0;
|
||||
$('#pth').removeClass('serr stou');
|
||||
pre = '';
|
||||
}
|
||||
//$('#pt_v').html(pre + $('#pth').data('title') + dmxsnf);
|
||||
if (opre != pre) ptit('');
|
||||
eblio = ebli;
|
||||
},1000);
|
||||
$('#idnt').click(function() {
|
||||
idntb.toggleClass('a');
|
||||
do_ajax('/rdmi',{s:idntb.hasClass('a') ? 1:0},function(json) {});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -120,29 +75,17 @@ function mhdr_status(c) {
|
||||
else $('#cfg-modal .modal-header').addClass(c);
|
||||
}
|
||||
|
||||
function loader(a) {
|
||||
|
||||
if (a) $('#cfg-modal .modal-header img').addClass('loader');
|
||||
function loader(showheader) {
|
||||
if (showheader) $('#cfg-modal .modal-header img').addClass('loader');
|
||||
else $('#cfg-modal .modal-header img').removeClass('loader');
|
||||
}
|
||||
|
||||
function do_ajax(p_url,p_data,f,i = -1,a = true) {
|
||||
|
||||
$.ajax({
|
||||
url: p_url,
|
||||
type: 'POST',
|
||||
data: p_data,
|
||||
dataType: 'json',
|
||||
async: a,
|
||||
success: function (json) {
|
||||
f(json,i);
|
||||
},
|
||||
error: function () {
|
||||
// console.log('do_ajax error');
|
||||
f();
|
||||
},
|
||||
timeout:2000
|
||||
});
|
||||
console.log("url : " + p_url);
|
||||
console.log("data : " + p_data);
|
||||
console.log("callback function : " + f);
|
||||
console.log("callback params : " + i);
|
||||
console.log("async : " + a);
|
||||
}
|
||||
|
||||
function copy_form_values(dir) {
|
||||
@@ -347,13 +290,6 @@ function generateNavBar() {
|
||||
o += '</div>';
|
||||
o += '</nav>';
|
||||
|
||||
o += '<div class="fixed-top text-center device-label" id="pth"></div>';
|
||||
|
||||
o += '<div class="container-fluid in">';
|
||||
o += '<h1></h1>';
|
||||
o += '<div class="row" id="boxes"></div>';
|
||||
o += '</div>';
|
||||
|
||||
o += '<div id="cfg-modal" class="modal fade" tabindex="-1" role="dialog">';
|
||||
o += '<div class="modal-dialog" role="document">';
|
||||
o += '<div class="modal-content">';
|
||||
@@ -381,17 +317,17 @@ var pre = '';
|
||||
var dmxsnf = '';
|
||||
|
||||
function ptit(t) {
|
||||
// console.log('setting title to ' + t);
|
||||
// console.log('setting title to ' + t);
|
||||
|
||||
if (t == $('#pth').data('title')) return;
|
||||
|
||||
// console.log('set');
|
||||
// console.log('set');
|
||||
|
||||
if (t.length) $('#pth').data('title',t);
|
||||
$('#pth').html($('#pth').data('title') + dmxsnf);
|
||||
$('#pt_v').html(pre + $('#pth').html());
|
||||
|
||||
// console.log($('#pth').html());
|
||||
// console.log($('#pth').html());
|
||||
}
|
||||
|
||||
function c_dt(n,t,e,c,it) {
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
</head>
|
||||
<body>
|
||||
<!-- NAV WILL BE ADDED HERE BY JS gens() FUNCTION IN BASE -->
|
||||
<div class="fixed-top text-center device-label" id="pth">iForte</div>
|
||||
|
||||
<div class="fixed-top text-center device-label" id="pth"></div>
|
||||
|
||||
<div class="container-fluid in">
|
||||
<h1>Device status</h1>
|
||||
<div class="row" id="boxes">
|
||||
@@ -245,66 +247,136 @@
|
||||
}
|
||||
$('.sb').unbind();
|
||||
$('#m-f').empty();
|
||||
$('#m-f').append(' < button type = "button"
|
||||
class = "btn btn-primary sb" > Save < /button>');if(a_m==0) $('#m-f').show();else $('#m-f').hide();var h='';if(a_m==0){h+=c_txt('dmxa','DMX address','Please put DMX address from 1 to 512');h+=c_opt('dmxp','DMX preset',[1],'Mode ',0,1,'');h+=c_opt('dmxi','DMX input',['wired','wireless','wireless XLR out'],'',0,1,'Can not set wireless input now!');h+=c_txt('rdmn','RDM label','Please insert label,max 32 characters')} else if(a_m==1){h+=c_btn('Power on time reset',0,' rh')} else if(a_m==2){h+=c_btn('LEDs temperature reset',0,' rt');h+=c_btn('PSU temperature reset',3,' rt');h+=c_btn('Driver temperature reset',1,' rt');h+=c_btn('Base temperature reset',2,' rt')} else if(a_m==3){h+=c_btn('Unlink Wireless module',0,' lwu')}$('#m-b').html(h);copy_form_values(1);$('#cfg-modal').modal();$('.sb').bind('click',function(){loader(1);var par=['dmxa','dmxp','dmxi','rdmn'];do_ajax('/set_dmx
|
||||
',pv(par),function (json){if(json){if(json['
|
||||
status ']==0){mhdr_status('
|
||||
suc ');copy_form_values(0);if(a_m==0){console.log(json['
|
||||
dmxf ']);fill_values(json,['
|
||||
dmxf '])}ptit(json['
|
||||
pt ']);close_modal()}show_errors(json['
|
||||
status '],par);loader(0)}})});$('.rh ').bind('
|
||||
click ',function(){loader(1);do_ajax(' / reset_hours ',{index:$(this).attr('
|
||||
value ')},function (json){if(json){mhdr_status('
|
||||
suc ');fill_values(json,['
|
||||
hr0 ','
|
||||
hr1 ','
|
||||
hr2 ','
|
||||
hr3 '])}loader(0)})});$('.rt ').bind('
|
||||
click ',function(){loader(1);do_ajax(' / reset_temps ',{index:$(this).attr('
|
||||
value ')},function (json){if(json){mhdr_status('
|
||||
suc ');fill_values(json,['
|
||||
tmr0 ','
|
||||
tmr1 ','
|
||||
tmr2 '])}loader(0)})});$('.lwu ').bind('
|
||||
click ',function(){loader(1);do_ajax(' / lwm ',{unlink:1},function (json){if(json){fill_values(json,['
|
||||
lwc ','
|
||||
lws ']);mhdr_status('
|
||||
suc ');close_modal()}loader(0)})})}$(document).ready(function(){$('
|
||||
h1 ').html('
|
||||
Device status ');var boxes='
|
||||
';boxes+=box(m_t[0],0,[['
|
||||
',['
|
||||
DMX address; dmxa ','
|
||||
DMX preset; dmxp; < li > < div id = "dmxp_v" > - < /div> < small id = "dmxf_v" > < /small> < /li>','DMX input;dmxi',' < li class = "mt-2" > IP address < /li>;;; < li class = "mt-2" > < div id = "ip_v" > - < /div> < /li>','MAC address;mac',' < li class = "mt-2" > RDM UID < /li>;;; < li class = "mt-2" > < div id = "rdmu_v" > - < /div> < /li>','RDM label;rdmn',]],]);var lot_ta='';lot_ta=' < ul class = "group" > < li > LED on time total < /li> < li > LED on time adaptive < /li> < /ul>',lot_ta+=' < ul class = "group vals" > < li > < div id = "h1_v" > - < /div>h < /li> < li > < div id = "hr1_v" > - < /div>h < /li> < /ul>',boxes+=box('Device times',1,[['',[' < li > Power on time < /li>;;; < li > < div id = "h0_v" > - < /div>h / < div id = "hr0_v" > - < /div>h < /li>',]],],' < p > < small > total / resettable < /small> < /p>'+lot_ta);boxes+=box('Device temperatures',2,[['',[' < li > LEDs < /li>;;; < li > < div id = "t0_v" > - < /div>&DG < div class = "tu" > < /div> / < div id = "tm0_v" > - < /div>&DG < div class = "tu" > < /div> / < div id = "tmr0_v" > - < /div>&DG < div class = "tu" > < /div> < /li>',' < li > PSU < /li>;;; < li > < div id = "t3_v" > - < /div>&DG < div class = "tu" > < /div> / < div id = "tm3_v" > - < /div>&DG < div class = "tu" > < /div> / < div id = "tmr3_v" > - < /div>&DG < div class = "tu" > < /div> < /li>',' < li > Driver < /li>;;; < li > < div id = "t1_v" > - < /div>&DG < div class = "tu" > < /div> / < div id = "tm1_v" > - < /div>&DG < div class = "tu" > < /div> / < div id = "tmr1_v" > - < /div>&DG < div class = "tu" > < /div> < /li>',' < li > Base < /li>;;; < li > < div id = "t2_v" > - < /div>&DG < div class = "tu" > < /div> / < div id = "tm2_v" > - < /div>&DG < div class = "tu" > < /div> / < div id = "tmr2_v" > - < /div>&DG < div class = "tu" > < /div> < /li>',]],],' < p > < small > current / maximum / resettable < /small> < /p>');boxes+=box('Wireless state',3,[['',['State;lwc','Signal strength;lws',]],]);boxes+=box('Software versions',-1,[['',['Display System','Module M','Module L1','Module L2','Module O','Module F-A','Module F-B','Module G1','Module G2','Module P','Module C1','Module C2','Module DL',]],],'','sw_vers');boxes+=box('Device state',-1,[['',['Device status;devs',]],],c_btn('',0,' esm dn')+' < div > Current RAINS status < /div> < div > < small class = "fl" > WET < /small> < small class = "fr" > DRY < /small> < /div> < div id = "rai"
|
||||
class = "rains" > < div > < /div> < /div> < div > MAX WET / resettable < /div> < div > < small class = "fl" > WET < /small> < small class = "fr" > DRY < /small> < /div> < div id = "rair"
|
||||
class = "rains" > < div > < /div> < /div>'+c_btn('MAX WET reset',0,' mwr')+' < p > < small id = "wrt" > < /small> < /p>');boxes+=' < div class = "col-12 box-c" > ';boxes+=' < h2 id = "sta_err" > Status messages < /h2>';boxes+=' < div class = "box" > ';boxes+=' < ul class = "group"
|
||||
id = "err_v" > ';boxes+=' < /ul>';boxes+=' < /div>';boxes+=' < /div>';$('#boxes').html(boxes);var emb=$('button.esm');emb.addClass('btn-success');function ems_btn(v){if(v==0){emb.removeClass('sa btn-warning').html('Enter standby mode').show()} else {emb.addClass('sa btn-warning').html('Escape standby mode').show()}}emb.click(function(){var run=true;var s_v=(emb.hasClass('sa') ? 0:1);if((s_v==1)&&!confirm('Are you sure you want to enter standby mode?')) run=false;if(run){do_ajax('/sbm
|
||||
',{s:s_v},function (json){ems_btn(json['
|
||||
sm ']);fill_values(json,['
|
||||
devs '])})}});var bussy=0;function do_5s(){bussy|=(1< < 0);
|
||||
$('#m-f').append(' <button type="button" class="btn btn-primary sb">Save</button>');
|
||||
if(a_m==0) $('#m-f').show();
|
||||
else $('#m-f').hide();
|
||||
var h='';if(a_m==0){
|
||||
h+=c_txt('dmxa','DMX address','Please put DMX address from 1 to 512');
|
||||
h+=c_opt('dmxp','DMX preset',[1],'Mode ',0,1,'');
|
||||
h+=c_opt('dmxi','DMX input',['wired','wireless','wireless XLR out'],'',0,1,'Can not set wireless input now!');
|
||||
h+=c_txt('rdmn','RDM label','Please insert label,max 32 characters')
|
||||
} else if(a_m==1){
|
||||
h+=c_btn('Power on time reset',0,' rh')
|
||||
} else if(a_m==2){
|
||||
h+=c_btn('LEDs temperature reset',0,' rt');
|
||||
h+=c_btn('PSU temperature reset',3,' rt');
|
||||
h+=c_btn('Driver temperature reset',1,' rt');
|
||||
h+=c_btn('Base temperature reset',2,' rt')
|
||||
} else if(a_m==3){
|
||||
h+=c_btn('Unlink Wireless module',0,' lwu')
|
||||
}
|
||||
|
||||
$('#m-b').html(h);
|
||||
copy_form_values(1);
|
||||
$('#cfg-modal').modal();
|
||||
$('.sb').bind('click',function(){
|
||||
loader(1);
|
||||
var par=['dmxa','dmxp','dmxi','rdmn'];
|
||||
do_ajax('/set_dmx',pv(par),function (json){
|
||||
if(json){
|
||||
if(json['status']==0){
|
||||
mhdr_status('suc');
|
||||
copy_form_values(0);
|
||||
if(a_m==0){
|
||||
console.log(json['dmxf']);
|
||||
fill_values(json,['dmxf'])
|
||||
} ptit(json['pt']);
|
||||
close_modal()
|
||||
}
|
||||
show_errors(json['status'],par);
|
||||
loader(0)
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$('.rh ').bind('click ',function(){
|
||||
loader(1);
|
||||
do_ajax('/reset_hours',{
|
||||
index: $(this).attr('value')
|
||||
},function (json){
|
||||
if(json){
|
||||
mhdr_status('suc');
|
||||
fill_values(json,['hr0','hr1','hr2','hr3'])
|
||||
}
|
||||
loader(0)
|
||||
})
|
||||
});
|
||||
|
||||
$('.rt').bind('click',function(){
|
||||
loader(1);
|
||||
do_ajax('/reset_temps',{
|
||||
index: $(this).attr('value')
|
||||
},function (json){
|
||||
if(json){
|
||||
mhdr_status('suc');
|
||||
fill_values(json,['tmr0','tmr1','tmr2'])
|
||||
}
|
||||
loader(0)
|
||||
})
|
||||
});
|
||||
|
||||
$('.lwu').bind('click',function(){
|
||||
loader(1);
|
||||
do_ajax('/lwm',{
|
||||
unlink:1
|
||||
},function (json){
|
||||
if(json){
|
||||
fill_values(json,['lwc','lws']);
|
||||
mhdr_status('suc');
|
||||
close_modal()
|
||||
}
|
||||
loader(0)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
var emb=$('button.esm');
|
||||
emb.addClass('btn-success');
|
||||
function ems_btn(v){
|
||||
if(v==0){
|
||||
emb.removeClass('sa btn-warning').html('Enter standby mode').show()
|
||||
} else {
|
||||
emb.addClass('sa btn-warning').html('Escape standby mode').show()
|
||||
}
|
||||
}
|
||||
emb.click(function(){
|
||||
var run=true;
|
||||
var s_v=(emb.hasClass('sa') ? 0:1);
|
||||
if((s_v==1)&&!confirm('Are you sure you want to enter standby mode?')) run=false;
|
||||
if(run){
|
||||
do_ajax('/sbm',{
|
||||
s:s_v
|
||||
},function (json){
|
||||
ems_btn(json['sm']);
|
||||
fill_values(json,['devs'])
|
||||
})
|
||||
}
|
||||
});
|
||||
var bussy=0;
|
||||
function do_5s(){bussy|=(1 << 0);
|
||||
do_ajax('/lwm', {}, function(json) {
|
||||
if (json) {
|
||||
fill_values(json, ['lwc', 'lws'])
|
||||
}
|
||||
bussy &= ~(1 < < 0)
|
||||
bussy &= ~(1 << 0)
|
||||
});
|
||||
bussy |= (1 < < 1);
|
||||
bussy |= (1 << 1);
|
||||
do_ajax('/reset_temps', {}, function(json) {
|
||||
if (json) {
|
||||
fill_values(json, ['t0', 't1', 't2', 't3', 'tm0', 'tm1', 'tm2', 'tm3', 'tmr0', 'tmr1', 'tmr2', 'tmr3']);
|
||||
$('.tu').html(json['tu'])
|
||||
}
|
||||
bussy &= ~(1 < < 1)
|
||||
bussy &= ~(1 << 1)
|
||||
});
|
||||
bussy |= (1 < < 3);
|
||||
bussy |= (1 << 3);
|
||||
do_ajax('/reset_hours', {}, function(json) {
|
||||
if (json) {
|
||||
fill_values(json, ['h0', 'h1', 'h2', 'h3', 'hr0', 'hr1', 'hr2', 'hr3'])
|
||||
}
|
||||
bussy &= ~(1 < < 3)
|
||||
bussy &= ~(1 << 3)
|
||||
});
|
||||
bussy |= (1 < < 4);
|
||||
bussy |= (1 << 4);
|
||||
do_ajax('/devsta', {}, function(json) {
|
||||
if (json) {
|
||||
fill_values(json, ['devs']);
|
||||
@@ -317,18 +389,20 @@
|
||||
devs: 'disconnected'
|
||||
}, ['devs'])
|
||||
}
|
||||
bussy &= ~(1 < < 4)
|
||||
bussy &= ~(1 << 4)
|
||||
});
|
||||
bussy |= (1 < < 7);
|
||||
bussy |= (1 << 7);
|
||||
do_ajax('/errors', {}, function(json) {
|
||||
if (json) {
|
||||
if (json['err']) {
|
||||
if (json['err'].length) $('#sta_err').addClass('err');
|
||||
else $('#sta_err').removeClass('err');
|
||||
var html = '';
|
||||
for (i = 0; i < json['err'].length; i++) html += ' < li > '+json['
|
||||
err '][i]+' < /li>';$('#err_v').html(html)}}bussy&=~(1< < 7)
|
||||
})
|
||||
for (i = 0; i < json['err'].length; i++) html += ' <li> ' + json['err'][i] + ' </li>';
|
||||
$('#err_v').html(html)
|
||||
}
|
||||
}
|
||||
bussy&=~(1 << 7)})
|
||||
}
|
||||
do_ajax('/status_i', {}, function(json) {
|
||||
if (json) {
|
||||
|
||||
Reference in New Issue
Block a user