Brian Read c8ce77259d * Mon May 12 2025 Brian Read <brianr@koozali.org> 11.0.0-1.sme
- Adding SM2 panel [SME: 13004]
- Upgrade to phpsysinfo 3.4.4
- Add code to delete inline styles and add css to make it look better.
- version saved / built uses the static version, which means no drops downs and choices.
2025-05-14 16:14:01 +01:00

67 lines
3.3 KiB
JavaScript

function renderPlugin_smart(data) {
if ((data.Plugins.Plugin_SMART !== undefined) && (data.Plugins.Plugin_SMART.columns !== undefined) && (items(data.Plugins.Plugin_SMART.columns.column).length > 0) && (data.Plugins.Plugin_SMART.disks !== undefined) && (items(data.Plugins.Plugin_SMART.disks.disk).length > 0)) {
var smartitems = items(data.Plugins.Plugin_SMART.columns.column);
var html = '';
var i,j;
var smartid;
var attribute_name;
html+="<thead>";
html+="<tr>";
html+="<th id=\"smart_name\" class=\"rightCell\">"+genlang(2, 'smart')+"</th>"; // Name
for (i = 0; i < smartitems.length ; i++) {
attribute_name = smartitems[i]["@attributes"].attribute_name;
if (typeof attribute_name === 'string')
attribute_name = attribute_name.replace(/_/g, " ").replace(/;/g, "<br>");
else
attribute_name = "Attribute " + smartitems[i]["@attributes"].id;
html+="<th class=\"sorttable_numeric rightCell\">"+ attribute_name + "</th>";
}
html+="</tr>";
html+="</thead>";
var diskitems = items(data.Plugins.Plugin_SMART.disks.disk);
html += '<tbody>';
for (i = 0; i < diskitems.length; i++) {
html += '<tr>';
if (diskitems[i]["@attributes"].event !== undefined)
html += '<th class="rightCell"><table class="borderless table-hover table-nopadding" style="float:right;"><tbody><tr><td>'+ diskitems[i]["@attributes"].name + ' </td><td><img style="vertical-align:middle;width:20px;" src="./gfx/attention.gif" alt="!" title="' + diskitems[i]["@attributes"].event + '"/></td></tr></tbody></table></th>';
else
html += '<th class="rightCell">'+ diskitems[i]["@attributes"].name + '</th>';
var attribitems = items(diskitems[i].attribute);
var valarray = [];
for (j = 0;j < attribitems.length; j++) {
valarray[attribitems[j]["@attributes"].id] = attribitems[j]["@attributes"];
}
for (j = 0; j < smartitems.length; j++) {
smartid = smartitems[j]["@attributes"].id;
if ((smartid !== undefined) && (valarray[smartid] !== undefined)) {
var itemvalue = valarray[smartid][smartitems[j]["@attributes"].name];
if ((itemvalue !== undefined) && (itemvalue !== '' )) {
if (smartid === "194") {
html += '<td class="rightCell">' + formatTemp(itemvalue, data.Options["@attributes"].tempFormat) + '</td>';
} else {
html += '<td class="rightCell">' + itemvalue + '</td>';
}
} else {
html += '<td></td>';
}
} else {
html += '<td></td>';
}
}
html += '</tr>';
}
html += '</tbody>';
$('#smart').empty().append(html);
$('#smart').addClass("sortable");
sorttable.makeSortable($('#smart')[0]);
sorttable.innerSortFunction.apply($('#smart_name')[0], []);
$('#block_smart').show();
} else {
$('#block_smart').hide();
}
}