build: Replace jscs+jshint with eslint
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.util.js
index 654f232..bee22c7 100644 (file)
                                query = $.param( params );
                        }
                        if ( query ) {
-                               url = title
-                                       ? util.wikiScript() + '?title=' + util.wikiUrlencode( title ) + '&' + query
-                                       util.wikiScript() + '?' + query;
+                               url = title ?
+                                       util.wikiScript() + '?title=' + util.wikiUrlencode( title ) + '&' + query :
+                                       util.wikiScript() + '?' + query;
                        } else {
                                url = mw.config.get( 'wgArticlePath' )
                                        .replace( '$1', util.wikiUrlencode( title ).replace( /\$/g, '$$$$' ) );
                 * @return {Mixed} Parameter value or null.
                 */
                getParamValue: function ( param, url ) {
-                       if ( url === undefined ) {
-                               url = location.href;
-                       }
                        // Get last match, stop at hash
                        var     re = new RegExp( '^[^#]*[&?]' + mw.RegExp.escape( param ) + '=([^&#]*)' ),
-                               m = re.exec( url );
+                               m = re.exec( url !== undefined ? url : location.href );
+
                        if ( m ) {
                                // Beware that decodeURIComponent is not required to understand '+'
                                // by spec, as encodeURIComponent does not produce it.
 
                        html5EmailRegexp = new RegExp(
                                // start of string
-                               '^'
-                               +
+                               '^' +
                                // User part which is liberal :p
-                               '[' + rfc5322Atext + '\\.]+'
-                               +
+                               '[' + rfc5322Atext + '\\.]+' +
                                // 'at'
-                               '@'
-                               +
+                               '@' +
                                // Domain first part
-                               '[' + rfc1034LdhStr + ']+'
-                               +
+                               '[' + rfc1034LdhStr + ']+' +
                                // Optional second part and following are separated by a dot
-                               '(?:\\.[' + rfc1034LdhStr + ']+)*'
-                               +
+                               '(?:\\.[' + rfc1034LdhStr + ']+)*' +
                                // End of string
                                '$',
                                // RegExp is case insensitive
                 * @return {boolean}
                 */
                isIPv4Address: function ( address, allowBlock ) {
+                       var block, RE_IP_BYTE, RE_IP_ADD;
+
                        if ( typeof address !== 'string' ) {
                                return false;
                        }
 
-                       var     block = allowBlock ? '(?:\\/(?:3[0-2]|[12]?\\d))?' : '',
-                               RE_IP_BYTE = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])',
-                               RE_IP_ADD = '(?:' + RE_IP_BYTE + '\\.){3}' + RE_IP_BYTE;
+                       block = allowBlock ? '(?:\\/(?:3[0-2]|[12]?\\d))?' : '';
+                       RE_IP_BYTE = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])';
+                       RE_IP_ADD = '(?:' + RE_IP_BYTE + '\\.){3}' + RE_IP_BYTE;
 
                        return ( new RegExp( '^' + RE_IP_ADD + block + '$' ).test( address ) );
                },
                 * @return {boolean}
                 */
                isIPv6Address: function ( address, allowBlock ) {
+                       var block, RE_IPV6_ADD;
+
                        if ( typeof address !== 'string' ) {
                                return false;
                        }
 
-                       var     block = allowBlock ? '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?' : '',
-                               RE_IPV6_ADD =
-                       '(?:' + // starts with "::" (including "::")
-                       ':(?::|(?::' + '[0-9A-Fa-f]{1,4}' + '){1,7})' +
-                       '|' + // ends with "::" (except "::")
-                       '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){0,6}::' +
-                       '|' + // contains no "::"
-                       '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){7}' +
-                       ')';
+                       block = allowBlock ? '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?' : '';
+                       RE_IPV6_ADD =
+                               '(?:' + // starts with "::" (including "::")
+                               ':(?::|(?::' + '[0-9A-Fa-f]{1,4}' + '){1,7})' +
+                               '|' + // ends with "::" (except "::")
+                               '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){0,6}::' +
+                               '|' + // contains no "::"
+                               '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){7}' +
+                               ')';
 
                        if ( new RegExp( '^' + RE_IPV6_ADD + block + '$' ).test( address ) ) {
                                return true;
                        RE_IPV6_ADD = '[0-9A-Fa-f]{1,4}' + '(?:::?' + '[0-9A-Fa-f]{1,4}' + '){1,6}';
 
                        return (
-                               new RegExp( '^' + RE_IPV6_ADD + block + '$' ).test( address )
-                               && /::/.test( address )
-                               && !/::.*::/.test( address )
+                               new RegExp( '^' + RE_IPV6_ADD + block + '$' ).test( address ) &&
+                               /::/.test( address ) &&
+                               !/::.*::/.test( address )
                        );
                },