espiceland: branch 2.0 r5167 - /branches/2.0/config/js/

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Fri Apr 1 11:49:24 CDT 2011


Author: espiceland
Date: Fri Apr  1 11:49:20 2011
New Revision: 5167

URL: http://svnview.digium.com/svn/asterisk-gui?view=rev&rev=5167
Log:
Better fix for webkit browser incompatibility.  Rewrite the prototyped trim() function with an implementation provided by Steve Levithan (Thanks!) and replace all uses of strip() with trim().

Modified:
    branches/2.0/config/js/astman.js
    branches/2.0/config/js/hardware.js
    branches/2.0/config/js/hardware_dahdi.js
    branches/2.0/config/js/misdn.js
    branches/2.0/config/js/session.js
    branches/2.0/config/js/timezone.js

Modified: branches/2.0/config/js/astman.js
URL: http://svnview.digium.com/svn/asterisk-gui/branches/2.0/config/js/astman.js?view=diff&rev=5167&r1=5166&r2=5167
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Fri Apr  1 11:49:20 2011
@@ -10,6 +10,9 @@
  * Ryan Brindley <rbrindley at digium.com>
  * Erin Spiceland <espiceland at digium.com>
  *
+ * Thanks to Steven Levithan (http://stevenlevithan.com) for his
+ * implementation of trim()
+ *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
  * any of the maintainers of this project for assistance;
@@ -288,14 +291,6 @@
 		return this.split('\n').join('<BR>');
 	};
 
-	String.prototype.strip = function(){
-		try {
-			return this.replace(/^\s+|\s+$/g, "");
-		} catch(e) {
-			return s;
-		}
-	};
-
 	String.prototype.times = function(a){
 		return ( a < 1 ) ? '' : new Array(a+1).join(this);
 	};
@@ -304,8 +299,13 @@
 		return this.replace(/<\/?[^>]+>/gi, '');
 	}
 
