MediaWiki:Gadget-edittop.js

From EntropiaPlanets Wiki - Entropia Universe Guides Wiki Info
Revision as of 16:19, 9 January 2012 by Tass (talk | contribs) (Created page with "// ********************************************************************** // ** ***WARNING! GLOBAL GADGET FILE*** ** // ************************...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// **********************************************************************
// **                 ***WARNING! GLOBAL GADGET FILE***                **
// **********************************************************************
if( ( wgAction == 'view' || wgAction == 'purge' ) && wgNamespaceNumber >= 0 ) {
	jQuery( document ).ready( function() {
		var localtitles = {
			en: 'Edit lead section',
			fr: 'Modifier le résumé introductif',
			it: 'Modifica della sezione iniziale',
			ja: '導入部を編集'
		};
		var h2s = document.getElementsByTagName( 'H2' );
		var h2 = h2s[0];
		if( !h2 ) {
			return;
		}
		if( h2.parentNode.id == 'toctitle' ) {
			h2 = h2s[1];
		}
		if( !h2 ) {
			return;
		}
		var span = h2.firstChild;
		if( !span || span.className != 'editsection' ) {
			return;
		}
		var zero = span.cloneNode( true );
		if( document.getElementById( 'featured-star' ) ) {
			zero.style.marginRight = '25px';
		}
		if( document.getElementById( 'spoken-icon' ) ) {
			zero.style.marginRight = '45px';
		}
		if( document.getElementById( 'protected-icon' ) && zero.style.marginRight ) {
			zero.style.marginRight = '70px';
		}
		var parent = document.getElementsByTagName( 'H1' )[0];
		parent.insertBefore( zero, parent.firstChild );
		var a = zero.getElementsByTagName( 'A' )[0];
		if( localtitles[wgUserLanguage] ) {
			a.title = localtitles[wgUserLanguage];
		} else {
			// TODO check for content of header, to get a more precise replacement
			a.title = a.title.replace( /:.*$/, ': 0' );
		}
		a.setAttribute( 'href', a.href.replace( /&section=1/, '&section=0' ) );
	});
}