Jump to content

User:Bratsche/monobook.js

From Wikipedia, the free encyclopedia
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.
//	<pre><nowiki>

/////////////////////////////////////////////////////////////////////////////////////////////////
//      Yay for Func! I forked this, and found out how great it was. RC patrol and life
//      is so much easier now. Thanks! (And go check out [[User:Func/monobook.js]]). The rest is
//      his, minus my name, FYI. The popups, however, are [[User:Lupin]]'s, and I added and modded a few
//      links
/////////////////////////////////////////////////////////////////////////////////////////////////
	
        //	In progress...you know, I should really finish
	//	each script before moving on to the next.
	//
document.write(
	'<script type="text/javascript" src="/w/index.php?title=' +
	'User:Func/wpfunc/blockiphelp.js' +
	'&action=raw&ctype=text/javascript&dontcountme=s"><'+'/script>'
);
//	Released into the public domain, btw.

//	Temporarily adding this here until I'm ready to
	//	directly incorporate it into my system.
	//
document.write(
	'<script type="text/javascript" src="/w/index.php?title=' +
	'User:Func/wpfunc/nupatrol.js' +
	'&action=raw&ctype=text/javascript&dontcountme=s"><'+'/script>'
);

	//	Func's (and Bratsche's ;) monobook.js, now with ADMIN powers.... :)
	//
