User:Playjustwhatifeel/timeless.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Playjustwhatifeel/timeless. |
/**
* MyUploads for Gallery-Tool
* Created in 2011 by [[User:Rillke]] (wrapper for [[c:MediaWiki:JSONListUploads.js]])
*
* Puts the tool links near the user upload link and on [[Special:ListFiles]].
**/
/* global importScript */
$( function () {
'use strict';
var user = mw.libs.commons.guessUser() || '',
href = mw.config.get( 'wgScript' ) + '?title=Special:MyGallery&withJS=MediaWiki:JSONListUploads.js',
dir = document.documentElement.dir === 'rtl' ? 'prepend' : 'append',
link = $( '<a>', {
text: ' (tool)',
href: href,
title: 'MyUploads Gallery tool'
} );
function userlink( id, gUser ) {
gUser = gUser || user;
return link.clone().attr( {
id: id,
href: href + '&gUser=' + gUser
} ).on( 'click', function ( e ) {
if ( window.JSONListUploads ) {
e.preventDefault();
$( document ).triggerHandler( 'JSONListUploads', [ 'start', gUser ] );
}
} );
}
$( '#pt-uploads' )[ dir ]( userlink( 'pt-upl', mw.config.get( 'wgUserName' ) ) );
if ( user ) {
$( '#tb-uploads' )[ dir ]( userlink( 't-MyGallery' ) );
setTimeout( function () {
if ( [ 2, 3 ].indexOf( mw.config.get( 'wgNamespaceNumber' ) ) !== -1 && user !== mw.config.get( 'wgUserName' ) ) {
$( '#ca-gallery' )[ dir ]( userlink( 'ca-ListUploads' ) ).find( 'a' ).css( 'display', 'inline-block' );
}
if ( !window.JSONListUploads ) {
importScript( 'MediaWiki:JSONListUploads.js' );
}
}, 1800 );
}
} );
if ( mw.config.get( 'wgNamespaceNumber' ) === -1 && mw.config.get( 'wgTitle' ) === 'MyGallery' ) {
$( '#firstHeading' ).contents().first().replaceWith( 'Gallery tool:' );
}