<html>
   <head>
      <meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
      <link rel="stylesheet" href='stylemain.css' type='text/css'>
      <link rel="stylesheet" href='colors.css' type='text/css'>

<style type="text/css">
body {font-size: medium;}
td {height: 25px;}
</style>

			<script language="javascript" src="util.js"></script>
            <script language="javascript">
<!-- hide

var obj0Items = '<%ejGetObject(MDMOID_WAN_SENSING)%>';

var obj0Rows = numOfRow(obj0Items);
//Enable}-{RetryInterval}-{Status}-{DetailedComments}-{CurrentTriedWANLinkType}-{CurrentTriedWANInterface}-{LastConnectedWANLinkType}-{LastConnectedWANInterface}-{PingAddress}-{PingInterval}-{PingFailedThreshhold}-{|,|
var obj0_EnableArray = getColFromList(obj0Items, "Enable");
var obj0_RetryIntervalArray = getColFromList(obj0Items, "RetryInterval");
var obj0_StatusArray = getColFromList(obj0Items, "Status");
var obj0_DetailedCommentsArray = getColFromList(obj0Items, "DetailedComments");
var obj0_CurrentTriedWANLinkTypeArray = getColFromList(obj0Items, "CurrentTriedWANLinkType");
var obj0_CurrentTriedWANInterfaceArray = getColFromList(obj0Items, "CurrentTriedWANInterface");
var obj0_LastConnectedWANLinkTypeArray = getColFromList(obj0Items, "LastConnectedWANLinkType");
var obj0_LastConnectedWANInterfaceArray = getColFromList(obj0Items, "LastConnectedWANInterface");
var obj0_PingAddressArray = getColFromList(obj0Items, "PingAddress");
var obj0_PingIntervalArray = getColFromList(obj0Items, "PingInterval");
var obj0_PingFailedThreshholdArray = getColFromList(obj0Items, "PingFailedThreshhold");
var obj0_pingSuccessedThreshholdArray = getColFromList(obj0Items, "PingSuccessedThreshhold");

var sessionKey='<%ejGetOther(sessionKey)%>';

function sendRefresh() { 
   window.location.href="autoRefreshwansensing.html"; 
}

function frmLoad() {

   var openhiddenpage = '<%ejGetOther(openhiddenpage)%>';
   if (openhiddenpage == "0" && top.location == self.location){
      //alert("You can't use the URL to access to the webpage directly, back to the home page");
      top.location="http://"+lanIpAddress+"/main.html";
   }   
   
   with ( document.forms[0] ) {
   	  if ( obj0_EnableArray[0] == '1' ){
         WSenable[1].checked = true;
      }else{
         WSenable[0].checked = true;
      }

	  getEleById("RetryInterval").innerText = obj0_RetryIntervalArray[0];
	  getEleById("Status").innerText = obj0_StatusArray[0];
	  getEleById("DetailedComments").innerText = obj0_DetailedCommentsArray[0];
	  getEleById("CurrentTriedWANLinkType").innerText = obj0_CurrentTriedWANLinkTypeArray[0];
	  getEleById("CurrentTriedWANInterface").innerText = obj0_CurrentTriedWANInterfaceArray[0];
	  getEleById("LastConnectedWANLinkType").innerText = obj0_LastConnectedWANLinkTypeArray[0];
	  getEleById("LastConnectedWANInterface").innerText = obj0_LastConnectedWANInterfaceArray[0];

	  pingAddress.value = obj0_PingAddressArray[0];
	  pingInterval.value = obj0_PingIntervalArray[0];
	  pingFailedThreshhold.value = obj0_PingFailedThreshholdArray[0];
	  pingSuccessedThreshhold.value = obj0_pingSuccessedThreshholdArray[0];

	  pingAddress1.value = '<%ejGetOther(wansensing, FirstIP)%>';
	  if (pingAddress1.value == '&nbsp;' || pingAddress1.value == '&nbsp'){
	     pingAddress1.value = '';
	  }
	  
   }

   setTimeout('sendRefresh()' , 10000); 
}

function btnApply() {
   var loc = 'wansensing.cmd?action=set&';

   with ( document.forms[0] ) {
   	
      if ( WSenable[1].checked == true ) 
         loc += 'WSenable=1';
      else
         loc += 'WSenable=0';

      if (pingAddress.value.length > 0){
         loc += "&pingAddress=" + pingAddress.value;
	  }

      if (!isNaN(pingInterval.value)){
         loc += "&pingInterval=" + pingInterval.value;
      } else {
         alert("PingInterval is not digit");
  	     return;
      }

	  if (!isNaN(pingFailedThreshhold.value)){
         loc += "&pingFailedThreshhold=" + pingFailedThreshhold.value;
      } else {
         alert("PingFailedThreshhold is not digit");
  	     return;
      }

	  if (!isNaN(pingSuccessedThreshhold.value)){
         loc += "&pingSuccessedThreshhold=" + pingSuccessedThreshhold.value;
      } else {
         alert("pingSuccessedThreshhold is not digit");
  	     return;
      }	  
   }
   
   loc += '&sessionKey=' + sessionKey;
   var code = 'location.assign("' + loc + '")';
   eval(code);
}


function Refresh() {
   var loc = 'wansensing.html';
   var code = 'location.assign("' + loc + '")';
   eval(code);
}



