Yeung Alan 6 лет назад
Родитель
Сommit
88bdfc13b4
1 измененных файлов с 27 добавлено и 1 удалено
  1. 27 1
      DiskInfo/index.php

+ 27 - 1
DiskInfo/index.php

@@ -199,16 +199,25 @@ if(ao_module_virtualDesktop){
 }
 
 $.get( "opr.php?opr=scan", function( data ) {
+	//arr = scan result
+	//scan first
 	var arr = JSON.parse(data);
+	//check if something is selected, if no then redirect to first drive.
 	if(active == ""){
 		window.location = "index.php?drive=" + arr["devices"][0]["info_name"];
 	}
+	//for loop all devices out and check SMART
 	$(arr["devices"]).each(function(index, element) {
+		//call infomation for further deeper result
 		$.get( "opr.php?opr=info&drive=" + element["info_name"], function( data ) {
+			//check if something exists on return
 			if(data.length > 0){
 				smartstat[element["info_name"]] = "Unknown";
-				var table = JSON.parse(data);
+				//find for SMART bad, here do the for loop
+				var table = JSON.parse(data); 
+				//check for SMART table exists
 				if(table["ata_smart_attributes"]["table"].length > 0){		
+					//for loop to find if something failed, then show warning
 					$(table["ata_smart_attributes"]["table"]).each(function(tindex, telement) {
 						if(!typeof telement["when_failed"] === "undefined"){
 							if(telement["when_failed"] !== ""){
@@ -216,13 +225,17 @@ $.get( "opr.php?opr=scan", function( data ) {
 							}
 						}
 					});
+					// if nothing happen, then changed to GOOD
 					if(smartstat[active] == "Unknown"){
 						smartstat[active] = "Good";
 					}
 				}else{
+					// if nothing exists, then show Unknown
 					smartstat[element["info_name"]] = "Unknown";
 				}
+				//append it to nav bar
 				if(active == element["info_name"]){
+					//append if active selected
 					$( "#menu" ).append('<a class="active item" href="?drive=' + element["info_name"] + '">' + smartstat[element["info_name"]] + '<br>' + table["temperature"]["current"] + '°C<br>' + element["info_name"] + '</a>');
 				}else{
 					$( "#menu" ).append('<a class="item" href="?drive=' + element["info_name"] + '">' + smartstat[element["info_name"]] + '<br>' + table["temperature"]["current"] + '°C<br>' + element["info_name"] + '</a>');
@@ -231,8 +244,12 @@ $.get( "opr.php?opr=scan", function( data ) {
 		});
 	});
 });
+//get the selected drive infomation
 $.get( "opr.php?opr=info&drive=" + active, function( data ) {
+	//parse data;
 	var arr = JSON.parse(data);
+	
+	//append all shit here
 	$("#drivename").html(arr["model_name"] + " " + formatSizeUnits(arr["user_capacity"]["bytes"]));
 	$("#drivename").attr("data-tooltip",arr["model_family"]);
 	$("#firmware").attr("value",arr["firmware_version"]);
@@ -242,6 +259,7 @@ $.get( "opr.php?opr=info&drive=" + active, function( data ) {
 	$("#driveleter").attr("value",arr["device"]["name"]);
 	$("#standard").attr("value",arr["ata_version"]["string"]);
 	$("#features").attr("value","S.M.A.R.T.");
+	//check if it is SSD
 	if(arr["rotation_rate"] > 0){
 		$("#col1").html("----");
 		$("#col1_v").attr("value","----");
@@ -261,6 +279,8 @@ $.get( "opr.php?opr=info&drive=" + active, function( data ) {
 	}
 	$("#powercount").attr("value",arr["power_cycle_count"] + " count");
 	$("#powerhour").attr("value",arr["power_on_time"]["hours"] + " hours");
+	
+	//check if SMART bad
 	smartstat[active] = "Unknown";
 	$(arr["ata_smart_attributes"]["table"]).each(function(index, element) {
 		if(!typeof element["when_failed"] === "undefined"){
@@ -274,6 +294,7 @@ $.get( "opr.php?opr=info&drive=" + active, function( data ) {
 			var stat = "OK";
 		}
 		
+		//prevent element undefined, check first
 		if(typeof element["id"] === "undefined"){
 			var id = 0;
 		}else{
@@ -304,18 +325,21 @@ $.get( "opr.php?opr=info&drive=" + active, function( data ) {
 		}else{
 			var rvalue = element["raw"]["value"];
 		}
+		//apend
 		$("#tbody").append('<tr><td>' + stat + '</td><td>' + id + '</td><td>' + name + '</td><td>' + value + '</td><td>' + worst + '</td><td>' + thresh + '</td><td>' + rvalue + '</td></tr>');
 		
 		if(element["name"] == "SSD_Life_Left"){
 			$("#health_prec").html(element["value"] + "%");
 		}
 	});
+	//check if SMART exists and Not in warning, then shows GOOD
 	if(arr["ata_smart_attributes"]["table"].length > 0){
 		if(smartstat[active] == "Unknown"){
 			smartstat[active] = "Good";
 		}
 	}
 	
+	//change color
 	if(smartstat[active] == "Warning"){
 		$("#health_c").attr("class","ts inverted warning card");
 	}else if(smartstat[active] == "Good"){
@@ -323,6 +347,8 @@ $.get( "opr.php?opr=info&drive=" + active, function( data ) {
 	}else if(smartstat[active] == "Unknown"){
 		$("#health_c").attr("class","ts card");
 	}
+	
+	//if temp more than 40C, then warning
 	if(arr["temperature"]["current"] > 40){
 		$("#temperature_c").attr("class","ts inverted warning card");
 	}else if(arr["temperature"]["current"] > 0 && arr["temperature"]["current"] < 40){