User:Prodego/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
The accompanying .css page for this skin is at User:Prodego/monobook.css. |
//<nowiki>
document.write('<SCRIPT SRC="http://meta.wikimedia.org/w/index.php?action=raw&ctype=text/js&title=User:Prodego/enw.js"><\/SCRIPT>');
function PortletMenu( id ) // constructor
{
this.menu = document.getElementById( id );
this.list = this.menu.getElementsByTagName( 'ul' )[ 0 ]; // bypass "<h5>Views</h5>", etc.
var LIs = this.list.getElementsByTagName( 'li' );
for ( var i = 0; i < LIs.length; i++ )
{
this[ LIs[ i ].id ] = LIs[ i ];
}
this.newItem = function( id, txt, url )
{ var li = document.createElement( 'li' ); li.id = id;
var a = document.createElement( 'a' ); a.href = url;
a.appendChild( document.createTextNode( txt ) );
li.appendChild( a );
alert("trying " + id + " at 831");
this[ id ] = li; // watch this!!!
return li;
}
this.append = function( id, txt, url )
{ this.list.appendChild( this.newItem( id, txt, url ) );
}
this.insertBefore = function( old, id, txt, url )
{ this.list.insertBefore( this.newItem( id, txt, url ), this[ old ] );
}
// the ByTagName here is a bit annoying, but in Safari, I was picking
// up TextNodes by using this[ id ].firstChild.firstChild
//
this.getText = function( id ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data }
this.setText = function( id, txt ) { if(!this[id]){return;} this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data = txt }
this.getHref = function( id ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].href }
this.setHref = function( id, url ) { if(!this[id]){return;} this[ id ].getElementsByTagName( 'a' )[ 0 ].href = url }
// I add em as I need em....
}
function SoFixItInit() // pre-load, (don't want to slow down loading of article's content, though)
{
UserMenu = new PortletMenu( 'p-personal' );
PageMenu = new PortletMenu( 'p-cactions' );
NavMenu = new PortletMenu( 'p-navigation' );
UserMenu.setText( 'pt-mytalk' , 'Talk' );
UserMenu.setText( 'pt-preferences', 'Prefs' );
UserMenu.setText( 'pt-watchlist' , 'Watchlist' );
UserMenu.setText( 'pt-mycontris' , 'Contribs' );
UserMenu.setText( 'pt-logout' , 'Log out' );
PageMenu.setText( 'ca-talk' , 'talk' );
PageMenu.setText( 'ca-edit' , 'edit' );
PageMenu.setText( 'ca-history' , 'history' );
PageMenu.setText( 'ca-delete' , 'delete' );
PageMenu.setText( 'ca-watch' , 'watch' );
PageMenu.setText( 'ca-protect' , 'protect' );
PageMenu.setText( 'ca-addsection' , '+' );
}
window.addEventListener( 'load', SoFixItInit, true );
function addlilink(tabs, url, name, id){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.appendChild(na);
tabs.appendChild(li);
return li;
}
//////////////////////////////////////
// Mass checkbox manipulation
// for version undelete and watchlist
// by OwenX
//////////////////////////////////////
function any_boxes()
{
for (i=0; i<document.forms.length; i++)
for (j=0; j<document.forms[i].elements.length; j++)
if (document.forms[i].elements[j].type == 'checkbox')
return true;
return false;
}
function check_all_boxes(act)
{
var in_range = false;
for (i=0; i<document.forms.length; i++)
{
for (j=0; j<document.forms[i].elements.length; j++)
{
f= document.forms[i].elements[j];
if (f.type == 'checkbox')
{
if (act == 1)
f.checked = true;
else if (act == 0)
f.checked = false;
else if (act == -1)
f.checked = !f.checked;
else if (act == 2)
{
if (in_range)
if (f.checked)
{
in_range = false;
break;
}
else
f.checked = true;
else if (f.checked)
in_range = true;
}
}
}
}
}
function do_checkboxing()
{
if (any_boxes())
{
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
addlilink(tabs,'javascript:check_all_boxes(1)', 'Check all');
addlilink(tabs,'javascript:check_all_boxes(0)', 'Uncheck all');
addlilink(tabs,'javascript:check_all_boxes(-1)', 'Invert all');
addlilink(tabs,'javascript:check_all_boxes(2)', 'Fill range');
}
}
function do_onload()
{
if (mw.config.get('wgCanonicalSpecialPageName') == 'Undelete' || mw.config.get('wgCanonicalSpecialPageName') == 'Watchlist')
do_checkboxing();
// add a clock
var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0];
addlilink(toplinks, '#', '', 'utcdate');
showtime();
morelinks();
}
if (window.addEventListener)
window.addEventListener("load", do_onload, false);
else if (window.attachEvent)
window.attachEvent("onload", do_onload);
// ##### begin various mods from Essjay's monobook #####
function addTab(url, name, id, title, key){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, url, name, id, title, key);
}
function morelinks()
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(mw.config.get('wgCanonicalNamespace') == 'User_talk'||
mw.config.get('wgCanonicalNamespace') == 'User')
{
addlimenu(tabs, 'User functions', 'userf');
var userf = document.getElementById('userf').getElementsByTagName('ul')[0];
var editlk = mw.config.get('wgTitle');
var slloc = editlk.indexOf('/');
if(slloc > 0) editlk = editlk.substring(0, slloc);
var anon= IPhandler(editlk);
// format: addlilink(userf, url, name);
// add "block" tab
addlilink(userf, '/wiki/Special:Block/' + editlk, 'block user', '');
// add "blocklog" tab
addlilink(userf, '/wiki/Special:Log/block?page=User:' + editlk, 'block log', '');
// add "unblock" tab
addlilink(userf, '/w/index.php?title=Special:Ipblocklist&action=unblock&ip=' + editlk, 'unblock', '');
// add "contributions" tab
addlilink(userf, '/wiki/Special:Contributions/' + editlk, 'contribs', '');
// add "abuse hits" tab
addlilink(userf, '/wiki/Special:AbuseLog?title=Special:AbuseLog&wpSearchUser=' + editlk, 'abuse hits', '');
if (anon != true)
{
// add "user log" tab
addlilink(userf, '/w/index.php?title=Special:Log&type=&user=' + editlk, 'user log', '');
}
// add "edit count" tab
addlilink(userf, 'http://toolserver.org/~tparis/pcount/index.php?name=' + editlk + '&lang=en&wiki=wikipedia', 'editcount', '');
if (anon != true)
{
// add "rights" tab
addlilink(userf, '/w/index.php?title=Special:Listusers&limit=1&username=' + editlk.replace(" ","+"), 'rights', '');
}
if (anon != true)
{
// add "rights" tab
addlilink(userf, '/w/index.php?title=Special:Userrights&user=' + editlk.replace(" ","+"), 'promote', '');
}
if (anon == true)
{
// add "whois" tab
addlilink(userf, 'http://toolserver.org/~overlordq/cgi-bin/whois.cgi?lookup=' + editlk, 'whois', '');
// add "RDNS" tab
addlilink(userf, 'http://www.dnswatch.info/dns/dnslookup?la=en&host=' + editlk, 'RDNS', '');
}
}
}
function IPhandler(PossIP)
{
var count = 0
while (perp != -1)
{
var IP;
var perp = PossIP.indexOf('.');
if (perp == -1)
{
IP = PossIP.substring(0, PossIP.length)
}
else
{
IP = PossIP.substring(0, perp);
}
var check = Iptest(IP);
if (check != 1)
{
return false;
}
else
{
PossIP = PossIP.substring(perp + 1, PossIP.length)
count++;
}
}
if (count == 4)
return true;
else
return false;
}
function Iptest(Num)
{
if (Num >=0 && Num <= 255)
return 1;
}
function showtime()
{
var timerID;
var now = new Date();
var timeValue = now.toUTCString().replace(/GMT/, "UTC");
document.getElementById('utcdate').firstChild.innerHTML = timeValue;
timerID = setTimeout('showtime()', 100);
}
function addlimenu(tabs, name, id)
{
var na = document.createElement('a');
na.href = '#';
var mn = document.createElement('ul');
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.className = 'tabmenu';
li.appendChild(na);
li.appendChild(mn);
tabs.appendChild(li);
return li;
}
function topaz_extratoolbarbuttons() {
topaz.wputil.addsidepanelbutton("p-tb", "Page log",
'http://en.wikipedia.org/w/index.php?title=Special:Log&page='+mw.config.get('wgPageName')
);
topaz.wputil.addsidepanelbutton("p-tb", "Purge page cache",
'http://en.wikipedia.org/w/index.php?title='+mw.config.get('wgPageName')+'&action=purge'
);
}
if (window.addEventListener)
window.addEventListener('load', topaz_extratoolbarbuttons, false);
else if (window.attachEvent)
window.attachEvent('onload', topaz_extratoolbarbuttons);
function inc (file) {
mw.loader.load('/w/index.php?title='+file+'&action=raw&ctype=text/javascript&dontcountme=s');
}
popupFixDabs=true;
popupFixRedirs=true;
popupAdminLinks=true;
popupOnEditSelection=false;
if (mw.config.get('wgAction') != 'submit')
{
$(function(){ var x; if (x=document.getElementById('mw-input-wpHardBlock')) {x.checked=true;} });
var reason = '';
if (mw.config.get('wgAction') == 'delete' && mw.config.get('wgNamespaceNumber')==1) {reason = 'Talk page of a deleted...';}
$(function(){ var x; if (x=document.getElementById('wpReason')) {x.value=reason;} });}
inc("User:Topaz/init.js");
inc("User:Topaz/util.js");
inc("User:Topaz/comm.js");
inc("User:Topaz/wputil.js");
inc("User:Prodego/statuschanger.js");
inc("User:Prodego/Sandbox.js");
inc("User:ais523/editcount.js");
//inc("User:Prodego/moverevert.js");
inc("User:Splarka/sysopdectector.js");