pari: trunk r45 - in /trunk/config: menus.html numberplan.html scripts/astman.js

asterisk-gui-commits at lists.digium.internal asterisk-gui-commits at lists.digium.internal
Tue Oct 3 10:37:00 CDT 2006


Author: pari
Date: Tue Oct  3 10:37:00 2006
New Revision: 45

URL: http://svn.digium.com/view/asterisk-gui?rev=45&view=rev
Log:
function for combobox in astman.js , but onkeyup event is conflicting with an existing onkeyup event in widgets.

Modified:
    trunk/config/menus.html
    trunk/config/numberplan.html
    trunk/config/scripts/astman.js

Modified: trunk/config/menus.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/menus.html?rev=45&r1=44&r2=45&view=diff
==============================================================================
--- trunk/config/menus.html (original)
+++ trunk/config/menus.html Tue Oct  3 10:37:00 2006
@@ -419,16 +419,10 @@
 
 
 function swap_step(a,b){
-	// get prioirty of a
-	// get priority of b
 	var tmp1 = $('steps').options[a].value.split(",") ;
 	var priority_1 = tmp1[1];
-
 	var tmp2 = $('steps').options[b].value.split(",") ;
 	var priority_2 = tmp2[1];
-
-	//alert("Change priority of " + $('steps').options[a].value +" to that of "+ priority_2);
-	//alert("Change priority of "+ $('steps').options[b].value +" to that of "+ priority_1);
 
 	tmp1.splice(1,1,priority_2);
 	tmp2.splice(1,1,priority_1);
@@ -454,7 +448,6 @@
 					$('status').innerHTML = "<i>Step Priority Updated!</i>";
 					update_updown();
 
-					// some thing is not ok here .. check
 			},
 			onFailure: function(t) {
 				alert("Config Error: " + t.status + ": " + t.statusText);
@@ -472,8 +465,7 @@
 
 
 function delete_step(){
-	// delete the selected step and update voicemenusdata
-	// and update 'select' object - steps
+	// delete the selected step and update voicemenusdata and update 'select' object - steps
 	var opt = {
 			method: 'get',
 			asynchronous: true,

Modified: trunk/config/numberplan.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/numberplan.html?rev=45&r1=44&r2=45&view=diff
==============================================================================
--- trunk/config/numberplan.html (original)
+++ trunk/config/numberplan.html Tue Oct  3 10:37:00 2006
@@ -236,22 +236,18 @@
 	// called "onpage load" and when the  'Customize Plans' checkbox  is  flipped
 		var tmp;
 		var x;
-		
 		for (x=0;x<$('extensions').options.length;x++) {
 				tmp = $('extensions').options[x].value.split(']');
 				if (tmp.length < 2) { $('extensions').options[x].style.color = '#0000CC'; }
 				$('extensions').options[x].disabled = false;
 		}
-
 		$('new').disabled = !$('modplan').checked;
 		$('planident').disabled = !$('modplan').checked;
 		$('comment').disabled = !$('modplan').checked;
 		$('include').disabled = !$('modplan').checked;
-
 		// If the submenu is the one that is currently highlighted then donot disable the delete button
 		tmp_as =  $('extensions').value.split(']');
 		if(tmp_as.length > 1){ }else{ $('delete').disabled = !$('modplan').checked; }
-
 	}
 
 
@@ -359,8 +355,6 @@
 		}
 		
 		parent.astmanEngine.config2list("users.conf", $('trunk'), new Array(), usercallbacks);
-		document.getElementById('combobox_div').style.display = "none";
-
 	}
 
 		function priority_up(){
@@ -456,45 +450,6 @@
 				select_item($('extensions'));
 
 		}
-
-
-		// Combox_box related
-		function combo_action(){
-			$('name').value = $('combosel').value;
-			document.getElementById('combobox_div').style.display = "none";
-			$('save').disabled= false;
-			$('cancel').disabled= false;
-		}
-
-		function combo_activate(){
-				tmp_left = $('name').offsetLeft;
-				tmp_top = $('name').offsetTop + $('name').offsetHeight;
-				tmp_parent = $('name');
-
-				while(tmp_parent.offsetParent != document.body){
-						tmp_parent = tmp_parent.offsetParent;
-						tmp_left += tmp_parent.offsetLeft;
-						tmp_top += tmp_parent.offsetTop;
-				}
-
-				$('combobox_div').style.left = tmp_left;
-				$('combobox_div').style.top = tmp_top ;
-				$('combobox_div').style.width = $('name').offsetWidth;
-
-				document.getElementById('combobox_div').style.display = "";
-		}
-
-		function combo_keypress(event){
-			if( event.keyCode == 13 || event.keyCode == 27 || event.keyCode == 9){
-					document.getElementById('combobox_div').style.display = "none";
-					return false;
-			}else{
-					document.getElementById('combobox_div').style.display = "";
-					return true;
-			}
-
-		}
-		// End of - Combox_box related
 
 </script>
 <body id="foo" onload="localajaxinit()">
@@ -534,9 +489,9 @@
 						<tr><td><b>.</b></td><td>Any number of additional digits</td></tr>
 					</table>
 				</td></tr>
