|
@@ -30,12 +30,13 @@ img {
|
|
|
Main Content start
|
|
|
//-->
|
|
|
<a id="loadinghref"><div id="loading" style="display:none;"><img src="img/giphy.gif"/></div></a>
|
|
|
+ <div id="loading2" style="display:none;"><img src="img/5minutes.gif"/></div>
|
|
|
<section class="envor-section">
|
|
|
<div class="container">
|
|
|
<div class="row">
|
|
|
<div class="col-lg-12">
|
|
|
<h2>Image <?php echo $lang->showWord("upgrade");?></h2>
|
|
|
- <div class="file-loading">
|
|
|
+ <div class="file-loading">
|
|
|
<input name="file_iso" id="file_iso" type="file" class="file" data-show-preview="false" data-show-upload="false" <?php //data-allowed-file-extensions='["iso"]' ?>>
|
|
|
</div>
|
|
|
|
|
@@ -45,7 +46,7 @@ img {
|
|
|
<div align="center"><button id="upload_iso"><?php echo $lang->showWord("set")?></button></div>
|
|
|
</article>
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
<div class="col-lg-12">
|
|
|
<h2><?php echo $lang->showWord("upgrade_status");?></h2>
|
|
|
<!-- <textarea id="description" rows="2" class="form-control" placeholder=""></textarea>-->
|
|
@@ -59,7 +60,7 @@ img {
|
|
|
</section>
|
|
|
</div>
|
|
|
|
|
|
-<?php
|
|
|
+<?php
|
|
|
include 'foot.php';
|
|
|
?>
|
|
|
|
|
@@ -71,7 +72,7 @@ img {
|
|
|
window.location="#loadinghref";
|
|
|
document.getElementById("loading").style.display="block";
|
|
|
var fileInput = document.getElementById('file_iso');
|
|
|
-
|
|
|
+
|
|
|
// 發送 Ajax 查詢請求並處理
|
|
|
var request = new XMLHttpRequest();
|
|
|
request.open("POST", "upgrade_iso_action.php");
|
|
@@ -96,7 +97,34 @@ img {
|
|
|
if (request.status == 200) {
|
|
|
document.getElementById("createResult").innerHTML = "";
|
|
|
document.getElementById("createResult").innerHTML = request.responseText;
|
|
|
+ document.getElementById("loading2").style.display="block";
|
|
|
+ var ts = 4*60*1000;
|
|
|
+ var idx=0;
|
|
|
+ var x = setInterval(function() {
|
|
|
+ idx++;
|
|
|
+ var t=ts-1000*idx;
|
|
|
+ if (t < 0) {
|
|
|
+ clearInterval(x);
|
|
|
+ document.getElementById("createResult").innerHTML = "<font color='#ff0000'>Upgrade done!</font>";
|
|
|
+ document.getElementById("loading2").style.display="none";
|
|
|
+ //location.href="upgrade_iso.php";
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ var cnt=0;
|
|
|
//location.href="upgrade_iso.php";
|
|
|
+ setInterval(function(){
|
|
|
+ var result=serverReachable();
|
|
|
+ if(!result) cnt=1;
|
|
|
+ if(result && cnt==1) cnt=2;
|
|
|
+ if(cnt==2) {
|
|
|
+ document.getElementById("createResult").innerHTML = "<font color='#ff0000'>Upgrade done!</font>";
|
|
|
+ document.getElementById("loading2").style.display="none";
|
|
|
+// cnt=3;
|
|
|
+ //location.href="upgrade_iso.php";
|
|
|
+ //return false;
|
|
|
+ }
|
|
|
+// if(cnt==3)return false;
|
|
|
+ },3000);
|
|
|
} else {
|
|
|
alert(JSON.parse(request.responseText).message);
|
|
|
}
|
|
@@ -108,29 +136,29 @@ img {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function formCheck(fw_tag)
|
|
|
{
|
|
|
var file_type;
|
|
|
-
|
|
|
+
|
|
|
if(fw_tag=="iso")
|
|
|
{
|
|
|
if(document.getElementById("file_iso").value.substring(document.getElementById("file_iso").value.length-3) != "hex")
|
|
|
{
|
|
|
// alert("Firmware file type is wrong, please check file type.(*.hex)");
|
|
|
// document.getElementById("file_iso").focus();
|
|
|
-
|
|
|
+
|
|
|
// return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(document.getElementById("file_iso").value.length <= 0)
|
|
|
{
|
|
|
alert("Firmware is not select, please check!");
|
|
|
document.getElementById("file_iso").focus();
|
|
|
-
|
|
|
+
|
|
|
return false;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
// if(confirm("Are you sure to update AC MCU firmware file now?...") == 1 )
|
|
|
return true;
|
|
|
// else
|
|
@@ -143,12 +171,35 @@ img {
|
|
|
function isNumberKey(evt)
|
|
|
{
|
|
|
var charCode = (evt.which) ? evt.which : event.keyCode
|
|
|
-
|
|
|
+
|
|
|
if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode != 46))
|
|
|
return false;
|
|
|
-
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ function serverReachable() {
|
|
|
+ // IE vs. standard XHR creation
|
|
|
+ var x = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" ),
|
|
|
+ s;
|
|
|
+ x.open(
|
|
|
+ // requesting the headers is faster, and just enough
|
|
|
+ "HEAD",
|
|
|
+ // append a random string to the current hostname,
|
|
|
+ // to make sure we're not hitting the cache
|
|
|
+ "//" + window.location.hostname + "/?rand=" + Math.random(),
|
|
|
+ // make a synchronous request
|
|
|
+ false
|
|
|
+ );
|
|
|
+ try {
|
|
|
+ x.send();
|
|
|
+ s = x.status;
|
|
|
+ // Make sure the server is reachable
|
|
|
+ return ( s >= 200 && s < 300 || s === 304 );
|
|
|
+ // catch network & other problems
|
|
|
+ } catch (e) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
</script>
|
|
|
|