- Use RegExp literals instead of new RegExp(...); when unnecessary.
- Fix bad use of object iteration on an array bug20376
// delay between keypress and suggestion (in ms)
var os_search_timeout = 250;
// these pairs of inputs/forms will be autoloaded at startup
// 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
// if we stopped the service
var os_is_stopped = false;
// max lines to show in suggest table
var c = document.getElementById(r.container);
var width = c.offsetWidth - os_operaWidthFix(c.offsetWidth);
var html = "<table class=\"os-suggest-results\" id=\""+r.resultTable+"\" style=\"width: "+width+"px;\">";
var c = document.getElementById(r.container);
var width = c.offsetWidth - os_operaWidthFix(c.offsetWidth);
var html = "<table class=\"os-suggest-results\" id=\""+r.resultTable+"\" style=\"width: "+width+"px;\">";
- r.results = new Array();
r.resultCount = results.length;
for(i=0;i<results.length;i++){
var title = os_decodeValue(results[i]);
r.resultCount = results.length;
for(i=0;i<results.length;i++){
var title = os_decodeValue(results[i]);
*/
'getLevelSelectors': function() {
var all = document.getElementsByTagName("select");
*/
'getLevelSelectors': function() {
var all = document.getElementsByTagName("select");
- var ours = new Array();
for (var i = 0; i < all.length; i++) {
var element = all[i];
if (element.id.match(/^mwProtect-level-/)) {
for (var i = 0; i < all.length; i++) {
var element = all[i];
if (element.id.match(/^mwProtect-level-/)) {
*/
'getExpiryInputs': function() {
var all = document.getElementsByTagName("input");
*/
'getExpiryInputs': function() {
var all = document.getElementsByTagName("input");
- var ours = new Array();
for (var i = 0; i < all.length; i++) {
var element = all[i];
if (element.name.match(/^mwProtect-expiry-/)) {
for (var i = 0; i < all.length; i++) {
var element = all[i];
if (element.name.match(/^mwProtect-expiry-/)) {
*/
'getExpirySelectors': function() {
var all = document.getElementsByTagName("select");
*/
'getExpirySelectors': function() {
var all = document.getElementsByTagName("select");
- var ours = new Array();
for (var i = 0; i < all.length; i++) {
var element = all[i];
if (element.id.match(/^mwProtectExpirySelection-/)) {
for (var i = 0; i < all.length; i++) {
var element = all[i];
if (element.id.match(/^mwProtectExpirySelection-/)) {
var mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js
function escapeQuotes(text) {
var mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js
function escapeQuotes(text) {
- var re = new RegExp("'","g");
- text = text.replace(re,"\\'");
- re = new RegExp("\\n","g");
- text = text.replace(re,"\\n");
- return escapeQuotesHTML(text);
+ return escapeQuotesHTML(text.replace(/'/g,"\\'").replace(/\n/g,"\\n"));
}
function escapeQuotesHTML(text) {
}
function escapeQuotesHTML(text) {
- var re = new RegExp('&',"g");
- text = text.replace(re,"&");
- re = new RegExp('"',"g");
- text = text.replace(re,""");
- re = new RegExp('<',"g");
- text = text.replace(re,"<");
- re = new RegExp('>',"g");
- text = text.replace(re,">");
- return text;
+ return text.replace(/&/g,"&")
+ .replace(/"/g,""")
+ .replace(/</gre,"<")
+ .replace(/>/g,">");
link.setAttribute( "title", tooltip );
}
if ( accesskey && tooltip ) {
link.setAttribute( "title", tooltip );
}
if ( accesskey && tooltip ) {
- updateTooltipAccessKeys( new Array( link ) );
+ updateTooltipAccessKeys( [link] );
}
if ( nextnode && nextnode.parentNode == node )
}
if ( nextnode && nextnode.parentNode == node )
// 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.
// 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.
// Make a local, possibly restricted, copy to avoid clobbering
// the original.
// Now deal with evil deprecated ta
var watchCheckboxExists = document.getElementById( 'wpWatchthis' ) ? true : false;
// Now deal with evil deprecated ta
var watchCheckboxExists = document.getElementById( 'wpWatchthis' ) ? true : false;
+ for (var id = 0; id < ta.length; id++) {
var n = document.getElementById(id);
if (n) {
var a = null;
var n = document.getElementById(id);
if (n) {
var a = null;
From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
*/
function getElementsByClassName(oElm, strTagName, oClassNames){
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 );
if ( typeof( oElm.getElementsByClassName ) == "function" ) {
/* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */
var arrNativeReturn = oElm.getElementsByClassName( oClassNames );
return arrReturnElements;
}
var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
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<oClassNames.length; i++){
arrRegExpClassNames[arrRegExpClassNames.length] =
if(typeof oClassNames == "object"){
for(var i=0; i<oClassNames.length; i++){
arrRegExpClassNames[arrRegExpClassNames.length] =
var reverse = (span.getAttribute("sortdir") == 'down');
var reverse = (span.getAttribute("sortdir") == 'down');
- var newRows = new Array();
- var staticRows = new Array();
+ var newRows = new [];
+ var staticRows = new [];
for (var j = rowStart; j < table.rows.length; j++) {
var row = table.rows[j];
if((" "+row.className+" ").indexOf(" unsortable ") < 0) {
for (var j = rowStart; j < table.rows.length; j++) {
var row = table.rows[j];
if((" "+row.className+" ").indexOf(" unsortable ") < 0) {
var oldIndex = (reverse ? -j : j);
var preprocessed = preprocessor( keyText.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "") );
var oldIndex = (reverse ? -j : j);
var preprocessed = preprocessor( keyText.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "") );
- newRows[newRows.length] = new Array(row, preprocessed, oldIndex);
- } else staticRows[staticRows.length] = new Array(row, false, j-rowStart);
+ newRows[newRows.length] = new [row, preprocessed, oldIndex];
+ } else staticRows[staticRows.length] = [row, false, j-rowStart];