From 3118c55c47f01db9781f075aecedf696a4064914 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Mon, 24 Aug 2009 17:15:32 +0000 Subject: [PATCH] - Use array literals instead of new Array(); (note that `new Array;` without () is actually supposed to break in IE6 iirc) - Use RegExp literals instead of new RegExp(...); when unnecessary. - Fix bad use of object iteration on an array bug20376 --- skins/common/mwsuggest.js | 6 +++--- skins/common/protect.js | 6 +++--- skins/common/wikibits.js | 37 ++++++++++++++----------------------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/skins/common/mwsuggest.js b/skins/common/mwsuggest.js index 77792b0616..8e37a4859e 100644 --- a/skins/common/mwsuggest.js +++ b/skins/common/mwsuggest.js @@ -24,8 +24,8 @@ var os_mouse_moved = false; // delay between keypress and suggestion (in ms) var os_search_timeout = 250; // these pairs of inputs/forms will be autoloaded at startup -var os_autoload_inputs = new Array('searchInput', 'searchInput2', 'powerSearchText', 'searchText'); -var os_autoload_forms = new Array('searchform', 'searchform2', 'powersearch', 'search' ); +var os_autoload_inputs = ['searchInput', 'searchInput2', 'powerSearchText', 'searchText']; +var os_autoload_forms = ['searchform', 'searchform2', 'powersearch', 'search']; // if we stopped the service var os_is_stopped = false; // max lines to show in suggest table @@ -364,7 +364,7 @@ function os_createResultTable(r, results){ var c = document.getElementById(r.container); var width = c.offsetWidth - os_operaWidthFix(c.offsetWidth); var html = ""; - r.results = new Array(); + r.results = []; r.resultCount = results.length; for(i=0;i',"g"); - text = text.replace(re,">"); - return text; + return text.replace(/&/g,"&") + .replace(/"/g,""") + .replace(//g,">"); } @@ -308,7 +299,7 @@ function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) { link.setAttribute( "title", tooltip ); } if ( accesskey && tooltip ) { - updateTooltipAccessKeys( new Array( link ) ); + updateTooltipAccessKeys( [link] ); } if ( nextnode && nextnode.parentNode == node ) @@ -354,7 +345,7 @@ function akeytt( doId ) { // A lot of user scripts (and some of the code below) break if // ta isn't defined, so we make sure it is. Explictly using // window.ta avoids a "ta is not defined" error. - if (!window.ta) window.ta = new Array; + if (!window.ta) window.ta = []; // Make a local, possibly restricted, copy to avoid clobbering // the original. @@ -367,7 +358,7 @@ function akeytt( doId ) { // Now deal with evil deprecated ta var watchCheckboxExists = document.getElementById( 'wpWatchthis' ) ? true : false; - for (var id in ta) { + for (var id = 0; id < ta.length; id++) { var n = document.getElementById(id); if (n) { var a = null; @@ -498,7 +489,7 @@ function toggle_element_check(ida,idb) { From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ */ function getElementsByClassName(oElm, strTagName, oClassNames){ - var arrReturnElements = new Array(); + var arrReturnElements = []; if ( typeof( oElm.getElementsByClassName ) == "function" ) { /* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */ var arrNativeReturn = oElm.getElementsByClassName( oClassNames ); @@ -511,7 +502,7 @@ function getElementsByClassName(oElm, strTagName, oClassNames){ return arrReturnElements; } var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); - var arrRegExpClassNames = new Array(); + var arrRegExpClassNames = []; if(typeof oClassNames == "object"){ for(var i=0; i