git-svn-id: https://svn.code.sf.net/p/freetel/code@655 01035d8c-6547-0410-b346-abe4f9...
authorhorse69 <horse69@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 2 Sep 2012 21:37:50 +0000 (21:37 +0000)
committerhorse69 <horse69@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 2 Sep 2012 21:37:50 +0000 (21:37 +0000)
mini-asterisk-gui2/minicommon.js
mini-asterisk-gui2/phones.js

index e3fb4366c6287944cb29cdcecceff7492d817a60..4c89e9a211ffd103f7440923e432abb42e1b6b70 100644 (file)
@@ -20,14 +20,23 @@ var ip_ext = [];
 
 var network = "no";
 
-// incomming calls are routed to these extensions ie (6003, ZAP/3)
-var number='';
-var code='';
+// incomming calls are routed to these extensions ie (6003, Zap/3)
+// this should be made dynamically from the reception line in extensions.conf
 
+//testing
+//var reception = [["6003","Zap/3"],["6004","Zap/4"],["6011","SIP/6011"],["6012","SIP/6012"]] ;
 
-var reception[]  =  {number, code};
+//max 4 receptions
+var reception = [["",""],["",""],["",""],["",""]] ;
 
+var recept_num = [];
+var ext_code =[];
+var recept_code =[];
+var recept_count = 0;
+var ext_count = 0;
+var iancount = 0;
 
+var items = [[1,2],[3,4],[5,6]];
 
 // these are the selections for the new reception numbers
 
@@ -133,11 +142,18 @@ function loadExtensionsConf(doc,status) {
                    if (zap[tech2] == undefined)
                        analog_ext[tech2] = "";
                    else
-                       analog_ext[tech2] = ext;                
+                       analog_ext[tech2] = ext; 
                }
                if (tech1 == "SIP") {
                    ip_ext[ext] = "";
                }
+
+               // save the codes for each extension
+               // need these for constructing the reception string
+               // using underscore instead of forward slash to avoid http managle 
+
+               ext_code[ext_count++] = tech1 +"_"+ tech2;
+               
            }
 
            // Save the reception numbers if they exist
@@ -145,24 +161,27 @@ function loadExtensionsConf(doc,status) {
            //  exten => s,1,Dial(Zap/4&SIP/6011) ;; mini-asterisk - don't remove this comment
 
            if(line.indexOf("exten => s,1,Dial") != -1) {
+
                i=0;
 
                // for each Zap/ read in a single digit and convert to extension
                while((ret = line.indexOf("Zap/"))!=-1) {
-                    reception[i].code = line.substr(ret,5);
-                    reception[i].number = analog_ext[line.substr(ret+4,1)];
+//                    recept_code[i] = line.substr(ret,5);
+                    recept_num[i] = analog_ext[line.substr(ret+4,1)];
                     line = line.substr(ret+6,line.length);
                    i++;
                }
 
                // for each SIP/ read in four digits
                while ((ret = line.indexOf("SIP/")) != -1) {
-                    reception[i].code = line.substr(ret,8);
-                    reception[i].number = line.substr(ret+4,4);
+//                    recept_code[i] = line.substr(ret,8);
+                    recept_num[i] = line.substr(ret+4,4);
                     line = line.substr(ret+9,line.length);
                    i++;
                }
 
+               recept_count = i;
+
            }
        }
     );
index 6a8b094f047b0b8528d8e296446a676e3078b66c..390a28a3647d6205967d4e92774b09091c0f1a1c 100644 (file)
@@ -54,12 +54,16 @@ function initialisePage() {
            html += "<td>" + '<input name="selected[]" type="checkbox" ' ;     
                // Underscore used instead of forward slash to pass thru html request
 
-            if (reception.indexOf(analog_ext[i]) != -1) {
+            if (recept_num.indexOf(analog_ext[i]) != -1) {
                    html += '" checked/>';
                }
            else {
                    html += '" unchecked/>';
            }
+
+           // save the reception code
+           recept_code[iancount++]=ext_code[i-1];
+
             html += "</td>";
        
            html += "<td>(Reception)</td>";
@@ -83,12 +87,16 @@ function initialisePage() {
                // Underscore used instead of forward slash to pass thru html request
  
 
-            if (reception.indexOf(ip_ext[j])!=-1) {
+            if (recept_num.indexOf(ip_ext[j])!=-1) {
                    html += '" checked/>';
                }
            else {
                    html += '" unchecked/>';
            }
+
+           // save the reception code
+           recept_code[iancount++]=ext_code[(i-1)+(j-1)];
+
             html += "</td>";
        
            html += "<td>(Reception)</td>";
@@ -168,15 +176,31 @@ function processIfconfig(doc, status) {
 function onClickApply(e) {
 
        // get the arguments from the form  selected[]
-///document.myform.elements['fav[]'].checked
-var arg ='';
-var total = document.getElementByName('selected[]');
+       ///document.myform.elements['fav[]'].checked
+       var arg ='';
+
+
+       //      number of check boxes in the form
+       var total = document.phones.elements['selected[]'].length;
+
+       var recept_box = document.phones.elements['selected[]'];
+
+       j=0;
        for (i=0;i<total; i++) {
-// in document.phones.elements['selected[]'] {
-               if (selected[x]<6010)
-               arg = arg + 'ZAP_'+i;
-        // construct new arg from selected
-       //downloadUrl("/cgi-bin/setring.cgi?"+arg1,null);
+
+               // construct new arg from selected
+               if(recept_box[i].checked) {
+                       
+                       j++;
+                       if (j>1)
+                               arg = arg+"&";
+
+                       // got to make up new codes
+                       arg = arg + recept_code[i];
+               }
+
        }
 
+       //downloadUrl("/cgi-bin/setring.cgi?"+arg,null);
+
 }