The remove priority (-) buttons now work. More formatting fixes.
authorBen Klang <ben@alkaloid.net>
Mon, 14 Nov 2005 04:14:57 +0000 (04:14 +0000)
committerBen Klang <ben@alkaloid.net>
Mon, 14 Nov 2005 04:14:57 +0000 (04:14 +0000)
New bug found: Opera and IE complain that the document.getElementById(foo)
are returning null.  My suspcicion is that it can't perform the getElementById
on elements rendered in js and stuffed into innerHTML.  Just a hunch....  Works
fine in Konq an FF.

At least one old bug:  Can't edit activated priority text boxes.  Daniel reports
slightly different results.  Needs more inspection.

git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@95 06cd67b6-e706-0410-b29e-9de616bca6e9

andrew.webprj
templates/javascript/dialplan.js

index 7a30043..49f0b99 100644 (file)
@@ -1,6 +1,6 @@
 <!DOCTYPE webproject>
 <webproject>
-  <project usePreviewPrefix="0" previewPrefix="" type="Local" usePersistentBookmarks="0" name="Shout" encoding="iso 8859-1" enableEvents="true" >
+  <project usePreviewPrefix="0" type="Local" previewPrefix="" usePersistentBookmarks="0" name="Shout" encoding="iso 8859-1" enableEvents="true" >
     <upload/>
     <defaultDTD>-//w3c//dtd xhtml 1.0 strict//en</defaultDTD>
     <item url="config/" uploadstatus="1" />
@@ -13,7 +13,7 @@
     <item modified_time="1131497449" url="lib/base.php" uploadstatus="1" />
     <item modified_time="1131851216" url="lib/Dialplan.php" uploadstatus="1" />
     <item modified_time="1130769960" url="lib/Driver.php" uploadstatus="1" />
-    <item modified_time="1131826057" url="lib/Shout.php" uploadstatus="1" />
+    <item modified_time="1131864412" url="lib/Shout.php" uploadstatus="1" />
     <item modified_time="1121689003" url="lib/System.php" uploadstatus="1" />
     <item modified_time="1130769961" url="lib/User.php" uploadstatus="1" />
     <item url="main/" uploadstatus="1" />
@@ -64,7 +64,7 @@
         <uploadeditem upload_time="1130769960" url="lib/Driver.php" />
         <uploadeditem upload_time="0" url="lib/Driver/" />
         <uploadeditem upload_time="1131765770" url="lib/Driver/ldap.php" />
-        <uploadeditem upload_time="1131826057" url="lib/Shout.php" />
+        <uploadeditem upload_time="1131864412" url="lib/Shout.php" />
         <uploadeditem upload_time="1121689003" url="lib/System.php" />
         <uploadeditem upload_time="1130769961" url="lib/User.php" />
         <uploadeditem upload_time="1131600576" url="lib/api.php" />
@@ -90,7 +90,7 @@
         <uploadeditem upload_time="1121689030" url="templates/dialplan/priority-form-end.inc" />
         <uploadeditem upload_time="1121689030" url="templates/dialplan/priority-form-line.inc" />
         <uploadeditem upload_time="0" url="templates/javascript/" />
-        <uploadeditem upload_time="1131864070" url="templates/javascript/dialplan.js" />
+        <uploadeditem upload_time="1131941381" url="templates/javascript/dialplan.js" />
         <uploadeditem upload_time="1131772201" url="templates/menu.inc" />
         <uploadeditem upload_time="1121578596" url="templates/table-limiter-begin.inc" />
         <uploadeditem upload_time="1121578596" url="templates/table-limiter-end.inc" />
     <item modified_time="1131045729" url="lib/defines.php" uploadstatus="1" />
     <item modified_time="1131497712" url="security.php" uploadstatus="1" />
     <item url="templates/javascript/" uploadstatus="1" />
-    <item modified_time="1131864070" url="templates/javascript/dialplan.js" uploadstatus="1" />
+    <item modified_time="1131941381" url="templates/javascript/dialplan.js" uploadstatus="1" />
     <item modified_time="1131784175" url="templates/dialplan/manager.inc" uploadstatus="1" />
     <treestatus>
       <openfolder url="lib" />
index 211c102..6b10ca9 100644 (file)
@@ -59,12 +59,13 @@ Dialplan.prototype.activatePriority = function(exten, prio)
 
     } else {
         var form = '';
-        //form += '<form id="renumber">';
         form += '    <span class="priorityBox">';
-        form += '        <input type="text" size="3" maxlength="3" name="newprio" value="'+this.curPrio+'" />';
+        form += '        <input id="p" type="text" size="3" maxlength="3" name="newprio"';
+        form +=              ' value="'+this.curPrio+'" />';
         form += '    </span>';
-        //form += '</form>';
         document.getElementById('pBox-'+this.curExten+'-'+this.curPrio).innerHTML = form;
+        document.getElementById('pBox-'+this.curExten+'-'+this.curPrio).p.focus;
+        document.getElementById('pBox-'+this.curExten+'-'+this.curPrio).p.select;
     }
 }
 
