/* * func.js - Function Define. * * Copyright (c) U-Media Communications, Inc. All Rights Reserved. * * $Id: v1.0 12-Dec-2007 Jacky.Yang Exp $ */ var IPandMask = "10.100.1.1,255.255.255.0"; //var currentIP = ""; var currentIP; var totalWaitTime=7; //second var renewTime=500; //millisecond, progress reflash clock. //var renewClock=100 / ((totalWaitTime*1000)/renewTime); var renewClock; var percent=0; var redirectURL; var urlPath, oldPercent, waitDHCPInfoValue; var updateIPAddresStopToWait = true; var updateWaitDHCPInfoStopToWait = true; var waitCount=0; var intval=""; var intval_cnt=0; docTemp = IPandMask; index = docTemp.indexOf(','); //IP currentIP = docTemp.substr(0, index); var current_lang = "EN"; function makeUpdateIPRequest(url, content) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert("Giving up :( Cannot create an XMLHTTP instance"); return false; } http_request.onreadystatechange = function () {alertUpdateIPContents()}; http_request.open('POST', url, true); http_request.send(content); } function alertUpdateIPContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { /*IPandMask = http_request.responseText; docTemp = IPandMask; index = docTemp.indexOf(','); //IP currentIP = docTemp.substr(0, index);*/ if (http_request.responseText != "NULL") currentIP = http_request.responseText; updateIPAddresStopToWait = true; //alert("alertUpdateIPContents:" + currentIP); //alert(currentIP); } else { //alert("There was a problem with the request."); } } } function updateIPAddress(){ if (updateIPAddresStopToWait == true) { makeUpdateIPRequest("../goform/updateIPAddress", "something"); updateIPAddresStopToWait = false; } } function makeWaitDHCPInfoRequest(url, content) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert("Giving up :( Cannot create an XMLHTTP instance"); return false; } http_request.onreadystatechange = function () {alertWaitDHCPInfoContents()}; http_request.open('POST', url, true); http_request.send(content); } function alertWaitDHCPInfoContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { waitDHCPInfoValue = http_request.responseText; docTemp = waitDHCPInfoValue; index = docTemp.indexOf(','); //IP currentIP = docTemp.substr(0, index); updateWaitDHCPInfoStopToWait = true; //alert("alertUpdateIPContents:" + currentIP); //alert(currentIP); } else { //alert("There was a problem with the request."); } } } function waitDHCPInfo(){ //alert("waitDHCPInfo"); //alert(waitDHCPInfoValue); if (updateWaitDHCPInfoStopToWait == true) { waitDHCPInfoValue=""; currentIP=""; //updateIPAddress(); makeWaitDHCPInfoRequest("../goform/waitDHCPInfo", "something"); updateWaitDHCPInfoStopToWait = false; } //if ((waitDHCPInfoValue != "") && (waitCount < 20)) document.getElementById("returnField").innerHTML = ""; setTimeout("waitDHCPInfo()", 500); //if ((waitDHCPInfoValue != 1) && (waitCount < 50)) //alert("waitDHCPInfoValue: " + waitDHCPInfoValue); /*if ((waitDHCPInfoValue == "")) { waitCount++; setTimeout("waitDHCPInfo()", 500); } else { document.getElementById("returnField").innerHTML = ""; }*/ } function wait_page() { /*if (percent > 80) { rebootRedirect.location.href="http://" + currentIP +"/rebootredirect.asp"; }*/ if(myBrowser()=="Chrome" || myBrowser()=="FF")//Griffin Chrome and FF use setTimeout can't work { if(intval=="") { window.clearInterval(intval); intval=""; intval_cnt=0; intval=window.setInterval("wait_page_intval()", 1000);//Chorme and FF always 1s } return; } if(myBrowser()!="Safari" && myBrowser()!="Chrome") { if ((Math.round(percent) > 50) && (Math.round(percent)%5) == 0) rebootRedirect.location.href=redirectURL; } if (percent == 0) { renewClock=100 / ((totalWaitTime*1000)/renewTime); //redirectURL = ".." + location.pathname; objectDisplay("saveField", "none"); objectDisplay("mainform", "none"); if(current_lang != "SA"){ document.getElementById("waitform").innerHTML = "
Processing, Please wait......
 
"; } else{ document.getElementById("waitform").innerHTML = "
Processing, Please wait......
 
"; } } percent+=renewClock; if (percent >= 100) { percent = 100; location.href = redirectURL; return; } document.getElementById("progress").style.width = Math.round(percent) + "%"; document.getElementById("progressValue").innerHTML = Math.round(percent) + "%"; if (percent != 100) window.setTimeout("wait_page()", renewTime); } function wait_page_intval() { if (percent == 0) { objectDisplay("saveField", "none"); objectDisplay("mainform", "none"); if(current_lang != "SA"){ document.getElementById("waitform").innerHTML = "
Processing, Please wait......
 
"; } else{ document.getElementById("waitform").innerHTML = "
Processing, Please wait......
 
