function renderPlugin_snmppinfo(data) {
var directives = {
Device: {
text: function () {
var Name = (this["Name"] !== undefined) ? (' (' + this["Name"] + ')'): '';
return this["Device"] + Name;
}
},
Percent: {
html: function () {
var max = parseInt(this["MaxCapacity"]);
var level = parseInt(this["Level"]);
var percent = 0;
if (max>0 && (level>=0) && (level<=max) ) {
percent = Math.round(100*level/max);
} else if (max==-2 && (level>=0) && (level<=100) ) {
percent = level;
} else if (level==-3) {
percent = 100;
}
return '
' + percent + '%
';
}
},
Units: {
text: function () {
var max = parseInt(this["MaxCapacity"]);
var level = parseInt(this["Level"]);
if (max>0 && (level>=0) && (level<=max) ) {
return level+" / "+max;
} else if (max==-2 && (level>=0) && (level<=100) ) {
return level+" / 100";
} else if (level==-3) {
return "enough";
} else {
return "unknown";
}
}
}
};
if (data['Plugins']['Plugin_SNMPPInfo'] !== undefined) {
var printers = items(data['Plugins']['Plugin_SNMPPInfo']['Printer']);
if (printers.length > 0) {
var html = "";
html+="";
html+="";
html+="Printer | ";
html+="Percent | ";
html+="Units | ";
html+="
";
html+="";
for (var i = 0; i < printers.length; i++) {
html+="";
html+=" | ";
html+=" | ";
html+=" | ";
html+="
";
try {
var datas = items(printers[i]["MarkerSupplies"]);
for (var j = 0; j < datas.length; j++) {
html+="";
html+=" | ";
html+=" | ";
html+=" | ";
html+="
";
}
}
catch (err) {
$("#snmppinfo-" + i).hide();
}
}
$("#snmppinfo").empty().append(html);
for (var i = 0; i < printers.length; i++) {
$('#snmppinfo-'+ i).render(printers[i]["@attributes"], directives);
try {
var datas = items(printers[i]["MarkerSupplies"]);
for (var j = 0; j < datas.length; j++) {
$('#snmppinfo-'+ i+ "-" + j).render(datas[j]["@attributes"], directives);
}
}
catch (err) {
$("#snmppinfo-" + i).hide();
}
}
$('#snmppinfo').treegrid({
initialState: 'expanded',
expanderExpandedClass: 'normalicon normalicon-down',
expanderCollapsedClass: 'normalicon normalicon-right'
});
$('#block_snmppinfo').show();
} else {
$('#block_snmppinfo').hide();
}
} else {
$('#block_snmppinfo').hide();
}
}