From: James D. Forrester Date: Sat, 14 Feb 2015 20:29:43 +0000 (-0800) Subject: test: Remove several jscs over-rides and make the code pass X-Git-Tag: 1.31.0-rc.0~12397 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22statistiques_visites%22%2C%22%22%29%20.%20%22?a=commitdiff_plain;h=09293a7b51c0ad6ba60c8f0e65446b561ca75fd7;p=lhc%2Fweb%2Fwiklou.git test: Remove several jscs over-rides and make the code pass Rules newly instated from the coding standards: * disallowKeywordsOnNewLine * disallowImplicitTypeConversion * requireLineBreakAfterVariableAssignment * requireSpaceAfterLineComment * validateIndentation Change-Id: I3d1845b1ed68037b6a4275ba9f333c3ccc36359a --- diff --git a/.jscsrc b/.jscsrc index 34b2435a31..98b81db9dc 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,12 +1,7 @@ { "preset": "wikimedia", - "disallowKeywordsOnNewLine": null, "disallowQuotedKeysInObjects": null, - "disallowImplicitTypeConversion": null, - "requireLineBreakAfterVariableAssignment": null, - "requireSpaceAfterLineComment": null, "requireSpacesInsideParentheses": null, - "requireSpacesInsideArrayBrackets": null, - "validateIndentation": null + "requireSpacesInsideArrayBrackets": null } diff --git a/resources/src/jquery/jquery.badge.js b/resources/src/jquery/jquery.badge.js index 023b6e28fc..777386612f 100644 --- a/resources/src/jquery/jquery.badge.js +++ b/resources/src/jquery/jquery.badge.js @@ -45,7 +45,8 @@ $.fn.badge = function ( text, inline, displayZero ) { var $badge = this.find( '.mw-badge' ), badgeStyleClass = 'mw-badge-' + ( inline ? 'inline' : 'overlay' ), - isImportant = true, displayBadge = true; + isImportant = true, + displayBadge = true; // If we're displaying zero, ensure style to be non-important if ( mw.language.convertNumber( text, true ) === 0 ) { diff --git a/resources/src/jquery/jquery.client.js b/resources/src/jquery/jquery.client.js index 3796b0b1ab..df0696fac2 100644 --- a/resources/src/jquery/jquery.client.js +++ b/resources/src/jquery/jquery.client.js @@ -292,7 +292,7 @@ } } // compare will be -1, 0 or 1, depending on comparison result - if ( !( eval( '' + compare + op + '0' ) ) ) { + if ( !( eval( String( compare + op + '0' ) ) ) ) { return false; } } else if ( typeof val === 'number' ) { diff --git a/resources/src/jquery/jquery.getAttrs.js b/resources/src/jquery/jquery.getAttrs.js index a2e2be5987..64827fb785 100644 --- a/resources/src/jquery/jquery.getAttrs.js +++ b/resources/src/jquery/jquery.getAttrs.js @@ -3,7 +3,9 @@ */ function serializeControls( controls ) { - var i, data = {}, len = controls.length; + var i, + data = {}, + len = controls.length; for ( i = 0; i < len; i++ ) { data[ controls[i].name ] = controls[i].value; diff --git a/resources/src/jquery/jquery.tablesorter.js b/resources/src/jquery/jquery.tablesorter.js index 8e1c3f0ae4..afff1a6837 100644 --- a/resources/src/jquery/jquery.tablesorter.js +++ b/resources/src/jquery/jquery.tablesorter.js @@ -1112,9 +1112,9 @@ return '99999999'; } } else if ( ( match = s.match( ts.dateRegex[1] ) ) !== null ) { - s = [ match[3], '' + ts.monthNames[match[2]], match[1] ]; + s = [ match[3], String( ts.monthNames[match[2]] ), match[1] ]; } else if ( ( match = s.match( ts.dateRegex[2] ) ) !== null ) { - s = [ match[3], '' + ts.monthNames[match[1]], match[2] ]; + s = [ match[3], String( ts.monthNames[match[1]] ), match[2] ]; } else { // Should never get here return '99999999'; diff --git a/resources/src/jquery/jquery.textSelection.js b/resources/src/jquery/jquery.textSelection.js index e8fc8e4ff5..5111930517 100644 --- a/resources/src/jquery/jquery.textSelection.js +++ b/resources/src/jquery/jquery.textSelection.js @@ -513,9 +513,9 @@ // Apply defaults switch ( command ) { - //case 'getContents': // no params - //case 'setContents': // no params with defaults - //case 'getSelection': // no params + // case 'getContents': // no params + // case 'setContents': // no params with defaults + // case 'getSelection': // no params case 'encapsulateSelection': options = $.extend( { pre: '', // Text to insert before the cursor/selection diff --git a/resources/src/mediawiki.language/languages/fi.js b/resources/src/mediawiki.language/languages/fi.js index 453a675d5d..d9c2b06d28 100644 --- a/resources/src/mediawiki.language/languages/fi.js +++ b/resources/src/mediawiki.language/languages/fi.js @@ -17,7 +17,7 @@ mediaWiki.language.convertGrammar = function ( word, form ) { if ( word.match( /wiki$/i ) ) { aou = false; } - //append i after final consonant + // append i after final consonant if ( word.match( /[bcdfghjklmnpqrstvwxz]$/i ) ) { word += 'i'; } diff --git a/resources/src/mediawiki.language/languages/hsb.js b/resources/src/mediawiki.language/languages/hsb.js index 2d6b733ebd..2c0abd3df9 100644 --- a/resources/src/mediawiki.language/languages/hsb.js +++ b/resources/src/mediawiki.language/languages/hsb.js @@ -14,6 +14,6 @@ mediaWiki.language.convertGrammar = function ( word, form ) { case 'lokatiw': // lokatiw word = 'wo ' + word; break; - } + } return word; }; diff --git a/resources/src/mediawiki.language/languages/hy.js b/resources/src/mediawiki.language/languages/hy.js index 9cae360b9d..c4a1cf7307 100644 --- a/resources/src/mediawiki.language/languages/hy.js +++ b/resources/src/mediawiki.language/languages/hy.js @@ -24,6 +24,6 @@ mediaWiki.language.convertGrammar = function ( word, form ) { word = word + 'ի'; } break; - } + } return word; }; diff --git a/resources/src/mediawiki.language/languages/os.js b/resources/src/mediawiki.language/languages/os.js index 787be36df3..554e99d4c5 100644 --- a/resources/src/mediawiki.language/languages/os.js +++ b/resources/src/mediawiki.language/languages/os.js @@ -21,15 +21,14 @@ mediaWiki.language.convertGrammar = function ( word, form ) { if ( word.match( /тæ$/i ) ) { word = word.slice( 0, -1 ); endAllative = 'æм'; - } - // Works if word is in singular form. - // Checking if word ends on one of the vowels: е, ё, и, о, ы, э, ю, я. - else if ( word.match( /[аæеёиоыэюя]$/i ) ) { + } else if ( word.match( /[аæеёиоыэюя]$/i ) ) { + // Works if word is in singular form. + // Checking if word ends on one of the vowels: е, ё, и, о, ы, э, ю, я. jot = 'й'; - } - // Checking if word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic. - // Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы. - else if ( word.match( /у$/i ) ) { + } else if ( word.match( /у$/i ) ) { + // Checking if word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic. + // Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы. + if ( !word.slice( -2, -1 ).match( /[аæеёиоыэюя]$/i ) ) { jot = 'й'; } @@ -50,8 +49,7 @@ mediaWiki.language.convertGrammar = function ( word, form ) { case 'ablative': if ( jot === 'й' ) { ending = hyphen + jot + 'æ'; - } - else { + } else { ending = hyphen + jot + 'æй'; } break; diff --git a/resources/src/mediawiki.language/mediawiki.language.js b/resources/src/mediawiki.language/mediawiki.language.js index 8b3a0853cf..bb8a84b02c 100644 --- a/resources/src/mediawiki.language/mediawiki.language.js +++ b/resources/src/mediawiki.language/mediawiki.language.js @@ -134,7 +134,9 @@ $.extend( mw.language, { * @return {string} */ listToText: function ( list ) { - var text = '', i = 0; + var text = '', + i = 0; + for ( ; i < list.length; i++ ) { text += list[i]; if ( list.length - 2 === i ) { diff --git a/resources/src/mediawiki.language/mediawiki.language.numbers.js b/resources/src/mediawiki.language/mediawiki.language.numbers.js index a0b814108e..c7f150f942 100644 --- a/resources/src/mediawiki.language/mediawiki.language.numbers.js +++ b/resources/src/mediawiki.language/mediawiki.language.numbers.js @@ -187,7 +187,7 @@ tmp[ transformTable[ i ] ] = i; } transformTable = tmp; - numberString = num + ''; + numberString = String( num ); } else { numberString = mw.language.commafy( num, pattern ); } diff --git a/resources/src/mediawiki.legacy/ajax.js b/resources/src/mediawiki.legacy/ajax.js index cf9e27f117..3660c20544 100644 --- a/resources/src/mediawiki.legacy/ajax.js +++ b/resources/src/mediawiki.legacy/ajax.js @@ -9,186 +9,186 @@ /*global alert */ ( function ( mw ) { -/** - * if sajax_debug_mode is true, this function outputs given the message into - * the element with id = sajax_debug; if no such element exists in the document, - * it is injected. - */ -function debug( text ) { - if ( !window.sajax_debug_mode ) { - return false; - } + /** + * if sajax_debug_mode is true, this function outputs given the message into + * the element with id = sajax_debug; if no such element exists in the document, + * it is injected. + */ + function debug( text ) { + if ( !window.sajax_debug_mode ) { + return false; + } - var b, m, - e = document.getElementById( 'sajax_debug' ); + var b, m, + e = document.getElementById( 'sajax_debug' ); - if ( !e ) { - e = document.createElement( 'p' ); - e.className = 'sajax_debug'; - e.id = 'sajax_debug'; + if ( !e ) { + e = document.createElement( 'p' ); + e.className = 'sajax_debug'; + e.id = 'sajax_debug'; - b = document.getElementsByTagName( 'body' )[0]; + b = document.getElementsByTagName( 'body' )[0]; - if ( b.firstChild ) { - b.insertBefore( e, b.firstChild ); - } else { - b.appendChild( e ); + if ( b.firstChild ) { + b.insertBefore( e, b.firstChild ); + } else { + b.appendChild( e ); + } } - } - m = document.createElement( 'div' ); - m.appendChild( document.createTextNode( text ) ); + m = document.createElement( 'div' ); + m.appendChild( document.createTextNode( text ) ); - e.appendChild( m ); + e.appendChild( m ); - return true; -} + return true; + } -/** - * Compatibility wrapper for creating a new XMLHttpRequest object. - */ -function createXhr() { - debug( 'sajax_init_object() called..' ); - var a; - try { - // Try the new style before ActiveX so we don't - // unnecessarily trigger warnings in IE 7 when - // set to prompt about ActiveX usage - a = new XMLHttpRequest(); - } catch ( xhrE ) { + /** + * Compatibility wrapper for creating a new XMLHttpRequest object. + */ + function createXhr() { + debug( 'sajax_init_object() called..' ); + var a; try { - a = new window.ActiveXObject( 'Msxml2.XMLHTTP' ); - } catch ( msXmlE ) { + // Try the new style before ActiveX so we don't + // unnecessarily trigger warnings in IE 7 when + // set to prompt about ActiveX usage + a = new XMLHttpRequest(); + } catch ( xhrE ) { try { - a = new window.ActiveXObject( 'Microsoft.XMLHTTP' ); - } catch ( msXhrE ) { - a = null; + a = new window.ActiveXObject( 'Msxml2.XMLHTTP' ); + } catch ( msXmlE ) { + try { + a = new window.ActiveXObject( 'Microsoft.XMLHTTP' ); + } catch ( msXhrE ) { + a = null; + } } } - } - if ( !a ) { - debug( 'Could not create connection object.' ); - } + if ( !a ) { + debug( 'Could not create connection object.' ); + } - return a; -} + return a; + } -/** - * Perform an AJAX call to MediaWiki. Calls are handled by AjaxDispatcher.php - * func_name - the name of the function to call. Must be registered in $wgAjaxExportList - * args - an array of arguments to that function - * target - the target that will handle the result of the call. If this is a function, - * if will be called with the XMLHttpRequest as a parameter; if it's an input - * element, its value will be set to the resultText; if it's another type of - * element, its innerHTML will be set to the resultText. - * - * Example: - * sajax_do_call( 'doFoo', [1, 2, 3], document.getElementById( 'showFoo' ) ); - * - * This will call the doFoo function via MediaWiki's AjaxDispatcher, with - * (1, 2, 3) as the parameter list, and will show the result in the element - * with id = showFoo - */ -function doAjaxRequest( func_name, args, target ) { - var i, x, uri, post_data; - uri = mw.util.wikiScript() + '?action=ajax'; - if ( window.sajax_request_type === 'GET' ) { - if ( uri.indexOf( '?' ) === -1 ) { - uri = uri + '?rs=' + encodeURIComponent( func_name ); + /** + * Perform an AJAX call to MediaWiki. Calls are handled by AjaxDispatcher.php + * func_name - the name of the function to call. Must be registered in $wgAjaxExportList + * args - an array of arguments to that function + * target - the target that will handle the result of the call. If this is a function, + * if will be called with the XMLHttpRequest as a parameter; if it's an input + * element, its value will be set to the resultText; if it's another type of + * element, its innerHTML will be set to the resultText. + * + * Example: + * sajax_do_call( 'doFoo', [1, 2, 3], document.getElementById( 'showFoo' ) ); + * + * This will call the doFoo function via MediaWiki's AjaxDispatcher, with + * (1, 2, 3) as the parameter list, and will show the result in the element + * with id = showFoo + */ + function doAjaxRequest( func_name, args, target ) { + var i, x, uri, post_data; + uri = mw.util.wikiScript() + '?action=ajax'; + if ( window.sajax_request_type === 'GET' ) { + if ( uri.indexOf( '?' ) === -1 ) { + uri = uri + '?rs=' + encodeURIComponent( func_name ); + } else { + uri = uri + '&rs=' + encodeURIComponent( func_name ); + } + for ( i = 0; i < args.length; i++ ) { + uri = uri + '&rsargs[]=' + encodeURIComponent( args[i] ); + } + // uri = uri + '&rsrnd=' + new Date().getTime(); + post_data = null; } else { - uri = uri + '&rs=' + encodeURIComponent( func_name ); - } - for ( i = 0; i < args.length; i++ ) { - uri = uri + '&rsargs[]=' + encodeURIComponent( args[i] ); + post_data = 'rs=' + encodeURIComponent( func_name ); + for ( i = 0; i < args.length; i++ ) { + post_data = post_data + '&rsargs[]=' + encodeURIComponent( args[i] ); + } } - //uri = uri + '&rsrnd=' + new Date().getTime(); - post_data = null; - } else { - post_data = 'rs=' + encodeURIComponent( func_name ); - for ( i = 0; i < args.length; i++ ) { - post_data = post_data + '&rsargs[]=' + encodeURIComponent( args[i] ); + x = createXhr(); + if ( !x ) { + alert( 'AJAX not supported' ); + return false; } - } - x = createXhr(); - if ( !x ) { - alert( 'AJAX not supported' ); - return false; - } - try { - x.open( window.sajax_request_type, uri, true ); - } catch ( e ) { - if ( location.hostname === 'localhost' ) { - alert( 'Your browser blocks XMLHttpRequest to "localhost", try using a real hostname for development/testing.' ); + try { + x.open( window.sajax_request_type, uri, true ); + } catch ( e ) { + if ( location.hostname === 'localhost' ) { + alert( 'Your browser blocks XMLHttpRequest to "localhost", try using a real hostname for development/testing.' ); + } + throw e; } - throw e; - } - if ( window.sajax_request_type === 'POST' ) { - x.setRequestHeader( 'Method', 'POST ' + uri + ' HTTP/1.1' ); - x.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); - } - x.setRequestHeader( 'Pragma', 'cache=yes' ); - x.setRequestHeader( 'Cache-Control', 'no-transform' ); - x.onreadystatechange = function () { - if ( x.readyState !== 4 ) { - return; + if ( window.sajax_request_type === 'POST' ) { + x.setRequestHeader( 'Method', 'POST ' + uri + ' HTTP/1.1' ); + x.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); } + x.setRequestHeader( 'Pragma', 'cache=yes' ); + x.setRequestHeader( 'Cache-Control', 'no-transform' ); + x.onreadystatechange = function () { + if ( x.readyState !== 4 ) { + return; + } - debug( 'received (' + x.status + ' ' + x.statusText + ') ' + x.responseText ); + debug( 'received (' + x.status + ' ' + x.statusText + ') ' + x.responseText ); - //if ( x.status != 200 ) - // alert( 'Error: ' + x.status + ' ' + x.statusText + ': ' + x.responseText ); - //else + // if ( x.status != 200 ) + // alert( 'Error: ' + x.status + ' ' + x.statusText + ': ' + x.responseText ); + // else - if ( typeof target === 'function' ) { - target( x ); - } else if ( typeof target === 'object' ) { - if ( target.tagName === 'INPUT' ) { - if ( x.status === 200 ) { - target.value = x.responseText; - } - //else alert( 'Error: ' + x.status + ' ' + x.statusText + ' (' + x.responseText + ')' ); - } else { - if ( x.status === 200 ) { - target.innerHTML = x.responseText; + if ( typeof target === 'function' ) { + target( x ); + } else if ( typeof target === 'object' ) { + if ( target.tagName === 'INPUT' ) { + if ( x.status === 200 ) { + target.value = x.responseText; + } + // else alert( 'Error: ' + x.status + ' ' + x.statusText + ' (' + x.responseText + ')' ); } else { - target.innerHTML = '
Error: ' + x.status + - ' ' + x.statusText + ' (' + x.responseText + ')
'; + if ( x.status === 200 ) { + target.innerHTML = x.responseText; + } else { + target.innerHTML = '
Error: ' + x.status + + ' ' + x.statusText + ' (' + x.responseText + ')
'; + } } + } else { + alert( 'Bad target for sajax_do_call: not a function or object: ' + target ); } - } else { - alert( 'Bad target for sajax_do_call: not a function or object: ' + target ); - } - }; + }; + + debug( func_name + ' uri = ' + uri + ' / post = ' + post_data ); + x.send( post_data ); + debug( func_name + ' waiting..' ); - debug( func_name + ' uri = ' + uri + ' / post = ' + post_data ); - x.send( post_data ); - debug( func_name + ' waiting..' ); + return true; + } - return true; -} + /** + * @return {boolean} Whether the browser supports AJAX + */ + function wfSupportsAjax() { + var request = createXhr(), + supportsAjax = request ? true : false; -/** - * @return {boolean} Whether the browser supports AJAX - */ -function wfSupportsAjax() { - var request = createXhr(), - supportsAjax = request ? true : false; - - request = undefined; - return supportsAjax; -} - -// Expose + Mark as deprecated -var deprecationNotice = 'Sajax is deprecated, use jQuery.ajax or mediawiki.api instead.'; - -// Variables -mw.log.deprecate( window, 'sajax_debug_mode', false, deprecationNotice ); -mw.log.deprecate( window, 'sajax_request_type', 'GET', deprecationNotice ); -// Methods -mw.log.deprecate( window, 'sajax_debug', debug, deprecationNotice ); -mw.log.deprecate( window, 'sajax_init_object', createXhr, deprecationNotice ); -mw.log.deprecate( window, 'sajax_do_call', doAjaxRequest, deprecationNotice ); -mw.log.deprecate( window, 'wfSupportsAjax', wfSupportsAjax, deprecationNotice ); + request = undefined; + return supportsAjax; + } + + // Expose + Mark as deprecated + var deprecationNotice = 'Sajax is deprecated, use jQuery.ajax or mediawiki.api instead.'; + + // Variables + mw.log.deprecate( window, 'sajax_debug_mode', false, deprecationNotice ); + mw.log.deprecate( window, 'sajax_request_type', 'GET', deprecationNotice ); + // Methods + mw.log.deprecate( window, 'sajax_debug', debug, deprecationNotice ); + mw.log.deprecate( window, 'sajax_init_object', createXhr, deprecationNotice ); + mw.log.deprecate( window, 'sajax_do_call', doAjaxRequest, deprecationNotice ); + mw.log.deprecate( window, 'wfSupportsAjax', wfSupportsAjax, deprecationNotice ); }( mediaWiki ) ); diff --git a/resources/src/mediawiki.legacy/protect.js b/resources/src/mediawiki.legacy/protect.js index f9069b6fd0..bc73048378 100644 --- a/resources/src/mediawiki.legacy/protect.js +++ b/resources/src/mediawiki.legacy/protect.js @@ -6,7 +6,8 @@ var ProtectionForm = window.ProtectionForm = { * on the protection form */ init: function () { - var $cell = $( '' ), $row = $( '' ).append( $cell ); + var $cell = $( '' ), + $row = $( '' ).append( $cell ); if ( !$( '#mwProtectSet' ).length ) { return false; diff --git a/resources/src/mediawiki.legacy/wikibits.js b/resources/src/mediawiki.legacy/wikibits.js index dc21472a75..dffc6e810c 100644 --- a/resources/src/mediawiki.legacy/wikibits.js +++ b/resources/src/mediawiki.legacy/wikibits.js @@ -7,198 +7,198 @@ ua = navigator.userAgent.toLowerCase(), onloadFuncts = []; -/** - * User-agent sniffing. - * - * @deprecated since 1.17 Use jquery.client instead - */ - -msg = 'Use feature detection or module jquery.client instead.'; - -mw.log.deprecate( win, 'clientPC', ua, msg ); - -// Ignored dummy values -mw.log.deprecate( win, 'is_gecko', false, msg ); -mw.log.deprecate( win, 'is_chrome_mac', false, msg ); -mw.log.deprecate( win, 'is_chrome', false, msg ); -mw.log.deprecate( win, 'webkit_version', false, msg ); -mw.log.deprecate( win, 'is_safari_win', false, msg ); -mw.log.deprecate( win, 'is_safari', false, msg ); -mw.log.deprecate( win, 'webkit_match', false, msg ); -mw.log.deprecate( win, 'is_ff2', false, msg ); -mw.log.deprecate( win, 'ff2_bugs', false, msg ); -mw.log.deprecate( win, 'is_ff2_win', false, msg ); -mw.log.deprecate( win, 'is_ff2_x11', false, msg ); -mw.log.deprecate( win, 'opera95_bugs', false, msg ); -mw.log.deprecate( win, 'opera7_bugs', false, msg ); -mw.log.deprecate( win, 'opera6_bugs', false, msg ); -mw.log.deprecate( win, 'is_opera_95', false, msg ); -mw.log.deprecate( win, 'is_opera_preseven', false, msg ); -mw.log.deprecate( win, 'is_opera', false, msg ); -mw.log.deprecate( win, 'ie6_bugs', false, msg ); - -/** - * DOM utilities for handling of events, text nodes and selecting elements - * - * @deprecated since 1.17 Use jQuery instead - */ -msg = 'Use jQuery instead.'; - -// Ignored dummy values -mw.log.deprecate( win, 'doneOnloadHook', undefined, msg ); -mw.log.deprecate( win, 'onloadFuncts', [], msg ); -mw.log.deprecate( win, 'runOnloadHook', $.noop, msg ); -mw.log.deprecate( win, 'changeText', $.noop, msg ); -mw.log.deprecate( win, 'killEvt', $.noop, msg ); -mw.log.deprecate( win, 'addHandler', $.noop, msg ); -mw.log.deprecate( win, 'hookEvent', $.noop, msg ); -mw.log.deprecate( win, 'addClickHandler', $.noop, msg ); -mw.log.deprecate( win, 'removeHandler', $.noop, msg ); -mw.log.deprecate( win, 'getElementsByClassName', function () { return []; }, msg ); -mw.log.deprecate( win, 'getInnerText', function () { return ''; }, msg ); - -// Run a function after the window onload event is fired -mw.log.deprecate( win, 'addOnloadHook', function ( hookFunct ) { - if ( onloadFuncts ) { - onloadFuncts.push( hookFunct ); - } else { - // If func queue is gone the event has happened already, - // run immediately instead of queueing. - hookFunct(); - } -}, msg ); - -$( win ).on( 'load', function () { - var i, functs; - - // Don't run twice - if ( !onloadFuncts ) { - return; - } - - // Deference and clear onloadFuncts before running any - // hooks to make sure we don't miss any addOnloadHook - // calls. - functs = onloadFuncts.slice(); - onloadFuncts = undefined; - - // Execute the queued functions - for ( i = 0; i < functs.length; i++ ) { - functs[i](); - } -} ); - -/** - * Toggle checkboxes with shift selection - * - * @deprecated since 1.17 Use jquery.checkboxShiftClick instead - */ -msg = 'Use jquery.checkboxShiftClick instead.'; -mw.log.deprecate( win, 'checkboxes', [], msg ); -mw.log.deprecate( win, 'lastCheckbox', null, msg ); -mw.log.deprecate( win, 'setupCheckboxShiftClick', $.noop, msg ); -mw.log.deprecate( win, 'addCheckboxClickHandlers', $.noop, msg ); -mw.log.deprecate( win, 'checkboxClickHandler', $.noop, msg ); - -/** - * Add a button to the default editor toolbar - * - * @deprecated since 1.17 Use mw.toolbar instead - */ -mw.log.deprecate( win, 'mwEditButtons', [], 'Use mw.toolbar instead.' ); -mw.log.deprecate( win, 'mwCustomEditButtons', [], 'Use mw.toolbar instead.' ); - -/** - * Spinner creation, injection and removal - * - * @deprecated since 1.18 Use jquery.spinner instead - */ -mw.log.deprecate( win, 'injectSpinner', $.noop, 'Use jquery.spinner instead.' ); -mw.log.deprecate( win, 'removeSpinner', $.noop, 'Use jquery.spinner instead.' ); - -/** - * Escape utilities - * - * @deprecated since 1.18 Use mw.html instead - */ -mw.log.deprecate( win, 'escapeQuotes', $.noop, 'Use mw.html instead.' ); -mw.log.deprecate( win, 'escapeQuotesHTML', $.noop, 'Use mw.html instead.' ); - -/** - * Display a message to the user - * - * @deprecated since 1.17 Use mediawiki.notify instead - * @param {string|HTMLElement} message To be put inside the message box - */ -mw.log.deprecate( win, 'jsMsg', function ( message ) { - if ( !arguments.length || message === '' || message === null ) { + /** + * User-agent sniffing. + * + * @deprecated since 1.17 Use jquery.client instead + */ + + msg = 'Use feature detection or module jquery.client instead.'; + + mw.log.deprecate( win, 'clientPC', ua, msg ); + + // Ignored dummy values + mw.log.deprecate( win, 'is_gecko', false, msg ); + mw.log.deprecate( win, 'is_chrome_mac', false, msg ); + mw.log.deprecate( win, 'is_chrome', false, msg ); + mw.log.deprecate( win, 'webkit_version', false, msg ); + mw.log.deprecate( win, 'is_safari_win', false, msg ); + mw.log.deprecate( win, 'is_safari', false, msg ); + mw.log.deprecate( win, 'webkit_match', false, msg ); + mw.log.deprecate( win, 'is_ff2', false, msg ); + mw.log.deprecate( win, 'ff2_bugs', false, msg ); + mw.log.deprecate( win, 'is_ff2_win', false, msg ); + mw.log.deprecate( win, 'is_ff2_x11', false, msg ); + mw.log.deprecate( win, 'opera95_bugs', false, msg ); + mw.log.deprecate( win, 'opera7_bugs', false, msg ); + mw.log.deprecate( win, 'opera6_bugs', false, msg ); + mw.log.deprecate( win, 'is_opera_95', false, msg ); + mw.log.deprecate( win, 'is_opera_preseven', false, msg ); + mw.log.deprecate( win, 'is_opera', false, msg ); + mw.log.deprecate( win, 'ie6_bugs', false, msg ); + + /** + * DOM utilities for handling of events, text nodes and selecting elements + * + * @deprecated since 1.17 Use jQuery instead + */ + msg = 'Use jQuery instead.'; + + // Ignored dummy values + mw.log.deprecate( win, 'doneOnloadHook', undefined, msg ); + mw.log.deprecate( win, 'onloadFuncts', [], msg ); + mw.log.deprecate( win, 'runOnloadHook', $.noop, msg ); + mw.log.deprecate( win, 'changeText', $.noop, msg ); + mw.log.deprecate( win, 'killEvt', $.noop, msg ); + mw.log.deprecate( win, 'addHandler', $.noop, msg ); + mw.log.deprecate( win, 'hookEvent', $.noop, msg ); + mw.log.deprecate( win, 'addClickHandler', $.noop, msg ); + mw.log.deprecate( win, 'removeHandler', $.noop, msg ); + mw.log.deprecate( win, 'getElementsByClassName', function () { return []; }, msg ); + mw.log.deprecate( win, 'getInnerText', function () { return ''; }, msg ); + + // Run a function after the window onload event is fired + mw.log.deprecate( win, 'addOnloadHook', function ( hookFunct ) { + if ( onloadFuncts ) { + onloadFuncts.push( hookFunct ); + } else { + // If func queue is gone the event has happened already, + // run immediately instead of queueing. + hookFunct(); + } + }, msg ); + + $( win ).on( 'load', function () { + var i, functs; + + // Don't run twice + if ( !onloadFuncts ) { + return; + } + + // Deference and clear onloadFuncts before running any + // hooks to make sure we don't miss any addOnloadHook + // calls. + functs = onloadFuncts.slice(); + onloadFuncts = undefined; + + // Execute the queued functions + for ( i = 0; i < functs.length; i++ ) { + functs[i](); + } + } ); + + /** + * Toggle checkboxes with shift selection + * + * @deprecated since 1.17 Use jquery.checkboxShiftClick instead + */ + msg = 'Use jquery.checkboxShiftClick instead.'; + mw.log.deprecate( win, 'checkboxes', [], msg ); + mw.log.deprecate( win, 'lastCheckbox', null, msg ); + mw.log.deprecate( win, 'setupCheckboxShiftClick', $.noop, msg ); + mw.log.deprecate( win, 'addCheckboxClickHandlers', $.noop, msg ); + mw.log.deprecate( win, 'checkboxClickHandler', $.noop, msg ); + + /** + * Add a button to the default editor toolbar + * + * @deprecated since 1.17 Use mw.toolbar instead + */ + mw.log.deprecate( win, 'mwEditButtons', [], 'Use mw.toolbar instead.' ); + mw.log.deprecate( win, 'mwCustomEditButtons', [], 'Use mw.toolbar instead.' ); + + /** + * Spinner creation, injection and removal + * + * @deprecated since 1.18 Use jquery.spinner instead + */ + mw.log.deprecate( win, 'injectSpinner', $.noop, 'Use jquery.spinner instead.' ); + mw.log.deprecate( win, 'removeSpinner', $.noop, 'Use jquery.spinner instead.' ); + + /** + * Escape utilities + * + * @deprecated since 1.18 Use mw.html instead + */ + mw.log.deprecate( win, 'escapeQuotes', $.noop, 'Use mw.html instead.' ); + mw.log.deprecate( win, 'escapeQuotesHTML', $.noop, 'Use mw.html instead.' ); + + /** + * Display a message to the user + * + * @deprecated since 1.17 Use mediawiki.notify instead + * @param {string|HTMLElement} message To be put inside the message box + */ + mw.log.deprecate( win, 'jsMsg', function ( message ) { + if ( !arguments.length || message === '' || message === null ) { + return true; + } + if ( typeof message !== 'object' ) { + message = $.parseHTML( message ); + } + mw.notify( message, { autoHide: true, tag: 'legacy' } ); return true; - } - if ( typeof message !== 'object' ) { - message = $.parseHTML( message ); - } - mw.notify( message, { autoHide: true, tag: 'legacy' } ); - return true; -}, 'Use mediawiki.notify instead.' ); - -/** - * Misc. utilities - * - * @deprecated since 1.17 Use mediawiki.util or jquery.accessKeyLabel instead - */ -msg = 'Use mediawiki.util instead.'; -mw.log.deprecate( win, 'addPortletLink', mw.util.addPortletLink, msg ); -mw.log.deprecate( win, 'appendCSS', mw.util.addCSS, msg ); -msg = 'Use jquery.accessKeyLabel instead.'; -mw.log.deprecate( win, 'tooltipAccessKeyPrefix', 'alt-', msg ); -mw.log.deprecate( win, 'tooltipAccessKeyRegexp', /\[(alt-)?(.)\]$/, msg ); -// mw.util.updateTooltipAccessKeys already generates a deprecation message. -win.updateTooltipAccessKeys = function () { - return mw.util.updateTooltipAccessKeys.apply( null, arguments ); -}; - -/** - * Wikipage import methods - */ - -// included-scripts tracker -win.loadedScripts = {}; - -win.importScript = function ( page ) { - var uri = mw.config.get( 'wgScript' ) + '?title=' + - mw.util.wikiUrlencode( page ) + - '&action=raw&ctype=text/javascript'; - return win.importScriptURI( uri ); -}; - -win.importScriptURI = function ( url ) { - if ( win.loadedScripts[url] ) { - return null; - } - win.loadedScripts[url] = true; - var s = document.createElement( 'script' ); - s.setAttribute( 'src', url ); - s.setAttribute( 'type', 'text/javascript' ); - document.getElementsByTagName( 'head' )[0].appendChild( s ); - return s; -}; - -win.importStylesheet = function ( page ) { - var uri = mw.config.get( 'wgScript' ) + '?title=' + - mw.util.wikiUrlencode( page ) + - '&action=raw&ctype=text/css'; - return win.importStylesheetURI( uri ); -}; - -win.importStylesheetURI = function ( url, media ) { - var l = document.createElement( 'link' ); - l.rel = 'stylesheet'; - l.href = url; - if ( media ) { - l.media = media; - } - document.getElementsByTagName( 'head' )[0].appendChild( l ); - return l; -}; + }, 'Use mediawiki.notify instead.' ); + + /** + * Misc. utilities + * + * @deprecated since 1.17 Use mediawiki.util or jquery.accessKeyLabel instead + */ + msg = 'Use mediawiki.util instead.'; + mw.log.deprecate( win, 'addPortletLink', mw.util.addPortletLink, msg ); + mw.log.deprecate( win, 'appendCSS', mw.util.addCSS, msg ); + msg = 'Use jquery.accessKeyLabel instead.'; + mw.log.deprecate( win, 'tooltipAccessKeyPrefix', 'alt-', msg ); + mw.log.deprecate( win, 'tooltipAccessKeyRegexp', /\[(alt-)?(.)\]$/, msg ); + // mw.util.updateTooltipAccessKeys already generates a deprecation message. + win.updateTooltipAccessKeys = function () { + return mw.util.updateTooltipAccessKeys.apply( null, arguments ); + }; + + /** + * Wikipage import methods + */ + + // included-scripts tracker + win.loadedScripts = {}; + + win.importScript = function ( page ) { + var uri = mw.config.get( 'wgScript' ) + '?title=' + + mw.util.wikiUrlencode( page ) + + '&action=raw&ctype=text/javascript'; + return win.importScriptURI( uri ); + }; + + win.importScriptURI = function ( url ) { + if ( win.loadedScripts[url] ) { + return null; + } + win.loadedScripts[url] = true; + var s = document.createElement( 'script' ); + s.setAttribute( 'src', url ); + s.setAttribute( 'type', 'text/javascript' ); + document.getElementsByTagName( 'head' )[0].appendChild( s ); + return s; + }; + + win.importStylesheet = function ( page ) { + var uri = mw.config.get( 'wgScript' ) + '?title=' + + mw.util.wikiUrlencode( page ) + + '&action=raw&ctype=text/css'; + return win.importStylesheetURI( uri ); + }; + + win.importStylesheetURI = function ( url, media ) { + var l = document.createElement( 'link' ); + l.rel = 'stylesheet'; + l.href = url; + if ( media ) { + l.media = media; + } + document.getElementsByTagName( 'head' )[0].appendChild( l ); + return l; + }; }( mediaWiki, jQuery ) ); diff --git a/resources/src/mediawiki.page/mediawiki.page.image.pagination.js b/resources/src/mediawiki.page/mediawiki.page.image.pagination.js index 26c32a5fa3..9ad9c30a79 100644 --- a/resources/src/mediawiki.page/mediawiki.page.image.pagination.js +++ b/resources/src/mediawiki.page/mediawiki.page.image.pagination.js @@ -3,7 +3,8 @@ */ ( function ( mw, $ ) { var jqXhr, $multipageimage, $spinner, - cache = {}, cacheOrder = []; + cache = {}, + cacheOrder = []; /* Fetch the next page, caching up to 10 last-loaded pages. * @param {string} url diff --git a/resources/src/mediawiki.special/mediawiki.special.preferences.js b/resources/src/mediawiki.special/mediawiki.special.preferences.js index 043d769329..a3eedd6dba 100644 --- a/resources/src/mediawiki.special/mediawiki.special.preferences.js +++ b/resources/src/mediawiki.special/mediawiki.special.preferences.js @@ -41,7 +41,7 @@ jQuery( function ( $ ) { } else { $( this ).css( 'height', 'auto' ); } - } ).insertBefore( $preftoc ); + } ).insertBefore( $preftoc ); /** * It uses document.getElementById for security reasons (HTML injections in $()). diff --git a/resources/src/mediawiki.special/mediawiki.special.upload.js b/resources/src/mediawiki.special/mediawiki.special.upload.js index f405c7a5b1..2f03c518f7 100644 --- a/resources/src/mediawiki.special/mediawiki.special.upload.js +++ b/resources/src/mediawiki.special/mediawiki.special.upload.js @@ -6,8 +6,9 @@ * @singleton */ ( function ( mw, $ ) { - var ajaxUploadDestCheck = mw.config.get( 'wgAjaxUploadDestCheck' ), - $license = $( '#wpLicense' ), uploadWarning, uploadLicense; + var uploadWarning, uploadLicense, + ajaxUploadDestCheck = mw.config.get( 'wgAjaxUploadDestCheck' ), + $license = $( '#wpLicense' ); window.wgUploadWarningObj = uploadWarning = { responseCache: { '': ' ' }, diff --git a/resources/src/mediawiki/mediawiki.Title.js b/resources/src/mediawiki/mediawiki.Title.js index eaf079f2f1..3efb7ecadc 100644 --- a/resources/src/mediawiki/mediawiki.Title.js +++ b/resources/src/mediawiki/mediawiki.Title.js @@ -731,7 +731,10 @@ set: function ( titles, state ) { titles = $.isArray( titles ) ? titles : [titles]; state = state === undefined ? true : !!state; - var pages = this.pages, i, len = titles.length; + var i, + pages = this.pages, + len = titles.length; + for ( i = 0; i < len; i++ ) { pages[ titles[i] ] = state; } diff --git a/resources/src/mediawiki/mediawiki.inspect.js b/resources/src/mediawiki/mediawiki.inspect.js index 3ad2be5f2d..22d3cbb31b 100644 --- a/resources/src/mediawiki/mediawiki.inspect.js +++ b/resources/src/mediawiki/mediawiki.inspect.js @@ -19,7 +19,9 @@ function humanSize( bytes ) { if ( !$.isNumeric( bytes ) || bytes === 0 ) { return bytes; } - var i = 0, units = [ '', ' kB', ' MB', ' GB', ' TB', ' PB' ]; + var i = 0, + units = [ '', ' kB', ' MB', ' GB', ' TB', ' PB' ]; + for ( ; bytes >= 1024; bytes /= 1024 ) { i++; } // Maintain one decimal for kB and above, but don't // add ".0" for bytes. @@ -39,7 +41,8 @@ * two properties, 'requires' and 'requiredBy'. */ getDependencyGraph: function () { - var modules = inspect.getLoadedModules(), graph = {}; + var modules = inspect.getLoadedModules(), + graph = {}; $.each( modules, function ( moduleIndex, moduleName ) { var dependencies = mw.loader.moduleRegistry[moduleName].dependencies || []; diff --git a/resources/src/mediawiki/mediawiki.jqueryMsg.js b/resources/src/mediawiki/mediawiki.jqueryMsg.js index 3eaa6d2cd1..b5c2dba943 100644 --- a/resources/src/mediawiki/mediawiki.jqueryMsg.js +++ b/resources/src/mediawiki/mediawiki.jqueryMsg.js @@ -267,7 +267,8 @@ * @return {string|Array} string of '[key]' if message missing, simple string if possible, array of arrays if needs parsing */ getAst: function ( key ) { - var cacheKey = [key, this.settings.onlyCurlyBraceTransform].join( ':' ), wikiText; + var wikiText, + cacheKey = [key, this.settings.onlyCurlyBraceTransform].join( ':' ); if ( this.astCache[ cacheKey ] === undefined ) { wikiText = this.settings.messages.get( key ); @@ -290,7 +291,7 @@ * @return {Mixed} abstract syntax tree */ wikiTextToAst: function ( input ) { - var pos, settings = this.settings, concat = Array.prototype.concat, + var pos, regularLiteral, regularLiteralWithoutBar, regularLiteralWithoutSpace, regularLiteralWithSquareBrackets, doubleQuote, singleQuote, backslash, anyCharacter, asciiAlphabetLiteral, escapedOrLiteralWithoutSpace, escapedOrLiteralWithoutBar, escapedOrRegularLiteral, @@ -298,7 +299,9 @@ htmlAttributeEquals, openHtmlStartTag, optionalForwardSlash, openHtmlEndTag, closeHtmlTag, openExtlink, closeExtlink, wikilinkPage, wikilinkContents, openWikilink, closeWikilink, templateName, pipe, colon, templateContents, openTemplate, closeTemplate, - nonWhitespaceExpression, paramExpression, expression, curlyBraceTransformExpression, result; + nonWhitespaceExpression, paramExpression, expression, curlyBraceTransformExpression, result, + settings = this.settings, + concat = Array.prototype.concat; // Indicates current position in input as we parse through it. // Shared among all parsing functions below. @@ -686,10 +689,10 @@ // Subset of allowed HTML markup. // Most elements and many attributes allowed on the server are not supported yet. function html() { - var result = null, parsedOpenTagResult, parsedHtmlContents, - parsedCloseTagResult, wrappedAttributes, attributes, - startTagName, endTagName, startOpenTagPos, startCloseTagPos, - endOpenTagPos, endCloseTagPos; + var parsedOpenTagResult, parsedHtmlContents, parsedCloseTagResult, + wrappedAttributes, attributes, startTagName, endTagName, startOpenTagPos, + startCloseTagPos, endOpenTagPos, endCloseTagPos, + result = null; // Break into three sequence calls. That should allow accurate reconstruction of the original HTML, and requiring an exact tag name match. // 1. open through closeHtmlTag @@ -1015,16 +1018,11 @@ page = nodes[0]; url = mw.util.getUrl( page ); - // [[Some Page]] or [[Namespace:Some Page]] if ( nodes.length === 1 ) { + // [[Some Page]] or [[Namespace:Some Page]] anchor = page; - } - - /* - * [[Some Page|anchor text]] or - * [[Namespace:Some Page|anchor] - */ - else { + } else { + // [[Some Page|anchor text]] or [[Namespace:Some Page|anchor]] anchor = nodes[1]; } @@ -1129,8 +1127,8 @@ * @return {string} selected pluralized form according to current language */ plural: function ( nodes ) { - var forms, firstChild, firstChildText, - explicitPluralForms = {}, explicitPluralFormNumber, formIndex, form, count; + var forms, firstChild, firstChildText, explicitPluralFormNumber, formIndex, form, count, + explicitPluralForms = {}; count = parseFloat( this.language.convertNumber( nodes[0], true ) ); forms = nodes.slice( 1 ); diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index 98a2f6a7f4..f2cdaabb50 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -1397,7 +1397,10 @@ } function sortQuery( o ) { - var sorted = {}, key, a = []; + var key, + sorted = {}, + a = []; + for ( key in o ) { if ( hasOwn.call( o, key ) ) { a.push( key ); @@ -1416,7 +1419,9 @@ * @private */ function buildModulesString( moduleMap ) { - var arr = [], p, prefix; + var p, prefix, + arr = []; + for ( prefix in moduleMap ) { p = prefix === '' ? '' : prefix + '.'; arr.push( p + moduleMap[prefix].join( ',' ) ); diff --git a/resources/src/mediawiki/mediawiki.util.js b/resources/src/mediawiki/mediawiki.util.js index d2022704a9..2c3c90fc14 100644 --- a/resources/src/mediawiki/mediawiki.util.js +++ b/resources/src/mediawiki/mediawiki.util.js @@ -340,7 +340,7 @@ // HTML5 defines a string as valid e-mail address if it matches // the ABNF: - // 1 * ( atext / "." ) "@" ldh-str 1*( "." ldh-str ) + // 1 * ( atext / "." ) "@" ldh-str 1*( "." ldh-str ) // With: // - atext : defined in RFC 5322 section 3.2.3 // - ldh-str : defined in RFC 1034 section 3.5 @@ -361,12 +361,12 @@ rfc5322Atext = 'a-z0-9!#$%&\'*+\\-/=?^_`{|}~'; // Next define the RFC 1034 'ldh-str' - // ::= | " " - // ::=