Thursday, December 27, 2007

WMI - Mochikit


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
table.prettytable thead,th,tfoot
{
background-color : #676789;
text-align : center;
font-weight: bold;
color: #fff;
}
table.prettytable
{
border: 1px solid black;
}

</style>
<script type="text/javascript" src="../../lib/MochiKit/MochiKit.js"></script>
<script type="text/javascript">

result = []

row_display = function (row)
{
return TR(null, map(partial(TD, null), row));
}

function getDiskInfo()
{
var loc = new ActiveXObject("WbemScripting.SWbemLocator");
var wmi = loc.ConnectServer("", "root\\cimv2");
var ins = wmi.ExecQuery("select * from Win32_LogicalDisk");
for (var col = new Enumerator(ins);!col.atEnd();col.moveNext())
{
var disq = col.item()
result.push([disq.DeviceId,disq.FreeSpace,disq.Size])
}

var newTable = TABLE({'class': 'prettytable'},
THEAD(null,row_display(["Name", "FreeSpace", "Size"])),
TFOOT(null,row_display(["foot1", "foot2", "foot3"])),
TBODY(null,map(row_display, result)));

appendChildNodes("theBody",newTable);

}
</script>
</head>
<body id="theBody" onload="getDiskInfo()">

</body>
</html>



Powered by ScribeFire.

No comments:

Post a Comment