// done hiding -->
</script>
   </head>
   <body onLoad='frmLoad()'>
      <blockquote>
         <form>
            <b>WAN Backup - Configuration<br></b>
            <br>
            <!-- pre>
            Function:select the highest priority wan as default wan to transmit data
            
            Description:
                highest priority rules:
                1) 1st rule: ping for every wan connection, if can not pass, siwtch the next priority wan
                2) 2nd rule: SFP > DSL > ETH > USB MODEM
                3) 3rd rule: IPoE > PPPoE

            E.g.
                There are three wans: WAN1(SFP IPoE), WAN2(SFP PPPoE), WAN3(DSL PPPoE)
                All of them had connected, select the WAN1 as default wan
                Running a long time, then WAN1 and WAN2 can not ping pass, WAN3 will be selected as default wan
                After a few time, WAN1 and WAN2 can ping pass, WAN1 will be selected as default wan again
            </pre -->
            <br>
            <br>
            <center>
            <div id='ctrlShow'>
            <table border="0" cellpadding="0" cellspacing="0">
               <tr>
                  <td width="200">Enable:</td>
                  <td width="100"><input name='WSenable' type='radio' onClick='enablClick()' />Disable</td>
                  <td width="100"><input name='WSenable' type='radio' onClick='enablClick()' />Enable</td>
               </tr>
            </table>
            </div>
            <br>
            
            <div id='bodyShow'>
            
            <div id='configurationShow'>
            <table border="0" cellpadding="0" cellspacing="0">
               <tr>
                  <td width="200"><span title="the ip you want to ping">First IP:</span></td>
                  <td width="200"><input type="text" name="pingAddress1" id='pingAddress1' style="width:160px;" maxlength="64" disabled/></td>
               </tr>
               <tr>
                  <td width="200"><span title="the ip you want to ping">Second IP:</span></td>
                  <td width="200"><input type="text" name="pingAddress" id='pingAddress' style="width:160px;" maxlength="64" /></td>
               </tr>
               <tr>
                  <td><span title="the interval of every ping packet, unit sec">Ping Interval(s):</span></td>
                  <td><input type="text" name="pingInterval" id='pingInterval' style="width:160px;" maxlength="2" /></td>
               </tr>
               
               <tr>
                  <td><span ></span></td>
                  <td><span ></span></td>
               </tr>

               <tr>
                  <td><span title="Main WAN -> LTE">Main WAN -> LTE</span></td>
                  <td><span ></span></td>
               </tr>
               
               <tr>
                  <td><span title="The number of successive Ping failures, if the number more than Ping Failed Count, re-select the default wan">Ping Fail Count:</span></td>
                  <td><input type="text" name="pingFailedThreshhold" id='pingFailedThreshhold' style="width:160px;" maxlength="2" /></td>
               </tr>

               <tr>
                  <td><span ></span></td>
                  <td><span ></span></td>
               </tr>
               
               <tr>
                  <td><span title="LTE -> Main WAN">LTE -> Main WAN</span></td>
                  <td><span ></span></td>
               </tr>
               <tr>
                  <td><span title="The number of successive Ping Success, if the number more than Ping Success Count, re-select the default wan">Ping Success Count:</span></td>
                  <td><input type="text" name="pingSuccessedThreshhold" id='pingSuccessedThreshhold' style="width:160px;" maxlength="2" /></td>
               </tr>
            </table>
            </div>
            <br/>
            <br/>
            <div id='stateShow'>
            <table border="0" cellpadding="0" cellspacing="0">
               <tr style="display:none">
                  <td width="200">RetryInterval:</td>
                  <td width="200"><span id='RetryInterval'></span></td>
               </tr>
               <tr style="display:none">
                  <td width="200">Status:</td>
                  <td width="200"><span id='Status'></span></td>
               </tr>
               <tr style="display:none">
                  <td>DetailedComments:</td>
                  <td><span id='DetailedComments'></span></td>
               </tr>
               <tr style="display:none">
                  <td>LastConnectedWANLinkType:</td>
                  <td><span id='LastConnectedWANLinkType'></span></td>
               </tr>
               <tr style="display:none">
                  <td>LastConnectedWANInterface:</td>
                  <td><span id='LastConnectedWANInterface'></span></td>
               </tr>
               <tr style="display:none">
                  <td>CurrentTriedWANLinkType:</td>
                  <td><span id='CurrentTriedWANLinkType'></span></td>
               </tr>
               <tr style="display:none">
                  <td>CurrentTriedWANInterface:</td>
                  <td><span id='CurrentTriedWANInterface'></span></td>
               </tr>
               <tr>
                  <td width="200"><span title="show current default dns interface">CurrentDefaultDNSInterface:</span></td>
                  <td width="200"><span id='CurrentDefaultDNSInterface'><%ejGetOther(wansensing, CurrentDefaultDNSInterface)%></span></td>
               </tr>
               <tr>
                  <td><span title="show current default route interface">CurrentDefaultRouteInterface:</span></td>
                  <td><span id='CurrentDefaultRouteInterface'><%ejGetOther(wansensing, CurrentDefaultRouteInterface)%></span></td>
               </tr>
            </table>
            </div>

            <br>
            </div>

            <br>

            <div id='actionShow'>
            <p align="center">
               <input type='button' onClick='btnApply()' value='Apply/Save'>
               <input type='button' onClick='Refresh()' value='Refresh'>
            </P>
            </div>
            </center>
         </form>
      </blockquote>
   </body>
</html>