@@ -74,6 +75,7 @@ Dialplan.prototype.deactivatePriority = function()
         document.getElementById('priority-'+this.curExten+'-'+this.curPrio).className = 'priority';
         document.getElementById('pButtons-'+this.curExten+'-'+this.curPrio).style['visibility'] = 'hidden';
     }
+    this.curPrio = 0;
 }
 
 Dialplan.prototype.drawPrioTable = function (exten)
@@ -98,7 +100,9 @@ Dialplan.prototype.drawPrioTable = function (exten)
         table += '        <span class="pElement" id="pApp-'+exten+'-'+p+'"\n';
         table += '            name="pApp-'+exten+'-'+p+'">\n';
         table += '            <span class="applicationBox"></span>\n';
-        table += '                <select name="app['+exten+']['+p+']">\n';
+        table += '                <select name="app['+exten+']['+p+']"';
+        table +=                    'onclick="javascript:'+this.object+'.activatePriority(\''+exten+'\', ';
+        table +=                    '\''+p+'\')">\n';
         table += this.genAppList(this.dp[exten]['priorities'][p]['application']);
         table += '                </select>\n';
         table += '            </span>\n';
@@ -147,7 +151,6 @@ Dialplan.prototype.addPrio = function(exten, prio)
 
         for (p in this.dp[exten]['priorities']) {
             p = Number(p);
-            prio = Number(prio);
             // Make a notch for the new priority by incrementing all priorities greater
             // than the requested one.  Try to exclude error handling priorities
             // which are unrelated to the changed extension.  See README for
@@ -156,20 +159,19 @@ Dialplan.prototype.addPrio = function(exten, prio)
             // error handling priorities.
             if (p > prio && (p < prio + 90 || p > prio + 100)) {
                 tmp[p + 1] = this.dp[exten]['priorities'][p];
-                plist[i] = p + 1;
+                plist[i++] = p + 1;
             } else {
                 tmp[p] = this.dp[exten]['priorities'][p];
-                plist[i] = p;
+                plist[i++] = p;
             }
-            i++;
         }
 
         // Seed the new priority
-        var newP = Number(prio) + 1;
-        tmp[newP] = new Array();
-        tmp[newP]['application'] = '';
-        tmp[newP]['args'] = '';
-        plist[i] = newP;
+        p = prio + 1;
+        tmp[p] = new Array();
+        tmp[p]['application'] = '';
+        tmp[p]['args'] = '';
+        plist[i] = p;
 
 
         // Empty the original array
@@ -178,19 +180,27 @@ Dialplan.prototype.addPrio = function(exten, prio)
         // Sort the priorities and put them back into the original array
         plist.sort(this._numCompare);
         for (i = 0; i < plist.length; i++) {
-
             p = Number(plist[i]);
             this.dp[exten]['priorities'][p] = tmp[p];
         }
     }
+
     this.curPrio = 0;
     this.drawPrioTable(exten);
+    this.activatePriority(exten, prio);
+    return true;
 }
 
 Dialplan.prototype.delPrio = function(exten, prio)
 {
     prio = Number(prio);
     if (this.dp[exten]['priorities'][prio] != 'undefined') {
+        // The .length method on this array always reports number of priorities + 1;
+        // Haven't yet solved this mystery but the below test does work correctly.
+        if (this.dp[exten]['priorities'].length <= 2) {
+            alert('Extensions must have at least one priority');
+            return false;
+        }
         // Due to javascript's inability to remove an array element while maintaining
         // associations, we copy the elements into a tmp array and ultimately replace
         // the object's copy.  We will also have to sort the resulting array manually
@@ -208,10 +218,10 @@ Dialplan.prototype.delPrio = function(exten, prio)
             // TODO: Make a decision about whether this is the best way to handle
             // error handling priorities.
             p = Number(p);
-            if (p != prio) {
-                if (p > prio && (p < prio + 90 || p > prio + 100)) {
-                    p = Number(p) - 1;
-                }
+            if (p > prio && (p < prio + 90 || p > prio + 100)) {
+                tmp[p - 1] = this.dp[exten]['priorities'][p];
+                plist[i++] = p - 1;
+            } else if (p != prio) {
                 tmp[p] = this.dp[exten]['priorities'][p];
                 plist[i++] = p;
             }
@@ -227,8 +237,10 @@ Dialplan.prototype.delPrio = function(exten, prio)
             this.dp[exten]['priorities'][p] = tmp[p];
         }
     }
+
     this.curPrio = 0;
     this.drawPrioTable(exten);
+    return true;
 }
 
 Dialplan.prototype._numCompare = function(a, b)