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 14:46, 24 September 2013 (Debugging.... console.log()). 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!' );
	$( '#p-logo a' ).css({ 'background-image': 'url(/media/wikipedia/commons/d/d1/Wikipedia-logo-v2-admin.png)', 'background-size': '135px 155px' });
	console.log( 'Changed background image!' );
	var listStyle = mw.util.addPortletLink(
		'p-cactions',
		'#',
		'O.o',
		'pt-admin_eye',
		'View page as an admin',
		null,
		null
	);
	console.log( 'Added toggle link!' );
	$( listStyle ).click( function ( e ) {
		console.time('admin-eye');
		e.preventDefault();
		/*, 'block' );*/
		$( 'div.sysop-show, p.sysop-show' ).css( 'display', function (i, val) {
			console.log( 'Displayed hidden div and p sections!' );
			return val === "block" ? "" : "block";
		});
		/*, 'inline' );*/
		$( 'span.sysop-show, small.sysop-show' ).css( 'display', function (i, val) {
			console.log( 'Displayed hidden span and small sections!' );
			return val === "inline" ? "" : "inline";
		});
		/*, 'table' );*/
		$( 'table.sysop-show' ).css( 'display', function (i, val) {
			console.log( 'Displayed hidden tables!' );
			return val === "table" ? "" : "table";
		});
		/*, 'list-item' );*/
		$( 'li.sysop-show' ).css( 'display', function (i, val) {
			console.log( 'Displayed hidden list items!' );
			return val === "list-item" ? "" : "list-item";
		});
		/* Toggle the link */
		$( 'li#pt-admin_eye a' ).html( function (i, val) {
			return val === "O.O" ? "o.o" : "O.O";
		});
		$( 'li#pt-admin_eye a' ).attr( 'title', function (i, val) {
			console.log( 'i - %s - val - %s', i, val );
			return val === "View page as an admin" ? "View page as a user" : "View page as an admin";
		});
		console.timeEnd('admin-eye');
	});
} else {console.warn( 'Hidden section NOT found!' );}