Merge pull request #264 from bergware/6.4-wip

Minor code optimizations
This commit is contained in:
tom mortensen
2018-02-22 09:30:36 -08:00
committed by GitHub
2 changed files with 18 additions and 17 deletions

View File

@@ -516,24 +516,23 @@ function toggle_CPU(init) {
if (!init) {
if ($.cookie('cpu')===undefined) $.cookie('cpu','close',{path:'/',expires:3650}); else $.removeCookie('cpu',{path:'/'});
}
if ($.cookie('cpu')===undefined) {
$('.cpu_open').show();
} else {
$('.cpu_open').hide();
}
$.cookie('cpu')===undefined ? $('.cpu_open').show() : $('.cpu_open').hide();
}
var cpuload = new NchanSubscriber('/sub/cpuload');
cpuload.on('message',function(message) {
// message should be something like: {"cpuload": {"cpu":[0,0],"cpu0":[0,0],"cpu1":[0,0],"cpu2":[0,0],"cpu3":[0,0]}}
// The array values are [<load-percentage>,<guest-percentage>]. guest-percentage is that part of load-percentage that is being consumed by VM guests
// var json = $.parseJSON(message);
// $.each(json["cpuload"],function(k,v) {
// $('#'+k).animate({width:v[0]+'%'},{step:function(){$('#'+k).css('overflow','visible');}}).text(v[0]+'%');
// });
// message is the cpuload.ini file contents
var ini = parseINI(message);
cpuload.on('message',function(data) {
/*
message should be something like: {"cpuload": {"cpu":[0,0],"cpu0":[0,0],"cpu1":[0,0],"cpu2":[0,0],"cpu3":[0,0]}}
The array values are [<load-percentage>,<guest-percentage>]. guest-percentage is that part of load-percentage that is being consumed by VM guests
var json = $.parseJSON(message);
$.each(json["cpuload"],function(k,v) {
$('#'+k).animate({width:v[0]+'%'},{step:function(){$('#'+k).css('overflow','visible');}}).text(v[0]+'%');
});
*/
//data is the cpuload.ini file contents
var ini = parseINI(data);
$.each(ini,function(k,v) {
$('#'+k).animate({width:v['host']+'%'},{step:function(){$('#'+k).css('overflow','visible');}}).text(v['host']+'%');
var load = v['host']+'%';
$('#'+k).animate({width:load},{step:function(){$('#'+k).css('overflow','visible');}}).text(load);
});
});
$(function() {

View File

@@ -372,8 +372,10 @@ watchDHCP.on('message', function(data) {
var id = row.split('_');
var form = $('form[name="'+id[0]+'_settings"]');
var key = id[2].split('=');
if (id[1]=='I') form.find('input[name="'+key[0]+'"]').val(key[1]);
else if (id[1]=='S') form.find('select[name="'+key[0]+'"]').val(key[1]);
switch (id[1]) {
case 'I': form.find('input[name="'+key[0]+'"]').val(key[1]); break;
case 'S': form.find('select[name="'+key[0]+'"]').val(key[1]); break;
}
}
});
$(function() {