From: Ben Klang Date: Mon, 28 Nov 2005 04:30:59 +0000 (+0000) Subject: Most of the dialplan UI now works! Lots of visual tweaks still need to happen X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b691dfae8aa52eddbdd676a0ce8db665bfc9859e;p=horde.git Most of the dialplan UI now works! Lots of visual tweaks still need to happen to really make it look sharp, but most of the envisioned functionality is in place. The ability to save changes it not yet present. One known bug at this point: Renumbering a priority to an existing priority seems to work. However renumbering a priority to an empty slot results in an empty target (the source prio is not saved). Not sure why yet... git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@97 06cd67b6-e706-0410-b29e-9de616bca6e9 --- diff --git a/andrew.webprj b/andrew.webprj index 43c40b8a1..3e4f4a22f 100644 --- a/andrew.webprj +++ b/andrew.webprj @@ -11,7 +11,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -52,7 +52,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -100,7 +100,7 @@ - + @@ -112,6 +112,11 @@ templates/ toolbars/ + + + + + Ben Klang ben@alkaloid.net No Debugger @@ -122,11 +127,6 @@ - - - - - diff --git a/lib/Dialplan.php b/lib/Dialplan.php index 26cce25b1..1447f5a86 100644 --- a/lib/Dialplan.php +++ b/lib/Dialplan.php @@ -195,7 +195,7 @@ class Shout_Dialplan print '//-->'."\n"; print ''."\n"; - print '
'."\n"; + print ''."\n"; print '
'."\n"; $e = 0; foreach($this->_dialplan['extensions'] as $extension => $priorities) { diff --git a/templates/javascript/dialplan.js b/templates/javascript/dialplan.js index c41f3c57c..0b9d2cbf7 100644 --- a/templates/javascript/dialplan.js +++ b/templates/javascript/dialplan.js @@ -21,22 +21,16 @@ function Dialplan(instanceName) this.dp = eval('shout_dialplan_entry_'+instanceName); this.applist = eval('shout_dialplan_applist_'+instanceName); this.object = 'shout_dialplan_object_'+instanceName; - this.curExten = ''; - this.curPrio = ''; - this.dom = new Array(); // Store rendered elements for IE - for (var e in this.dp) { - this.dom[e] = new Array(); - } + this.curExten = 0; + this.curPrio = 0; + this.prioActive = false; } Dialplan.prototype.highlightExten = function(exten) { - this.drawPrioTable(exten); if (this.curExten && this.curExten != exten) { - this.deactivatePriority(); - - document.getElementById('eBox-' + this.curExten).className = 'extensionBox'; - document.getElementById('pList-' + this.curExten).className = 'pList'; + this.dehighlightPrio(); + this.dehighlightExten(); } this.curExten = exten; @@ -44,42 +38,101 @@ Dialplan.prototype.highlightExten = function(exten) document.getElementById('pList-' + exten).className = 'pListHighlight'; } +Dialplan.prototype.dehighlightExten = function(exten) +{ + document.getElementById('eBox-' + this.curExten).className = 'extensionBox'; + document.getElementById('pList-' + this.curExten).className = 'pList'; + this.curExten = 0; +} -Dialplan.prototype.activatePriority = function(exten, prio) +Dialplan.prototype.highlightPrio = function(exten, prio) { - prio = Number(prio); - this.curPrio = Number(this.curPrio); - if (prio != this.curPrio || exten != this.curExten) { - if (this.curExten) { - this.deactivatePriority(); - } - if (exten != this.curExten) { - this.highlightExten(exten); - } + if (exten != this.curExten) { + this.highlightExten(exten); + } + if (this.curPrio && prio != this.curPrio) { + this.dehighlightPrio(); + } - this.curPrio = prio; - this.dom[exten][prio]['priority'].className = 'priorityHighlight'; - this.dom[exten][prio]['pButtons'].style['visibility'] = 'visible'; + this.curPrio = prio; + priority = document.getElementById('priority-'+exten+'-'+prio); + priority.className = 'priorityHighlight'; + priority.onclick = priority.activate; + document.getElementById('pButtons-'+exten+'-'+prio).style['visibility'] = 'visible'; +} - } else { - var form = ''; - form += ' '; - form += ' '; - form += ' '; - this.dom[exten][prio]['pBox'].innerHTML = form; - this.dom[exten][prio]['pBox'].p.focus; - this.dom[exten][prio]['pBox'].p.select; +Dialplan.prototype.dehighlightPrio = function() +{ + this.deactivatePrio(); + if (!this.curPrio) { + return true; } + + priority = document.getElementById('priority-'+this.curExten+'-'+this.curPrio); + priority.className = 'priority'; + priority.onclick = priority.highlight; + document.getElementById('pButtons-'+this.curExten+'-'+this.curPrio).style['visibility'] = 'hidden'; + this.curPrio = 0; + return true; } -Dialplan.prototype.deactivatePriority = function() + +Dialplan.prototype.activatePrio = function(exten, prio) { - if (this.curPrio && document.getElementById('pButtons-'+this.curExten+'-'+this.curPrio)) { - this.dom[this.curExten][this.curPrio]['priority'].className = 'priority'; - this.dom[this.curExten][this.curPrio]['pButtons'].style['visibility'] = 'hidden'; + document.getElementById('pBox-'+exten+'-'+prio).style['display'] = 'none'; + document.getElementById('pBoxInput-'+exten+'-'+prio).style['display'] = 'inline'; + document.getElementById('pApp-'+exten+'-'+prio).style['display'] = 'none'; + document.getElementById('pAppInput-'+exten+'-'+prio).style['display'] = 'inline'; + document.getElementById('pArgs-'+exten+'-'+prio).style['display'] = 'none'; + document.getElementById('pArgsInput-'+exten+'-'+prio).style['display'] = 'inline'; + this.prioActive = true; +} + +Dialplan.prototype.deactivatePrio = function() +{ + if (!this.prioActive) { + // Speed hack: If thie priority isn't active, don't go through the + // motions to deactivate it. + return true; } - this.curPrio = 0; + var dirty = false; + var pAppInput = document.getElementById('pAppInput-'+this.curExten+'-'+this.curPrio); + var pArgsInput = document.getElementById('pArgsInput-'+this.curExten+'-'+this.curPrio); + + if (pAppInput.value != this.dp[this.curExten]['priorities'][this.curPrio]['application']) { + this.dp[this.curExten]['priorities'][this.curPrio]['application'] = pAppInput.value; + dirty = true; + } + + if (pArgsInput != this.dp[this.curExten]['priorities'][this.curPrio]['args']) { + this.dp[this.curExten]['priorities'][this.curPrio]['args'] = pArgsInput.value; + dirty = true; + } + + // Check to see if the priority number was updated + prio = Number(document.getElementById('pBoxInput-'+this.curExten+'-'+this.curPrio).value); + if (this.curPrio != prio) { + this.renumberPrio(prio); + this.curPrio = prio; + // Since we've just redrawn the prio table no sense in drawing it again + dirty = false; + } + + // This test is purely a speed hack. Redrawing the prio table is slower than simply resetting + // the status of the elements. However if data has changed we are forced to redraw the prio table. + if (dirty) { + this.drawPrioTable(this.curExten); + } else { + document.getElementById('pBox-'+this.curExten+'-'+this.curPrio).style['display'] = 'inline'; + document.getElementById('pBoxInput-'+this.curExten+'-'+this.curPrio).style['display'] = 'none'; + document.getElementById('pApp-'+this.curExten+'-'+this.curPrio).style['display'] = 'inline'; + document.getElementById('pAppInput-'+this.curExten+'-'+this.curPrio).style['display'] = 'none'; + document.getElementById('pArgs-'+this.curExten+'-'+this.curPrio).style['display'] = 'inline'; + document.getElementById('pArgsInput-'+this.curExten+'-'+this.curPrio).style['display'] = 'none'; + } + this.prioActive = false; + + return true; } Dialplan.prototype.drawPrioTable = function (exten) @@ -102,20 +155,24 @@ Dialplan.prototype.drawPrioTable = function (exten) var priority = document.createElement('div'); priority.className = 'priority'; priority.id = 'priority-' + exten + '-' + p; + // The next 5 lines are hijinks required to make the highlighting work properly. We + // have to save a reference to this object in the pElement object so we can call back + // into the activate/deactivate routines. We also have to save the prio and exten because + // the onclick assignment has to be a function reference which takes no arguments. + // See above and below comments disparaging javascript. + priority.dp = this; + priority.exten = exten; + priority.prio = p; + priority.highlight = function () { this.dp.highlightPrio(this.exten, this.prio); } + priority.activate = function () { this.dp.activatePrio(this.exten, this.prio); } + priority.onclick = priority.highlight; pList.appendChild(priority); - this.dom[exten][p] = new Array(); - this.dom[exten][p]['priority'] = priority; -// table += ' \n'; var pButtons = document.createElement('span'); pButtons.className = 'pButtons'; pButtons.id = 'pButtons-' + exten + '-' + p; priority.appendChild(pButtons); - this.dom[exten][p]['pButtons'] = pButtons; -// table += ' +\n'; var button = document.createElement('span'); button.className = 'add'; button.id = 'pButton-add-'+exten+'-'+p; @@ -126,10 +183,7 @@ Dialplan.prototype.drawPrioTable = function (exten) button.onclick = button.addPrio; button.innerHTML='+'; pButtons.appendChild(button); - this.dom[exten][p]['pButton-add'] = button; -// table += ' -\n'; var button = document.createElement('span'); button.className = 'remove'; button.id = 'pButton-del-'+exten+'-'+p; @@ -140,99 +194,85 @@ Dialplan.prototype.drawPrioTable = function (exten) button.onclick = button.delPrio; button.innerHTML='-'; pButtons.appendChild(button); - this.dom[exten][p]['pButton-del'] = button; - -// table += ' \n'; -// table += ' \n'; var pElement = document.createElement('span'); pElement.className = 'pElement'; - pElement.id = 'pBox-'+exten+'-'+p; - // The next 5 lines are hijinks required to make the highlighting work properly. We - // have to save a reference to this object in the pElement object so we can call back - // into the activate/deactivate routines. We also have to save the prio and exten because - // the onclick assignment has to be a function reference which takes no arguments. - // See above and below comments disparaging javascript. - pElement.dp = this; - pElement.exten = exten; - pElement.prio = p; - pElement.activate = function () { this.dp.activatePriority(this.exten, this.prio); } - pElement.onclick = pElement.activate; priority.appendChild(pElement); - this.dom[exten][p]['pBox'] = pElement; - -// table += ' '+p+'\n'; - var priorityBox = document.createElement('span'); - priorityBox.className = 'priorityBox'; - priorityBox.innerHTML = p; - pElement.appendChild(priorityBox); -// table += ' \n'; + var pBox = document.createElement('span'); + pBox.className = 'pBox'; + pBox.id = 'pBox-'+exten+'-'+p; + pBox.style['display'] = 'inline'; + pBox.innerHTML = p; + pElement.appendChild(pBox); + + var pBoxInput = document.createElement('input'); + pBoxInput.type = 'text'; + pBoxInput.size = 3; + pBoxInput.id = 'pBoxInput-'+exten+'-'+p; + pBoxInput.name = 'pBoxInput-'+exten+'-'+p; + pBoxInput.value = p; + pBoxInput.maxlength = 3; + pBoxInput.style['display'] = 'none'; + pBoxInput.dp = this; + pBoxInput.exten = exten; + pBoxInput.prio = p; + pBoxInput.onblur = pBoxInput.deactivate; + pBoxInput.deactivate = function () { this.dp.deactivatePriority(); } + pElement.appendChild(pBoxInput); -// table += ' \n'; var pElement = document.createElement('span'); pElement.className = 'pElement'; - pElement.id = 'pApp-' + exten + '-' + p; priority.appendChild(pElement); - this.dom[exten][p]['pApp'] = pElement; - -// table += ' \n'; - var applicationBox = document.createElement('span'); - applicationBox.className = 'applicationBox'; - applicationBox.id = 'applicationBox-' + exten + '-' + p; - pElement.appendChild(applicationBox); - this.dom[exten][p]['applicationBox'] = applicationBox; - - var selectHTML = ''; - selectHTML += ' \n'; - applicationBox.innerHTML = selectHTML; - -// table += ' \n'; -// table += ' \n'; - -// table += ' \n'; + + var pApp = document.createElement('span'); + pApp.className = 'pApp'; + pApp.id = 'pApp-' + exten + '-' + p; + pApp.style['display'] = 'inline'; + pElement.appendChild(pApp); + pApp.innerHTML = this.dp[exten]['priorities'][p]['application']; + + var pAppInput = document.createElement('select'); + pAppInput.className = 'pAppInput'; + pAppInput.id = 'pAppInput-' + exten + '-' + p; + pAppInput.name = 'pAppInput-' + exten + '-' + p; + pAppInput.style['display'] ='none'; + pElement.appendChild(pAppInput); + this.genAppList(pAppInput, this.dp[exten]['priorities'][p]['application']); + var pElement = document.createElement('span'); pElement.className = 'pElement'; - pElement.id = 'pArgs-' + exten + '-' + p; priority.appendChild(pElement); - this.dom[exten][p]['pArgs'] = pElement; - -// table += ' '; -// table += this.dp[exten]['priorities'][p]['args']+'\n'; - var argsBox = document.createElement('span'); - argsBox.className = 'argBox'; - argsBox.id = 'argsBox-' + exten + '-' + p; - argsBox.innerHTML = this.dp[exten]['priorities'][p]['args']; - pElement.appendChild(argsBox); - this.dom[exten][p]['argsBox'] = argsBox; - -// table += ' \n'; -// table += '
\n'; + + var pArgs = document.createElement('span'); + pArgs.className = 'pArgs'; + pArgs.id = 'pArgs-' + exten + '-' + p; + pArgs.innerHTML = this.dp[exten]['priorities'][p]['args']; + pElement.appendChild(pArgs); + + var pArgsInput = document.createElement('input'); + pArgsInput.className = 'pArgsInput'; + pArgsInput.id = 'pArgsInput-' + exten + '-' + p; + pArgsInput.name = 'pArgsInput-' + exten + '-' + p; + pArgsInput.value = this.dp[exten]['priorities'][p]['args']; + pArgsInput.style['display'] = 'none'; + pElement.appendChild(pArgsInput); } -// document.getElementById('pList-'+exten).innerHTML = table; + return true; } -Dialplan.prototype.genAppList = function (app) +Dialplan.prototype.genAppList = function (selectObj, app) { - var appstring = ''; for (var a in this.applist) { - appstring += '