"; } } percent=intval_cnt*100/totalWaitTime; intval_cnt++; if (percent >= 100) { percent = 100; location.href = redirectURL; window.clearInterval(intval); intval=""; intval_cnt=0; return; } document.getElementById("progress").style.width = Math.round(percent) + "%"; document.getElementById("progressValue").innerHTML = Math.round(percent) + "%"; } function connecting_wait_page() { //alert(currentIP + ", percent=" + percent); //if ( ((Math.round(percent) > 10) && (Math.round(percent)%2) == 0) && ((Math.round(percent) < 30) && ((Math.round(percent)%2) == 0)) ) if ( (Math.round(percent) >= 20) && ((Math.round(percent)%5) == 0) && (oldPercent != (Math.round(percent)%5))) { updateIPAddress(); oldPercent = Math.round(percent)%5; //alert("connecting_wait_page: " + currentIP); rebootRedirect.location.href="http://" + currentIP +"/rebootredirect.asp"; } /*if ((Math.round(percent) > 60) && ((Math.round(percent)%5) == 0)) rebootRedirect.location.href="http://" + currentIP +"/rebootredirect.asp";*/ if (percent == 0) { renewClock=100 / ((totalWaitTime*1000)/renewTime); //redirectURL = ".." + location.pathname; objectDisplay("mainform", "none"); if(current_lang != "SA"){ document.getElementById("waitform").innerHTML = "
Processing, Please wait......
 
"; } else{ document.getElementById("waitform").innerHTML = "
Processing, Please wait......
 
"; } } percent+=renewClock; if (percent >= 100) { percent = 100; //location.href = redirectURL; location.href="http://" + currentIP +"/rebootredirect.asp"; //return; } document.getElementById("progress").style.width = Math.round(percent) + "%"; document.getElementById("progressValue").innerHTML = Math.round(percent) + "%"; if (percent != 100) window.setTimeout("connecting_wait_page()", renewTime); } function process_page() { //if ((percent > 30)) updateIPAddress(); if ((Math.round(percent) > 70) && (Math.round(percent)%5) == 0) rebootRedirect.location.href="http://" + currentIP +"/rebootredirect.asp"; if (percent == 0) { renewClock=100 / ((totalWaitTime*1000)/renewTime); //redirectURL = ".." + location.pathname; objectDisplay("mainform", "none"); if(current_lang != "SA"){ document.getElementById("waitform").innerHTML = "
Processing, Please wait......
 
"; } else{ document.getElementById("waitform").innerHTML = "
Processing, Please wait......
 
"; } } percent+=renewClock; if (percent >= 100) { percent = 100; location.href = redirectURL; //return; } document.getElementById("progress").style.width = Math.round(percent) + "%"; document.getElementById("progressValue").innerHTML = Math.round(percent) + "%"; if (percent != 100) window.setTimeout("process_page()", renewTime); } function reboot_page() { //if ((percent > 30)) if(myBrowser()=="Chrome" || myBrowser()=="FF")//Griffin Chrome and FF use setTimeout can't work { if(intval=="") { window.clearInterval(intval); intval=""; intval_cnt=0; intval=window.setInterval("reboot_page_intval()", 1000);//Chorme and FF always 1s } return; } if(myBrowser()!="Safari" && myBrowser()!="Chrome") { if ((Math.round(percent) > 70) && (Math.round(percent)%5) == 0) rebootRedirect.location.href="http://" + currentIP +"/rebootredirect.asp"; } if (percent == 0) { renewClock=100 / ((totalWaitTime*1000)/renewTime); //redirectURL = ".." + location.pathname; objectDisplay("mainform", "none"); if(current_lang != "SA"){ document.getElementById("waitform").innerHTML = "
Rebooting, Please wait......
 
"; } else{ document.getElementById("waitform").innerHTML = "
Rebooting, Please wait......
 
"; } } percent+=renewClock; if (percent >= 100) { percent = 100; location.href = redirectURL; return; } document.getElementById("progress").style.width = Math.round(percent) + "%"; document.getElementById("progressValue").innerHTML = Math.round(percent) + "%"; if (percent != 100) window.setTimeout("reboot_page()", renewTime); } function reboot_page_intval() { if ((Math.round(percent) > 70) && (Math.round(percent)%5) == 0) rebootRedirect.location.href="http://" + currentIP +"/rebootredirect.asp"; if (percent == 0) { objectDisplay("mainform", "none"); if(current_lang != "SA"){ document.getElementById("waitform").innerHTML = "
Rebooting, Please wait......
 
"; } else{ document.getElementById("waitform").innerHTML = "
Rebooting, Please wait......
 
"; } } percent=intval_cnt*100/totalWaitTime; intval_cnt++; if (percent >= 100) { percent = 100; location.href = redirectURL; window.clearInterval(intval); intval=""; intval_cnt=0; return; } document.getElementById("progress").style.width = Math.round(percent) + "%"; document.getElementById("progressValue").innerHTML = Math.round(percent) + "%"; } //Griffin -check browser version function myBrowser(){ var userAgent = navigator.userAgent; var isOpera = userAgent.indexOf("Opera") > -1; var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera ; var isFF = userAgent.indexOf("Firefox") > -1 ; var isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") < 1 ; var isChrome = userAgent.indexOf("Chrome") > -1 ; if(isIE){ var IE5 = IE55 = IE6 = IE7 = IE8 = false; var reIE = new RegExp("MSIE (//d+//.//d+);"); reIE.test(userAgent); var fIEVersion = parseFloat(RegExp["$1"]); IE55 = fIEVersion == 5.5 ; IE6 = fIEVersion == 6.0 ; IE7 = fIEVersion == 7.0 ; IE8 = fIEVersion == 8.0 ; if(IE55){ return "IE55"; } if(IE6){ return "IE6"; } if(IE7){ return "IE7"; } if(IE8){ return "IE8"; } } if(isFF){ return "FF"; } if(isOpera){ return "Opera"; } if(isSafari){ return "Safari"; } if(isChrome){ return "Chrome"; } } //myBrowser() end