<?php
require("../../inc/header.inc");
require("./function.inc");
?>
<body onload="javascript:adjust();" onresize="javascript:adjust();" leftmargin="15" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">


<?php
adjust_head();

adjust_title_head();
echo "<FORM NAME=\"downForm\" action=\"./raidStatus.php\" method=\"post\">";
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "$strSysStatus > NSS > RAID";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
		$helpId="1.2.7";
		showHelp($helpId);
		echo "</td>";
	echo "</tr>";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "&nbsp;";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Clear\">";
		echo "<a href=\"./raidStatus.php?clear_flag=1\"><img align=absBottom border=0 src=\"../../images/delete.gif\" width=\"14\" height=\"14\">$strClear</a>";
		echo "</td>";
	echo "</tr>";
echo "</table>";
adjust_title_tail();
adjust_content_head();


echo "<br>";
echo "<center><font size=2 color=\"blue\">Raid summary information</font></center>";
echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#ffffff\">";
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td width=\"12%\">Server</td>";
echo "<td width=\"10%\">Disk Count</td>";
echo "<td width=\"10%\">Disk#0</td>";
echo "<td width=\"10%\">Disk#1</td>";
echo "<td width=\"10%\">Disk#2</td>";
echo "<td width=\"10%\">Disk#3</td>";
echo "<td width=\"10%\">Disk#4</td>";
echo "<td width=\"10%\">Disk#5</td>";
echo "<td width=\"18%\">Refresh Time";
echo "</tr>";

echo "<tr id=\"blank_line\">";
echo "<td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td>";
echo "</tr>";

if($clear_flag == 1)
{
	$sql="delete from RAID_DB.raid_status ";
	//echo "$sql<br>";
	mysqli_query($pubConn,$sql);
}

for($index=0;$index<16;$index++)
{
	echo "<tr id=\"tr_{$index}\">";
	for($disk_index=0;$disk_index<9;$disk_index++)
	{
		echo "<td id=\"td_{$index}_{$disk_index}\">--</td>";
	}
	echo "</tr>";
}

adjust_content_tail();
?>

<script language="JavaScript">
function updateStatus()
{
	var fixurl="./raidStatus_update.php";
	var browserr = navigator.appName;
	if(browserr == "Microsoft Internet Explorer")
	{
		request_oo = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		request_oo = new XMLHttpRequest();
	}
	request_oo.open("GET",fixurl,"false");

	request_oo.onreadystatechange=function()
	{ 
		checkUpdateState(); 
	}
	request_oo.send(null);
	setTimeout("updateStatus()", 10000);
}

function checkUpdateState()
{
	//not
	if(request_oo.readyState == 3)
	{
		//alert("not finish");
	}
	if(request_oo.readyState == 4)
	{
		var response = request_oo.responseText;
		//alert(response);
		
		var module=response.split(';');
		for(i=0;i<module.length;i++)
		{
			var items=module[i].split(',');
			//alert(items.length);
			if(items.length < 1)
				continue;
			
			var kind=items[0].replace(/(^\s*)|(\s*$)/g, "");
			if(kind == 'tr')
			{
				var line_id=items[1].replace(/(^\s*)|(\s*$)/g, "");
				var line_display=items[2].replace(/(^\s*)|(\s*$)/g, "");
				//alert(line_id);
				if(line_display == 'none')
					document.getElementById(line_id).style.display='none';
				else
					document.getElementById(line_id).style.display='';
			}
			else if(kind == 'td')
			{
				var item_id=items[1].replace(/(^\s*)|(\s*$)/g, "");
				var item_value=items[2].replace(/(^\s*)|(\s*$)/g, "");
				var item_color=items[3].replace(/(^\s*)|(\s*$)/g, "");
				document.getElementById(item_id).style.color=item_color;
				document.getElementById(item_id).innerHTML=item_value;
			}
		}
		
	}
}

updateStatus();
</script>