if ( window.addEventListener ) // modern browsers, screw IE :)
{
		function WikiInit()
		{
			Wiki = {}; // global

			Wiki.href = window.location.href;
			Wiki.path = window.location.pathname;
			Wiki.quer = window.location.search;
				if ( Wiki.quer.length < 2 ) Wiki.quer = '';

			Wiki.wiki = ! Wiki.path.indexOf( '/wiki/' );

			Wiki.diff = Wiki.quer.indexOf( 'diff=' ) != -1;
			Wiki.edit = ( Wiki.quer.indexOf( 'action=edit' ) != -1 ) || ( Wiki.quer.indexOf( 'action=submit' ) != -1 );

			Wiki.user = Wiki.href.indexOf( 'User:' ) != -1; // make more robust
			Wiki.talk = Wiki.href.indexOf( 'User_talk:' ) != -1; // make more robust
			Wiki.spec = Wiki.href.indexOf( 'Special:' ) != -1;


			Wiki.recentchanges =
				Wiki.href.indexOf( 'Special:Recentchanges'   ) != -1 ||
				Wiki.href.indexOf( 'Special%3ARecentchanges' ) != -1  ;
		}

			//	Pass actions from one page to the next via
			//	window.name; which is faster and easier than
			//	using a cookie.
			//
		function PassItOn( _action_ )
		{	if ( _action_ ) window.name = 'wpFuncAction=' + _action_;
			else
			{	var hack = window.name; window.name = '';
				if ( ! hack.indexOf( 'wpFuncAction=' ) )
				{	hack = hack.substr( 13 );
					if ( hack == 'lastdiff' )
					{	if ( Wiki.quer )
							window.location.href += '&diff=0';
						else
							window.location.href += '?diff=0';
					}
					// more to come....
				}
			}
		}

	function wpFuncPreLoad()
	{
		WikiInit();		//	Global Wiki object.
		PassItOn();		//	Do we need to be somewhere else?
	}
	wpFuncPreLoad();

				//	Remind me to ask the developers to throw
				//	unique IDs onto important elements!!!
				//
			function GetByClass( className, tagName, elemObj )
			{	var i, filter, found = [];
				elemObj = elemObj || document;
				if ( tagName )
				{	filter = elemObj.getElementsByTagName( tagName );
					for ( i = 0; i < filter.length; i++ )
						if ( filter[ i ].className == className )
							found.push( filter[ i ] );
				}
				else // blah, do it when I need it
				{
				}
				return found;
			}

			function SP(x)
			{	var i, s = ''; x = x || 1; while ( x-- ) s += ' ';
				return document.createTextNode( s );
			}
			function NB(x)
			{	var i, s = ''; x = x || 1; while ( x-- ) s += '\xA0';
				return document.createTextNode( s );
			}
			function BR(){ return document.createElement( 'br' ) }

			function NewLink( txt, url, plainlinks, linkColor )
			{	var a = document.createElement( 'a' );
					a.appendChild( document.createTextNode( txt ) );
					a.href = url;
				if ( plainlinks ) a.className = 'plainlinks';
				if ( linkColor )
				{	if ( typeof linkColor == "string" )
							a.style.color = linkColor;
					else	a.style.color = '#FF0000'; // old default behavior
				}
				return a;
			}

		function RCPatrol() // for admins, (working on a non-admin version)
		{
			var table, TDs, otitle, ntitle, prevLink, currLink, link, rollback, contribs, block;

			var tr, td;

			if ( Wiki.diff )
			{
					//	<table ... class="diff">
					//
				table = GetByClass( 'diff', 'table', document.getElementById( 'bodyContent' ) )[ 0 ];
				TDs = table.getElementsByTagName( 'td' );

				otitle = TDs[ 0 ];	//	<td ... class="diff-otitle">
				ntitle = TDs[ 1 ];	//	<td ... class="diff-ntitle">

				olinks = otitle.getElementsByTagName( 'a' );
				nlinks = ntitle.getElementsByTagName( 'a' );

				prevLink = olinks[ 0 ];	//	"<a ...>Revision as of..."
				prevUser = olinks[ 1 ];	//	"<a ...>255.255.255.255</a>"
				contribs = olinks[ 3 ];	//	"<a ...>contributions"
				currLink = nlinks[ 0 ];	//	"<a ...>Current Revision"
				rollback = nlinks[ 4 ];	//	"<a ...>rollback" may not exist!!!
					if ( ! rollback || rollback.href.indexOf( 'action=rollback' ) == -1 )
						rollback = null;

				prevLink.parentNode.appendChild( NB(2) );
				link = NewLink( 'EDIT', prevLink.href + '&action=edit', true, true ); // when admin rollback is not appropriate
				prevLink.parentNode.appendChild( link );

				if ( rollback )
				{	currLink.parentNode.appendChild( NB(2) );
					link = NewLink( 'ROLLBACK', rollback.href, true, true );
					link.onclick = function(){ PassItOn( 'lastdiff' ) };
					currLink.parentNode.appendChild( link );
				}

					//	green  yellow  red
					//	 log    ???    !!!

				user = prevUser.firstChild.nodeValue;

				link = NewLink( '!!!', '/w/index.php?title=Special:Blockip&ip=' + user, true, '#FF0000' );
				contribs.parentNode.insertBefore( link, contribs.nextSibling );
				contribs.parentNode.insertBefore( NB(2), contribs.nextSibling );

				link = NewLink( '???', '/wiki/Special:Ipblocklist?action=search&ip=' + user, true, '#AAAA00' );
				contribs.parentNode.insertBefore( link, contribs.nextSibling );
				contribs.parentNode.insertBefore( NB(2), contribs.nextSibling );

				link = NewLink( 'log', '/w/index.php?title=Special%3ALog&page=User%3A' + user, true, '#00AA00' );
				contribs.parentNode.insertBefore( link, contribs.nextSibling );
				contribs.parentNode.insertBefore( NB(2), contribs.nextSibling );

				contribs.parentNode.insertBefore( contribs.previousSibling.cloneNode(true), contribs.nextSibling ); // ' | '
			}
			else if ( Wiki.edit )
			{
				gEditForm = document.getElementById( 'editform' );
				gTextBox  = gEditForm[ 'wpTextbox1' ];
				gSummary  = gEditForm[ 'wpSummary' ];
				gMinorBox = gEditForm[ 'wpMinoredit' ];
				gWatchBox = gEditForm[ 'wpWatchthis' ];

				var addtexts = document.createElement( 'div' );

				function Inserter( seeText, addText, editSum, addLoc, color, submit ) // local function
				{
					var a = NewLink( seeText, '', true, color );
						a.addText = addText;
						a.addLoc = addLoc || 8; // 2 == top; 5 == insertion-loc; 8 == bottom
						a.editSum = editSum || '';
						a.submit = submit || false;

						a.onclick = function()
						{
								 if ( this.addLoc == 8 ) gTextBox.value += this.addText;
							else if ( this.addLoc == 2 ) gTextBox.value  = this.addText + gTextBox.value;
							else /* this.addLoc == 5; Safari problems */ ;
	
							gMinorBox.checked = true;
							gWatchBox.checked = false;

							if ( this.editSum ) gSummary.value += this.editSum;

							if ( this.submit ) gEditForm.submit();

							return false;
						}
					return a;
				}
				if ( Wiki.talk ) // here is where we tell the vandals to piss off
				{
					var kTest  = '#0000AA', // blue
						kWarn  = '#00AA00', // green
						kFinal = '#AAAA00', // yellow
						kBlock = '#AA0000'; // red

					var tableTags =
						[	[	[ 'test', 'test' ],
								[ 'test2', 'test 2', 'test2a', 'test 2a' ], // special case
								[ 'test3', 'test 3' ],
								[ 'test4', 'final warning' ],
								[ 'bbblock`', 'blocked' ]
							],
							[	null,
								[ 'blanking', 'blanking' ],
								[ 'blanking2', 'blanking 2' ],
								[ 'blanking3', 'final warning' ],
								[ 'blanking4', 'blocked' ]
							],
							[	[ 'drmafd', 'removing AFDs' ],
								[ 'drmafd2', 'removing AFDs, 2nd' ],
								[ 'drmafd3', 'removing AFDs, 3rd' ],
								[ 'drmafd4', 'final warning' ],
								[ 'drmafd5', 'blocked' ]
							],
							[	[ 'spam', 'spam' ],
								[ 'spam2', 'spammer' ],
								[ 'spam2a', 'repeated spamming' ],
								[ 'spam3', 'final warning' ],
								[ 'spam4', 'blocked' ]
							],
							[	[ 'verror', 'test' ],
								[ 'verror2', 'test 2' ],
								[ 'verror3', 'test 3' ],
								[ 'verror4', 'final warning' ],
								[ 'verror5', 'blocked' ]
							],
							[	null,
								null,
								[ '3RR', '3RR warning' ],
								[ '3RR2', 'final 3RR warning' ],
								[ '3RR3', 'blocked for 3RR' ]
							],
							[	null,
								null,
								[ 'attack', 'personal attacks' ],
								null,
								null
							]
						];

					table = document.createElement( 'table' );

						//	Formatting
						//
					table.style.fontSize = 'x-small';

					var i, j, a, color;
					for ( i = 0; i < tableTags.length; i++ )
					{	tr = document.createElement( 'tr' );
						a = tableTags[ i ];
						for ( j = 0; j < 5; j++ )
						{	td = document.createElement( 'td' );
							color =	( j == 0 ) ? kTest  :
									( j  < 3 ) ? kWarn  :
									( j == 3 ) ? kFinal :
									             kBlock ;
							if ( a[ j ] )
							{	td.appendChild(
									Inserter(
										a[ j ][ 0 ], // click on text
										'{{subst:' + a[ j ][ 0 ] + '}} ~~~~\n\n', // insert this text
										a[ j ][ 1 ], // edit summary text
										8, // insert at end
										color
									)
								);
								td.appendChild( NB() );
								td.appendChild(
									Inserter(
										'!', // click on text
										'{{subst:' + a[ j ][ 0 ] + '}} ~~~~\n\n', // insert this text
										a[ j ][ 1 ], // edit summary text
										8, // insert at end
										color,
										true // auto-sumbit
									)
								);
								if ( a[ j ][ 2 ] ) // 2 links in one cell, ie: test2a
								{	td.appendChild( BR() );
									td.appendChild(Inserter(a[j][2],'{{subst:'+a[j][2]+'}} ~~~~\n\n',a[j][3],8,color));
									td.appendChild( NB() );
									td.appendChild(Inserter('!','{{subst:'+a[j][2]+'}} ~~~~\n\n',a[j][3],8,color,true));
								}
							}
							else td.appendChild( NB() );
							tr.appendChild( td );
						}
						table.appendChild( tr );
					}

					addtexts.appendChild( table );

					var span = document.createElement( 'span' );
						span.style.fontSize = 'x-small';

						span.appendChild(Inserter('Welcomenpov','{{subst:Welcomenpov}} ~~~~\n\n','pov',8,'#0000AA'));
						span.appendChild(NB());
						span.appendChild(Inserter('!','{{subst:Welcomenpov}} ~~~~\n\n','pov',8,'#0000AA',true));
						span.appendChild( NB(4) );

						span.appendChild(Inserter('nothanks|PAGE','{{subst:nothanks|PAGE}} ~~~~\n\n','copyvio',8,'#0000AA'));
						span.appendChild( NB(4) );

						span.appendChild(Inserter('vanity|PAGE','{{subst:vanity|PAGE}} ~~~~\n\n','[[WP:NOT]]',8,'#0000AA'));
						span.appendChild( NB(4) );

					addtexts.appendChild( span );
				}
				gEditForm.parentNode.insertBefore( addtexts, gEditForm );
			}
			else if ( Wiki.recentchanges )
			{
					//	Hide the annoying stuff at the top...don't need it when I'm on patrol
					//
				table = document.getElementById( 'bodyContent' ).getElementsByTagName( 'table' )[ 0 ];
				table.style.display = 'none';

			}

				//	'Hide' link next to 'Recent changes' link in the nav portlet
				//
			li = NavMenu.items[ 'n-recentchanges' ];
			li.firstChild.firstChild.nodeValue = 'RC\xA0Patrol'; // need the space li.appendChild( NewLink( 'Anons', '/w/index.php?title=Special:Recentchanges&hideliu=1&limit=500' ) );
		}

				//	Due to problems with Safari, this CURRENTLY will only insert at the END for now.
				//
			function FieldInsert( field, text, _where_ )
			{
				field.value += text;
			}

		function PortletMenu( id )	//	constructor
		{
			this.port = document.getElementById( id );
			this.menu = this.port.getElementsByTagName( 'ul' )[ 0 ];

			this.menu.style.textTransform = 'none'; // override the CSS

			this.items = {};
			this.links = {};

			var i, o, items = this.menu.getElementsByTagName( 'li' );

			for ( i = 0; i < items.length; i++ )
			{
					//	now with sanity checks
					//
				if ( ( o = items[ i ] ) )
				{	this.items[ o.id ] = o;
					if ( o.firstChild && o.firstChild.href )
					{
						this.links[ o.id ] = o.firstChild;
						this.links[ o.id ].style.textTransform = 'none'; // I could do this in the .css...
					}
				}
			}

			this.register = function( id, txt, url )	//	internal, basically
			{	var li = document.createElement( 'li' );
					li.id = id;
					var a = NewLink( txt, url );
				li.appendChild( a );
				this.items[ id ] = li;
				this.links[ id ] = a;
				a.style.textTransform = 'none'; // I hate css so much....
				return li;
			}

			this.append = function( id, txt, url )
			{	this.menu.appendChild( this.register( id, txt, url ) );
			};

			this.insert = function( before, id, txt, url )
			{	this.menu.insertBefore( this.register( id, txt, url ), this.items[ before ] );
			};

			this.follow = function( after, id, txt, url )
			{	this.menu.insertBefore( this.register( id, txt, url ), this.items[ after ].nextSibling );
			}

			this.getText = function( id      ){ return this.links[ id ].firstChild.nodeValue       };
			this.setText = function( id, txt ){        this.links[ id ].firstChild.nodeValue = txt };

			this.getHref = function( id      ){ return this.links[ id ].href       };
			this.setHref = function( id, url ){        this.links[ id ].href = url };
		}

		function PageActions()
		{	//	ca-nstab-main		Article			/wiki/PAGE      | /w/...action=edit
			//	ca-nstab-user		User page		/wiki/User:USER | /w/...action=edit
			//	ca-article			Special Page	(I find 'ca-article' slightly ironic, since it isn't.)
			//
			//	ca-talk				Discussion		/wiki/Talk:... User_talk... /w/...action=edit
			//
			//	ca-edit				Edit this page	/w/...action=edit
			//	ca-addsection		+				/w/...action=edit&section=new
			//	ca-viewsource		View source		/w/...action=edit
			//
			//	ca-history			History			/w/...action=history
			//
			//	ca-protect			Protect			/w/...action=protect
			//	ca-delete			Delete			/w/...action=delete
			//
			//	ca-move				Move			Special:Movepage/PAGE
			//
			//	ca-watch			Watch			/w/...action=watch
			//	ca-unwatch			Unwatch			/w/...action=unwatch
			//
			//		User  Talk  Edits  Logs    Edit  0  +  History  Diff  Protect  Delete  Move    Watch  Logs  Purge
			//		Page  Talk                 Edit  0     History  Diff  Protect  Delete  Move    Watch  Logs  Purge

				//	As an admin, I'm not sure when this would be nessesary....
				//
			var edit = PageMenu.items[ 'ca-viewsource' ] ? 'ca-viewsource' : 'ca-edit';

				//	I need the space.
				//
			if ( PageMenu.items[ 'ca-talk' ]       ) PageMenu.setText( 'ca-talk', 'Talk' );
			if ( PageMenu.items[ 'ca-edit' ]       ) PageMenu.setText( 'ca-edit', 'Edit' );
			if ( PageMenu.items[ 'ca-viewsource' ] ) PageMenu.setText( 'ca-viewsource', 'View' );

				//	Move the offset from off of the right of ca-talk to the left of ca-edit
				//
				//		from /skins-1.5/monobook/main.css :
				//
				//		/* offsets to distinguish the tab groups */
				//		li#ca-talk { margin-right: 1.6em; }
				//		li#ca-watch, li#ca-unwatch, li#ca-varlang-0, li#ca-print { margin-left: 1.6em; }
				//
			if ( PageMenu.items[ 'ca-talk' ] )
			{
				PageMenu.items[ 'ca-talk' ].style.marginRight = '0.3em'; // ??? how to just go back to the browser's default ???
				PageMenu.items[     edit  ].style.marginLeft  = '1.6em';
			}

			if ( PageMenu.items[ 'ca-nstab-user' ] )
			{
				PageMenu.setText( 'ca-nstab-user', 'User' );

					//	User: or User talk:
					//
				var user = document.getElementsByTagName( 'h1' )[ 0 ].firstChild.nodeValue;
					user = user.substr( user.indexOf( ':' ) + 1 );

				if ( user.indexOf( '/' ) != -1 )	//	subpage
					user = user.split( '/' )[ 0 ];

				PageMenu.insert( edit, 'ca-edits', 'Edits', '/wiki/Special:Contributions/' + user );
				PageMenu.insert( edit, 'ca-logs',  'Active Logs',  '/w/index.php?title=Special%3ALog&user=' + user );
			}

			if ( PageMenu.items[ 'ca-nstab-main' ] )
				PageMenu.setText( 'ca-nstab-main', 'Page' );

			if ( PageMenu.items[ edit ] )
			{
					//	This is so cool...I wish I knew who Bratsche stole it from. :)
					//
				PageMenu.follow( edit, 'ca-sec0', 'Sec=0', PageMenu.links[ edit ] + '&section=0' );
			}

			if ( PageMenu.items[ 'ca-history' ] )	//	if it has a history, then it is purgable
			{
				PageMenu.follow( 'ca-history', 'ca-lastdiff', 'Diff',
					PageMenu.links[ 'ca-history' ].href.replace( /action=history/, 'diff=0' ) );


				var page = document.getElementsByTagName( 'h1' )[ 0 ].firstChild.nodeValue;
				if ( ! page.indexOf( 'Editing ' ) ) page = page.substr( 8 );
				PageMenu.append( 'ca-logs', 'Passive Logs', '/w/index.php?title=Special%3ALog&page=' + page );

				PageMenu.append( 'ca-purge', 'Purge',
					PageMenu.links[ 'ca-history' ].href.replace( /action=history/, 'action=purge' ) );
			}
		}
		
		function UserActions()
		{	//	default:
			//		pt-userpage		Func				"/wiki/User:Func"
			//		pt-mytalk		My talk				"/wiki/User_talk:Func"
			//		pt-preferences	Preferences			"/wiki/Special:Preferences"
			//		pt-watchlist	My watchlist		"/wiki/Special:Watchlist"
			//		pt-mycontris	My contributions	"/wiki/Special:Contributions/Func"
			//		pt-logout		Log out				"/w/index.php?title=Special:Userlogout&amp;returnto=PAGE"
			//
			//	want:
			//		pt-userpage		Func	"/wiki/User:Func"
			//	*	pt-userdiff		=0		"/wiki/User:Func?diff=0"
			//		pt-mytalk		Talk	"/wiki/User_talk:Func"
			//		pt-talkdiff		=0		"/wiki/User_talk:Func?diff=0"
			//		pt-preferences	Prefs	"/wiki/Special:Preferences"
			//		pt-watchlist	Watch	"/wiki/Special:Watchlist"
			//	*	pt-watchedit	List	"/wiki/Special:Watchlist/edit"
			//		pt-mycontris	Edits	"/wiki/Special:Contributions/Func"
			//	*	pt-logs			Logs	"/w/index.php?title=Special%3ALog&user=Func"
			//	*	pt-kate			Kate	"http://kohl.wikimedia.org/~kate/cgi-bin/count_edits?user=Func&dbname=enwiki"
			//	*	pt-irc			#IRC	"irc://irc.freenode.net/wikipedia"
			//		pt-logout		Out		"/w/index.php?title=Special:Userlogout&amp;returnto=PAGE"
			//	*	pt-utc			(utc)	"javascript:..."

			UserMenu.setText( 'pt-mytalk',      'Talk'  );
			UserMenu.setText( 'pt-preferences', 'Prefs' );
			UserMenu.setText( 'pt-watchlist',   'Watch' );
			UserMenu.setText( 'pt-mycontris',   'Edits' );
			UserMenu.setText( 'pt-logout',      'Out'   );

			UserMenu.insert( 'pt-mytalk',      'pt-userdiff',  '=0', '/wiki/User:Bratsche?diff=0' );
                        UserMenu.insert( 'pt-mytalk',      'pt-usertwo',   'User2', '/wiki/User:Bratsche/User2' );
                         UserMenu.insert( 'pt-mytalk', 'pt-usertwodiff',   '=0', '/wiki/User:Bratsche/User2?diff=0' ); 
			UserMenu.insert( 'pt-preferences', 'pt-talkdiff',  '=0', '/wiki/User_talk:Bratsche?diff=0' );
			UserMenu.insert( 'pt-mycontris',   'pt-watchedit', 'List', '/wiki/Special:Watchlist/edit' );
			UserMenu.insert( 'pt-logout',      'pt-logs',      'Logs', '/w/index.php?title=Special%3ALog&user=Bratsche' );
			UserMenu.insert( 'pt-logout',      'pt-kate',      'Kate', 'http://tools.wikimedia.de/~kate/cgi-bin/count_edits?user=Bratsche&dbname=enwiki' );
			UserMenu.insert( 'pt-logout',      'pt-irc',       '#IRC', 'irc://irc.freenode.net/wikipedia' );

			UserMenu.append( 'pt-utc', UTCTime(), 'javascript:void UserMenu.setText( "pt-utc", UTCTime() )' );

		}

		function NavActions()
		{

		}
		
		function ToolActions()
		{
			var n = 1;

			ToolMenu.append( 't-' + n++, 'Is Blocked?', '/wiki/Special:Ipblocklist' );
			ToolMenu.append( 't-' + n++, 'Block!!!', '/wiki/Special:Blockip' );
			ToolMenu.append( 't-' + n++, 'All Logs', '/wiki/Special:Log' );
			ToolMenu.append( 't-' + n++, 'Block Log', '/w/index.php?title=Special%3ALog&type=block' );
			ToolMenu.append( 't-' + n++, 'New Users', '/w/index.php?title=Special%3ALog&type=newusers' );
                        ToolMenu.append( 't-' + n++, 'WP:AFD/Old', '/wiki/Wikipedia:Articles_for_deletion/Old' );
                        ToolMenu.append( 't-' + n++, 'Monobook', '/wiki/User:Bratsche/monobook.js' );
		}

			function UTCTime()
			{		//	Get a date stamp for the time in UTC-land.
					//		for the future: a format arg
				var s = '',
					d = new Date(),
					a = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
				return	d.getUTCDate() + ' ' +
						a[ d.getUTCMonth() ] + ' ' +
						d.getUTCFullYear() + ' ' +
						( '0' + d.getUTCHours()   ).substr( -2 ) + ':' +
						( '0' + d.getUTCMinutes() ).substr( -2 ) + ' ' + 'UTC';
			}

	function wpFuncOnLoad()
	{
		PageMenu = new PortletMenu( 'p-cactions' );
		UserMenu = new PortletMenu( 'p-personal' );
		 NavMenu = new PortletMenu( 'p-navigation' );
		ToolMenu = new PortletMenu( 'p-tb' );

		RCPatrol();

		PageActions();
		UserActions();
		 NavActions();
		ToolActions();
	}
	window.addEventListener( 'load', wpFuncOnLoad, false );
}
// Last update: 21:51, 15 Feb 2005 (UTC)