-				<tr><td>Pattern:</td><td><input size='18' id='name' onfocus="combo_activate();" onkeychange="combo_activate();" onfocusout="document.getElementById('combobox_div').style.display ='none';" onkeypress="combo_keypress(event);">
-						<div id="combobox_div" style="position: absolute; top:0px; left:0px; z-index:10000 ">
-						  <select size=5 id="combosel" onclick="combo_action();" style="font-family: Verdana, Arial, Helvetica, Sans-Serif;font-size: 11px; ">
+				<tr><td>Pattern:</td><td><input size='18' id='name'>
+						<div id="combobox_div">
+						  <select size=5 id="combosel" style="font-family: Verdana, Arial, Helvetica, Sans-Serif;font-size: 11px; ">
 							<option value="_9NXXXXXX">_9NXXXXXX (Seven Digit Dial)</option>
 							<option value="_9NXXNXXXXXX">_9NXXNXXXXXX (Ten Digit Dial)</option>
 							<option value='_91NXXNXXXXXX'>_91NXXNXXXXXX (1+ Dial)</option>
@@ -544,6 +499,11 @@
 							<option value='_9911.'>_9911. (Emergency)</option>
 						  </select>
 						  </div>
+						<SCRIPT LANGUAGE="JavaScript">
+						<!--
+						combo_box('name', "combobox_div","combosel");
+						//-->
+						</SCRIPT>
 				</td></tr>
 				<tr><td>Trunk:</td><td><select id='trunk'></select></td></tr>
 				<tr><td>Priority:</td><td><input size='4' id='priority'></td></tr>

Modified: trunk/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/scripts/astman.js?rev=45&r1=44&r2=45&view=diff
==============================================================================
--- trunk/config/scripts/astman.js (original)
+++ trunk/config/scripts/astman.js Tue Oct  3 10:37:00 2006
@@ -18,6 +18,93 @@
  * at the top of the source tree.
  *
  */
+
+function combo_box(a, b, c ){	
+		var combo_text = document.getElementById(a);
+		var combo_selectdiv = document.getElementById(b);
+		var combo_selectbox = document.getElementById(c);
+		var TAB = 9;
+		var ENTER = 13;
+		var ESC = 27;
+		var KEYUP = 38;
+		var KEYDN = 40;
+		var BKSPACE = 8;
+		combo_selectdiv.style.position ="absolute";
+		combo_selectdiv.style.top = "0px";
+		combo_selectdiv.style.left = "0px";
+//		combo_selectdiv.style.z-index = 10000;
+		combo_selectdiv.style.display = "none";
+		combo_text.onkeychange = function(){
+			combobox_activate();
+		};
+		combo_text.onfocus = function(){
+			combobox_activate();
+		};
+		combo_text.onfocusout = function(){
+			combo_selectdiv.style.display ='none';
+		};
+		combo_text.onkeypress = function(event){
+				if( event.keyCode == ENTER || event.keyCode == ESC || event.keyCode == TAB){
+						combo_selectdiv.style.display = "none";
+						return false;
+				}else if( event.keyCode == KEYDN ||  event.keyCode == KEYUP ){
+						combo_selectbox.focus();
+						return false;
+				}else if( event.keyCode == BKSPACE && combo_text.value.length ==0 ){
+						combo_selectdiv.style.display = "none";
+						return false;
+				}else{
+						combo_selectdiv.style.display = "";
+						return true;
+				}
+		};
+		combo_text.onkeyup = function(event){
+				if( event.keyCode == ENTER || event.keyCode == ESC || event.keyCode == TAB){
+				return false;
+				}
+				for (var i=0; i < combo_selectbox.options.length; i++){
+						if(	combo_selectbox.options[i].value.toLowerCase().match(combo_text.value.toLowerCase()) ){
+							combo_selectbox.selectedIndex = i;
+							return true;
+						}
+				}
+				combo_selectdiv.style.display = "none";				
+		}
+		combo_selectbox.onkeypress= function(event) {
+				if( event.keyCode == ENTER ){
+						combo_text.value = combo_selectbox.value;
+						combo_text.focus();
+						combo_selectdiv.style.display = "none";
+						return false;
+				}else if( event.keyCode == ESC ){
+						combo_text.focus();
+						combo_selectdiv.style.display = "none";
+				}else{
+						return true;
+				}
+		};
+		combo_selectbox.onclick= function() {
+					combo_text.value = combo_selectbox.value;
+					combo_text.focus();
+					combo_selectdiv.style.display = "none";
+		};
+		function combobox_activate(){
+				var tmp_left = combo_text.offsetLeft;
+				var tmp_top = combo_text.offsetTop + combo_text.offsetHeight;
+				var tmp_parent = combo_text;
+				while(tmp_parent.offsetParent != document.body){
+						tmp_parent = tmp_parent.offsetParent;
+						tmp_left += tmp_parent.offsetLeft;
+						tmp_top += tmp_parent.offsetTop;
+				}
+				combo_selectdiv.style.left = tmp_left;
+				combo_selectdiv.style.top = tmp_top ;
+				combo_selectdiv.style.width = combo_text.offsetWidth;
+				combo_selectdiv.style.display = "";
+		}
+}
+
+
 
 function  InArray(search_array, searchstring ){
 	var i = search_array.length



More information about the asterisk-gui-commits mailing list