Error with update reception button. Changed dynamic to static html
authorhorse69 <horse69@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 4 Sep 2012 22:27:52 +0000 (22:27 +0000)
committerhorse69 <horse69@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 4 Sep 2012 22:27:52 +0000 (22:27 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@661 01035d8c-6547-0410-b346-abe4f91aad63

mini-asterisk-gui2/cgi-bin/setring.cgi
mini-asterisk-gui2/minicommon.js
mini-asterisk-gui2/phones.html
mini-asterisk-gui2/phones.js

index 6b7d43f0733d1a2032bdb858c6472eb42adf3e70..aa22a796b207d7a4e1683d1f85b5f9fcf920cbd2 100755 (executable)
@@ -23,7 +23,7 @@ EOF
 
 echo "Input $QUERY_STRING"
 
-a=`echo "$QUERY_STRING" | sed -n 's,_,/,pg'`
+a=`echo "$QUERY_STRING" | sed -n "s/=on*//pg" | sed -n 's,_,/,pg'`
 
 # escape & if present
 echo "$a" | grep "&" >> /dev/null
@@ -32,8 +32,8 @@ if [ $? -eq 0 ]; then
 fi
 
 echo "Mods $a"
-#sed -i "s_s,1,Dial(.*) ;; mini-asterisk_s,1,Dial($a) ;; mini-asterisk_" /etc/asterisk/extensions.conf
 sed -i "s_s,1,Dial(.*) ;; mini-asterisk_s,1,Dial($a) ;; mini-asterisk_" /etc/asterisk/extensions.conf
+#sed -i "s_s,1,Dial(.*) ;; mini-asterisk_s,1,Dial($a) ;; mini-asterisk_" /etc/asterisk/extensions.conf
 
 #reload extensions.conf
 
index 935f820a4d5d0d74c1b3fa31069bd71651c66ea4..fef0d5daa14f1fcf411aa6fbaa8d56c8f25d8198 100644 (file)
@@ -233,6 +233,15 @@ function OnRestartReturn(doc,status) {
       initialisePage();
 }
 
+function GenericReturn(doc,status) {
+    loadHtmlTextFile(doc, function(line) {
+           //parseSipShowPeers(line);
+       }
+       );
+
+      initialisePage();
+}
+
 function OnUpgradeReturn(doc,status) {
     loadHtmlTextFile(doc, function(line) {
            //parseSipShowPeers(line);
@@ -362,4 +371,43 @@ function downloadUrl(url, callback) {
 
 }
 
+/**
+ * This functions wraps XMLHttpRequest open/send function.
+ * It lets you specify a URL and will call the callback if
+ * it gets a status code of 200.
+ * @param {String} url The URL to retrieve
+ * @param {Function} callback The function to call once retrieved.
+ */
+function downloadUrl2(url, callback) {
+    var status = -1;
+    var request = createXmlHttpRequest();
+    if (!request) {
+       return false;
+    }
+
+/*    request.onreadystatechange = function() {
+       if (request.readyState == 4) {
+           try {
+               status = request.status;
+           } catch (e) {
+               // Usually indicates request timed out in FF.
+           }
+           if (status == 200) {
+               callback(request.responseText, request.status);
+               request.onreadystatechange = function() {};
+           }
+       }
+    }
+ */
+
+   request.open('GET', url, true);
+    try {
+       request.send(null);
+    } catch (e) {
+       changeStatus(e);
+    }
+
+}
+
+
 
index a299aa01518bb9fbb90c12e689a972a95797387d..03347709abc7adc938ef2823c60bca073d7ca4e4 100644 (file)
@@ -22,8 +22,8 @@
   <tr>
     <td><div id="menu"></div></td>
     <td><div id="phones_table"></div></td>
+    <td><input type="button" style="width:100%" value="update reception" onClick="onClickUpdateReception()"></td>
   </tr>
-
   </table>
 </body>
 </html>
index c8404becaa47fb95e2708a148022696d504fc86c..cad21f9a1f1c1b2dd49d84768b523eeb7356f06c 100644 (file)
@@ -66,7 +66,7 @@ function initialisePage() {
 
             html += "</td>";
        
-           html += "<td>(Reception)</td>";
+//         html += "<td>(Reception)</td>";
             html += "<td>" + '<img src="tick.png" />' + "</td>";
             html += "</tr>";
        }
@@ -110,15 +110,16 @@ function initialisePage() {
     }
 
     // print out submit button
-
+       //doesn't work ... Only use static html buttons
 
     html += "<tr>";
     html += "<td>";
     html += "<a href=ipphones.html    /a>Add IP Phone";
     html += "</td>";
-    html += "<td>";
-    html += "<input type='submit' value='Update Reception' onClick='onClickApply(event)'/>";
+/*    html += "<td>";
+    html += "<input type='submit' value='Update Reception' onClick='onUpdateReception()'/>";
     html += "</td>";
+*/
     html += "</tr>";
 
 
@@ -158,6 +159,10 @@ function initialisePage() {
 
     downloadUrl("/cgi-bin/ifconfig.cgi?arg=eth0", processIfconfig);
 //    downloadUrl("/cgi-bin/ifconfig.cgi?arg=eth1", processIfconfig);
+
+       // downloadUrl works fine here.
+//    downloadUrl("/cgi-bin/setring.cgi?Zap_3=on", null);
+
 }
 
 
@@ -176,11 +181,11 @@ function processIfconfig(doc, status) {
     document.getElementById('ipaddress').innerHTML = ip;
 }
 
-function onClickApply(e) {
+function onClickUpdateReception() {
 
        // get the arguments from the form  selected[]
        ///document.myform.elements['fav[]'].checked
-       var arg ='';
+       var arg ="";
 
 
        //      number of check boxes in the form
@@ -199,11 +204,25 @@ function onClickApply(e) {
                                arg = arg+"&";
 
                        // got to make up new codes
-                       arg = arg + recept_code[i];
+                       arg = arg + recept_code[i] + "=on";
                }
 
        }
+        var arg2 =  "/cgi-bin/setring.cgi?" + arg;
+       downloadUrl(arg2,null);
+
 
-       downloadUrl("/cgi-bin/setring.cgi?"+arg,null);
+/*     
 
+       // ok looks like static buttons work but my dynamic button line 112 doesnt.
+
+    var ret = downloadUrl("/cgi-bin/setring.cgi?Zap_3=on", GenericReturn);
+    if (ret == false) {
+       throw new Error("XMLHttpRequest not supported");
+       }
+*/
 }
+
+
+
+