network screen starting OK for static IP
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 8 Mar 2011 02:59:59 +0000 (02:59 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 8 Mar 2011 02:59:59 +0000 (02:59 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@279 01035d8c-6547-0410-b346-abe4f91aad63

mini-asterisk-gui2/cgi-bin/getemergencyip.cgi [new file with mode: 0644]
mini-asterisk-gui2/menu.js
mini-asterisk-gui2/minicommon.js
mini-asterisk-gui2/network.html
mini-asterisk-gui2/network.js
mini-asterisk-gui2/phones.js

diff --git a/mini-asterisk-gui2/cgi-bin/getemergencyip.cgi b/mini-asterisk-gui2/cgi-bin/getemergencyip.cgi
new file mode 100644 (file)
index 0000000..6d58b67
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+# getemergency.cgi
+# David Rowe 8 March 2011
+#
+# CGI to return emergency IP details
+
+cat <<EOF
+Content-type: text/html
+
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="-1">
+</head>
+<body>
+EOF
+
+if [ -f /etc/rc.d/S05network-backdoor ]; then
+  backdoor=`sed -n 's/IPADDRESS="\(.*\)"/\1/p' /etc/init.d/network-backdoor`
+  echo BACKDOOR=\"$backdoor\"
+fi
+
+cat <<EOF
+</body>
+</html>
+EOF
index 3e2cb8d3c586360be0e32eda32a3ba7edaa8ad49..109113dda6a0081d102b107328a625c85bfac7a9 100644 (file)
@@ -7,13 +7,13 @@
 */
 
 var menuItems = [
-    '<a href="phones.sh">Phone System</a>',
+    '<a href="phones.html">Phone System</a>',
     '<a href="about.sh">About</a>',
     '<a href="admin.sh">Admin</a>',
     '<a href="faq.sh">FAQ</a>',
     '<a href="ipphones.sh">IP Phones</a>',
     '<a href="logout.sh">Logout</a>',
-    '<a href="network.sh">Network</a>',
+    '<a href="network.html">Network</a>',
     '<a href="voiplines.sh">VOIP Line</a>'
 ];
 
index 3b2cb45b3504415bcf3d4e2a76a71f5a24cdd1ec..edf51422161daf9bdbe45016df99078c8ceb5ddc 100644 (file)
@@ -185,6 +185,23 @@ function loadHtmlTextFile(doc, textLineProcessing) {
 }
 
 
+// called when Fping CGI returns
+
+function processFping(doc, status) {
+
+    // Change icon based on ping results
+
+    var icon;
+
+    if (doc.indexOf("google.com") != -1)
+       icon = '<img src="tick.png" />';
+    else
+       icon = '<img src="cross.png" />';
+
+    document.getElementById('internet').innerHTML = icon;
+}
+
+
 /**
  * Returns an XMLHttp instance to use for asynchronous
  * downloading. This method will never throw an exception, but will
index 82f91ba031a7e47eb14f82e6f6ed966181c72841..d5a8bf2701e5f3ed872991ad06d2a38fa8248d59 100644 (file)
       <table align="center" width=600 border=0>
         <tr><td colspan="2" align="left" valign="top"><h2>Network</h2></td></tr>
         <tr>
-          <td><input type="radio" id="static" name="dhcp" value="no" onClick="doStatic()">Static</td>
-          <td><input type="radio" id="dhcp"   name="dhcp" value="yes" onClick="doDHCP()">DHCP</td>
+          <td><input type="radio" name="static" value="no" onClick="doStatic()">Static</td>
+          <td><input type="radio" name="dhcp" value="yes" onClick="doDHCP()">DHCP</td>
         </tr>
         <tr><td>IP Address:</td><td><input type="text" name="ipaddress" onBlur="isIP(this)"></td></tr>
         <tr><td>Netmask:</td><td><input type="text" name="netmask" onBlur="isIP(this)"></td></tr>
         <tr><td>Gateway:</td><td><input type="text" name="gateway" onBlur="isIP(this)"></td></tr>
         <tr><td>DNS:</td><td><input type="text" name="dns" onBlur="isIP(this)"></td></tr>
         <tr onMouseOver="popUp(event,'network_backdoor')" onmouseout="popUp(event,'network_backdoor')">
-          <td>Emergency IP:</td><td><input type="text" name="backdoor" id="backdoor" onBlur="isIP(this)"></td>
+          <td>Emergency IP:</td><td><input type="text" name="backdoor" onBlur="isIP(this)"></td>
         </tr>
         <tr onMouseOver="popUp(event,'network_internet')" onmouseout="popUp(event,'network_internet')">
          <td>Internet Connection:</td>
index 4310f9946a30bda2c7b4e87d12046e78343ebd6f..653a47ab07a7f2068d50889a1f7be1896a8a5558 100644 (file)
@@ -21,6 +21,26 @@ function initialise() {
 }
 
 
+function greyout(dhcp) {
+
+    if (dhcp == "yes") {
+       document.network.static.checked = 0;
+       document.network.dhcp.checked = 1;
+       document.network.ipaddress.disabled = 1;
+       document.network.netmask.disabled = 1;
+       document.network.gateway.disabled = 1;
+       document.network.dns.disabled = 1;
+    }
+    else {
+       document.network.static.checked = 1;
+       document.network.dhcp.checked = 0;
+       document.network.ipaddress.disabled = 0;
+       document.network.netmask.disabled = 0;
+       document.network.gateway.disabled = 0;
+       document.network.dns.disabled = 0;
+    }
+}
+
 // called when DHCP CGI returns
 
 function processDhcp(doc,status) {
@@ -31,11 +51,10 @@ function processDhcp(doc,status) {
        }
        );
 
+    greyout(dhcp);
+
     if (dhcp == "no") {
-       downloadUrl("/cgi-bin/getconf.cgi?file=../init.d/network-static", processStatic);
-    }
-    else {
-        // grey out fields
+        downloadUrl("/cgi-bin/getconf.cgi?file=../init.d/network-static", processStatic);
     }
 }
 
@@ -47,9 +66,22 @@ function processStatic(doc,status) {
            parseNetwork(line);
        }
        );
-
+        
+    downloadUrl("/cgi-bin/getemergencyip.cgi", processEmergencyIp);
 }
 
+// called when Emergency CGI returns
+
+function processEmergencyIp(doc,status) {
+    loadHtmlTextFile(doc, function(line) {
+           parseNetwork(line);
+       }
+       );
+        
+    // fire off fping CGI
+
+    downloadUrl("/cgi-bin/fpingnodes.cgi?ip=google.com", processFping);
+}
 
 function parseNetwork(line) {
 
@@ -82,6 +114,11 @@ function parseNetwork(line) {
       document.network.dns.value = dns;
    }
 
+   if (line.indexOf("BACKDOOR=") != -1) {
+      var s = line.split('"');
+      var backdoor = s[1];
+      document.network.backdoor.value = backdoor;
+   }
 }
 
 
index 176567078f91baef034677304b7a60cd92280640..7c7b2154e984928dd53dc502442ec47266c30913 100644 (file)
@@ -78,22 +78,6 @@ function initialisePage() {
 }
 
 
-// called when Fping CGI returns
-
-function processFping(doc, status) {
-
-    // Change icon based on ping results
-
-    var icon;
-
-    if (doc.indexOf("google.com") != -1)
-       icon = '<img src="tick.png" />';
-    else
-       icon = '<img src="cross.png" />';
-
-    document.getElementById('internet').innerHTML = icon;
-}
-
 // called when ifconfig CGI returns
 
 function processIfconfig(doc, status) {