+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/IEFixes.js
- *
- * Internet Explorer JavaScript fixes
- */
-
-( function( $, mw ) {
-
-/* Support */
-
-/**
- * Expand links for printing
- */
-String.prototype.hasClass = function( classWanted ) {
- var classArr = this.split(/\s/);
- for ( var i = 0; i < classArr.length; i++ ) {
- if ( classArr[i].toLowerCase() == classWanted.toLowerCase() ) {
- return true;
- }
- }
- return false;
-}
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Global Variables */
-
- 'isMSIE55': ( window.showModalDialog && window.clipboardData && window.createPopup ),
- 'doneIETransform': null,
- 'doneIEAlphaFix': null,
- 'expandedURLs': null,
-
- /* Functions */
-
- 'hookit': function() {
- if ( !doneIETransform && document.getElementById && document.getElementById( 'bodyContent' ) ) {
- doneIETransform = true;
- relativeforfloats();
- fixalpha();
- }
- },
- /**
- * Fixes PNG alpha transparency
- */
- function fixalpha( logoId ) {
- // bg
- if ( isMSIE55 && !doneIEAlphaFix ) {
- var plogo = document.getElementById( logoId || 'p-logo' );
- if ( !plogo ) {
- return;
- }
- var logoa = plogo.getElementsByTagName('a')[0];
- if ( !logoa ) {
- return;
- }
- var bg = logoa.currentStyle.backgroundImage;
- var imageUrl = bg.substring( 5, bg.length - 2 );
- doneIEAlphaFix = true;
- if ( imageUrl.substr( imageUrl.length - 4 ).toLowerCase() == '.png' ) {
- var logospan = logoa.appendChild( document.createElement( 'span' ) );
- logoa.style.backgroundImage = 'none';
- logospan.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + imageUrl + ')';
- logospan.style.height = '100%';
- logospan.style.position = 'absolute';
- logospan.style.width = logoa.currentStyle.width;
- logospan.style.cursor = 'hand';
- // Center image with hack for IE5.5
- if ( document.documentElement.dir == 'rtl' ) {
- logospan.style.right = '50%';
- logospan.style.setExpression( 'marginRight', '"-" + (this.offsetWidth / 2) + "px"' );
- } else {
- logospan.style.left = '50%';
- logospan.style.setExpression( 'marginLeft', '"-" + (this.offsetWidth / 2) + "px"' );
- }
- logospan.style.top = '50%';
- logospan.style.setExpression( 'marginTop', '"-" + (this.offsetHeight / 2) + "px"' );
- var linkFix = logoa.appendChild( logoa.cloneNode() );
- linkFix.style.position = 'absolute';
- linkFix.style.height = '100%';
- linkFix.style.width = '100%';
- }
- }
- },
- /*
- * Fixes IE6 disappering float bug
- */
- 'relativeforfloats': function() {
- var bc = document.getElementById( 'bodyContent' );
- if ( bc ) {
- var tables = bc.getElementsByTagName( 'table' );
- var divs = bc.getElementsByTagName( 'div' );
- }
- setrelative( tables );
- setrelative( divs );
- },
- 'setrelative': function ( nodes ) {
- var i = 0;
- while ( i < nodes.length ) {
- if( ( ( nodes[i].style.float && nodes[i].style.float != ( 'none' ) ||
- ( nodes[i].align && nodes[i].align != ( 'none' ) ) ) &&
- ( !nodes[i].style.position || nodes[i].style.position != 'relative' ) ) )
- {
- nodes[i].style.position = 'relative';
- }
- i++;
- }
- },
- 'onbeforeprint': function() {
- expandedURLs = [];
- var contentEl = document.getElementById( 'content' );
- if ( contentEl ) {
- var allLinks = contentEl.getElementsByTagName( 'a' );
- for ( var i = 0; i < allLinks.length; i++ ) {
- if ( allLinks[i].className.hasClass( 'external' ) && !allLinks[i].className.hasClass( 'free' ) ) {
- var expandedLink = document.createElement( 'span' );
- var expandedText = document.createTextNode( ' (' + allLinks[i].href + ')' );
- expandedLink.appendChild( expandedText );
- allLinks[i].parentNode.insertBefore( expandedLink, allLinks[i].nextSibling );
- expandedURLs[i] = expandedLink;
- }
- }
- }
- },
- 'onafterprint': function() {
- for ( var i = 0; i < expandedURLs.length; i++ ) {
- if ( expandedURLs[i] ) {
- expandedURLs[i].removeNode( true );
- }
- }
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- mw.legacy.hookit();
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/ajax.js
- *
- * Original licensing information:
- * Remote Scripting Library
- * (c) Copyright 2005 ModernMethod, Inc.
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Global Variables */
-
- 'sajax_debug_mode': false,
- 'sajax_debug_mode': 'GET',
-
- /* Functions */
-
- /**
- * 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
- *
- * @param string text debug message to append to log
- * @return boolean true when in debug mode, false when not
- */
- 'sajax_debug': function( text ) {
- if ( mw.legacy.sajax_debug_mode ) {
- var $e = $( '#sajax_debug' );
- if ( !$e.length ) {
- $e = $( '<p class="sajax_debug" id="sajax_debug"></p>' ).prependTo( $( 'body' ) );
- }
- $e.append( $( '<div></div>' ).text( text ) );
- return true;
- }
- return false;
- },
- /**
- * Gets an XMLHttpRequest or equivilant ActiveXObject
- *
- * @reuturn mixed request object on success, boolean false on failure
- */
- 'sajax_init_object': function() {
- mw.legacy.sajax_debug( 'sajax_init_object() called..' );
- var request = false;
- try {
- // Try the 'new' style before ActiveX so we don't unnecessarily trigger warnings in IE 7 when the user's
- // security settings are set to prompt about ActiveX usage
- request = new XMLHttpRequest();
- } catch ( e ) {
- try {
- request = new ActiveXObject( 'Msxml2.XMLHTTP' );
- } catch ( e ) {
- try {
- request = new ActiveXObject( 'Microsoft.XMLHTTP' );
- } catch ( oc ) {
- request = null;
- }
- }
- }
- if ( !request ) {
- mw.legacy.sajax_debug( 'Could not create connection object.' );
- }
- return request;
- },
- /**
- * Performs an ajax call to mediawiki. Calls are handeled by AjaxDispatcher.php
- *
- * @param string method name of the function to call. Must be registered in $wgAjaxExportList
- * @param array arguments arguments to that function
- * @param mixed 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
- * // 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
- * sajax_do_call( 'doFoo', [1, 2, 3], document.getElementById( 'showFoo' ) );
- */
- 'sajax_do_call': function( method, arguments, target ) {
- var post_data;
- var uri = mw.legacy.wgServer +
- ( ( mw.legacy.wgScript == null ) ? ( mw.legacy.wgScriptPath + '/index.php' ) : mw.legacy.wgScript ) +
- '?action=ajax';
- if ( mw.legacy.sajax_request_type == 'GET' ) {
- if ( uri.indexOf( '?' ) == -1 ) {
- uri = uri + '?rs=' + encodeURIComponent( method );
- } else {
- uri = uri + '&rs=' + encodeURIComponent( method );
- }
- for ( var i = 0; i < arguments.length; i++ ) {
- uri = uri + '&rsargs[]=' + encodeURIComponent( arguments[i] );
- }
- post_data = null;
- } else {
- post_data = 'rs=' + encodeURIComponent( method );
- for ( var i = 0; i < arguments.length; i++ ) {
- post_data = post_data + '&rsargs[]=' + encodeURIComponent( arguments[i] );
- }
- }
- var request = mw.legacy.sajax_init_object();
- if ( !request ) {
- alert( 'AJAX not supported' );
- return false;
- }
- try {
- request.open( mw.legacy.sajax_request_type, uri, true );
- } catch ( e ) {
- if ( window.location.hostname == 'localhost' ) {
- alert(
- 'Your browser blocks XMLHttpRequest to \'localhost\', ' +
- 'try using a real hostname for development/testing.'
- );
- }
- throw e;
- }
- if ( mw.legacy.sajax_request_type == 'POST' ) {
- request.setRequestHeader( 'Method', 'POST ' + uri + ' HTTP/1.1' );
- request.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
- }
- request.setRequestHeader( 'Pragma', 'cache=yes' );
- request.setRequestHeader( 'Cache-Control', 'no-transform' );
- request.onreadystatechange = function() {
- if ( request.readyState != 4 ) {
- return;
- }
- mw.legacy.sajax_debug(
- 'received (' + request.status + ' ' + request.statusText + ') ' + request.responseText
- );
- if ( typeof( target ) == 'function' ) {
- target( request );
- } else if ( typeof( target ) == 'object' ) {
- $target = $( target );
- if ( $target.is( 'input' ) ) {
- if ( request.status == 200 ) {
- $target.val();
- }
- } else {
- if ( request.status == 200 ) {
- $target.html( request.responseText );
- } else {
- $target.html(
- '<div class="error">' +
- 'Error: ' + request.status + ' ' + request.statusText +
- ' (' + request.responseText + ')' +
- '</div>'
- );
- }
- }
- } else {
- alert( 'Bad target for sajax_do_call: not a function or object: ' + target );
- }
- return;
- }
- mw.legacy.sajax_debug( method + ' uri = ' + uri + ' / post = ' + post_data );
- request.send( post_data );
- mw.legacy.sajax_debug( method + ' waiting..' );
- delete x;
- return true;
- },
- /**
- * Ajax compatibility test
- *
- * @return boolean whether the browser supports XMLHttpRequest
- */
- 'wfSupportsAjax': function() {
- var request = mw.legacy.sajax_init_object();
- var result = request ? true : false;
- delete request;
- return result;
- }
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/ajaxwatch.js
- *
- * AJAX functionality for the watch/unwatch link
- *
- * @depends mw.legacy.jsMsg() from mw.legacy.wikibits.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Global Variables */
-
- 'wgAjaxWatch': {
-
- /* Global Variables */
-
- 'watchMsg': 'Watch',
- 'unwatchMsg': 'Unwatch',
- 'watchingMsg': 'Watching...',
- 'unwatchingMsg': 'Unwatching...',
- 'tooltip-ca-watchMsg': 'Add this page to your watchlist',
- 'tooltip-ca-unwatchMsg': 'Remove this page from your watchlist',
-
- /* Functions */
-
- /**
- * Sets the text of the watch/unwatch link
- *
- * @param object link DOM node or jQuery selection of link to set text of
- * @param string action message to use ('watch', 'unwatch', 'watching' or 'unwatching')
- */
- 'setLinkText': function( link, action ) {
- var $link = $( link );
- if ( action == 'watch' || action == 'unwatch' ) {
- // save the accesskey from the title
- var keyCommand = $link.attr( 'title' ).match( /\[.*?\]$/ ) ?
- $link.attr( 'title' ).match( /\[.*?\]$/ )[0] : '';
- $link.attr( 'title', wgAjaxWatch['tooltip-ca-' + action + 'Msg'] + ' ' + keyCommand );
- }
- if ( $link.data( 'icon' ) ) {
- $link.attr( 'alt', wgAjaxWatch[action + 'Msg'] );
- if ( action == 'watching' || action == 'unwatching' ) {
- $link.addClass( 'loading' );
- } else {
- $link.removeClass( 'loading' );
- }
- } else {
- $link.html( wgAjaxWatch[action+'Msg'] );
- }
- },
- /**
- * Processes responses from the server
- *
- * @param object response data from server
- */
- 'processResult': function( response ) {
- response = response.watch;
- var $link = $(this);
- // To ensure we set the same status for all watch links with the same target we trigger a custom event on
- // *all* watch links.
- if ( response.watched !== undefined ) {
- wgAjaxWatch.$links.trigger( 'mw-ajaxwatch', [response.title, 'watch'] );
- } else if ( response.unwatched !== undefined ){
- wgAjaxWatch.$links.trigger( 'mw-ajaxwatch', [response.title, 'unwatch'] );
- } else {
- // Either we got an error code or it just plain broke.
- window.location.href = $link.attr( 'href' );
- return;
- }
- mw.legacy.jsMsg( response.message, 'watch' );
- // Bug 12395 - update the watch checkbox on edit pages when the page is watched or unwatched via the tab.
- if ( response.watched !== undefined ) {
- $j( '#wpWatchthis' ).attr( 'checked', '1' );
- } else {
- $j( '#wpWatchthis' ).removeAttr( 'checked' );
- }
- }
- } );
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- var $links = $( '.mw-watchlink a, a.mw-watchlink' );
- // BC with older skins...
- $links = $links
- .add( $( '#ca-watch a, #ca-unwatch a, a#mw-unwatch-link1' ) )
- .add( $( 'a#mw-unwatch-link2, a#mw-watch-link2, a#mw-watch-link1' ) );
- // ...allowing people to add inline animated links is a little scary
- $links = $links.filter( ':not( #bodyContent *, #content * )' );
- $links.each( function() {
- var $link = $(this);
- $link
- .data( 'icon', $link.parent().hasClass( 'icon' ) )
- .data( 'action', $link.attr( 'href' ).match( /[\?\&]action=unwatch/i ) ? 'unwatch' : 'watch' );
- var title = $link.attr( 'href' ).match( /[\?\&]title=(.*?)&/i )[1];
- $link.data( 'target', decodeURIComponent( title ).replace( /_/g, ' ' ) );
- } );
- $links.click( function( event ) {
- var $link = $(this);
- if ( mw.legacy.wgAjaxWatch.supported === false || !mw.legacy.wgEnableWriteAPI || !mw.legacy.wfSupportsAjax() ) {
- // Lazy initialization so we don't toss up ActiveX warnings on initial page load for IE 6 users with
- // security settings.
- mw.legacy.wgAjaxWatch.$links.unbind( 'click' );
- return true;
- }
- mw.legacy.wgAjaxWatch.setLinkText( $link, $link.data( 'action' ) + 'ing' );
- var url = mw.legacy.wgScriptPath + '/api' + mw.legacy.wgScriptExtension + '?action=watch&format=json&title='
- + encodeURIComponent( $link.data( 'target' ) ) + ( $link.data( 'action' ) == 'unwatch' ? '&unwatch' : '' );
- $.get( url, {}, mw.legacy.wgAjaxWatch.processResult, 'json' );
- return false;
- } );
- // When a request returns, a custom event 'mw-ajaxwatch' is triggered on *all* watch links, so they can be updated
- // if necessary
- $links.bind( 'mw-ajaxwatch', function( event, target, action ) {
- var $link = $(this);
- var foo = $link.data( 'target' );
- if ( $link.data( 'target' ) == target ) {
- var otheraction = action == 'watch' ? 'unwatch' : 'watch';
- $link.data( 'action', otheraction );
- wgAjaxWatch.setLinkText( $link, otheraction );
- $link.attr( 'href', $link.attr( 'href' ).replace( '/&action=' + action + '/', '&action=' + otheraction ) );
- if ( $link.parent().attr( 'id' ) == 'ca-' + action ){
- $link.parent().attr( 'id', 'ca-' + otheraction );
- }
- }
- return false;
- } );
- mw.legacy.wgAjaxWatch.$links = $links;
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/block.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Functions */
-
- 'considerChangingExpiryFocus': function() {
- var $expiry = $( '#wpBlockExpiry' );
- var $other = $( '#wpBlockOther' );
- if ( $expiry.length && $other.length ) {
- if ( $expiry.val() == 'other' ) {
- $other.css( 'display', '' );
- } else {
- $other.css( 'display', 'none' );
- }
- }
- },
- 'updateBlockOptions': function() {
- var $target = $( '#mw-bi-target' );
- if ( $target.length ) {
- var address = $target.val();
- var isEmpty = address.match( /^\s*$/ );
- var isIp = address.match( /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7})(\/\d+)?$/ );
- var isIpRange = isIp && address.match( /\/\d+$/ );
- $( '#wpAnonOnlyRow' ).css( 'display', !isIp && !isEmpty ? 'none' : '' );
- $( '#wpEnableAutoblockRow,#wpEnableHideUser' ).css( 'display', isIp && !isEmpty ? 'none' : '' );
- $( '#wpEnableWatchUser' ).css( 'display', isIpRange && !isEmpty ? 'none' : '' );
- }
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- mw.legacy.considerChangingExpiryFocus();
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/changepassword.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Functions */
-
- 'onNameChange': function() {
- var state = mw.legacy.wgUserName != $( '#wpName' ).val();
- $( '#wpPassword' ).attr( 'disabled', state );
- $( '#wpComment' ).attr( 'disabled', !state );
- },
- 'onNameChangeHook': function() {
- $( '#wpName' ).blur( mw.legacy.onNameChange );
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- mw.legacy.onNameChangeHook();
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/edit.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Global Variables */
-
- 'currentFocused': null,
-
- /* Functions */
-
- /**
- * Generates the actual toolbar buttons with localized text we use it to avoid creating the toolbar
- * where javascript is not enabled
- */
- 'addButton': function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId ) {
- // Don't generate buttons for browsers which don't fully support it.
- mw.legacy.mwEditButtons.push( {
- 'imageId': imageId,
- 'imageFile': imageFile,
- 'speedTip': speedTip,
- 'tagOpen': tagOpen,
- 'tagClose': tagClose,
- 'sampleText': sampleText
- } );
- },
- /**
- * Generates the actual toolbar buttons with localized text we use it to avoid creating the toolbar where JavaScript
- * is not enabled
- */
- 'mwInsertEditButton': function( parent, item ) {
- var $image = $( '<img />' )
- .attr( {
- 'width': 23,
- 'height': 22,
- 'class': 'mw-toolbar-editbutton',
- 'id': item.imageId ? item.imageId : null,
- 'src': = item.imageFile,
- 'border': 0,
- 'alt': item.speedTip,
- 'title': item.speedTip
- } )
- .css( 'cursor', 'pointer' )
- .click( function() {
- mw.legacy.insertTags( item.tagOpen, item.tagClose, item.sampleText );
- // Click tracking
- if ( typeof $.trackAction != 'undefined' ) {
- $.trackAction( 'oldedit.' + item.speedTip.replace( / /g, '-' ) );
- }
- return false;
- } )
- .appendTo( $( parent ) );
- return true;
- },
- /**
- * Sets up the toolbar
- */
- 'mwSetupToolbar': function() {
- var $toolbar = $( '#toolbar' );
- var $textbox = $( 'textarea' ).get( 0 );
- if ( !$toolbar.length || !$textbox.length ) {
- return false;
- }
- // Only check for selection capability if the textarea is visible - errors will occur otherwise - just because
- // the textarea is not visible, doesn't mean we shouldn't build out the toolbar though - it might have been
- // replaced with some other kind of control
- if (
- $textbox.is( ':visible' ) &&
- !( document.selection && document.selection.createRange ) &&
- textboxes[0].selectionStart === null
- ) {
- return false;
- }
- for ( var i = 0; i < mw.legacy.mwEditButtons.length; i++ ) {
- mw.legacy.mwInsertEditButton( $toolbar, mw.legacy.mwEditButtons[i] );
- }
- for ( var i = 0; i < mw.legacy.mwCustomEditButtons.length; i++ ) {
- mw.legacy.mwInsertEditButton( $toolbar, mw.legacy.mwCustomEditButtons[i] );
- }
- return true;
- },
- /**
- * Apply tagOpen/tagClose to selection in textarea, use sampleText instead of selection if there is none
- */
- 'insertTags': function( tagOpen, tagClose, sampleText ) {
- function checkSelectedText() {
- if ( !selText ) {
- selText = sampleText;
- isSample = true;
- } else if ( selText.charAt( selText.length - 1 ) == ' ' ) { // exclude ending space char
- selText = selText.substring( 0, selText.length - 1 );
- tagClose += ' ';
- }
- }
- var currentFocused = $( mw.legacy.currentFocused );
- if (
- typeof $.fn.textSelection != 'undefined' &&
- ( $currentFocused.name().toLowerCase() == 'iframe' || $currentFocused.attr( 'id' ) == 'wpTextbox1' )
- ) {
- $j( '#wpTextbox1' ).textSelection(
- 'encapsulateSelection', { 'pre': tagOpen, 'peri': sampleText, 'post': tagClose }
- );
- return;
- }
- var $textarea;
- if ( $( 'form[name=editform]' ) {
- $textarea = $currentFocused;
- } else {
- // Some alternate form? take the first one we can find
- $textarea = $( 'textarea' ).get( 0 );
- }
- var selText, isSample = false;
- // Text selection implementation for IE and Opera
- if ( document.selection && document.selection.createRange ) {
- // Save window scroll position
- if ( document.documentElement && document.documentElement.scrollTop ) {
- var winScroll = document.documentElement.scrollTop
- } else if ( document.body ) {
- var winScroll = document.body.scrollTop;
- }
- // Get current selection
- $textarea.focus();
- var range = document.selection.createRange();
- selText = range.text;
- // Insert tags
- checkSelectedText();
- range.text = tagOpen + selText + tagClose;
- // Mark sample text as selected
- if ( isSample && range.moveStart ) {
- if ( window.opera ) {
- tagClose = tagClose.replace( /\n/g,'' );
- }
- range.moveStart( 'character', - tagClose.length - selText.length );
- range.moveEnd( 'character', - tagClose.length );
- }
- range.select();
- // Restore window scroll position
- if ( document.documentElement && document.documentElement.scrollTop ) {
- document.documentElement.scrollTop = winScroll;
- } else if ( document.body ) {
- document.body.scrollTop = winScroll;
- }
- }
- // Text selection implementation for Mozilla, Chrome and Safari
- else if ( $textarea[0].selectionStart || $textarea[0].selectionStart == '0' ) {
- // Save textarea scroll position
- var textScroll = $textarea.scrollTop;
- // Get current selection
- $textarea.focus();
- var startPos = $textarea[0].selectionStart;
- var endPos = $textarea[0].selectionEnd;
- selText = $textarea.value.substring( startPos, endPos );
- // Insert tags
- checkSelectedText();
- $textarea.val(
- $textarea.val().substring( 0, startPos ) +
- tagOpen + selText + tagClose +
- $textarea.val().substring( endPos, $textarea.val().length )
- );
- // Set new selection
- if ( isSample ) {
- $textarea[0].selectionStart = startPos + tagOpen.length;
- $textarea[0].selectionEnd = startPos + tagOpen.length + selText.length;
- } else {
- $textarea[0].selectionStart = startPos + tagOpen.length + selText.length + tagClose.length;
- $textarea[0].selectionEnd = $textarea[0].selectionStart;
- }
- // Restore textarea scroll position
- $textarea[0].scrollTop = textScroll;
- }
- },
- /**
- * Restore the edit box scroll state following a preview operation,
- * and set up a form submission handler to remember this state
- */
- 'scrollEditBox': function() {
- var $textbox = $( '#wpTextbox1' );
- var $scrollTop = $( '#wpScrolltop' );
- var $editForm = $( '#editform' );
- if ( $editForm.length && $textbox.length && $scrollTop.length ) {
- if ( scrollTop.val() ) {
- $textbox.scrollTop = $scrollTop.val();
- }
- $editForm.submit( function() {
- $scrollTop.val( $textbox.scrollTop );
- } );
- }
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- mw.legacy.scrollEditBox();
- mw.legacy.mwSetupToolbar();
- mw.legacy.currentFocused = $( '#wpTextbox1' ).get( 0 );
- // http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html focus does not bubble normally, but using a
- // trick we can do event delegation on the focus event on all text inputs to make the toolbox usable on all of them
- $( '#editform' ).focus( function() {
- $(this).each( function( e ) {
- var elm = e.target || e.srcElement;
- if ( !elm ) {
- return;
- }
- var tagName = elm.tagName.toLowerCase();
- var type = elm.type || '';
- if ( tagName !== 'textarea' && tagName !== 'input' ) {
- return;
- }
- if ( tagName === 'input' && type.toLowerCase() !== 'text' ) {
- return;
- }
- mw.legacy.currentFocused = elm;
- } );
- } );
- // HACK: make currentFocused work with the usability iframe - with proper focus detection support (HTML 5!) this'll
- // be much cleaner
- var $iframe = $j( '.wikiEditor-ui-text iframe' );
- if ( $iframe.length > 0 ) {
- $j( $iframe.get( 0 ).contentWindow.document )
- // For IE
- .add( $iframe.get( 0 ).contentWindow.document.body )
- .focus( function() { mw.legacy.currentFocused = $iframe.get( 0 ); } );
- }
- // Make sure edit summary does not exceed byte limit
- var $summary = $( '#wpSummary' );
- if ( !$summary.length ) {
- return;
- }
- // L must be capitalized in length
- $summary.get( 0 ).maxLength = 250;
- $summary.keypress( function( e ) {
- // First check to see if this is actually a character key being pressed. Based on key-event info from
- // http://unixpapa.com/js/key.html note === sign, if undefined, still could be a real key
- if ( e.which === 0 || e.charCode === 0 || e.ctrlKey || e.altKey || e.metaKey ) {
- // A special key (backspace, etc) so don't interefere.
- return true;
- }
- // This basically figures out how many bytes a utf-16 string (which is what js sees) will take in utf-8 by
- // replacing a 2 byte character with 2 *'s, etc, and counting that. Note, surogate (\uD800-\uDFFF) characters
- // are counted as 2 bytes, since theres two of them and the actual character takes 4 bytes in utf-8 (2*2=4).
- // Might not work perfectly in edge cases such as such as illegal sequences, but that should never happen.
- len = summary.value
- .replace(/[\u0080-\u07FF\uD800-\uDFFF]/g, '**')
- .replace(/[\u0800-\uD7FF\uE000-\uFFFF]/g, '***')
- .length;
- // 247 as this doesn't count character about to be inserted.
- if ( len > 247 ) {
- if ( e.preventDefault ) {
- e.preventDefault();
- }
- // IE
- e.returnValue = false;
- return false;
- }
- } );
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/enhancedchanges.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Functions */
-
- /**
- * Switch an RC line between hidden/shown
- *
- * @param integer idNumber : the id number of the RC group
- */
- 'toggleVisibility': function( idNumber ) {
- var elements = [
- '#mw-rc-openarrow-' + idNumber,
- '#mw-rc-closearrow-' + idNumber,
- '#mw-rc-subentries-' + idNumber
- ];
- $( elements.join( ',' ) ).toggleClass( 'mw-changeslist-hidden' ).toggleClass( 'mw-changeslist-expanded' );
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- /*
- * Add the CSS to hide parts that should be collapsed
- *
- * We do this with JS so everything will be expanded by default
- * if JS is disabled
- */
- $( 'head' ).append(
- '<style type="text/css">\
- .mw-changeslist-hidden { display:none; }\
- div.mw-changeslist-expanded { display:block; }\
- span.mw-changeslist-expanded { display:inline !important; visibility:visible !important; }\
- </style>'
- );
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/history.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Functions */
-
- 'historyRadios': function( parent ) {
- var inputs = parent.getElementsByTagName('input');
- var radios = [];
- for (var i = 0; i < inputs.length; i++) {
- if (inputs[i].name == 'diff' || inputs[i].name == 'oldid') {
- radios[radios.length] = inputs[i];
- }
- }
- return radios;
- },
- /*
- * Check selection and tweak visibility/class onclick
- */
- 'diffcheck': function() {
- var dli = false; // the li where the diff radio is checked
- var oli = false; // the li where the oldid radio is checked
- var hf = document.getElementById('pagehistory');
- if (!hf) {
- return true;
- }
- var lis = hf.getElementsByTagName('li');
- for (var i=0;i<lis.length;i++) {
- var inputs = historyRadios(lis[i]);
- if (inputs[1] && inputs[0]) {
- if (inputs[1].checked || inputs[0].checked) { // this row has a checked radio button
- if (inputs[1].checked && inputs[0].checked && inputs[0].value == inputs[1].value) {
- return false;
- }
- if (oli) { // it's the second checked radio
- if (inputs[1].checked) {
- if ( (typeof oli.className) != 'undefined') {
- oli.classNameOriginal = oli.className.replace( 'selected', '' );
- } else {
- oli.classNameOriginal = '';
- }
-
- oli.className = 'selected '+oli.classNameOriginal;
- return false;
- }
- } else if (inputs[0].checked) {
- return false;
- }
- if (inputs[0].checked) {
- dli = lis[i];
- }
- if (!oli) {
- inputs[0].style.visibility = 'hidden';
- }
- if (dli) {
- inputs[1].style.visibility = 'hidden';
- }
- if ( (typeof lis[i].className) != 'undefined') {
- lis[i].classNameOriginal = lis[i].className.replace( 'selected', '' );
- } else {
- lis[i].classNameOriginal = '';
- }
-
- lis[i].className = 'selected '+lis[i].classNameOriginal;
- oli = lis[i];
- } else { // no radio is checked in this row
- if (!oli) {
- inputs[0].style.visibility = 'hidden';
- } else {
- inputs[0].style.visibility = 'visible';
- }
- if (dli) {
- inputs[1].style.visibility = 'hidden';
- } else {
- inputs[1].style.visibility = 'visible';
- }
- if ( typeof lis[i].classNameOriginal != 'undefined' ) {
- lis[i].className = lis[i].classNameOriginal;
- }
- }
- }
- }
- return true;
- },
- /*
- * Attach event handlers to the input elements on history page
- */
- 'histrowinit': function() {
- var hf = document.getElementById('pagehistory');
- if (!hf) return;
- var lis = hf.getElementsByTagName('li');
- for (var i = 0; i < lis.length; i++) {
- var inputs = historyRadios(lis[i]);
- if (inputs[0] && inputs[1]) {
- inputs[0].onclick = diffcheck;
- inputs[1].onclick = diffcheck;
- }
- }
- diffcheck();
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- mw.legacy.histrowinit();
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/htmlform.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Global Variables */
-
- 'htmlforms': {
- 'selectOrOtherSelectChanged': function( e ) {
- var select;
- if ( !e ) {
- e = window.event;
- }
- if ( e.target ) {
- select = e.target;
- } else if ( e.srcElement ) {
- select = e.srcElement;
- }
- // Defeat Safari bug
- if ( select.nodeType == 3 ) {
- select = select.parentNode;
- }
- var id = select.id;
- var textbox = document.getElementById( id + '-other' );
- if ( select.value == 'other' ) {
- textbox.disabled = false;
- } else {
- textbox.disabled = true;
- }
- }
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- // Find select-or-other fields
- $( 'select .mw-htmlform-select-or-other' ).each( function() {
- $(this).change( function() { mw.legacy.htmlforms.selectOrOtherSelectChanged(); } );
- // Use a fake event to update it.
- mw.legacy.htmlforms.selectOrOtherSelectChanged( { 'target': $(this).get( 0 ) } );
- } );
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/metadata.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
- /**
- * Exif metadata display for MediaWiki file uploads
- *
- * Add an expand/collapse link and collapse by default if set to (with JS disabled, user will see all items)
- *
- * Example:
- * attachMetadataToggle( 'mw_metadata', 'More...', 'Fewer...' );
- */
- 'attachMetadataToggle': function( tableId, showText, hideText ) {
- if ( document.createTextNode ) {
- var box = document.getElementById( tableId );
- if ( !box ) {
- return false;
- }
- var tbody = box.getElementsByTagName('tbody')[0];
- var row = document.createElement( 'tr' );
- var col = document.createElement( 'td' );
- col.colSpan = 2;
- var link = document.createElement( 'a' );
- link.href = '#';
- link.onclick = function() {
- if ( box.className == 'mw_metadata collapsed' ) {
- changeText( link, hideText );
- box.className = 'mw_metadata expanded';
- } else {
- changeText( link, showText );
- box.className = 'mw_metadata collapsed';
- }
- return false;
- };
- var text = document.createTextNode( hideText );
- link.appendChild( text );
- col.appendChild( link );
- row.appendChild( col );
- tbody.appendChild( row );
- // And collapse!
- link.onclick();
- return true;
- }
- return false;
- }
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/mwsuggest.js
- *
- * OpenSearch ajax suggestion engine for MediaWiki
- *
- * Uses core MediaWiki open search support to fetch suggestions and show them below search boxes and other inputs
- *
- * by Robert Stojnic (April 2008)
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Global Variables */
-
- // search_box_id -> Results object
- 'os_map': {},
- // cached data, url -> json_text
- 'os_cache': {},
- // global variables for suggest_keypress
- 'os_cur_keypressed': 0,
- 'os_keypressed_count': 0,
- // type: Timer
- 'os_timer': null,
- // tie mousedown/up events
- 'os_mouse_pressed': false,
- 'os_mouse_num': -1,
- // if true, the last change was made by mouse (and not keyboard)
- 'os_mouse_moved': false,
- // delay between keypress and suggestion (in ms)
- 'os_search_timeout': 250,
- // these pairs of inputs/forms will be autoloaded at startup
- 'os_autoload_inputs': new Array('searchInput', 'searchInput2', 'powerSearchText', 'searchText'),
- 'os_autoload_forms': new Array('searchform', 'searchform2', 'powersearch', 'search' ),
- // if we stopped the service
- 'os_is_stopped': false,
- // max lines to show in suggest table
- 'os_max_lines_per_suggest': 7,
- // number of steps to animate expansion/contraction of container width
- 'os_animation_steps': 6,
- // num of pixels of smallest step
- 'os_animation_min_step': 2,
- // delay between steps (in ms)
- 'os_animation_delay': 30,
- // max width of container in percent of normal size (1 == 100%)
- 'os_container_max_width': 2,
- // currently active animation timer
- 'os_animation_timer': null,
- // <datalist> is a new HTML5 element that allows you to manually supply
- // suggestion lists and have them rendered according to the right platform
- // conventions. However, the only shipping browser as of early 2010 is Opera,
- // and that has a fatal problem: the suggestion lags behind what the user types
- // by one keypress. (Reported as DSK-276870 to Opera's secret bug tracker.)
- // The code here otherwise seems to work, though, so this can be flipped on
- // (maybe with a UA check) when some browser has a better implementation.
- // 'os_use_datalist': 'list' in document.createElement( 'input' ),
- 'os_use_datalist': false,
-
- /* Functions */
-
- /**
- * Timeout timer class that will fetch the results
- */
- 'os_Timer': function( id, r, query ) {
- this.id = id;
- this.r = r;
- this.query = query;
- },
- /**
- * Property class for single search box
- */
- 'os_Results': function( name, formname ) {
- this.searchform = formname; // id of the searchform
- this.searchbox = name; // id of the searchbox
- this.container = name + 'Suggest'; // div that holds results
- this.resultTable = name + 'Result'; // id base for the result table (+num = table row)
- this.resultText = name + 'ResultText'; // id base for the spans within result tables (+num)
- this.toggle = name + 'Toggle'; // div that has the toggle (enable/disable) link
- this.query = null; // last processed query
- this.results = null; // parsed titles
- this.resultCount = 0; // number of results
- this.original = null; // query that user entered
- this.selected = -1; // which result is selected
- this.containerCount = 0; // number of results visible in container
- this.containerRow = 0; // height of result field in the container
- this.containerTotal = 0; // total height of the container will all results
- this.visible = false; // if container is visible
- this.stayHidden = false; // don't try to show if lost focus
- },
- /**
- * Timer user to animate expansion/contraction of container width
- */
- 'os_AnimationTimer': function( r, target ) {
- this.r = r;
- var current = document.getElementById(r.container).offsetWidth;
- this.inc = Math.round( ( target - current ) / os_animation_steps );
- if( this.inc < os_animation_min_step && this.inc >=0 ) {
- this.inc = os_animation_min_step; // minimal animation step
- }
- if( this.inc > -os_animation_min_step && this.inc < 0 ) {
- this.inc = -os_animation_min_step;
- }
- this.target = target;
- },
-
- /* Intialization Functions */
-
- /**
- * Initialization, call upon page onload
- */
- 'os_MWSuggestInit': function() {
- for( i = 0; i < os_autoload_inputs.length; i++ ) {
- var id = os_autoload_inputs[i];
- var form = os_autoload_forms[i];
- element = document.getElementById( id );
- if( element != null ) {
- os_initHandlers( id, form, element );
- }
- }
- },
- /**
- * Init Result objects and event handlers
- */
- 'os_initHandlers': function( name, formname, element ) {
- var r = new os_Results( name, formname );
- var formElement = document.getElementById( formname );
- if( !formElement ) {
- // Older browsers (Opera 8) cannot get form elements
- return;
- }
- // event handler
- os_hookEvent( element, 'keyup', function( event ) { os_eventKeyup( event ); } );
- os_hookEvent( element, 'keydown', function( event ) { os_eventKeydown( event ); } );
- os_hookEvent( element, 'keypress', function( event ) { os_eventKeypress( event ); } );
- if ( !os_use_datalist ) {
- // These are needed for the div hack to hide it if the user blurs.
- os_hookEvent( element, 'blur', function( event ) { os_eventBlur( event ); } );
- os_hookEvent( element, 'focus', function( event ) { os_eventFocus( event ); } );
- // We don't want browser auto-suggestions interfering with our div, but
- // autocomplete must be on for datalist to work (at least in Opera
- // 10.10).
- element.setAttribute( 'autocomplete', 'off' );
- }
- // stopping handler
- os_hookEvent( formElement, 'submit', function( event ) { return os_eventOnsubmit( event ); } );
- os_map[name] = r;
- // toggle link
- if( document.getElementById( r.toggle ) == null ) {
- // TODO: disable this while we figure out a way for this to work in all browsers
- /* if( name == 'searchInput' ) {
- // special case: place above the main search box
- var t = os_createToggle( r, 'os-suggest-toggle' );
- var searchBody = document.getElementById( 'searchBody' );
- var first = searchBody.parentNode.firstChild.nextSibling.appendChild(t);
- } else {
- // default: place below search box to the right
- var t = os_createToggle( r, 'os-suggest-toggle-def' );
- var top = element.offsetTop + element.offsetHeight;
- var left = element.offsetLeft + element.offsetWidth;
- t.style.position = 'absolute';
- t.style.top = top + 'px';
- t.style.left = left + 'px';
- element.parentNode.appendChild( t );
- // only now width gets calculated, shift right
- left -= t.offsetWidth;
- t.style.left = left + 'px';
- t.style.visibility = 'visible';
- } */
- }
- },
- 'os_hookEvent': function( element, hookName, hookFunct ) {
- if ( element.addEventListener ) {
- element.addEventListener( hookName, hookFunct, false );
- } else if ( window.attachEvent ) {
- element.attachEvent( 'on' + hookName, hookFunct );
- }
- },
-
- /* Keyboard Event Functions */
-
- /**
- * Event handler that will fetch results on keyup
- */
- 'os_eventKeyup': function( e ) {
- var targ = os_getTarget( e );
- var r = os_map[targ.id];
- if( r == null ) {
- return; // not our event
- }
-
- // some browsers won't generate keypressed for arrow keys, catch it
- if( os_keypressed_count == 0 ) {
- os_processKey( r, os_cur_keypressed, targ );
- }
- var query = targ.value;
- os_fetchResults( r, query, os_search_timeout );
- },
- /**
- * Catch arrows up/down and escape to hide the suggestions
- */
- 'os_processKey': function( r, keypressed, targ ) {
- if ( keypressed == 40 && !r.visible && os_timer == null ) {
- // If the user hits the down arrow, fetch results immediately if none
- // are already displayed.
- r.query = '';
- os_fetchResults( r, targ.value, 0 );
- }
- // Otherwise, if we're not using datalist, we need to handle scrolling and
- // so on.
- if ( os_use_datalist ) {
- return;
- }
- if ( keypressed == 40 ) { // Arrow Down
- if ( r.visible ) {
- os_changeHighlight( r, r.selected, r.selected + 1, true );
- }
- } else if ( keypressed == 38 ) { // Arrow Up
- if ( r.visible ) {
- os_changeHighlight( r, r.selected, r.selected - 1, true );
- }
- } else if( keypressed == 27 ) { // Escape
- document.getElementById( r.searchbox ).value = r.original;
- r.query = r.original;
- os_hideResults( r );
- } else if( r.query != document.getElementById( r.searchbox ).value ) {
- // os_hideResults( r ); // don't show old suggestions
- }
- },
- /**
- * When keys is held down use a timer to output regular events
- */
- 'os_eventKeypress': function( e ) {
- var targ = os_getTarget( e );
- var r = os_map[targ.id];
- if( r == null ) {
- return; // not our event
- }
-
- var keypressed = os_cur_keypressed;
-
- os_keypressed_count++;
- os_processKey( r, keypressed, targ );
- },
- /**
- * Catch the key code (Firefox bug)
- */
- 'os_eventKeydown': function( e ) {
- if ( !e ) {
- e = window.event;
- }
- var targ = os_getTarget( e );
- var r = os_map[targ.id];
- if( r == null ) {
- return; // not our event
- }
-
- os_mouse_moved = false;
-
- os_cur_keypressed = ( e.keyCode == undefined ) ? e.which : e.keyCode;
- os_keypressed_count = 0;
- },
- /**
- * When the form is submitted hide everything, cancel updates...
- */
- 'os_eventOnsubmit': function( e ) {
- var targ = os_getTarget( e );
-
- os_is_stopped = true;
- // kill timed requests
- if( os_timer != null && os_timer.id != null ) {
- clearTimeout( os_timer.id );
- os_timer = null;
- }
- // Hide all suggestions
- for( i = 0; i < os_autoload_inputs.length; i++ ) {
- var r = os_map[os_autoload_inputs[i]];
- if( r != null ) {
- var b = document.getElementById( r.searchform );
- if( b != null && b == targ ) {
- // set query value so the handler won't try to fetch additional results
- r.query = document.getElementById( r.searchbox ).value;
- }
- os_hideResults( r );
- }
- }
- return true;
- },
- /**
- * Hide results from the user, either making the div visibility=hidden or detaching the datalist from the input.
- */
- 'os_hideResults': function( r ) {
- if ( os_use_datalist ) {
- document.getElementById( r.searchbox ).setAttribute( 'list', '' );
- } else {
- var c = document.getElementById( r.container );
- if ( c != null ) {
- c.style.visibility = 'hidden';
- }
- }
- r.visible = false;
- r.selected = -1;
- },
- 'os_decodeValue': function( value ) {
- if ( decodeURIComponent ) {
- return decodeURIComponent( value );
- }
- if( unescape ) {
- return unescape( value );
- }
- return null;
- },
- 'os_encodeQuery': function( value ) {
- if ( encodeURIComponent ) {
- return encodeURIComponent( value );
- }
- if( escape ) {
- return escape( value );
- }
- return null;
- },
- /**
- * Handles data from XMLHttpRequest, and updates the suggest results
- */
- 'os_updateResults': function( r, query, text, cacheKey ) {
- os_cache[cacheKey] = text;
- r.query = query;
- r.original = query;
- if( text == '' ) {
- r.results = null;
- r.resultCount = 0;
- os_hideResults( r );
- } else {
- try {
- var p = eval( '(' + text + ')' ); // simple json parse, could do a safer one
- if( p.length < 2 || p[1].length == 0 ) {
- r.results = null;
- r.resultCount = 0;
- os_hideResults( r );
- return;
- }
- if ( os_use_datalist ) {
- os_setupDatalist( r, p[1] );
- } else {
- os_setupDiv( r, p[1] );
- }
- } catch( e ) {
- // bad response from server or such
- os_hideResults( r );
- os_cache[cacheKey] = null;
- }
- }
- },
- /**
- * Create and populate a <datalist>.
- *
- * @param r os_Result object
- * @param results Array of the new results to replace existing ones
- */
- 'os_setupDatalist': function( r, results ) {
- var s = document.getElementById( r.searchbox );
- var c = document.getElementById( r.container );
- if ( c == null ) {
- c = document.createElement( 'datalist' );
- c.setAttribute( 'id', r.container );
- document.body.appendChild( c );
- } else {
- c.innerHTML = '';
- }
- s.setAttribute( 'list', r.container );
-
- r.results = new Array();
- r.resultCount = results.length;
- r.visible = true;
- for ( i = 0; i < results.length; i++ ) {
- var title = os_decodeValue( results[i] );
- var opt = document.createElement( 'option' );
- opt.value = title;
- r.results[i] = title;
- c.appendChild( opt );
- }
- },
- /**
- * Fetch namespaces from checkboxes or hidden fields in the search form, if none defined use wgSearchNamespaces
- * global
- */
- 'os_getNamespaces': function( r ) {
- var namespaces = '';
- var elements = document.forms[r.searchform].elements;
- for( i = 0; i < elements.length; i++ ) {
- var name = elements[i].name;
- if( typeof name != 'undefined' && name.length > 2 && name[0] == 'n' &&
- name[1] == 's' && (
- ( elements[i].type == 'checkbox' && elements[i].checked ) ||
- ( elements[i].type == 'hidden' && elements[i].value == '1' )
- )
- ) {
- if( namespaces != '' ) {
- namespaces += '|';
- }
- namespaces += name.substring( 2 );
- }
- }
- if( namespaces == '' ) {
- namespaces = wgSearchNamespaces.join('|');
- }
- return namespaces;
- },
- /**
- * Update results if user hasn't already typed something else
- */
- 'os_updateIfRelevant': function( r, query, text, cacheKey ) {
- var t = document.getElementById( r.searchbox );
- if( t != null && t.value == query ) { // check if response is still relevant
- os_updateResults( r, query, text, cacheKey );
- }
- r.query = query;
- },
- /**
- * Fetch results after some timeout
- */
- 'os_delayedFetch': function() {
- if( os_timer == null ) {
- return;
- }
- var r = os_timer.r;
- var query = os_timer.query;
- os_timer = null;
- var path = wgMWSuggestTemplate.replace( '{namespaces}', os_getNamespaces( r ) )
- .replace( '{dbname}', wgDBname )
- .replace( '{searchTerms}', os_encodeQuery( query ) );
- // try to get from cache, if not fetch using ajax
- var cached = os_cache[path];
- if( cached != null && cached != undefined ) {
- os_updateIfRelevant( r, query, cached, path );
- } else {
- var xmlhttp = sajax_init_object();
- if( xmlhttp ) {
- try {
- xmlhttp.open( 'GET', path, true );
- xmlhttp.onreadystatechange = function() {
- if ( xmlhttp.readyState == 4 && typeof os_updateIfRelevant == 'function' ) {
- os_updateIfRelevant( r, query, xmlhttp.responseText, path );
- }
- };
- xmlhttp.send( null );
- } catch ( e ) {
- if ( window.location.hostname == 'localhost' ) {
- alert( 'Your browser blocks XMLHttpRequest to "localhost", try using a real hostname for development/testing.' );
- }
- throw e;
- }
- }
- }
- },
- /**
- * Init timed update via os_delayedUpdate()
- */
- 'os_fetchResults': function( r, query, timeout ) {
- if( query == '' ) {
- r.query = '';
- os_hideResults( r );
- return;
- } else if( query == r.query ) {
- return; // no change
- }
-
- os_is_stopped = false; // make sure we're running
-
- // cancel any pending fetches
- if( os_timer != null && os_timer.id != null ) {
- clearTimeout( os_timer.id );
- }
- // schedule delayed fetching of results
- if( timeout != 0 ) {
- os_timer = new os_Timer( setTimeout( 'os_delayedFetch()', timeout ), r, query );
- } else {
- os_timer = new os_Timer( null, r, query );
- os_delayedFetch(); // do it now!
- }
- },
- /**
- * Find event target
- */
- 'os_getTarget': function( e ) {
- if ( !e ) {
- e = window.event;
- }
- if ( e.target ) {
- return e.target;
- } else if ( e.srcElement ) {
- return e.srcElement;
- } else {
- return null;
- }
- },
- /**
- * Check if x is a valid integer
- */
- 'os_isNumber': function( x ) {
- if( x == '' || isNaN( x ) ) {
- return false;
- }
- for( var i = 0; i < x.length; i++ ) {
- var c = x.charAt( i );
- if( !( c >= '0' && c <= '9' ) ) {
- return false;
- }
- }
- return true;
- },
- /**
- * Call this to enable suggestions on input (id=inputId), on a form (name=formName)
- */
- 'os_enableSuggestionsOn': function( inputId, formName ) {
- os_initHandlers( inputId, formName, document.getElementById( inputId ) );
- },
- /**
- * Call this to disable suggestios on input box (id=inputId)
- */
- 'os_disableSuggestionsOn': function( inputId ) {
- r = os_map[inputId];
- if( r != null ) {
- // cancel/hide results
- os_timer = null;
- os_hideResults( r );
- // turn autocomplete on !
- document.getElementById( inputId ).setAttribute( 'autocomplete', 'on' );
- // remove descriptor
- os_map[inputId] = null;
- }
-
- // Remove the element from the os_autoload_* arrays
- var index = os_autoload_inputs.indexOf( inputId );
- if ( index >= 0 ) {
- os_autoload_inputs[index] = os_autoload_forms[index] = '';
- }
- },
-
- /* Div-only Functions */
-
- /**
- * Event: loss of focus of input box
- */
- 'os_eventBlur': function( e ) {
- var targ = os_getTarget( e );
- var r = os_map[targ.id];
- if( r == null ) {
- return; // not our event
- }
- if( !os_mouse_pressed ) {
- os_hideResults( r );
- // force canvas to stay hidden
- r.stayHidden = true;
- // cancel any pending fetches
- if( os_timer != null && os_timer.id != null ) {
- clearTimeout( os_timer.id );
- }
- os_timer = null;
- }
- },
- /**
- * Event: focus (catch only when stopped)
- */
- 'os_eventFocus': function( e ) {
- var targ = os_getTarget( e );
- var r = os_map[targ.id];
- if( r == null ) {
- return; // not our event
- }
- r.stayHidden = false;
- },
- /**
- * Create and populate a <div>, for non-<datalist>-supporting browsers.
- *
- * @param r os_Result object
- * @param results Array of the new results to replace existing ones
- */
- 'os_setupDiv': function( r, results ) {
- var c = document.getElementById( r.container );
- if ( c == null ) {
- c = os_createContainer( r );
- }
- c.innerHTML = os_createResultTable( r, results );
- // init container table sizes
- var t = document.getElementById( r.resultTable );
- r.containerTotal = t.offsetHeight;
- r.containerRow = t.offsetHeight / r.resultCount;
- os_fitContainer( r );
- os_trimResultText( r );
- os_showResults( r );
- },
- /**
- * Create the result table to be placed in the container div
- */
- 'os_createResultTable': function( r, results ) {
- 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.results[i] = title;
- html += '<tr><td class="os-suggest-result" id="' + r.resultTable + i + '"><span id="' + r.resultText + i + '">' + title + '</span></td></tr>';
- }
- html += '</table>';
- return html;
- },
- /**
- * Show results div
- */
- 'os_showResults': function( r ) {
- if( os_is_stopped ) {
- return;
- }
- if( r.stayHidden ) {
- return;
- }
- os_fitContainer( r );
- var c = document.getElementById( r.container );
- r.selected = -1;
- if( c != null ) {
- c.scrollTop = 0;
- c.style.visibility = 'visible';
- r.visible = true;
- }
- },
- 'os_operaWidthFix': function( x ) {
- // For browsers that don't understand overflow-x, estimate scrollbar width
- if( typeof document.body.style.overflowX != 'string' ) {
- return 30;
- }
- return 0;
- },
-
- /* Brower-dependent Functions */
-
- 'f_clientWidth': function() {
- return f_filterResults(
- window.innerWidth ? window.innerWidth : 0,
- document.documentElement ? document.documentElement.clientWidth : 0,
- document.body ? document.body.clientWidth : 0
- );
- },
- 'f_clientHeight': function() {
- return f_filterResults(
- window.innerHeight ? window.innerHeight : 0,
- document.documentElement ? document.documentElement.clientHeight : 0,
- document.body ? document.body.clientHeight : 0
- );
- },
- 'f_scrollLeft': function() {
- return f_filterResults(
- window.pageXOffset ? window.pageXOffset : 0,
- document.documentElement ? document.documentElement.scrollLeft : 0,
- document.body ? document.body.scrollLeft : 0
- );
- },
- 'f_scrollTop': function() {
- return f_filterResults(
- window.pageYOffset ? window.pageYOffset : 0,
- document.documentElement ? document.documentElement.scrollTop : 0,
- document.body ? document.body.scrollTop : 0
- );
- },
- 'f_filterResults': function( n_win, n_docel, n_body ) {
- var n_result = n_win ? n_win : 0;
- if ( n_docel && ( !n_result || ( n_result > n_docel ) ) ) {
- n_result = n_docel;
- }
- return n_body && ( !n_result || ( n_result > n_body ) ) ? n_body : n_result;
- },
- /**
- * Get the height available for the results container
- */
- 'os_availableHeight': function( r ) {
- var absTop = document.getElementById( r.container ).style.top;
- var px = absTop.lastIndexOf( 'px' );
- if( px > 0 ) {
- absTop = absTop.substring( 0, px );
- }
- return f_clientHeight() - ( absTop - f_scrollTop() );
- },
- /**
- * Get element absolute position {left,top}
- */
- 'os_getElementPosition': function( elemID ) {
- var offsetTrail = document.getElementById( elemID );
- var offsetLeft = 0;
- var offsetTop = 0;
- while ( offsetTrail ) {
- offsetLeft += offsetTrail.offsetLeft;
- offsetTop += offsetTrail.offsetTop;
- offsetTrail = offsetTrail.offsetParent;
- }
- if ( navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined' ) {
- offsetLeft += document.body.leftMargin;
- offsetTop += document.body.topMargin;
- }
- return { left:offsetLeft, top:offsetTop };
- },
- /**
- * Create the container div that will hold the suggested titles
- */
- 'os_createContainer': function( r ) {
- var c = document.createElement( 'div' );
- var s = document.getElementById( r.searchbox );
- var pos = os_getElementPosition( r.searchbox );
- var left = pos.left;
- var top = pos.top + s.offsetHeight;
- c.className = 'os-suggest';
- c.setAttribute( 'id', r.container );
- document.body.appendChild( c );
-
- // dynamically generated style params
- // IE workaround, cannot explicitely set "style" attribute
- c = document.getElementById( r.container );
- c.style.top = top + 'px';
- c.style.left = left + 'px';
- c.style.width = s.offsetWidth + 'px';
-
- // mouse event handlers
- c.onmouseover = function( event ) { os_eventMouseover( r.searchbox, event ); };
- c.onmousemove = function( event ) { os_eventMousemove( r.searchbox, event ); };
- c.onmousedown = function( event ) { return os_eventMousedown( r.searchbox, event ); };
- c.onmouseup = function( event ) { os_eventMouseup( r.searchbox, event ); };
- return c;
- },
- /**
- * Change container height to fit to screen
- */
- 'os_fitContainer': function( r ) {
- var c = document.getElementById( r.container );
- var h = os_availableHeight( r ) - 20;
- var inc = r.containerRow;
- h = parseInt( h / inc ) * inc;
- if( h < ( 2 * inc ) && r.resultCount > 1 ) { // min: two results
- h = 2 * inc;
- }
- if( ( h / inc ) > os_max_lines_per_suggest ) {
- h = inc * os_max_lines_per_suggest;
- }
- if( h < r.containerTotal ) {
- c.style.height = h + 'px';
- r.containerCount = parseInt( Math.round( h / inc ) );
- } else {
- c.style.height = r.containerTotal + 'px';
- r.containerCount = r.resultCount;
- }
- },
- /**
- * If some entries are longer than the box, replace text with "..."
- */
- 'os_trimResultText': function( r ) {
- // find max width, first see if we could expand the container to fit it
- var maxW = 0;
- for( var i = 0; i < r.resultCount; i++ ) {
- var e = document.getElementById( r.resultText + i );
- if( e.offsetWidth > maxW ) {
- maxW = e.offsetWidth;
- }
- }
- var w = document.getElementById( r.container ).offsetWidth;
- var fix = 0;
- if( r.containerCount < r.resultCount ) {
- fix = 20; // give 20px for scrollbar
- } else {
- fix = os_operaWidthFix( w );
- }
- if( fix < 4 ) {
- fix = 4; // basic padding
- }
- maxW += fix;
-
- // resize container to fit more data if permitted
- var normW = document.getElementById( r.searchbox ).offsetWidth;
- var prop = maxW / normW;
- if( prop > os_container_max_width ) {
- prop = os_container_max_width;
- } else if( prop < 1 ) {
- prop = 1;
- }
- var newW = Math.round( normW * prop );
- if( w != newW ) {
- w = newW;
- if( os_animation_timer != null ) {
- clearInterval( os_animation_timer.id );
- }
- os_animation_timer = new os_AnimationTimer( r, w );
- os_animation_timer.id = setInterval( 'os_animateChangeWidth()', os_animation_delay );
- w -= fix; // this much is reserved
- }
-
- // trim results
- if( w < 10 ) {
- return;
- }
- for( var i = 0; i < r.resultCount; i++ ) {
- var e = document.getElementById( r.resultText + i );
- var replace = 1;
- var lastW = e.offsetWidth + 1;
- var iteration = 0;
- var changedText = false;
- while( e.offsetWidth > w && ( e.offsetWidth < lastW || iteration < 2 ) ) {
- changedText = true;
- lastW = e.offsetWidth;
- var l = e.innerHTML;
- e.innerHTML = l.substring( 0, l.length - replace ) + '...';
- iteration++;
- replace = 4; // how many chars to replace
- }
- if( changedText ) {
- // show hint for trimmed titles
- document.getElementById( r.resultTable + i ).setAttribute( 'title', r.results[i] );
- }
- }
- },
- /**
- * Invoked on timer to animate change in container width
- */
- 'os_animateChangeWidth': function() {
- var r = os_animation_timer.r;
- var c = document.getElementById( r.container );
- var w = c.offsetWidth;
- var normW = document.getElementById( r.searchbox ).offsetWidth;
- var normL = os_getElementPosition( r.searchbox ).left;
- var inc = os_animation_timer.inc;
- var target = os_animation_timer.target;
- var nw = w + inc;
- if( ( inc > 0 && nw >= target ) || ( inc <= 0 && nw <= target ) ) {
- // finished !
- c.style.width = target + 'px';
- clearInterval( os_animation_timer.id );
- os_animation_timer = null;
- } else {
- // in-progress
- c.style.width = nw + 'px';
- if( document.documentElement.dir == 'rtl' ) {
- c.style.left = ( normL + normW + ( target - nw ) - os_animation_timer.target - 1 ) + 'px';
- }
- }
- },
- /**
- * Change the highlighted row (i.e. suggestion), from position cur to next
- */
- 'os_changeHighlight': function( r, cur, next, updateSearchBox ) {
- if ( next >= r.resultCount ) {
- next = r.resultCount - 1;
- }
- if ( next < -1 ) {
- next = -1;
- }
- r.selected = next;
- if ( cur == next ) {
- return; // nothing to do.
- }
-
- if( cur >= 0 ) {
- var curRow = document.getElementById( r.resultTable + cur );
- if( curRow != null ) {
- curRow.className = 'os-suggest-result';
- }
- }
- var newText;
- if( next >= 0 ) {
- var nextRow = document.getElementById( r.resultTable + next );
- if( nextRow != null ) {
- nextRow.className = os_HighlightClass();
- }
- newText = r.results[next];
- } else {
- newText = r.original;
- }
-
- // adjust the scrollbar if any
- if( r.containerCount < r.resultCount ) {
- var c = document.getElementById( r.container );
- var vStart = c.scrollTop / r.containerRow;
- var vEnd = vStart + r.containerCount;
- if( next < vStart ) {
- c.scrollTop = next * r.containerRow;
- } else if( next >= vEnd ) {
- c.scrollTop = ( next - r.containerCount + 1 ) * r.containerRow;
- }
- }
-
- // update the contents of the search box
- if( updateSearchBox ) {
- os_updateSearchQuery( r, newText );
- }
- },
- 'os_HighlightClass': function() {
- var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
- if ( match ) {
- var webKitVersion = parseInt( match[1] );
- if ( webKitVersion < 523 ) {
- // CSS system highlight colors broken on old Safari
- // https://bugs.webkit.org/show_bug.cgi?id=6129
- // Safari 3.0.4, 3.1 known ok
- return 'os-suggest-result-hl-webkit';
- }
- }
- return 'os-suggest-result-hl';
- },
- 'os_updateSearchQuery': function( r, newText ) {
- document.getElementById( r.searchbox ).value = newText;
- r.query = newText;
- },
-
- /* Mouse Event Functions */
-
- /**
- * Mouse over the container
- */
- 'os_eventMouseover': function( srcId, e ) {
- var targ = os_getTarget( e );
- var r = os_map[srcId];
- if( r == null || !os_mouse_moved ) {
- return; // not our event
- }
- var num = os_getNumberSuffix( targ.id );
- if( num >= 0 ) {
- os_changeHighlight( r, r.selected, num, false );
- }
- },
- /**
- * Get row where the event occured (from its id)
- */
- 'os_getNumberSuffix': function( id ) {
- var num = id.substring( id.length - 2 );
- if( !( num.charAt( 0 ) >= '0' && num.charAt( 0 ) <= '9' ) ) {
- num = num.substring( 1 );
- }
- if( os_isNumber( num ) ) {
- return parseInt( num );
- } else {
- return -1;
- }
- },
- /**
- * Save mouse move as last action
- */
- 'os_eventMousemove': function( srcId, e ) {
- os_mouse_moved = true;
- },
- /**
- * Mouse button held down, register possible click
- */
- 'os_eventMousedown': function( srcId, e ) {
- var targ = os_getTarget( e );
- var r = os_map[srcId];
- if( r == null ) {
- return; // not our event
- }
- var num = os_getNumberSuffix( targ.id );
-
- os_mouse_pressed = true;
- if( num >= 0 ) {
- os_mouse_num = num;
- // os_updateSearchQuery( r, r.results[num] );
- }
- // keep the focus on the search field
- document.getElementById( r.searchbox ).focus();
-
- return false; // prevents selection
- },
- /**
- * Mouse button released, check for click on some row
- */
- 'os_eventMouseup': function( srcId, e ) {
- var targ = os_getTarget( e );
- var r = os_map[srcId];
- if( r == null ) {
- return; // not our event
- }
- var num = os_getNumberSuffix( targ.id );
-
- if( num >= 0 && os_mouse_num == num ) {
- os_updateSearchQuery( r, r.results[num] );
- os_hideResults( r );
- document.getElementById( r.searchform ).submit();
- }
- os_mouse_pressed = false;
- // keep the focus on the search field
- document.getElementById( r.searchbox ).focus();
- },
- /**
- * Return the span element that contains the toggle link (dead code?)
- */
- 'os_createToggle': function( r, className ) {
- var t = document.createElement( 'span' );
- t.className = className;
- t.setAttribute( 'id', r.toggle );
- var link = document.createElement( 'a' );
- link.setAttribute( 'href', 'javascript:void(0);' );
- link.onclick = function() { os_toggle( r.searchbox, r.searchform ); };
- var msg = document.createTextNode( wgMWSuggestMessages[0] );
- link.appendChild( msg );
- t.appendChild( link );
- return t;
- },
- /**
- * Call when user clicks on some of the toggle links (dead code?)
- */
- 'os_toggle': function( inputId, formName ) {
- r = os_map[inputId];
- var msg = '';
- if( r == null ) {
- os_enableSuggestionsOn( inputId, formName );
- r = os_map[inputId];
- msg = wgMWSuggestMessages[0];
- } else{
- os_disableSuggestionsOn( inputId, formName );
- msg = wgMWSuggestMessages[1];
- }
- // change message
- var link = document.getElementById( r.toggle ).firstChild;
- link.replaceChild( document.createTextNode( msg ), link.firstChild );
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- mw.legacy.os_MWSuggestInit();
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/prefs.js
- *
- * Generate toc from prefs form, fold sections
- *
- * FIXME: Needs testing on IE/Mac and Safari
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Functions */
-
- 'tabbedprefs': function() {
- var prefform = document.getElementById( 'preferences' );
- if ( !prefform || !document.createElement ) {
- return;
- }
- if ( prefform.nodeName.toLowerCase() == 'a' ) {
- return; // Occasional IE problem
- }
- prefform.className = prefform.className + 'jsprefs';
- var sections = [];
- var children = prefform.childNodes;
- var seci = 0;
- for ( var i = 0; i < children.length; i++ ) {
- if ( children[i].nodeName.toLowerCase() == 'fieldset' ) {
- children[i].id = 'prefsection-' + seci;
- children[i].className = 'prefsection';
- if ( is_opera ) {
- children[i].className = 'prefsection operaprefsection';
- }
- var legends = children[i].getElementsByTagName('legend');
- sections[seci] = {};
- if ( legends[0] ) {
- legends[0].className = 'mainLegend';
- }
- if ( legends[0] && legends[0].firstChild.nodeValue ) {
- sections[seci].text = legends[0].firstChild.nodeValue;
- } else {
- sections[seci].text = '# ' + seci;
- }
- sections[seci].secid = children[i].id;
- seci++;
- if ( sections.length != 1 ) {
- children[i].style.display = 'none';
- } else {
- var selectedid = children[i].id;
- }
- }
- }
- var toc = document.createElement( 'ul' );
- toc.id = 'preftoc';
- toc.selectedid = selectedid;
- for ( i = 0; i < sections.length; i++ ) {
- var li = document.createElement( 'li' );
- if ( i === 0 ) {
- li.className = 'selected';
- }
- var a = document.createElement( 'a' );
- a.href = '#' + sections[i].secid;
- a.onmousedown = a.onclick = uncoversection;
- a.appendChild( document.createTextNode( sections[i].text ) );
- a.secid = sections[i].secid;
- li.appendChild( a );
- toc.appendChild( li );
- }
- prefform.parentNode.insertBefore( toc, prefform.parentNode.childNodes[0] );
- document.getElementById( 'prefsubmit' ).id = 'prefcontrol';
- },
- 'uncoversection': function() {
- var oldsecid = this.parentNode.parentNode.selectedid;
- var newsec = document.getElementById( this.secid );
- if ( oldsecid != this.secid ) {
- var ul = document.getElementById( 'preftoc' );
- document.getElementById( oldsecid ).style.display = 'none';
- newsec.style.display = 'block';
- ul.selectedid = this.secid;
- var lis = ul.getElementsByTagName( 'li' );
- for ( var i = 0; i< lis.length; i++ ) {
- lis[i].className = '';
- }
- this.parentNode.className = 'selected';
- }
- return false;
- },
- /**
- * Timezone stuff tz in format [+-]HHMM
- */
- 'checkTimezone': function( tz, msg ) {
- var localclock = new Date();
- // returns negative offset from GMT in minutes
- var tzRaw = localclock.getTimezoneOffset();
- var tzHour = Math.floor( Math.abs( tzRaw ) / 60 );
- var tzMin = Math.abs( tzRaw ) % 60;
- var tzString = ( ( tzRaw >= 0 ) ? '-' : '+' ) + ( ( tzHour < 10 ) ? '0' : '' ) + tzHour + ( ( tzMin < 10 ) ? '0' : '' ) + tzMin;
- if ( tz != tzString ) {
- var junk = msg.split('$1');
- document.write( junk[0] + 'UTC' + tzString + junk[1] );
- }
- },
- 'timezoneSetup': function() {
- var tzSelect = document.getElementById( 'mw-input-timecorrection' );
- var tzTextbox = document.getElementById( 'mw-input-timecorrection-other' );
-
- if ( tzSelect && tzTextbox ) {
- addHandler( tzSelect, 'change', function( e ) { updateTimezoneSelection( false ); } );
- addHandler( tzTextbox, 'blur', function( e ) { updateTimezoneSelection( true ); } );
- }
-
- updateTimezoneSelection( false );
- },
- /**
- * Timezone stuff tz in format [-]HH:MM - won't yet work with non-even tzs
- */
- 'fetchTimezone': function() {
- // FIXME: work around Safari bug
- var localclock = new Date();
- // returns negative offset from GMT in minutes
- var tzRaw = localclock.getTimezoneOffset();
- var tzHour = Math.floor( Math.abs( tzRaw ) / 60 );
- var tzMin = Math.abs( tzRaw ) % 60;
- var tzString = ( ( tzRaw >= 0 ) ? '-' : '' ) + ( ( tzHour < 10 ) ? '0' : '' ) + tzHour +
- ':' + ( ( tzMin < 10 ) ? '0' : '' ) + tzMin;
- return tzString;
- },
- 'guessTimezone': function() {
- var textbox = document.getElementById( 'mw-input-timecorrection-other' );
- var selector = document.getElementById( 'mw-input-timecorrection' );
-
- selector.value = 'other';
- textbox.value = fetchTimezone();
- textbox.disabled = false; // The changed handler doesn't trip, obviously.
- updateTimezoneSelection( true );
- },
- 'updateTimezoneSelection': function( force_offset ) {
- var selector = document.getElementById( 'mw-input-timecorrection' );
-
- if ( selector.value == 'guess' ) {
- return guessTimezone();
- }
-
- var textbox = document.getElementById( 'mw-input-timecorrection-other' );
- var localtimeHolder = document.getElementById( 'wpLocalTime' );
- var servertime = document.getElementsByName( 'wpServerTime' )[0].value;
- var minDiff = 0;
-
- // Compatibility code.
- if ( !selector.value ) {
- selector.value = selector.options[selector.selectedIndex].value;
- }
-
- // Handle force_offset
- if ( force_offset ) {
- selector.value = 'other';
- }
-
- // Get min_diff
- if ( selector.value == 'other' ) {
- // Grab data from the textbox, parse it.
- var diffArr = textbox.value.split(':');
- if ( diffArr.length == 1 ) {
- // Specification is of the form [-]XX
- minDiff = parseInt( diffArr[0], 10 ) * 60;
- } else {
- // Specification is of the form [-]XX:XX
- minDiff = Math.abs( parseInt( diffArr[0], 10 ) ) * 60 + parseInt( diffArr[1], 10 );
- if ( parseInt( diffArr[0], 10 ) < 0 ) {
- minDiff = -minDiff;
- }
- }
- } else {
- // Grab data from the selector value
- var diffArr = selector.value.split('|');
- minDiff = parseInt( diffArr[1], 10 );
- }
-
- // Gracefully handle non-numbers.
- if ( isNaN( minDiff ) ) {
- minDiff = 0;
- }
-
- // Determine local time from server time and minutes difference, for display.
- var localTime = parseInt( servertime, 10 ) + minDiff;
-
- // Bring time within the [0,1440) range.
- while ( localTime < 0 ) {
- localTime += 1440;
- }
- while ( localTime >= 1440 ) {
- localTime -= 1440;
- }
-
- // Split to hour and minute
- var hour = String( Math.floor( localTime / 60 ) );
- if ( hour.length < 2 ) {
- hour = '0' + hour;
- }
- var min = String(localTime%60);
- if ( min.length < 2 ) {
- min = '0' + min;
- }
- changeText( localtimeHolder, hour + ':' + min );
-
- // If the user selected from the drop-down, fill the offset field.
- if ( selector.value != 'other' ) {
- hour = String( Math.abs( Math.floor( minDiff / 60 ) ) );
- if ( hour.length < 2 ) {
- hour = '0' + hour;
- }
- if ( minDiff < 0 ) {
- hour = '-' + hour;
- }
- min = String(minDiff%60);
- if ( min.length < 2 ) {
- min = '0' + min;
- }
- textbox.value = hour + ':' + min;
- }
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- mw.legacy.timezoneSetup();
- mw.legacy.tabbedprefs();
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/preview.js
- *
- * Inline ("Live") preview
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Functions */
-
- 'doLivePreview': function( e ) {
- e.preventDefault();
- $j( mw ).trigger( 'LivePreviewPrepare' );
- var postData = $j('#editform').formToArray();
- postData.push( { 'name' : 'wpPreview', 'value' : '1' } );
- // Hide active diff, used templates, old preview if shown
- var copyElements = ['#wikiPreview', '.templatesUsed', '.hiddencats', '#catlinks'];
- var copySelector = copyElements.join(',');
- $j.each( copyElements, function(k,v) { $j(v).fadeOut('fast'); } );
- // Display a loading graphic
- var loadSpinner = $j('<div class="mw-ajax-loader"/>');
- $j('#wikiPreview').before( loadSpinner );
- var page = $j('<div/>');
- var target = $j('#editform').attr('action');
- if ( !target ) {
- target = window.location.href;
- }
- page.load( target + ' ' + copySelector, postData, function() {
- for ( var i=0; i<copyElements.length; ++i) {
- // For all the specified elements, find the elements in the loaded page
- // and the real page, empty the element in the real page, and fill it
- // with the content of the loaded page
- var copyContent = page.find( copyElements[i] ).contents();
- $j(copyElements[i]).empty().append( copyContent );
- var newClasses = page.find( copyElements[i] ).attr('class');
- $j(copyElements[i]).attr( 'class', newClasses );
- }
- $j.each( copyElements, function(k,v) {
- // Don't belligerently show elements that are supposed to be hidden
- $j(v).fadeIn( 'fast', function() { $j(this).css('display', ''); } );
- } );
- loadSpinner.remove();
- $j( mw ).trigger( 'LivePreviewDone', [copyElements] );
- } );
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- // Shamelessly stolen from the jQuery form plugin, which is licensed under the GPL.
- // http://jquery.malsup.com/form/#download
- $j.fn.formToArray = function() {
- var a = [];
- if (this.length == 0) return a;
- var form = this[0];
- var els = form.elements;
- if (!els) return a;
- for(var i=0, max=els.length; i < max; i++) {
- var el = els[i];
- var n = el.name;
- if (!n) continue;
- var v = $j.fieldValue(el, true);
- if (v && v.constructor == Array) {
- for(var j=0, jmax=v.length; j < jmax; j++)
- a.push({name: n, value: v[j]});
- }
- else if (v !== null && typeof v != 'undefined')
- a.push({name: n, value: v});
- }
- if (form.clk) {
- // input type=='image' are not found in elements array! handle it here
- var $input = $(form.clk), input = $input[0], n = input.name;
- if (n && !input.disabled && input.type == 'image') {
- a.push({name: n, value: $input.val()});
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
- }
- }
- return a;
- }
- /**
- * Returns the value of the field element.
- */
- $j.fieldValue = function(el, successful) {
- var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
- if (typeof successful == 'undefined') successful = true;
- if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
- (t == 'checkbox' || t == 'radio') && !el.checked ||
- (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
- tag == 'select' && el.selectedIndex == -1))
- return null;
- if (tag == 'select') {
- var index = el.selectedIndex;
- if (index < 0) return null;
- var a = [], ops = el.options;
- var one = (t == 'select-one');
- var max = (one ? index+1 : ops.length);
- for(var i=(one ? index : 0); i < max; i++) {
- var op = ops[i];
- if (op.selected) {
- var v = op.value;
- if (!v) // extra pain for IE...
- v = (op.attributes && op.attributes['value'] &&
- !(op.attributes['value'].specified))
- ? op.text : op.value;
- if (one) return v;
- a.push(v);
- }
- }
- return a;
- }
- return el.value;
- };
- $j('#wpPreview').click( doLivePreview );
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/protect.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Global Variables */
-
- 'ProtectionForm': {
-
- /* Global Variables */
-
- 'existingMatch': false,
-
- /* Functions */
-
- /**
- * Set up the protection chaining interface (i.e. "unlock move permissions" checkbox)
- * on the protection form
- *
- * @param Object opts : parameters with members:
- * tableId Identifier of the table containing UI bits
- * labelText Text to use for the checkbox label
- * numTypes The number of protection types
- * existingMatch True if all the existing expiry times match
- */
- 'init': function( opts ) {
- if( !( document.createTextNode && document.getElementById && document.getElementsByTagName ) )
- return false;
- var box = document.getElementById( opts.tableId );
- if( !box )
- return false;
- var boxbody = box.getElementsByTagName('tbody')[0]
- var row = document.createElement( 'tr' );
- boxbody.insertBefore( row, boxbody.firstChild.nextSibling );
- this.existingMatch = opts.existingMatch;
- var cell = document.createElement( 'td' );
- row.appendChild( cell );
- // If there is only one protection type, there is nothing to chain
- if( opts.numTypes > 1 ) {
- var check = document.createElement( 'input' );
- check.id = 'mwProtectUnchained';
- check.type = 'checkbox';
- cell.appendChild( check );
- addClickHandler( check, function() { ProtectionForm.onChainClick(); } );
-
- cell.appendChild( document.createTextNode( ' ' ) );
- var label = document.createElement( 'label' );
- label.htmlFor = 'mwProtectUnchained';
- label.appendChild( document.createTextNode( opts.labelText ) );
- cell.appendChild( label );
-
- check.checked = !this.areAllTypesMatching();
- this.enableUnchainedInputs( check.checked );
- }
- this.updateCascadeCheckbox();
- return true;
- },
-
- /**
- * Sets the disabled attribute on the cascade checkbox depending on the current selected levels
- */
- 'updateCascadeCheckbox': function() {
- // For non-existent titles, there is no cascade option
- if( !document.getElementById( 'mwProtect-cascade' ) ) {
- return;
- }
- var lists = this.getLevelSelectors();
- for( var i = 0; i < lists.length; i++ ) {
- if( lists[i].selectedIndex > -1 ) {
- var items = lists[i].getElementsByTagName( 'option' );
- var selected = items[ lists[i].selectedIndex ].value;
- if( !this.isCascadeableLevel(selected) ) {
- document.getElementById( 'mwProtect-cascade' ).checked = false;
- document.getElementById( 'mwProtect-cascade' ).disabled = true;
- return;
- }
- }
- }
- document.getElementById( 'mwProtect-cascade' ).disabled = false;
- },
- /**
- * Is this protection level cascadeable?
- * @param String level
- *
- * @return boolean
- *
- */
- 'isCascadeableLevel': function( level ) {
- for (var k = 0; k < wgCascadeableLevels.length; k++) {
- if ( wgCascadeableLevels[k] == level ) {
- return true;
- }
- }
- return false;
- },
- /**
- * When protection levels are locked together, update the rest
- * when one action's level changes
- *
- * @param Element source Level selector that changed
- */
- 'updateLevels': function(source) {
- if( !this.isUnchained() )
- this.setAllSelectors( source.selectedIndex );
- this.updateCascadeCheckbox();
- },
- /**
- * When protection levels are locked together, update the
- * expiries when one changes
- *
- * @param Element source expiry input that changed
- */
- 'updateExpiry': function(source) {
- if( !this.isUnchained() ) {
- var expiry = source.value;
- this.forEachExpiryInput(function(element) {
- element.value = expiry;
- });
- }
- var listId = source.id.replace( /^mwProtect-(\w+)-expires$/, 'mwProtectExpirySelection-$1' );
- var list = document.getElementById( listId );
- if (list && list.value != 'othertime' ) {
- if ( this.isUnchained() ) {
- list.value = 'othertime';
- } else {
- this.forEachExpirySelector(function(element) {
- element.value = 'othertime';
- });
- }
- }
- },
- /**
- * When protection levels are locked together, update the
- * expiry lists when one changes and clear the custom inputs
- *
- * @param Element source expiry selector that changed
- */
- 'updateExpiryList': function(source) {
- if( !this.isUnchained() ) {
- var expiry = source.value;
- this.forEachExpirySelector(function(element) {
- element.value = expiry;
- });
- this.forEachExpiryInput(function(element) {
- element.value = '';
- });
- }
- },
- /**
- * Update chain status and enable/disable various bits of the UI
- * when the user changes the "unlock move permissions" checkbox
- */
- 'onChainClick': function() {
- if( this.isUnchained() ) {
- this.enableUnchainedInputs( true );
- } else {
- this.setAllSelectors( this.getMaxLevel() );
- this.enableUnchainedInputs( false );
- }
- this.updateCascadeCheckbox();
- },
- /**
- * Returns true if the named attribute in all objects in the given array are matching
- */
- 'matchAttribute' : function( objects, attrName ) {
- var value = null;
-
- // Check levels
- for ( var i = 0; i < objects.length; i++ ) {
- var element = objects[i];
- if ( value == null ) {
- value = element[attrName];
- } else {
- if ( value != element[attrName] ) {
- return false;
- }
- }
- }
- return true;
- },
- /**
- * Are all actions protected at the same level, with the same expiry time?
- *
- * @return boolean
- */
- 'areAllTypesMatching': function() {
- return this.existingMatch
- && this.matchAttribute( this.getLevelSelectors(), 'selectedIndex' )
- && this.matchAttribute( this.getExpirySelectors(), 'selectedIndex' )
- && this.matchAttribute( this.getExpiryInputs(), 'value' );
- },
- /**
- * Is protection chaining off?
- *
- * @return bool
- */
- 'isUnchained': function() {
- var element = document.getElementById( 'mwProtectUnchained' );
- return element
- ? element.checked
- : true; // No control, so we need to let the user set both levels
- },
- /**
- * Find the highest protection level in any selector
- */
- 'getMaxLevel': function() {
- var maxIndex = -1;
- this.forEachLevelSelector(function(element) {
- if (element.selectedIndex > maxIndex) {
- maxIndex = element.selectedIndex;
- }
- });
- return maxIndex;
- },
- /**
- * Protect all actions at the specified level
- *
- * @param int index Protection level
- */
- 'setAllSelectors': function(index) {
- this.forEachLevelSelector(function(element) {
- if (element.selectedIndex != index) {
- element.selectedIndex = index;
- }
- });
- },
- /**
- * Apply a callback to each protection selector
- *
- * @param callable func Callback function
- */
- 'forEachLevelSelector': function(func) {
- var selectors = this.getLevelSelectors();
- for (var i = 0; i < selectors.length; i++) {
- func(selectors[i]);
- }
- },
- /**
- * Get a list of all protection selectors on the page
- *
- * @return Array
- */
- '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-/)) {
- ours[ours.length] = element;
- }
- }
- return ours;
- },
- /**
- * Apply a callback to each expiry input
- *
- * @param callable func Callback function
- */
- 'forEachExpiryInput': function(func) {
- var inputs = this.getExpiryInputs();
- for (var i = 0; i < inputs.length; i++) {
- func(inputs[i]);
- }
- },
- /**
- * Get a list of all expiry inputs on the page
- *
- * @return Array
- */
- '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-/)) {
- ours[ours.length] = element;
- }
- }
- return ours;
- },
- /**
- * Apply a callback to each expiry selector list
- * @param callable func Callback function
- */
- 'forEachExpirySelector': function(func) {
- var inputs = this.getExpirySelectors();
- for (var i = 0; i < inputs.length; i++) {
- func(inputs[i]);
- }
- },
- /**
- * Get a list of all expiry selector lists on the page
- *
- * @return Array
- */
- '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-/)) {
- ours[ours.length] = element;
- }
- }
- return ours;
- },
- /**
- * Enable/disable protection selectors and expiry inputs
- *
- * @param boolean val Enable?
- */
- 'enableUnchainedInputs': function(val) {
- var first = true;
- this.forEachLevelSelector(function(element) {
- if (first) {
- first = false;
- } else {
- element.disabled = !val;
- }
- });
- first = true;
- this.forEachExpiryInput(function(element) {
- if (first) {
- first = false;
- } else {
- element.disabled = !val;
- }
- });
- first = true;
- this.forEachExpirySelector(function(element) {
- if (first) {
- first = false;
- } else {
- element.disabled = !val;
- }
- });
- }
- }
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/rightclick.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Functions */
-
- 'setupRightClickEdit': function() {
- if (document.getElementsByTagName) {
- var spans = document.getElementsByTagName('span');
- for (var i = 0; i < spans.length; i++) {
- var el = spans[i];
- if(el.className == 'editsection') {
- mw.legacy.addRightClickEditHandler(el);
- }
- }
- }
- }
- 'addRightClickEditHandler': function(el) {
- for (var i = 0; i < el.childNodes.length; i++) {
- var link = el.childNodes[i];
- if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') {
- var editHref = link.getAttribute('href');
- // find the enclosing (parent) header
- var prev = el.parentNode;
- if (prev && prev.nodeType == 1 &&
- prev.nodeName.match(/^[Hh][1-6]$/)) {
- prev.oncontextmenu = function(e) {
- if (!e) { e = window.event; }
- // e is now the event in all browsers
- var targ;
- if (e.target) { targ = e.target; }
- else if (e.srcElement) { targ = e.srcElement; }
- if (targ.nodeType == 3) { // defeat Safari bug
- targ = targ.parentNode;
- }
- // targ is now the target element
- // We don't want to deprive the noble reader of a context menu
- // for the section edit link, do we? (Might want to extend this
- // to all <a>'s?)
- if (targ.nodeName.toLowerCase() != 'a'
- || targ.parentNode.className != 'editsection') {
- document.location = editHref;
- return false;
- }
- return true;
- };
- }
- }
- }
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- mw.legacy.setupRightClickEdit();
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/search.js
- *
- * Progressive enhancement for Special:Search
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Functions */
-
- /**
- * Change the search link to what user entered
- */
- 'mwSearchHeaderClick': function( obj ) {
- var searchbox = document.getElementById( 'searchText' );
- if ( searchbox === null ) {
- searchbox = document.getElementById( 'powerSearchText' );
- }
- if ( searchbox === null ) {
- return; // should always have either normal or advanced search
- }
- var searchterm = searchbox.value;
- var parts = obj.href.split( 'search=' );
- var lastpart = '';
- var prefix = 'search=';
- if ( parts.length > 1 && parts[1].indexOf('&') >= 0 ) {
- lastpart = parts[1].substring( parts[1].indexOf('&') );
- } else {
- prefix = '&search=';
- }
- obj.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart;
- },
- 'mwToggleSearchCheckboxes': function( btn ) {
- if ( !document.getElementById ) {
- return;
- }
- var nsInputs = document.getElementById( 'powersearch' ).getElementsByTagName( 'input' );
- var isChecked = false;
- for ( var i = 0; i < nsInputs.length; i++ ) {
- var pattern = /^ns/;
- if ( ( nsInputs[i].type == 'checkbox' ) && ( pattern.test( nsInputs[i].name ) ) ) {
- switch ( btn ) {
- case 'none':
- if ( nsInputs[i].checked ) {
- nsInputs[i].checked = false;
- }
- break;
- case 'all':
- if ( !nsInputs[i].checked ) {
- nsInputs[i].checked = true;
- }
- break;
- }
- }
- }
- }
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/upload.js
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( true, mw.legacy, {
-
- /* Global Variables */
-
- 'wgUploadWarningObj': {
-
- /* Global Variables */
-
- 'responseCache' : { '' : ' ' },
- 'nameToCheck' : '',
- 'typing': false,
- 'delay': 500, // ms
- 'timeoutID': false,
-
- /* Functions */
-
- 'keypress': function () {
- if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
-
- // Find file to upload
- var destFile = document.getElementById( 'wpDestFile' );
- var warningElt = document.getElementById( 'wpDestFile-warning' );
- if ( !destFile || !warningElt ) return ;
- this.nameToCheck = destFile.value ;
- // Clear timer
- if ( this.timeoutID ) {
- window.clearTimeout( this.timeoutID );
- }
- // Check response cache
- for ( cached in this.responseCache ) {
- if ( this.nameToCheck == cached ) {
- this.setWarning( this.responseCache[this.nameToCheck] );
- return;
- }
- }
- this.timeoutID = window.setTimeout( 'wgUploadWarningObj.timeout()', this.delay );
- },
- 'checkNow': function ( fname ) {
- if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
- if ( this.timeoutID ) {
- window.clearTimeout( this.timeoutID );
- }
- this.nameToCheck = fname;
- this.timeout();
- },
- 'timeout' : function() {
- if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
- injectSpinner( document.getElementById( 'wpDestFile' ), 'destcheck' );
-
- // Get variables into local scope so that they will be preserved for the
- // anonymous callback. fileName is copied so that multiple overlapping
- // ajax requests can be supported.
- var obj = this;
- var fileName = this.nameToCheck;
- sajax_do_call( 'SpecialUpload::ajaxGetExistsWarning', [this.nameToCheck],
- function ( result ) {
- obj.processResult( result, fileName )
- }
- );
- },
- 'processResult' : function ( result, fileName ) {
- removeSpinner( 'destcheck' );
- this.setWarning( result.responseText );
- this.responseCache[fileName] = result.responseText;
- },
- 'setWarning' : function ( warning ) {
- var warningElt = document.getElementById( 'wpDestFile-warning' );
- var ackElt = document.getElementsByName( 'wpDestFileWarningAck' );
-
- this.setInnerHTML( warningElt, warning );
-
- // Set a value in the form indicating that the warning is acknowledged and
- // doesn't need to be redisplayed post-upload
- if ( warning == '' || warning == ' ' ) {
- ackElt[0].value = '';
- } else {
- ackElt[0].value = '1';
- }
- },
- 'setInnerHTML' : function ( element, text ) {
- // Check for no change to avoid flicker in IE 7
- if ( element.innerHTML != text ) {
- element.innerHTML = text;
- }
- }
- },
- var wgUploadLicenseObj = {
-
- /* Global Variables */
-
- 'responseCache' : { '' : '' },
-
- /* Functions */
-
- 'fetchPreview': function( license ) {
- if ( !wgAjaxLicensePreview ) return;
- for ( cached in this.responseCache ) {
- if ( cached == license ) {
- this.showPreview( this.responseCache[license] );
- return;
- }
- }
- injectSpinner( document.getElementById( 'wpLicense' ), 'license' );
- var title = document.getElementById( 'wpDestFile' ).value;
- if ( !title ) title = 'File:Sample.jpg';
- var url = wgScriptPath + '/api' + wgScriptExtension
- + '?action=parse&text={{' + encodeURIComponent( license ) + '}}'
- + '&title=' + encodeURIComponent( title )
- + '&prop=text&pst&format=json';
- var req = sajax_init_object();
- req.onreadystatechange = function() {
- if ( req.readyState == 4 && req.status == 200 )
- wgUploadLicenseObj.processResult( eval( '( ' + req.responseText + ' )' ), license );
- };
- req.open( 'GET', url, true );
- req.send( '' );
- },
- 'processResult' : function( result, license ) {
- removeSpinner( 'license' );
- this.responseCache[license] = result['parse']['text']['*'];
- this.showPreview( this.responseCache[license] );
- },
- 'showPreview' : function( preview ) {
- var previewPanel = document.getElementById( 'mw-license-preview' );
- if( previewPanel.innerHTML != preview )
- previewPanel.innerHTML = preview;
- }
- },
-
- /* Functions */
-
- 'licenseSelectorCheck': function() {
- var selector = document.getElementById( 'wpLicense' );
- var selection = selector.options[selector.selectedIndex].value;
- if( selector.selectedIndex > 0 ) {
- if( selection == '' ) {
- // Option disabled, but browser is broken and doesn't respect this
- selector.selectedIndex = 0;
- }
- }
- // We might show a preview
- wgUploadLicenseObj.fetchPreview( selection );
- },
- 'wgUploadSetup': function() {
- // Disable URL box if the URL copy upload source type is not selected
- var e = document.getElementById( 'wpSourceTypeurl' );
- if( e ) {
- if( !e.checked ) {
- var ein = document.getElementById( 'wpUploadFileURL' );
- if( ein )
- ein.setAttribute( 'disabled', 'disabled' );
- }
- }
- // For MSIE/Mac: non-breaking spaces cause the <option> not to render.
- // But for some reason, setting the text to itself works
- var selector = document.getElementById( 'wpLicense' );
- if ( selector ) {
- var ua = navigator.userAgent;
- var isMacIe = ( ua.indexOf( 'MSIE' ) != -1 ) && ( ua.indexOf( 'Mac' ) != -1 );
- if ( isMacIe ) {
- for ( var i = 0; i < selector.options.length; i++ ) {
- selector.options[i].text = selector.options[i].text;
- }
- }
- }
- // Toggle source type
- var sourceTypeCheckboxes = document.getElementsByName( 'wpSourceType' );
- for ( var i = 0; i < sourceTypeCheckboxes.length; i++ ) {
- sourceTypeCheckboxes[i].onchange = toggleUploadInputs;
- }
- // AJAX wpDestFile warnings
- if ( wgAjaxUploadDestCheck ) {
- // Insert an event handler that fetches upload warnings when wpDestFile
- // has been changed
- document.getElementById( 'wpDestFile' ).onchange = function ( e ) {
- wgUploadWarningObj.checkNow( this.value );
- };
- // Insert a row where the warnings will be displayed just below the
- // wpDestFile row
- var optionsTable = document.getElementById( 'mw-htmlform-description' ).tBodies[0];
- var row = optionsTable.insertRow( 1 );
- var td = document.createElement( 'td' );
- td.id = 'wpDestFile-warning';
- td.colSpan = 2;
- row.appendChild( td );
- }
- if ( wgAjaxLicensePreview ) {
- // License selector check
- document.getElementById( 'wpLicense' ).onchange = licenseSelectorCheck;
- // License selector table row
- var wpLicense = document.getElementById( 'wpLicense' );
- var wpLicenseRow = wpLicense.parentNode.parentNode;
- var wpLicenseTbody = wpLicenseRow.parentNode;
- var row = document.createElement( 'tr' );
- var td = document.createElement( 'td' );
- row.appendChild( td );
- td = document.createElement( 'td' );
- td.id = 'mw-license-preview';
- row.appendChild( td );
- wpLicenseTbody.insertBefore( row, wpLicenseRow.nextSibling );
- }
- // fillDestFile setup
- for ( var i = 0; i < wgUploadSourceIds.length; i++ )
- document.getElementById( wgUploadSourceIds[i] ).onchange = function ( e ) {
- fillDestFilename( this.id );
- };
- },
- /**
- * Iterate over all upload source fields and disable all except the selected one.
- *
- * @param enabledId
- * The id of the selected radio button
- * @return emptiness
- */
- 'toggleUploadInputs': function() {
- // Iterate over all rows with UploadSourceField
- var rows;
- if ( document.getElementsByClassName ) {
- rows = document.getElementsByClassName( 'mw-htmlform-field-UploadSourceField' );
- } else {
- // Older browsers don't support getElementsByClassName
- rows = new Array();
- var allRows = document.getElementsByTagName( 'tr' );
- for ( var i = 0; i < allRows.length; i++ ) {
- if ( allRows[i].className == 'mw-htmlform-field-UploadSourceField' )
- rows.push( allRows[i] );
- }
- }
- for ( var i = 0; i < rows.length; i++ ) {
- var inputs = rows[i].getElementsByTagName( 'input' );
- // Check if this row is selected
- var isChecked = true; // Default true in case wpSourceType is not found
- for ( var j = 0; j < inputs.length; j++ ) {
- if ( inputs[j].name == 'wpSourceType' )
- isChecked = inputs[j].checked;
- }
- // Disable all unselected rows
- for ( var j = 0; j < inputs.length; j++ ) {
- if ( inputs[j].type != 'radio' )
- inputs[j].disabled = !isChecked;
- }
- }
- },
- 'fillDestFilename': function( id ) {
- if ( !wgUploadAutoFill ) {
- return;
- }
- if ( !document.getElementById ) {
- return;
- }
- // Remove any previously flagged errors
- var e = document.getElementById( 'mw-upload-permitted' );
- if( e ) e.className = '';
- var e = document.getElementById( 'mw-upload-prohibited' );
- if( e ) e.className = '';
- var path = document.getElementById( id ).value;
- // Find trailing part
- var slash = path.lastIndexOf( '/' );
- var backslash = path.lastIndexOf( '\\' );
- var fname;
- if ( slash == -1 && backslash == -1 ) {
- fname = path;
- } else if ( slash > backslash ) {
- fname = path.substring( slash+1, 10000 );
- } else {
- fname = path.substring( backslash+1, 10000 );
- }
- // Clear the filename if it does not have a valid extension.
- // URLs are less likely to have a useful extension, so don't include them in the
- // extension check.
- if( wgStrictFileExtensions && wgFileExtensions && id != 'wpUploadFileURL' ) {
- var found = false;
- if ( fname.lastIndexOf( '.' ) != -1 ) {
- var ext = fname.substr( fname.lastIndexOf( '.' ) + 1 );
- for ( var i = 0; i < wgFileExtensions.length; i++ ) {
- if ( wgFileExtensions[i].toLowerCase() == ext.toLowerCase() ) {
- found = true;
- break;
- }
- }
- }
- if ( !found ) {
- // Not a valid extension
- // Clear the upload and set mw-upload-permitted to error
- document.getElementById( id ).value = '';
- var e = document.getElementById( 'mw-upload-permitted' );
- if ( e ) e.className = 'error';
- var e = document.getElementById( 'mw-upload-prohibited' );
- if ( e ) e.className = 'error';
- // Clear wpDestFile as well
- var e = document.getElementById( 'wpDestFile' )
- if ( e ) e.value = '';
-
- return false;
- }
- }
- // Capitalise first letter and replace spaces by underscores
- // FIXME: $wgCapitalizedNamespaces
- fname = fname.charAt( 0 ).toUpperCase().concat( fname.substring( 1,10000 ) ).replace( / /g, '_' );
- // Output result
- var destFile = document.getElementById( 'wpDestFile' );
- if ( destFile ) {
- destFile.value = fname;
- wgUploadWarningObj.checkNow( fname ) ;
- }
- },
- 'toggleFilenameFiller': function() {
- if ( !document.getElementById ) return;
- var upfield = document.getElementById( 'wpUploadFile' );
- var destName = document.getElementById( 'wpDestFile' ).value;
- if ( destName=='' || destName==' ' ) {
- wgUploadAutoFill = true;
- } else {
- wgUploadAutoFill = false;
- }
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- mw.legacy.wgUploadSetup();
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Legacy emulation for the now depricated skins/common/wikibits.js
- *
- * MediaWiki JavaScript support functions
- *
- * Global external objects used by this script: ta, stylepath, skin
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-/*
- * Scary user-agent detection stuff
- */
-mw.legacy.clientPC = navigator.userAgent.toLowerCase(); // Get client info
-mw.legacy.is_gecko = /gecko/.test( mw.legacy.clientPC ) && !/khtml|spoofer|netscape\/7\.0/.test(mw.legacy.clientPC);
-mw.legacy.webkit_match = mw.legacy.clientPC.match(/applewebkit\/(\d+)/);
-if (mw.legacy.webkit_match) {
- mw.legacy.is_safari = mw.legacy.clientPC.indexOf('applewebkit') != -1 &&
- mw.legacy.clientPC.indexOf('spoofer') == -1;
- mw.legacy.is_safari_win = mw.legacy.is_safari && mw.legacy.clientPC.indexOf('windows') != -1;
- mw.legacy.webkit_version = parseInt(mw.legacy.webkit_match[1]);
- // Tests for chrome here, to avoid breaking old scripts safari left alone
- // This is here for accesskeys
- mw.legacy.is_chrome = mw.legacy.clientPC.indexOf('chrome') !== -1 &&
- mw.legacy.clientPC.indexOf('spoofer') === -1;
- mw.legacy.is_chrome_mac = mw.legacy.is_chrome && mw.legacy.clientPC.indexOf('mac') !== -1
-}
-// For accesskeys; note that FF3+ is included here!
-mw.legacy.is_ff2 = /firefox\/[2-9]|minefield\/3/.test( mw.legacy.clientPC );
-mw.legacy.ff2_bugs = /firefox\/2/.test( mw.legacy.clientPC );
-// These aren't used here, but some custom scripts rely on them
-mw.legacy.is_ff2_win = mw.legacy.is_ff2 && mw.legacy.clientPC.indexOf('windows') != -1;
-mw.legacy.is_ff2_x11 = mw.legacy.is_ff2 && mw.legacy.clientPC.indexOf('x11') != -1;
-if (mw.legacy.clientPC.indexOf('opera') != -1) {
- mw.legacy.is_opera = true;
- mw.legacy.is_opera_preseven = window.opera && !document.childNodes;
- mw.legacy.is_opera_seven = window.opera && document.childNodes;
- mw.legacy.is_opera_95 = /opera\/(9\.[5-9]|[1-9][0-9])/.test( mw.legacy.clientPC );
- mw.legacy.opera6_bugs = mw.legacy.is_opera_preseven;
- mw.legacy.opera7_bugs = mw.legacy.is_opera_seven && !mw.legacy.is_opera_95;
- mw.legacy.opera95_bugs = /opera\/(9\.5)/.test( mw.legacy.clientPC );
-}
-// As recommended by <http://msdn.microsoft.com/en-us/library/ms537509.aspx>,
-// avoiding false positives from moronic extensions that append to the IE UA
-// string (bug 23171)
-mw.legacy.ie6_bugs = false;
-if ( /MSIE ([0-9]{1,}[\.0-9]{0,})/.exec( mw.legacy.clientPC ) != null && parseFloat( RegExp.$1 ) <= 6.0 ) {
- mw.legacy.ie6_bugs = true;
-}
-
-$.extend( true, mw.legacy, {
-
- /*
- * Events
- *
- * Add any onload functions in this hook (please don't hard-code any events in the xhtml source)
- */
-
- /* Global Variables */
-
- 'doneOnloadHook': null,
- 'onloadFuncts': [],
-
- /* Functions */
-
- 'addOnloadHook': function( hookFunct ) {
- // Allows add-on scripts to add onload functions
- if( !mw.legacy.doneOnloadHook ) {
- mw.legacy.onloadFuncts[mw.legacy.onloadFuncts.length] = hookFunct;
- } else {
- hookFunct(); // bug in MSIE script loading
- }
- },
- 'hookEvent': function( hookName, hookFunct ) {
- addHandler( window, hookName, hookFunct );
- },
- 'killEvt': function( evt ) {
- evt = evt || window.event || window.Event; // W3C, IE, Netscape
- if ( typeof ( evt.preventDefault ) != 'undefined' ) {
- evt.preventDefault(); // Don't follow the link
- evt.stopPropagation();
- } else {
- evt.cancelBubble = true; // IE
- }
- return false; // Don't follow the link (IE)
- },
-
- /*
- * Dynamic loading
- */
-
- /* Global Variables */
-
- 'loadedScripts': {},
-
- /* Functions */
-
- 'importScript': function( page ) {
- // TODO: might want to introduce a utility function to match wfUrlencode() in PHP
- var uri = wgScript + '?title=' +
- encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') +
- '&action=raw&ctype=text/javascript';
- return importScriptURI( uri );
- },
- 'importScriptURI': function( url ) {
- if ( mw.legacy.loadedScripts[url] ) {
- return null;
- }
- mw.legacy.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;
- },
- 'importStylesheet': function( page ) {
- return importStylesheetURI( wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent( page.replace(/ /g,'_') ) );
- },
- 'importStylesheetURI': function( url, media ) {
- var l = document.createElement( 'link' );
- l.type = 'text/css';
- l.rel = 'stylesheet';
- l.href = url;
- if( media ) {
- l.media = media;
- }
- document.getElementsByTagName('head')[0].appendChild( l );
- return l;
- },
- 'appendCSS': function( text ) {
- var s = document.createElement( 'style' );
- s.type = 'text/css';
- s.rel = 'stylesheet';
- if ( s.styleSheet ) {
- s.styleSheet.cssText = text; // IE
- } else {
- s.appendChild( document.createTextNode( text + '' ) ); // Safari sometimes borks on null
- }
- document.getElementsByTagName('head')[0].appendChild( s );
- return s;
- },
- 'runOnloadHook': function() {
- // don't run anything below this for non-dom browsers
- if ( mw.legacy.doneOnloadHook || !( document.getElementById && document.getElementsByTagName ) ) {
- return;
- }
- // set this before running any hooks, since any errors below
- // might cause the function to terminate prematurely
- mw.legacy.doneOnloadHook = true;
- updateTooltipAccessKeys( null );
- setupCheckboxShiftClick();
- sortables_init();
- // Run any added-on functions
- for ( var i = 0; i < mw.legacy.onloadFuncts.length; i++ ) {
- mw.legacy.onloadFuncts[i]();
- }
- },
- /**
- * Add an event handler to an element
- *
- * @param Element element Element to add handler to
- * @param String attach Event to attach to
- * @param callable handler Event handler callback
- */
- 'addHandler': function( element, attach, handler ) {
- if( window.addEventListener ) {
- element.addEventListener( attach, handler, false );
- } else if( window.attachEvent ) {
- element.attachEvent( 'on' + attach, handler );
- }
- },
- /**
- * Add a click event handler to an element
- *
- * @param Element element Element to add handler to
- * @param callable handler Event handler callback
- */
- 'addClickHandler': function( element, handler ) {
- addHandler( element, 'click', handler );
- },
- /**
- * Removes an event handler from an element
- *
- * @param Element element Element to remove handler from
- * @param String remove Event to remove
- * @param callable handler Event handler callback to remove
- */
- 'removeHandler': function( element, remove, handler ) {
- if( window.removeEventListener ) {
- element.removeEventListener( remove, handler, false );
- } else if( window.detachEvent ) {
- element.detachEvent( 'on' + remove, handler );
- }
- },
-
- /*
- * Toolbar
- */
-
- /* Global Variables */
-
- 'mwEditButtons': [],
- 'mwCustomEditButtons': [],
-
- /**
- * Tooltips and access-keys
- */
-
- /* Global Variables */
-
- /**
- * Set the accesskey prefix based on browser detection.
- */
- 'tooltipAccessKeyPrefix': ( function() {
- if ( mw.legacy.is_opera ) {
- return 'shift-esc-';
- } else if ( mw.legacy.is_chrome ) {
- return mw.legacy.is_chrome_mac ? 'ctrl-option-' : 'alt-';
- } else if ( !mw.legacy.is_safari_win && mw.legacy.is_safari && mw.legacy.webkit_version > 526 ) {
- return 'ctrl-alt-';
- } else if (
- !mw.legacy.is_safari_win &&
- (
- mw.legacy.is_safari ||
- mw.legacy.clientPC.indexOf( 'mac' ) != -1 ||
- mw.legacy.clientPC.indexOf( 'konqueror' ) != -1
- )
- ) {
- return 'ctrl-';
- } else if ( mw.legacy.is_ff2 ) {
- return 'alt-shift-';
- }
- return 'alt-';
- } )(),
- 'tooltipAccessKeyRegexp': /\[(ctrl-)?(alt-)?(shift-)?(esc-)?(.)\]$/,
- // Dummy for deprecated function
- 'ta': [],
-
- /* Functions */
-
- /**
- * Add the appropriate prefix to the accesskey shown in the tooltip.
- * If the nodeList parameter is given, only those nodes are updated;
- * otherwise, all the nodes that will probably have accesskeys by
- * default are updated.
- *
- * @param Array nodeList -- list of elements to update
- */
- 'updateTooltipAccessKeys': function( nodeList ) {
- if ( !nodeList ) {
- // Rather than scan all links on the whole page, we can just scan these
- // containers which contain the relevant links. This is really just an
- // optimization technique.
- var linkContainers = [
- 'column-one', // Monobook and Modern
- 'mw-head', 'mw-panel', 'p-logo' // Vector
- ];
- for ( var i in linkContainers ) {
- var linkContainer = document.getElementById( linkContainers[i] );
- if ( linkContainer ) {
- updateTooltipAccessKeys( linkContainer.getElementsByTagName( 'a' ) );
- }
- }
- // these are rare enough that no such optimization is needed
- updateTooltipAccessKeys( document.getElementsByTagName( 'input' ) );
- updateTooltipAccessKeys( document.getElementsByTagName( 'label' ) );
- return;
- }
- for ( var i = 0; i < nodeList.length; i++ ) {
- var element = nodeList[i];
- var tip = element.getAttribute( 'title' );
- if ( tip && mw.legacy.tooltipAccessKeyRegexp.exec( tip ) ) {
- tip = tip.replace(mw.legacy.tooltipAccessKeyRegexp,
- '[' + mw.legacy.tooltipAccessKeyPrefix + '$5]');
- element.setAttribute( 'title', tip );
- }
- }
- },
- // Dummy function for depricated feature
- 'akeytt': function( doId ) { },
-
- /*
- * Checkboxes
- */
-
- /* Global Varibles */
-
- 'checkboxes': null,
- 'lastCheckbox': null,
-
- /* Functions */
-
- 'setupCheckboxShiftClick': function() {
- mw.legacy.checkboxes = [];
- mw.legacy.lastCheckbox = null;
- var inputs = document.getElementsByTagName( 'input' );
- addCheckboxClickHandlers( inputs );
- },
- 'addCheckboxClickHandlers': function( inputs, start ) {
- if ( !start ) {
- start = 0;
- }
- var finish = start + 250;
- if ( finish > inputs.length ) {
- finish = inputs.length;
- }
- for ( var i = start; i < finish; i++ ) {
- var cb = inputs[i];
- if ( !cb.type || cb.type.toLowerCase() != 'checkbox' ) {
- continue;
- }
- var end = mw.legacy.checkboxes.length;
- mw.legacy.checkboxes[end] = cb;
- cb.index = end;
- addClickHandler( cb, checkboxClickHandler );
- }
- if ( finish < inputs.length ) {
- setTimeout( function() {
- addCheckboxClickHandlers( inputs, finish );
- }, 200 );
- }
- },
- 'checkboxClickHandler': function( e ) {
- if ( typeof e == 'undefined' ) {
- e = window.event;
- }
- if ( !e.shiftKey || mw.legacy.lastCheckbox === null ) {
- mw.legacy.lastCheckbox = this.index;
- return true;
- }
- var endState = this.checked;
- var start, finish;
- if ( this.index < mw.legacy.lastCheckbox ) {
- start = this.index + 1;
- finish = mw.legacy.lastCheckbox;
- } else {
- start = mw.legacy.lastCheckbox;
- finish = this.index - 1;
- }
- for ( var i = start; i <= finish; ++i ) {
- mw.legacy.checkboxes[i].checked = endState;
- if( i > start && typeof mw.legacy.checkboxes[i].onchange == 'function' ) {
- mw.legacy.checkboxes[i].onchange(); // fire triggers
- }
- }
- mw.legacy.lastCheckbox = this.index;
- return true;
- },
-
- /*
- * Table of contents
- */
-
- /* Functions */
-
- 'showTocToggle': function() {
- if ( document.createTextNode ) {
- // Uses DOM calls to avoid document.write + XHTML issues
- var linkHolder = document.getElementById( 'toctitle' );
- var existingLink = document.getElementById( 'togglelink' );
- if ( !linkHolder || existingLink ) {
- // Don't add the toggle link twice
- return;
- }
- var outerSpan = document.createElement( 'span' );
- outerSpan.className = 'toctoggle';
- var toggleLink = document.createElement( 'a' );
- toggleLink.id = 'togglelink';
- toggleLink.className = 'internal';
- toggleLink.href = '#';
- addClickHandler( toggleLink, function( evt ) { toggleToc(); return killEvt( evt ); } );
- toggleLink.appendChild( document.createTextNode( tocHideText ) );
- outerSpan.appendChild( document.createTextNode( '[' ) );
- outerSpan.appendChild( toggleLink );
- outerSpan.appendChild( document.createTextNode( ']' ) );
- linkHolder.appendChild( document.createTextNode( ' ' ) );
- linkHolder.appendChild( outerSpan );
- var cookiePos = document.cookie.indexOf( 'hidetoc=' );
- if ( cookiePos > -1 && document.cookie.charAt( cookiePos + 8 ) == 1 ) {
- toggleToc();
- }
- }
- },
- 'toggleToc': function() {
- var tocmain = document.getElementById( 'toc' );
- var toc = document.getElementById('toc').getElementsByTagName('ul')[0];
- var toggleLink = document.getElementById( 'togglelink' );
-
- if ( toc && toggleLink && toc.style.display == 'none' ) {
- changeText( toggleLink, tocHideText );
- toc.style.display = 'block';
- document.cookie = 'hidetoc=0';
- tocmain.className = 'toc';
- } else {
- changeText( toggleLink, tocShowText );
- toc.style.display = 'none';
- document.cookie = 'hidetoc=1';
- tocmain.className = 'toc tochidden';
- }
- return false;
- },
-
- /*
- * Table sorting
- *
- * Script based on one (c) 1997-2006 Stuart Langridge and Joost de Valk:
- * http://www.joostdevalk.nl/code/sortable-table/
- * http://www.kryogenix.org/code/browser/sorttable/
- *
- * @todo don't break on colspans/rowspans (bug 8028)
- * @todo language-specific digit grouping/decimals (bug 8063)
- * @todo support all accepted date formats (bug 8226)
- */
-
- /* Global Variables */
-
- 'ts_image_path': mw.legacy.stylepath + '/common/images/',
- 'ts_image_up': 'sort_up.gif',
- 'ts_image_down': 'sort_down.gif',
- 'ts_image_none': 'sort_none.gif',
- // The non-American-inclined can change to "true"
- 'ts_europeandate': mw.legacy.wgContentLanguage != 'en',
- 'ts_alternate_row_colors': false,
- 'ts_number_transform_table': null,
- 'ts_number_regex': null,
-
- /* Functions */
-
- 'sortables_init': function() {
- var idnum = 0;
- // Find all tables with class sortable and make them sortable
- var tables = getElementsByClassName( document, 'table', 'sortable' );
- for ( var ti = 0; ti < tables.length ; ti++ ) {
- if ( !tables[ti].id ) {
- tables[ti].setAttribute( 'id', 'sortable_table_id_' + idnum );
- ++idnum;
- }
- mw.legacy.ts_makeSortable( tables[ti] );
- }
- },
- 'ts_makeSortable': function( table ) {
- var firstRow;
- if ( table.rows && table.rows.length > 0 ) {
- if ( table.tHead && table.tHead.rows.length > 0 ) {
- firstRow = table.tHead.rows[table.tHead.rows.length-1];
- } else {
- firstRow = table.rows[0];
- }
- }
- if ( !firstRow ) {
- return;
- }
- // We have a first row: assume it's the header, and make its contents clickable links
- for ( var i = 0; i < firstRow.cells.length; i++ ) {
- var cell = firstRow.cells[i];
- if ( (' ' + cell.className + ' ').indexOf(' unsortable ') == -1 ) {
- cell.innerHTML += '<a href="#" class="sortheader" '
- + 'onclick="mw.legacy.ts_resortTable(this);return false;">'
- + '<span class="sortarrow">'
- + '<img src="'
- + mw.legacy.ts_image_path
- + mw.legacy.ts_image_none
- + '" alt="↓"/></span></a>';
- }
- }
- if ( mw.legacy.ts_alternate_row_colors ) {
- mw.legacy.ts_alternate( table );
- }
- },
- 'ts_getInnerText': function( el ) {
- return getInnerText( el );
- },
- 'ts_resortTable': function( lnk ) {
- // get the span
- var span = lnk.getElementsByTagName('span')[0];
- var td = lnk.parentNode;
- var tr = td.parentNode;
- var column = td.cellIndex;
- var table = tr.parentNode;
- while ( table && !( table.tagName && table.tagName.toLowerCase() == 'table' ) ) {
- table = table.parentNode;
- }
- if ( !table ) {
- return;
- }
- if ( table.rows.length <= 1 ) {
- return;
- }
- // Generate the number transform table if it's not done already
- if ( mw.legacy.ts_number_transform_table === null ) {
- mw.legacy.ts_initTransformTable();
- }
- // Work out a type for the column
- // Skip the first row if that's where the headings are
- var rowStart = ( table.tHead && table.tHead.rows.length > 0 ? 0 : 1 );
- var bodyRows = 0;
- if (rowStart == 0 && table.tBodies) {
- for (var i=0; i < table.tBodies.length; i++ ) {
- bodyRows += table.tBodies[i].rows.length;
- }
- if (bodyRows < table.rows.length)
- rowStart = 1;
- }
- var itm = '';
- for ( var i = rowStart; i < table.rows.length; i++ ) {
- if ( table.rows[i].cells.length > column ) {
- itm = mw.legacy.ts_getInnerText(table.rows[i].cells[column]);
- itm = itm.replace(/^[\s\xa0]+/, '').replace(/[\s\xa0]+$/, '');
- if ( itm != '' ) {
- break;
- }
- }
- }
- // TODO: bug 8226, localised date formats
- var sortfn = mw.legacy.ts_sort_generic;
- var preprocessor = mw.legacy.ts_toLowerCase;
- if ( /^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/.test( itm ) ) {
- preprocessor = mw.legacy.ts_dateToSortKey;
- } else if ( /^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/.test( itm ) ) {
- preprocessor = mw.legacy.ts_dateToSortKey;
- } else if ( /^\d\d[\/.-]\d\d[\/.-]\d\d$/.test( itm ) ) {
- preprocessor = mw.legacy.ts_dateToSortKey;
- // (minus sign)([pound dollar euro yen currency]|cents)
- } else if ( /(^([-\u2212] *)?[\u00a3$\u20ac\u00a4\u00a5]|\u00a2$)/.test( itm ) ) {
- preprocessor = mw.legacy.ts_currencyToSortKey;
- } else if ( mw.legacy.ts_number_regex.test( itm ) ) {
- preprocessor = mw.legacy.ts_parseFloat;
- }
- var reverse = ( span.getAttribute( 'sortdir' ) == 'down' );
- var newRows = new Array();
- var staticRows = new Array();
- for ( var j = rowStart; j < table.rows.length; j++ ) {
- var row = table.rows[j];
- if( (' ' + row.className + ' ').indexOf(' unsortable ') < 0 ) {
- var keyText = mw.legacy.ts_getInnerText( row.cells[column] );
- if( keyText === undefined ) {
- keyText = '';
- }
- 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.sort( sortfn );
- var arrowHTML;
- if ( reverse ) {
- arrowHTML = '<img src="' + mw.legacy.ts_image_path + mw.legacy.ts_image_down + '" alt="↓"/>';
- newRows.reverse();
- span.setAttribute( 'sortdir', 'up' );
- } else {
- arrowHTML = '<img src="' + mw.legacy.ts_image_path + mw.legacy.ts_image_up + '" alt="↑"/>';
- span.setAttribute( 'sortdir', 'down' );
- }
- for ( var i = 0; i < staticRows.length; i++ ) {
- var row = staticRows[i];
- newRows.splice( row[2], 0, row );
- }
- // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
- // don't do sortbottom rows
- for ( var i = 0; i < newRows.length; i++ ) {
- if ( ( ' ' + newRows[i][0].className + ' ').indexOf(' sortbottom ') == -1 ) {
- table.tBodies[0].appendChild( newRows[i][0] );
- }
- }
- // do sortbottom rows only
- for ( var i = 0; i < newRows.length; i++ ) {
- if ( ( ' ' + newRows[i][0].className + ' ').indexOf(' sortbottom ') != -1 ) {
- table.tBodies[0].appendChild( newRows[i][0] );
- }
- }
- // Delete any other arrows there may be showing
- var spans = getElementsByClassName( tr, 'span', 'sortarrow' );
- for ( var i = 0; i < spans.length; i++ ) {
- spans[i].innerHTML = '<img src="' + mw.legacy.ts_image_path + mw.legacy.ts_image_none + '" alt="↓"/>';
- }
- span.innerHTML = arrowHTML;
-
- if ( mw.legacy.ts_alternate_row_colors ) {
- mw.legacy.ts_alternate( table );
- }
- },
- 'ts_initTransformTable': function() {
- if ( typeof wgSeparatorTransformTable == 'undefined'
- || ( wgSeparatorTransformTable[0] == '' && wgDigitTransformTable[2] == '' ) )
- {
- var digitClass = '[0-9,.]';
- mw.legacy.ts_number_transform_table = false;
- } else {
- mw.legacy.ts_number_transform_table = {};
- // Unpack the transform table
- // Separators
- var ascii = wgSeparatorTransformTable[0].split('\t');
- var localised = wgSeparatorTransformTable[1].split('\t');
- for ( var i = 0; i < ascii.length; i++ ) {
- mw.legacy.ts_number_transform_table[localised[i]] = ascii[i];
- }
- // Digits
- ascii = wgDigitTransformTable[0].split('\t');
- localised = wgDigitTransformTable[1].split('\t');
- for ( var i = 0; i < ascii.length; i++ ) {
- mw.legacy.ts_number_transform_table[localised[i]] = ascii[i];
- }
- // Construct regex for number identification
- var digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ',', '\\.'];
- var maxDigitLength = 1;
- for ( var digit in mw.legacy.ts_number_transform_table ) {
- // Escape regex metacharacters
- digits.push(
- digit.replace( /[\\\\$\*\+\?\.\(\)\|\{\}\[\]\-]/,
- function( s ) { return '\\' + s; } )
- );
- if ( digit.length > maxDigitLength ) {
- maxDigitLength = digit.length;
- }
- }
- if ( maxDigitLength > 1 ) {
- var digitClass = '[' + digits.join( '', digits ) + ']';
- } else {
- var digitClass = '(' + digits.join( '|', digits ) + ')';
- }
- }
- // We allow a trailing percent sign, which we just strip. This works fine
- // if percents and regular numbers aren't being mixed.
- mw.legacy.ts_number_regex = new RegExp(
- '^(' +
- '[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?' + // Fortran-style scientific
- '|' +
- '[-+\u2212]?' + digitClass + '+%?' + // Generic localised
- ')$', 'i'
- );
- },
- 'ts_toLowerCase': function( s ) {
- return s.toLowerCase();
- },
- 'ts_dateToSortKey': function( date ) {
- // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
- if ( date.length == 11 ) {
- switch ( date.substr( 3, 3 ).toLowerCase() ) {
- case 'jan':
- var month = '01';
- break;
- case 'feb':
- var month = '02';
- break;
- case 'mar':
- var month = '03';
- break;
- case 'apr':
- var month = '04';
- break;
- case 'may':
- var month = '05';
- break;
- case 'jun':
- var month = '06';
- break;
- case 'jul':
- var month = '07';
- break;
- case 'aug':
- var month = '08';
- break;
- case 'sep':
- var month = '09';
- break;
- case 'oct':
- var month = '10';
- break;
- case 'nov':
- var month = '11';
- break;
- case 'dec':
- var month = '12';
- break;
- // default: var month = '00';
- }
- return date.substr( 7, 4 ) + month + date.substr( 0, 2 );
- } else if ( date.length == 10 ) {
- if ( mw.legacy.ts_europeandate == false ) {
- return date.substr( 6, 4 ) + date.substr( 0, 2 ) + date.substr( 3, 2 );
- } else {
- return date.substr( 6, 4 ) + date.substr( 3, 2 ) + date.substr( 0, 2 );
- }
- } else if ( date.length == 8 ) {
- var yr = date.substr( 6, 2 );
- if ( parseInt( yr ) < 50 ) {
- yr = '20' + yr;
- } else {
- yr = '19' + yr;
- }
- if ( mw.legacy.ts_europeandate == true ) {
- return yr + date.substr( 3, 2 ) + date.substr( 0, 2 );
- } else {
- return yr + date.substr( 0, 2 ) + date.substr( 3, 2 );
- }
- }
- return '00000000';
- },
- 'ts_parseFloat': function( s ) {
- if ( !s ) {
- return 0;
- }
- if ( mw.legacy.ts_number_transform_table != false ) {
- var newNum = '', c;
-
- for ( var p = 0; p < s.length; p++ ) {
- c = s.charAt( p );
- if ( c in mw.legacy.ts_number_transform_table ) {
- newNum += mw.legacy.ts_number_transform_table[c];
- } else {
- newNum += c;
- }
- }
- s = newNum;
- }
- var num = parseFloat( s.replace(/[, ]/g, '').replace('\u2212', '-') );
- return ( isNaN( num ) ? -Infinity : num );
- },
- 'ts_currencyToSortKey': function( s ) {
- return mw.legacy.ts_parseFloat(s.replace(/[^-\u22120-9.,]/g,''));
- },
- 'ts_sort_generic': function( a, b ) {
- return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : a[2] - b[2];
- },
- 'ts_alternate': function( table ) {
- // Take object table and get all it's tbodies.
- var tableBodies = table.getElementsByTagName( 'tbody' );
- // Loop through these tbodies
- for ( var i = 0; i < tableBodies.length; i++ ) {
- // Take the tbody, and get all it's rows
- var tableRows = tableBodies[i].getElementsByTagName( 'tr' );
- // Loop through these rows
- // Start at 1 because we want to leave the heading row untouched
- for ( var j = 0; j < tableRows.length; j++ ) {
- // Check if j is even, and apply classes for both possible results
- var oldClasses = tableRows[j].className.split(' ');
- var newClassName = '';
- for ( var k = 0; k < oldClasses.length; k++ ) {
- if ( oldClasses[k] != '' && oldClasses[k] != 'even' && oldClasses[k] != 'odd' ) {
- newClassName += oldClasses[k] + ' ';
- }
- }
- tableRows[j].className = newClassName + ( j % 2 == 0 ? 'even' : 'odd' );
- }
- }
- },
-
- /*
- * Skins
- */
-
- /* Functions */
-
- 'changeText': function( el, newText ) {
- // Safari work around
- if ( el.innerText ) {
- el.innerText = newText;
- } else if ( el.firstChild && el.firstChild.nodeValue ) {
- el.firstChild.nodeValue = newText;
- }
- },
- 'escapeQuotes': function( text ) {
- var re = new RegExp( '\'', 'g' );
- text = text.replace( re, '\\\'' );
- re = new RegExp( '\\n', 'g' );
- text = text.replace( re, '\\n' );
- return escapeQuotesHTML( text );
- },
- 'escapeQuotesHTML': function( 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;
- },
- /**
- * Add a link to one of the portlet menus on the page, including:
- *
- * p-cactions: Content actions (shown as tabs above the main content in Monobook)
- * p-personal: Personal tools (shown at the top right of the page in Monobook)
- * p-navigation: Navigation
- * p-tb: Toolbox
- *
- * This function exists for the convenience of custom JS authors. All
- * but the first three parameters are optional, though providing at
- * least an id and a tooltip is recommended.
- *
- * By default the new link will be added to the end of the list. To
- * add the link before a given existing item, pass the DOM node of
- * that item (easily obtained with document.getElementById()) as the
- * nextnode parameter; to add the link _after_ an existing item, pass
- * the node's nextSibling instead.
- *
- * @param String portlet -- id of the target portlet ("p-cactions", "p-personal", "p-navigation" or "p-tb")
- * @param String href -- link URL
- * @param String text -- link text (will be automatically lowercased by CSS for p-cactions in Monobook)
- * @param String id -- id of the new item, should be unique and preferably have the appropriate prefix ("ca-", "pt-", "n-" or "t-")
- * @param String tooltip -- text to show when hovering over the link, without accesskey suffix
- * @param String accesskey -- accesskey to activate this link (one character, try to avoid conflicts)
- * @param Node nextnode -- the DOM node before which the new item should be added, should be another item in the same list
- *
- * @return Node -- the DOM node of the new item (an LI element) or null
- */
- 'addPortletLink': function( portlet, href, text, id, tooltip, accesskey, nextnode ) {
- var root = document.getElementById( portlet );
- if ( !root ) {
- return null;
- }
- var uls = root.getElementsByTagName( 'ul' );
- var node;
- if ( uls.length > 0 ) {
- node = uls[0];
- } else {
- node = document.createElement( 'ul' );
- var lastElementChild = null;
- for ( var i = 0; i < root.childNodes.length; ++i ) { /* get root.lastElementChild */
- if ( root.childNodes[i].nodeType == 1 ) {
- lastElementChild = root.childNodes[i];
- }
- }
- if ( lastElementChild && lastElementChild.nodeName.match( /div/i ) ) {
- /* Insert into the menu divs */
- lastElementChild.appendChild( node );
- } else {
- root.appendChild( node );
- }
- }
- if ( !node ) {
- return null;
- }
- // unhide portlet if it was hidden before
- root.className = root.className.replace( /(^| )emptyPortlet( |$)/, '$2' );
- var span = document.createElement( 'span' );
- span.appendChild( document.createTextNode( text ) );
- var link = document.createElement( 'a' );
- link.appendChild( span );
- link.href = href;
- var item = document.createElement( 'li' );
- item.appendChild( link );
- if ( id ) {
- item.id = id;
- }
- if ( accesskey ) {
- link.setAttribute( 'accesskey', accesskey );
- tooltip += ' [' + accesskey + ']';
- }
- if ( tooltip ) {
- link.setAttribute( 'title', tooltip );
- }
- if ( accesskey && tooltip ) {
- updateTooltipAccessKeys( new Array( link ) );
- }
- if ( nextnode && nextnode.parentNode == node ) {
- node.insertBefore( item, nextnode );
- } else {
- node.appendChild( item ); // IE compatibility (?)
- }
- return item;
- },
- /**
- * Add a cute little box at the top of the screen to inform the user of
- * something, replacing any preexisting message.
- *
- * @param String -or- Dom Object message HTML to be put inside the right div
- * @param String className Used in adding a class; should be different for each
- * call to allow CSS/JS to hide different boxes. null = no class used.
- * @return Boolean True on success, false on failure
- */
- 'jsMsg': function( message, className ) {
- if ( !document.getElementById ) {
- return false;
- }
- // We special-case skin structures provided by the software. Skins that
- // choose to abandon or significantly modify our formatting can just define
- // an mw-js-message div to start with.
- var messageDiv = document.getElementById( 'mw-js-message' );
- if ( !messageDiv ) {
- messageDiv = document.createElement( 'div' );
- if ( document.getElementById( 'column-content' )
- && document.getElementById( 'content' ) ) {
- // MonoBook, presumably
- document.getElementById( 'content' ).insertBefore(
- messageDiv,
- document.getElementById( 'content' ).firstChild
- );
- } else if ( document.getElementById( 'content' )
- && document.getElementById( 'article' ) ) {
- // Non-Monobook but still recognizable (old-style)
- document.getElementById( 'article').insertBefore(
- messageDiv,
- document.getElementById( 'article' ).firstChild
- );
- } else {
- return false;
- }
- }
- messageDiv.setAttribute( 'id', 'mw-js-message' );
- messageDiv.style.display = 'block';
- if( className ) {
- messageDiv.setAttribute( 'class', 'mw-js-message-' + className );
- }
- if ( typeof message === 'object' ) {
- while ( messageDiv.hasChildNodes() ) { // Remove old content
- messageDiv.removeChild( messageDiv.firstChild );
- }
- messageDiv.appendChild( message ); // Append new content
- } else {
- messageDiv.innerHTML = message;
- }
- return true;
- },
- /**
- * Inject a cute little progress spinner after the specified element
- *
- * @param element Element to inject after
- * @param id Identifier string (for use with removeSpinner(), below)
- */
- 'injectSpinner': function( element, id ) {
- var spinner = document.createElement( 'img' );
- spinner.id = 'mw-spinner-' + id;
- spinner.src = mw.legacy.stylepath + '/common/images/spinner.gif';
- spinner.alt = spinner.title = '...';
- if( element.nextSibling ) {
- element.parentNode.insertBefore( spinner, element.nextSibling );
- } else {
- element.parentNode.appendChild( spinner );
- }
- },
- /**
- * Remove a progress spinner added with injectSpinner()
- *
- * @param id Identifier string
- */
- 'removeSpinner': function( id ) {
- var spinner = document.getElementById( 'mw-spinner-' + id );
- if( spinner ) {
- spinner.parentNode.removeChild( spinner );
- }
- },
-
- /*
- * DOM manipulation and traversal
- */
-
- /* Functions */
-
- 'getInnerText': function( el ) {
- if ( typeof el == 'string' ) {
- return el;
- }
- if ( typeof el == 'undefined' ) {
- return el;
- }
- if ( el.textContent ) {
- return el.textContent; // not needed but it is faster
- }
- if ( el.innerText ) {
- return el.innerText; // IE doesn't have textContent
- }
- var str = '';
- var cs = el.childNodes;
- var l = cs.length;
- for ( var i = 0; i < l; i++ ) {
- switch ( cs[i].nodeType ) {
- case 1: // ELEMENT_NODE
- str += mw.legacy.ts_getInnerText( cs[i] );
- break;
- case 3: // TEXT_NODE
- str += cs[i].nodeValue;
- break;
- }
- }
- return str;
- },
- /**
- * Written by Jonathan Snook, http://www.snook.ca/jonathan
- * Add-ons by Robert Nyman, http://www.robertnyman.com
- * Author says "The credit comment is all it takes, no license. Go crazy with it!:-)"
- * From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
- */
- 'getElementsByClassName': function( oElm, strTagName, oClassNames ) {
- var arrReturnElements = new Array();
- if ( typeof( oElm.getElementsByClassName ) == 'function' ) {
- /* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */
- var arrNativeReturn = oElm.getElementsByClassName( oClassNames );
- if ( strTagName == '*' ) {
- return arrNativeReturn;
- }
- for ( var h = 0; h < arrNativeReturn.length; h++ ) {
- if( arrNativeReturn[h].tagName.toLowerCase() == strTagName.toLowerCase() ) {
- arrReturnElements[arrReturnElements.length] = arrNativeReturn[h];
- }
- }
- return arrReturnElements;
- }
- var arrElements = ( strTagName == '*' && oElm.all ) ? oElm.all : oElm.getElementsByTagName( strTagName );
- var arrRegExpClassNames = new Array();
- if( typeof oClassNames == 'object' ) {
- for( var i = 0; i < oClassNames.length; i++ ) {
- arrRegExpClassNames[arrRegExpClassNames.length] =
- new RegExp('(^|\\s)' + oClassNames[i].replace(/\-/g, '\\-') + '(\\s|$)');
- }
- } else {
- arrRegExpClassNames[arrRegExpClassNames.length] =
- new RegExp('(^|\\s)' + oClassNames.replace(/\-/g, '\\-') + '(\\s|$)');
- }
- var oElement;
- var bMatchesAll;
- for( var j = 0; j < arrElements.length; j++ ) {
- oElement = arrElements[j];
- bMatchesAll = true;
- for( var k = 0; k < arrRegExpClassNames.length; k++ ) {
- if( !arrRegExpClassNames[k].test( oElement.className ) ) {
- bMatchesAll = false;
- break;
- }
- }
- if( bMatchesAll ) {
- arrReturnElements[arrReturnElements.length] = oElement;
- }
- }
- return ( arrReturnElements );
- },
- 'redirectToFragment': function( fragment ) {
- var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
- if ( match ) {
- var webKitVersion = parseInt( match[1] );
- if ( webKitVersion < 420 ) {
- // Released Safari w/ WebKit 418.9.1 messes up horribly
- // Nightlies of 420+ are ok
- return;
- }
- }
- if ( window.location.hash == '' ) {
- window.location.hash = fragment;
- // Mozilla needs to wait until after load, otherwise the window doesn't
- // scroll. See <https://bugzilla.mozilla.org/show_bug.cgi?id=516293>.
- // There's no obvious way to detect this programmatically, so we use
- // version-testing. If Firefox fixes the bug, they'll jump twice, but
- // better twice than not at all, so make the fix hit future versions as
- // well.
- if ( mw.legacy.is_gecko ) {
- addOnloadHook(function() {
- if ( window.location.hash == fragment ) {
- window.location.hash = fragment;
- }
- });
- }
- }
- }
-} );
-
-/* Initialization */
-
-$( document ).ready( function() {
- if ( wgBreakFrames ) {
- // Un-trap us from framesets
- if ( window.top != window ) {
- window.top.location = window.location;
- }
- }
- // Special stylesheet links for Monobook only (see bug 14717)
- if ( typeof stylepath != 'undefined' && skin == 'monobook' ) {
- if ( mw.legacy.opera6_bugs ) {
- importStylesheetURI( stylepath + '/' + skin + '/Opera6Fixes.css' );
- } else if ( mw.legacy.opera7_bugs ) {
- importStylesheetURI( stylepath + '/' + skin + '/Opera7Fixes.css' );
- } else if ( mw.legacy.opera95_bugs ) {
- importStylesheetURI( stylepath + '/' + skin + '/Opera9Fixes.css' );
- } else if ( mw.legacy.ff2_bugs ) {
- importStylesheetURI( stylepath + '/' + skin + '/FF2Fixes.css' );
- }
- }
- if ( mw.legacy.ie6_bugs ) {
- importScriptURI( mw.legacy.stylepath + '/common/IEFixes.js' );
- }
- // NOTE: All skins should call runOnloadHook() at the end of html output, so this should be redundant - it's here
- // just in case
- runOnloadHook();
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * User-agent detection
- */
-
-( function( $, mw ) {
-
-/* Extension */
-
-$.extend( mw.utilities, {
- 'client': {
- /**
- * Returns an object containing information about the browser
- *
- * The resulting client object will be in the following format:
- * {
- * 'name': 'firefox',
- * 'layout': 'gecko',
- * 'os': 'linux'
- * 'version': '3.5.1',
- * 'versionBase': '3',
- * 'versionNumber': 3.5,
- * }
- */
- this.profile = function() {
- // Use the cached version if possible
- if ( typeof this.profile === 'undefined' ) {
-
- /* Configuration */
-
- // Name of browsers or layout engines we don't recognize
- var uk = 'unknown';
- // Generic version digit
- var x = 'x';
- // Strings found in user agent strings that need to be conformed
- var wildUserAgents = [ 'Opera', 'Navigator', 'Minefield', 'KHTML', 'Chrome', 'PLAYSTATION 3'];
- // Translations for conforming user agent strings
- var userAgentTranslations = [
- // Tons of browsers lie about being something they are not
- [/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''],
- // Chrome lives in the shadow of Safari still
- ['Chrome Safari', 'Chrome'],
- // KHTML is the layout engine not the browser - LIES!
- ['KHTML', 'Konqueror'],
- // Firefox nightly builds
- ['Minefield', 'Firefox'],
- // This helps keep differnt versions consistent
- ['Navigator', 'Netscape'],
- // This prevents version extraction issues, otherwise translation would happen later
- ['PLAYSTATION 3', 'PS3'],
- ];
- // Strings which precede a version number in a user agent string - combined and used as match 1 in
- // version detectection
- var versionPrefixes = [
- 'camino', 'chrome', 'firefox', 'netscape', 'netscape6', 'opera', 'version', 'konqueror', 'lynx',
- 'msie', 'safari', 'ps3'
- ];
- // Used as matches 2, 3 and 4 in version extraction - 3 is used as actual version number
- var versionSuffix = '(\/|\;?\s|)([a-z0-9\.\+]*?)(\;|dev|rel|\\)|\s|$)';
- // Names of known browsers
- var browserNames = [
- 'camino', 'chrome', 'firefox', 'netscape', 'konqueror', 'lynx', 'msie', 'opera', 'safari', 'ipod',
- 'iphone', 'blackberry', 'ps3'
- ];
- // Tanslations for conforming browser names
- var browserTranslations = [];
- // Names of known layout engines
- var layoutNames = ['gecko', 'konqueror', 'msie', 'opera', 'webkit'];
- // Translations for conforming layout names
- var layoutTranslations = [['konqueror', 'khtml'], ['msie', 'trident'], ['opera', 'presto']];
- // Names of known operating systems
- var osNames = ['win', 'mac', 'linux', 'sunos', 'solaris', 'iphone'];
- // Translations for conforming operating system names
- var osTranslations = [['sunos', 'solaris']];
-
- /* Methods */
-
- // Performs multiple replacements on a string
- function translate( source, translations ) {
- for ( var i = 0; i < translations.length; i++ ) {
- source = source.replace( translations[i][0], translations[i][1] );
- }
- return source;
- };
-
- /* Pre-processing */
-
- var userAgent = navigator.userAgent, match, browser = uk, layout = uk, os = uk, version = x;
- if ( match = new RegExp( '(' + wildUserAgents.join( '|' ) + ')' ).exec( userAgent ) ) {
- // Takes a userAgent string and translates given text into something we can more easily work with
- userAgent = translate( userAgent, userAgentTranslations );
- }
- // Everything will be in lowercase from now on
- userAgent = userAgent.toLowerCase();
-
- /* Extraction */
-
- if ( match = new RegExp( '(' + browserNames.join( '|' ) + ')' ).exec( userAgent ) ) {
- browser = translate( match[1], browserTranslations );
- }
- if ( match = new RegExp( '(' + layoutNames.join( '|' ) + ')' ).exec( userAgent ) ) {
- layout = translate( match[1], layoutTranslations );
- }
- if ( match = new RegExp( '(' + osNames.join( '|' ) + ')' ).exec( navigator.platform.toLowerCase() ) ) {
- var os = translate( match[1], osTranslations );
- }
- if ( match = new RegExp( '(' + versionPrefixes.join( '|' ) + ')' + versionSuffix ).exec( userAgent ) ) {
- version = match[3];
- }
-
- /* Edge Cases -- did I mention about how user agent string lie? */
-
- // Decode Safari's crazy 400+ version numbers
- if ( name.match( /safari/ ) && version > 400 ) {
- version = '2.0';
- }
- // Expose Opera 10's lies about being Opera 9.8
- if ( name === 'opera' && version >= 9.8) {
- version = userAgent.match( /version\/([0-9\.]*)/i )[1] || 10;
- }
-
- /* Caching */
-
- this.profile = {
- 'browser': browser,
- 'layout': layout,
- 'os': os,
- 'version': version,
- 'versionBase': ( version !== x ? new String( version ).substr( 0, 1 ) : x ),
- 'versionNumber': ( parseFloat( version, 10 ) || 0.0 )
- };
- }
- return this.profile;
- };
- /**
- * Checks the current browser against a support map object to determine if the browser has been black-listed or
- * not. If the browser was not configured specifically it is assumed to work. It is assumed that the body
- * element is classified as either "ltr" or "rtl". If neither is set, "ltr" is assumed.
- *
- * A browser map is in the following format:
- * {
- * 'ltr': {
- * // Multiple rules with configurable operators
- * 'msie': [['>=', 7], ['!=', 9]],
- * // Blocked entirely
- * 'iphone': false
- * },
- * 'rtl': {
- * // Test against a string
- * 'msie': [['!==', '8.1.2.3']],
- * // RTL rules do not fall through to LTR rules, you must explicity set each of them
- * 'iphone': false
- * }
- * }
- *
- * @param map Object of browser support map
- *
- * @return Boolean true if browser known or assumed to be supported, false if blacklisted
- */
- this.test = function( map ) {
- var client = this.client();
- // Check over each browser condition to determine if we are running in a compatible client
- var browser = map[$( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'][client.browser];
- if ( typeof browser !== 'object' ) {
- // Unknown, so we assume it's working
- return true;
- }
- for ( var condition in browser ) {
- var op = browser[condition][0];
- var val = browser[condition][1];
- if ( val === false ) {
- return false;
- } else if ( typeof val == 'string' ) {
- if ( !( eval( 'client.version' + op + '"' + val + '"' ) ) ) {
- return false;
- }
- } else if ( typeof val == 'number' ) {
- if ( !( eval( 'client.versionNumber' + op + val ) ) ) {
- return false;
- }
- }
- }
- return true;
- };
- }
-} );
\ No newline at end of file
+++ /dev/null
-/*
- * Diff-view progressive enhancement (ported from skins/common/diff.js)
- *
- * Fixes an overflow bug in old versions of Firefox
- */
-
-( function( $, mw ) {
-
-/* Initialization */
-
-$( document ).ready( function() {
- /*
- * Workaround for overflow bug in Mozilla 1.1 and earlier, where scrolling <div>s in <td> cells collapse their
- * height to a single line.
- *
- * Known to be fixed in 1.2.1 (Gecko 20021130), but the CSS hacks I've tried with overflow-x disable the scrolling
- * all the way until Mozilla 1.8 / FF 1.5 and break Opera as well.
- *
- * So... we check for reaaaally old Gecko and hack in an alternate rule to let the wide cells spill instead of
- * scrolling them. Not ideal as it won't work if JS is disabled, of course.
- */
- if ( window.navigator && window.navigator.product == 'Gecko' && window.navigator.productSub < '20021130' ) {
- document.styleSheets[document.styleSheets.length - 1].insertRule(
- 'table.diff td div { overflow: visible; }',
- document.styleSheets[document.styleSheets.length - 1].cssRules.length
- );
- }
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-/*
- * Web-installer progressive enhancement (ported from skins/common/config.js)
- *
- * Makes elements in the configuration form interactive and hides portions of the form when not in-use
- */
-
-( function( $, mw ) {
-
-/* Initialization */
-
-$( document ).ready( function() {
- // Show/hide code for help text
- $( '.config-show-help a' ).click( function() {
- $(this).parent().siblings( '.config-help-message' ).show( 'slow' );
- $(this).parent().siblings( '.config-hide-help' ).show();
- $(this).parent().hide();
- return false;
- } );
- $( '.config-hide-help a' ).click( function() {
- $(this).parent().siblings( '.config-help-message' ).hide( 'slow' );
- $(this).parent().siblings( '.config-show-help' ).show();
- $(this).parent().hide();
- return false;
- } );
- // Show/hide code for DB-specific options
- // FIXME: Do we want slow, fast, or even non-animated (instantaneous) showing/hiding here?
- $( '.dbRadio' ).each( function() { $( '#' + $(this).attr( 'rel' ) ).hide(); } );
- $( '#' + $( '.dbRadio:checked' ).attr( 'rel' ) ).show();
- $( '.dbRadio' ).click( function() {
- var $checked = $( '.dbRadio:checked' );
- var $wrapper = $( '#' + $checked.attr( 'rel' ) );
- if ( !$wrapper.is( ':visible' ) ) {
- $( '.dbWrapper' ).hide( 'slow' );
- $wrapper.show( 'slow' );
- }
- } );
- // Scroll to the bottom of upgrade log
- $( "#config-update-log" ).each( function() { this.scrollTop = this.scrollHeight; } );
- // Show/hide Creative Commons thingy
- $( '.licenseRadio' ).click( function() {
- var $wrapper = $( '#config-cc-wrapper' );
- if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) {
- $wrapper.show( 'slow' );
- } else {
- $wrapper.hide( 'slow' );
- }
- } );
- // Show/hide random stuff (email, upload)
- $( '.showHideRadio' ).click( function() {
- var $wrapper = $( '#' + $(this).attr( 'rel' ) );
- if ( $(this).is( ':checked' ) ) {
- $wrapper.show( 'slow' );
- } else {
- $wrapper.hide( 'slow' );
- }
- } );
- $( '.hideShowRadio' ).click( function() {
- var $wrapper = $( '#' + $(this).attr( 'rel' ) );
- if ( $(this).is( ':checked' ) ) {
- $wrapper.hide( 'slow' );
- } else {
- $wrapper.show( 'slow' );
- }
- } );
- // Enable/disable "other" textboxes
- $( '.enableForOther' ).click( function() {
- var $textbox = $( '#' + $(this).attr( 'rel' ) );
- if ( $(this).val() == 'other' ) { // FIXME: Ugh, this is ugly
- $textbox.removeAttr( 'disabled' );
- } else {
- $textbox.attr( 'disabled', 'disabled' );
- }
- } );
- // Synchronize radio button label for sitename with textbox
- $label = $( 'label[for=config__NamespaceType_site-name]' );
- labelText = $label.text();
- $label.text( labelText.replace( '$1', '' ) );
- $( '#config_wgSitename' ).bind( 'keyup change', syncText ).each( syncText );
- function syncText() {
- var value = $(this).val()
- .replace( /[\[\]\{\}|#<>%+? ]/g, '_' )
- .replace( /&/, '&' )
- .replace( /__+/g, '_' )
- .replace( /^_+/, '' )
- .replace( /_+$/, '' );
- value = value.substr( 0, 1 ).toUpperCase() + value.substr( 1 );
- $label.text( labelText.replace( '$1', value ) );
- }
- // Show/Hide memcached servers when needed
- $( "input[name$='config_wgMainCacheType']" ).change( function() {
- var $memc = $( "#config-memcachewrapper" );
- if ( $( "input[name$='config_wgMainCacheType']:checked" ).val() == 'memcached' ) {
- $memc.show( 'slow' );
- } else {
- $memc.hide( 'slow' );
- }
- } );
-} );
-
-} )( jQuery, mediaWiki );
\ No newline at end of file
+++ /dev/null
-@CHARSET "UTF-8";
-
-#tests li.bar {
- color: yellow;
-}
\ No newline at end of file
+++ /dev/null
-// Test output
-$( '#tests' ).append( '<li class="bar">Bar (3)</li>' );
\ No newline at end of file
+++ /dev/null
-@CHARSET "UTF-8";
-
-#tests li.baz {
- color: blue;
-}
\ No newline at end of file
+++ /dev/null
-// Test output
-$( '#tests' ).append( '<li class="baz">Baz (1)</li>' );
\ No newline at end of file
+++ /dev/null
-@CHARSET "UTF-8";
-
-#tests li.buz {
- color: green;
-}
\ No newline at end of file
+++ /dev/null
-// Test output
-$( '#tests' ).append( '<li class="buz">Buz (2)</li>' );
\ No newline at end of file
+++ /dev/null
-@CHARSET "UTF-8";
-
-#tests li.foo {
- color: orange;
-}
\ No newline at end of file
+++ /dev/null
-// Test output
-$( '#tests' ).append( '<li class="foo">Foo (4)</li>' );
+++ /dev/null
-<!doctype html>
-
-<html>
- <head>
- <title>Resource Loader Test</title>
- <style>
- #tests li {
- color: white;
- }
- </style>
- <script type="text/javascript" src="../../load.php?modules=jquery|mw&debug=1"></script>
- <script type="text/javascript" src="../../load.php?modules=test&debug=1"></script>
- <script>
- mw.config.set( 'wgScriptPath', '../..' );
- </script>
- </head>
- <body>
- <h1>Resource Loader Tests</h1>
- <ul id="tests"></ul>
- </body>
-</html>
\ No newline at end of file
+++ /dev/null
-// Registers the modules with the loading system
-mw.loader.register( 'test', ['foo'] );
-mw.loader.register( 'foo', ['bar'] );
-mw.loader.register( 'bar', ['buz'] );
-mw.loader.register( 'buz', ['baz'] );
-mw.loader.register( 'baz', [] );
\ No newline at end of file
+++ /dev/null
-@CHARSET "UTF-8";
-
-#tests li.test {
- color: red;
-}
\ No newline at end of file
+++ /dev/null
-// Test output
-$( '#tests' ).append( '<li class="test">Test (5)</li>' );
\ No newline at end of file