open hub + fix nav

This commit is contained in:
2023-03-02 21:07:03 +01:00
parent 3240d9a094
commit 881da45669
7 changed files with 108 additions and 288 deletions

View File

@@ -1,3 +1,102 @@
$(document).ready(function() {
$('body').prepend(generateNavBar());
var am = 0;
var mip = 0;
mip = 1;
var href = $(location).attr('pathname');
if (href.indexOf('personality') != -1) am = 1;
if (href.indexOf('logs') != -1) am = 2;
if (href.indexOf('sensors') != -1) am = 3;
if (href.indexOf('discovery') != -1) am = (3 + mip);
$('#navbar ul li').eq(am).addClass('active');
//handle settings
$(document).on('click','#scfg',function() {
mhdr_status('');
$('#m-t').html('Site settings');
var h = '<h3>Password settings</h3>';
h += c_txt('opswd','Old password','Please put old password (four digits)','','password');
h += c_txt('npswd','New password','Please put new password (four digits)','','password');
h += c_txt('npsch','New password check','New passwords check failed','','password');
$('#m-b').html(h);
$('.sb').unbind();
$('#cfg-modal').modal();
$('.sb').bind('click',function() {
loader(1);
var par = ['opswd','npswd','npsch'];
do_ajax('/set_cfg',pv(par),function (json) {
if (json) {
if (json['status'] == 0) {
mhdr_status('suc');
close_modal();
location = '/';
}
show_errors(json['status'],par);
loader(0);
}
});
});
});
//periodicly get status
var bsy = false;
var ebli = 0;
var eblio = 255;
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) {});
});
});
function get_cookie(n,d,ti=false) {
var r = d;
var c = document.cookie.split(';');
@@ -209,8 +308,7 @@ function box(t,id,p,su = '',vid = '',bc = '') {
return s;
}
function gens() {
function generateNavBar() {
var o = '<nav class="navbar fixed-top navbar-expand-md navbar-dark bg-dark">';
o += '<div class="container">';
@@ -322,102 +420,4 @@ function c_fsens(i,t,u) {
html += '</div>';
return html;
}
$(document).ready(function() {
$('body').prepend(gens());
var am = 0;
var mip = 0;
mip = 1;
var href = $(location).attr('pathname');
if (href.indexOf('personality') != -1) am = 1;
if (href.indexOf('logs') != -1) am = 2;
if (href.indexOf('sensors') != -1) am = 3;
if (href.indexOf('discovery') != -1) am = (3 + mip);
$('#navbar ul li').eq(am).addClass('active');
//handle settings
$(document).on('click','#scfg',function() {
mhdr_status('');
$('#m-t').html('Site settings');
var h = '<h3>Password settings</h3>';
h += c_txt('opswd','Old password','Please put old password (four digits)','','password');
h += c_txt('npswd','New password','Please put new password (four digits)','','password');
h += c_txt('npsch','New password check','New passwords check failed','','password');
$('#m-b').html(h);
$('.sb').unbind();
$('#cfg-modal').modal();
$('.sb').bind('click',function() {
loader(1);
var par = ['opswd','npswd','npsch'];
do_ajax('/set_cfg',pv(par),function (json) {
if (json) {
if (json['status'] == 0) {
mhdr_status('suc');
close_modal();
location = '/';
}
show_errors(json['status'],par);
loader(0);
}
});
});
});
//periodicly get status
var bsy = false;
var ebli = 0;
var eblio = 255;
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) {});
});
});
}