// [[User:Zocky/PicturePopups.js]] - please include this line 
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Zocky/PicturePopups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
function addLink(where, url, name, id, title, key, after){
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", or "p-navigation".
    //* url is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //* name is what will appear as the name of the button.
    //* id is the id of the button; it's best to define one.  
    //   Use a prefix to make sure its unique. Optional.
    //* title is the tooltip title that gives a longer description 
    //   of the button; if you define a accesskey, mention it here. Optional.
    //* key is the char you want for the accesskey. Optional.
    //* after is the id of the button you want to follow this one. Optional.
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        tabs.appendChild(li);
    }
    if(id) {
        if(key && title) { ta[id] = [key, title]; }
        else if(key) { ta[id] = [key, '']; }
        else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
    
//this helps automate AfD closing by adding a 'close' tab to AfD debates
//written by [[User:Johnleemk]] based on [[Wikipedia:WikiProject User scripts/Scripts/test-n.js]] by [[User:Celestianpower]]

function autoafd_result()
{
  var close = prompt("Result of debate?")
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "ab" + "}}";
  f.wpSummary.value = "Closing debate; result was " + close;
}

function autoafd_relist()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "relist" + "|~" + "~" + "~" + "~}}";
  f.wpSummary.value = "Relisting debate";
}

function autoafd_keep()
{
  var date = prompt("Nomination was made when?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD";
}

function autoafd_no_consensus()
{
  var date = prompt("Nomination was made when?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD with no consensus";
}

function autoafd_redirect()
{
  var date = prompt("Nomination was made when?")
  var redirect = prompt("Redirect to?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD";
}

function autoafd_merge()
{
  var date = prompt("Nomination was made when?")
  var redirect = prompt("Merge and redirect to?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD";
}

function autoafd_other()
{
  var date = prompt("Nomination was made when?")
  var result = prompt("Result was?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "AfDed; result was " + result;
}

function autoafd_add_afd_tabs()
{
  // Only add for pages with the right string somewhere in the title
  if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1)
    {
      addLink('p-cactions', 'javascript:autoafd_result()', "Close");
      addLink('p-cactions', 'javascript:autoafd_relist()', "Relist");
    }
  if (document.title.indexOf("Editing Talk:") != -1)
    {
      addLink('p-cactions', 'javascript:autoafd_keep()', "NKeep");
      addLink('p-cactions', 'javascript:autoafd_no_consensus()', "No_C");
      addLink('p-cactions', 'javascript:autoafd_redirect()', "Redir");
      addLink('p-cactions', 'javascript:autoafd_merge()', "Merge");
      addLink('p-cactions', 'javascript:autoafd_other()', "Other");
    }
}

addOnloadHook(autoafd_add_afd_tabs);

//end AfD closing script

//	</nowiki></pre>