Jump to content

User:Technical 13/Scripts/admin eye.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Technical 13 (talk | contribs) at 20:36, 25 September 2013 (Let's see it with the .svg instead of .png). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
if( $( ".sysop-show" ).length > 0){
	console.info( 'Hidden section found!' );//TRON
	$( '#p-logo a' ).css({ 'background-image': 'url(/media/wikipedia/commons/9/9c/Wikipedia-logo-v2-admin.svg)', 'background-size': '135px 155px' });
	console.log( 'Changed background image!' );//TRON
	var listStyle = mw.util.addPortletLink(
		'p-cactions',
		'#',
		'O.o',
		'pt-admin_eye',
		'View page as an admin',
		null,
		null
	);
	console.log( 'Added toggle link!' );//TRON
	$( listStyle ).click( function ( e ) {
		console.time('admin-eye');//TRON
		e.preventDefault();
		/*, 'block' );*/
		$( 'div.sysop-show, p.sysop-show' ).css( 'display', function (i, val) {
			if(val =="block"){var status = "Re-hid";}else{var status = "Displayed hidden";}//TRON
			console.log( '%s div and p sections!', status );//TRON
			return val === "block" ? "" : "block";
		});
		/*, 'inline' );*/
		$( 'span.sysop-show, small.sysop-show' ).css( 'display', function (i, val) {
			if(val =="inline"){var status = "Re-hid";}else{var status = "Displayed hidden";}//TRON
			console.log( '%s span and small sections!', status );//TRON
			return val === "inline" ? "" : "inline";
		});
		/*, 'table' );*/
		$( 'table.sysop-show' ).css( 'display', function (i, val) {
			if(val =="table"){var status = "Re-hid";}else{var status = "Displayed hidden";}//TRON
			console.log( '%s tables!', status );//TRON
			return val === "table" ? "" : "table";
		});
		/*, 'list-item' );*/
		$( 'li.sysop-show' ).css( 'display', function (i, val) {
			if(val =="list-item"){var status = "Re-hid";}else{var status = "Displayed hidden";}//TRON
			console.log( '%s list items!', status );//TRON
			return val === "list-item" ? "" : "list-item";
		});
		/* Toggle the link */
		$( 'li#pt-admin_eye a' ).html( function (i, val) {
			console.log( 'Updated toggle link from "%s"', val );//TRON
			return val === "O.O" ? "o.o" : "O.O";
		});
		$( 'li#pt-admin_eye a' ).attr( 'title', function (i, val) {
			console.log( 'Updated toggle link from "%s"', val );//TRON
			return val === "View page as an admin" ? "View page as a user" : "View page as an admin";
		});
		console.timeEnd('admin-eye');//TRON
	});
} else {
	console.warn( 'Hidden section NOT found!' );//TRON
}