From: drowe67 Date: Tue, 8 Mar 2011 02:59:59 +0000 (+0000) Subject: network screen starting OK for static IP X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=d5ab858eb735448d64a9ee292745942e78fc5a29;p=freetel-svn-tracking.git network screen starting OK for static IP git-svn-id: https://svn.code.sf.net/p/freetel/code@279 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/mini-asterisk-gui2/cgi-bin/getemergencyip.cgi b/mini-asterisk-gui2/cgi-bin/getemergencyip.cgi new file mode 100644 index 00000000..6d58b67b --- /dev/null +++ b/mini-asterisk-gui2/cgi-bin/getemergencyip.cgi @@ -0,0 +1,27 @@ +#!/bin/sh +# getemergency.cgi +# David Rowe 8 March 2011 +# +# CGI to return emergency IP details + +cat < + + + + + + +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 diff --git a/mini-asterisk-gui2/menu.js b/mini-asterisk-gui2/menu.js index 3e2cb8d3..109113dd 100644 --- a/mini-asterisk-gui2/menu.js +++ b/mini-asterisk-gui2/menu.js @@ -7,13 +7,13 @@ */ var menuItems = [ - 'Phone System', + 'Phone System', 'About', 'Admin', 'FAQ', 'IP Phones', 'Logout', - 'Network', + 'Network', 'VOIP Line' ]; diff --git a/mini-asterisk-gui2/minicommon.js b/mini-asterisk-gui2/minicommon.js index 3b2cb45b..edf51422 100644 --- a/mini-asterisk-gui2/minicommon.js +++ b/mini-asterisk-gui2/minicommon.js @@ -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 = ''; + else + icon = ''; + + document.getElementById('internet').innerHTML = icon; +} + + /** * Returns an XMLHttp instance to use for asynchronous * downloading. This method will never throw an exception, but will diff --git a/mini-asterisk-gui2/network.html b/mini-asterisk-gui2/network.html index 82f91ba0..d5a8bf27 100644 --- a/mini-asterisk-gui2/network.html +++ b/mini-asterisk-gui2/network.html @@ -27,15 +27,15 @@ - - + + - + diff --git a/mini-asterisk-gui2/network.js b/mini-asterisk-gui2/network.js index 4310f994..653a47ab 100644 --- a/mini-asterisk-gui2/network.js +++ b/mini-asterisk-gui2/network.js @@ -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; + } } diff --git a/mini-asterisk-gui2/phones.js b/mini-asterisk-gui2/phones.js index 17656707..7c7b2154 100644 --- a/mini-asterisk-gui2/phones.js +++ b/mini-asterisk-gui2/phones.js @@ -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 = ''; - else - icon = ''; - - document.getElementById('internet').innerHTML = icon; -} - // called when ifconfig CGI returns function processIfconfig(doc, status) {

Network

StaticDHCPStaticDHCP
IP Address:
Netmask:
Gateway:
DNS:
Emergency IP:Emergency IP:
Internet Connection: