Added nice tick icons. eth0 -> eth1
authorhorse69 <horse69@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 20 Mar 2012 08:08:36 +0000 (08:08 +0000)
committerhorse69 <horse69@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 20 Mar 2012 08:08:36 +0000 (08:08 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@348 01035d8c-6547-0410-b346-abe4f91aad63

mini-asterisk-gui2/cgi-bin/getnetwork.cgi [new file with mode: 0644]
mini-asterisk-gui2/minicommon.js
mini-asterisk-gui2/phones.js

diff --git a/mini-asterisk-gui2/cgi-bin/getnetwork.cgi b/mini-asterisk-gui2/cgi-bin/getnetwork.cgi
new file mode 100644 (file)
index 0000000..ceb0631
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+# getnetwork.cgi
+# Ian Roberts 19 March 2012
+#
+# CGI to return network connection 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
+
+internet=`fping google.com`;
+#packet_loss=`fping google.com -c 1 -q | sed -n 's/.*received, \(.*\)%.*/\1/p'`
+#if [ $packet_loss = "0" ]; then
+#    internet="yes";
+#fi
+
+echo INTERNET=\"$internet\"
+#echo PACKETLOSS=\"$packet_loss\"
+
+cat <<EOF
+</body>
+</html>
+EOF
index edf51422161daf9bdbe45016df99078c8ceb5ddc..81c92a20ecd67432e204513badd282139a594c81 100644 (file)
@@ -18,6 +18,8 @@ var zap = [];
 
 var ip_ext = [];
 
+var network = "no";
+
 function loadExtensions() {
 
     /* 
@@ -153,6 +155,26 @@ function loadIpExtensions(doc,status) {
        }
        );
 
+    // we get Network connection details
+
+    downloadUrl("/cgi-bin/getnetwork.cgi?cli=", loadNetwork);
+   // initialisePage();
+}
+
+// creates a network connection
+
+function loadNetwork(doc,status) {
+    loadHtmlTextFile(doc, function(line) {
+           //parseSipShowPeers(line);
+           if (line.indexOf("alive") != -1)  {
+               network = "yes";
+               }
+       }
+       );
+
+    // 
+
+    //downloadUrl("/cgi-bin/getnetwork.cgi?cli=", loadNetwork);
     initialisePage();
 }
 
index 7c7b2154e984928dd53dc502442ec47266c30913..3284d8b6bcfa5bc49dc5896345e213f9763286c1 100644 (file)
@@ -40,8 +40,13 @@ function initialisePage() {
     html += '<tr><td colspan="4" align="left" valign="top"><h2>Phones</h2></td></tr>';
     for(var i=0; i<zap.length; i++) {
         if (zap[i] == 'FXS') {
-           html += "<tr><td>" + analog_ext[i] + "</td>" + "<td>" + "Analog Phone" + "</td>";
-           html += "<td>Port" + i + "</td></tr>";
+            html += "<tr>";
+           html += "<td>" + analog_ext[i] + "</td>" + "<td>" + "Analog Phone" + "</td>";
+//         html += "<td>Port" + i  + "<td>" +"   <img src=" + "tick.png" + " />"+"</td>" + "</td></tr>";
+//         html += "<td>Port" + i  + "<td>" + '<img src="tick.png" />' + "</td>" + "</td></tr>";
+           html += "<td>Port" + i  + "</td>";
+            html += "<td>" + '<img src="tick.png" />' + "</td>";
+            html += "</tr>";
        }
     }
 
@@ -49,8 +54,11 @@ function initialisePage() {
 
     for (j in ip_ext) {
         if (ip_ext[j] != '') {
-           html += "<tr><td>" + j + "</td>" + "<td>" + "IP Phone" + "</td>";
-           html += "<td>" + ip_ext[j] + "</td></tr>";
+            html += "<tr>";
+           html += "<td>" + j + "</td>" + "<td>" + "IP Phone" + "</td>";
+           html += "<td>" + ip_ext[j] + "</td>";
+            html += "<td>" + '<img src="tick.png" />' + "</td>";
+            html += "</tr>";
        }
     }
 
@@ -59,8 +67,11 @@ function initialisePage() {
     html += '<tr><td colspan="4" align="left" valign="top"><h2>Phone Lines</h2></td></tr>';
     for(var i=0; i<zap.length; i++) {
         if (zap[i] == 'FXO') {
-           html += "<tr><td>" + "0" + "</td>" + "<td>" + "Analog Phone" + "</td>";
-           html += "<td>Port" + i + "</td></tr>";
+            html += "<tr>";
+           html += "<td>" + "0" + "</td>" + "<td>" + "Analog Phone" + "</td>";
+           html += "<td>Port" + i + "</td>";
+            html += "<td>" + '<img src="tick.png" />' + "</td>";
+            html += "</tr>";
        }
     }
 
@@ -74,7 +85,8 @@ function initialisePage() {
 
     // fire off Ifconfig IP address to get IP Address
 
-    downloadUrl("/cgi-bin/ifconfig.cgi?arg=eth0", processIfconfig);
+//    downloadUrl("/cgi-bin/ifconfig.cgi?arg=eth0", processIfconfig);
+    downloadUrl("/cgi-bin/ifconfig.cgi?arg=eth1", processIfconfig);
 }