-	String.prototype.trim = function(){ // alias to strip
-		return this.strip();
+	String.prototype.trim = function(){
+		/* Thanks to Steve Levithan (http://stevenlevithan.com) for this code */
+		var str = this.replace(/^\s\s*/, ''),
+				ws = /\s/,
+				i = str.length;
+		while (ws.test(str.charAt(--i)));
+		return str.slice(0, i+1);
 	};
 
 	String.prototype.withOut = function(k){
@@ -492,7 +492,7 @@
 				field = _$(field); 
 			}
 			var required = $(field).attr('required');
-			if( required ){
+			if( required && required.toString().isAstTrue() ){
 				var x = field.value.trim() ;
 				var pcn = ( field.className ) ? field.className : '' ;
 				if( !x ){
@@ -608,7 +608,7 @@
 			}
 			var cookies = ck.split(';');
 			for(var y=0; y < cookies.length; y++){
-				cookies[y] = cookies[y].strip();
+				cookies[y] = cookies[y].trim();
 				if( cookies[y].beginsWith(x +'=') ){
 					return cookies[y].split( x + '=' )[1] ;
 				}

Modified: branches/2.0/config/js/hardware.js
URL: http://svnview.digium.com/svn/asterisk-gui/branches/2.0/config/js/hardware.js?view=diff&rev=5167&r1=5166&r2=5167
==============================================================================
--- branches/2.0/config/js/hardware.js (original)
+++ branches/2.0/config/js/hardware.js Fri Apr  1 11:49:20 2011
@@ -3,9 +3,10 @@
  *
  * hardware.html functions
  *
- * Copyright (C) 2006-2008, Digium, Inc.
+ * Copyright (C) 2006-2011, Digium, Inc.
  *
  * Pari Nannapaneni <pari at digium.com>
+ * Erin Spiceland <espiceland at digium.com>
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -964,8 +965,8 @@
 
 		for( var e in fxx ){ if(fxx.hasOwnProperty(e)){	x.new_action('append', context, e, fxx[e]);	}}
 
-		if(bchanstring.strip()){ x.new_action('append', context, 'bchan', bchanstring); }
-		if(dchanstring.strip()){ x.new_action('append', context, 'dchan', dchanstring); }
+		if(bchanstring.trim()){ x.new_action('append', context, 'bchan', bchanstring); }
+		if(dchanstring.trim()){ x.new_action('append', context, 'dchan', dchanstring); }
 
 		// write back any actual analog ports
 		parent.sessionData.PORTS_SIGNALLING.ls = []; // reset previous signalling data

Modified: branches/2.0/config/js/hardware_dahdi.js
URL: http://svnview.digium.com/svn/asterisk-gui/branches/2.0/config/js/hardware_dahdi.js?view=diff&rev=5167&r1=5166&r2=5167
==============================================================================
--- branches/2.0/config/js/hardware_dahdi.js (original)
+++ branches/2.0/config/js/hardware_dahdi.js Fri Apr  1 11:49:20 2011
@@ -1075,9 +1075,9 @@
 
 		for( var e in fxx ){ if(fxx.hasOwnProperty(e)){	x.new_action('append', context, e, fxx[e]);	}}
 
-		if(bchanstring.strip()){ x.new_action('append', context, 'bchan', bchanstring); }
-		if(dchanstring.strip()){ x.new_action('append', context, 'dchan', dchanstring); }
-		if(hardhdlc.strip()){ x.new_action('append', context, 'hardhdlc', hardhdlc); }
+		if(bchanstring.trim()){ x.new_action('append', context, 'bchan', bchanstring); }
+		if(dchanstring.trim()){ x.new_action('append', context, 'dchan', dchanstring); }
+		if(hardhdlc.trim()){ x.new_action('append', context, 'hardhdlc', hardhdlc); }
 
 		// write back any actual analog ports
 		parent.sessionData.PORTS_SIGNALLING.ls = []; // reset previous signalling data

Modified: branches/2.0/config/js/misdn.js
URL: http://svnview.digium.com/svn/asterisk-gui/branches/2.0/config/js/misdn.js?view=diff&rev=5167&r1=5166&r2=5167
==============================================================================
--- branches/2.0/config/js/misdn.js (original)
+++ branches/2.0/config/js/misdn.js Fri Apr  1 11:49:20 2011
@@ -3,9 +3,10 @@
  *
  * misdn.html functions
  *
- * Copyright (C) 2006-2008, Digium, Inc.
+ * Copyright (C) 2006-2011, Digium, Inc.
  *
  * Pari Nannapaneni <pari at digium.com>
+ * Erin Spiceland <espiceland at digium.com>
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -101,12 +102,12 @@
 						c = b.split(",");
 						c.each( function(d) {
 							if(PORTS[d]){
-								PORTS[d]['portType'] = a.strip(); // set port type of port d to a
+								PORTS[d]['portType'] = a.trim(); // set port type of port d to a
 							}
 						});
 					}else{
 						if(PORTS[b]){
-							PORTS[b]['portType'] = a.strip(); // set port type of port b to a
+							PORTS[b]['portType'] = a.trim(); // set port type of port b to a
 						}
 					}
 				}

Modified: branches/2.0/config/js/session.js
URL: http://svnview.digium.com/svn/asterisk-gui/branches/2.0/config/js/session.js?view=diff&rev=5167&r1=5166&r2=5167
==============================================================================
--- branches/2.0/config/js/session.js (original)
+++ branches/2.0/config/js/session.js Fri Apr  1 11:49:20 2011
@@ -63,7 +63,7 @@
 
 	var cookies = ck.split(';');
 	for (var i=0; i < cookies.length; i++) {
-		var c = cookies[i].strip();
+		var c = cookies[i].trim();
 		if (c.beginsWith(varname + '=')) {
 			return c.split(varname + '=')[1];
 		}

Modified: branches/2.0/config/js/timezone.js
URL: http://svnview.digium.com/svn/asterisk-gui/branches/2.0/config/js/timezone.js?view=diff&rev=5167&r1=5166&r2=5167
==============================================================================
--- branches/2.0/config/js/timezone.js (original)
+++ branches/2.0/config/js/timezone.js Fri Apr  1 11:49:20 2011
@@ -3,9 +3,10 @@
  *
  * timezone.html functions
  *
- * Copyright (C) 2006-2008, Digium, Inc.
+ * Copyright (C) 2006-2011, Digium, Inc.
  *
  * Pari Nannapaneni <pari at digium.com>
+ * Erin Spiceland <espiceland at digium.com>
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -128,7 +129,7 @@
 		}else{
 			var p = op.split("->");
 			if(p.length > 1){
-				p = p[1].strip().split(upload_Path);
+				p = p[1].trim().split(upload_Path);
 				default_tz = p[1];
 			}
 		}




More information about the asterisk-gui-commits mailing list