Jump to content

MediaWiki:Gadget-edittop.js: Difference between revisions

From mediawiki.org
Content deleted Content added
Innv (talk | contribs)
mNo edit summary
add some braces and such
(One intermediate revision by the same user not shown)
Line 2: Line 2:
// ** ***WARNING! GLOBAL GADGET FILE*** **
// ** ***WARNING! GLOBAL GADGET FILE*** **
// **********************************************************************
// **********************************************************************
if( ( wgAction == 'view' || wgAction == 'purge' ) && wgNamespaceNumber >= 0 ) {
addOnloadHook( function edittop_hook() {
if ((wgAction == 'view' || wgAction == 'purge') && wgNamespaceNumber >=0)
var localtitles = {
addOnloadHook(function edittop_hook(){
en: 'Edit lead section',
var localtitles = {
fr: 'Modifier le résumé introductif',
en: 'Edit lead section',
it: 'Modifica della sezione iniziale',
fr: 'Modifier le résumé introductif',
ja: '導入部を編集'
it: 'Modifica della sezione iniziale',
};
ja: '導入部を編集'
var h2s = document.getElementsByTagName( 'H2' );
};
var h2 = h2s[0];
var h2s = document.getElementsByTagName('H2');
var h2 = h2s[0];
if( !h2 ) {
if (!h2) return;
return;
}
if (h2.parentNode.id == 'toctitle') h2 = h2s[1];
if( h2.parentNode.id == 'toctitle' ) {
if (!h2) return;
h2 = h2s[1];
var span = h2.firstChild;
}
if (!span || span.className != 'editsection') return;
if( !h2 ) {
var zero = span.cloneNode(true);
return;
if (document.getElementById('featured-star')) zero.style.marginRight = '25px';
}
if (document.getElementById('spoken-icon')) zero.style.marginRight = '45px';
var span = h2.firstChild;
if (document.getElementById('protected-icon') && zero.style.marginRight) zero.style.marginRight = '70px';
if( !span || span.className != 'editsection' ) {
var parent = document.getElementsByTagName('H1')[0];
return;
parent.insertBefore(zero, parent.firstChild);
}
var a = zero.getElementsByTagName('A')[0];
var zero = span.cloneNode( true );
if(localtitles[wgUserLanguage]) a.title = localtitles[wgUserLanguage];
if( document.getElementById( 'featured-star' ) ) {
// TODO check for content of header, to get a more precise replacement
zero.style.marginRight = '25px';
else a.title = a.title.replace(/:.*$/,': 0');
}
a.setAttribute('href', a.href.replace(/&section=1/,'&section=0'));
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' ) );
});
}

Revision as of 01:00, 24 March 2011

// **********************************************************************
// **                 ***WARNING! GLOBAL GADGET FILE***                **
// **********************************************************************
if( ( wgAction == 'view' || wgAction == 'purge' ) && wgNamespaceNumber >= 0 ) {
	addOnloadHook( function edittop_hook() {
		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' ) );
	});
}