User:Doh5678/WhatLinksHere.js
Wikisimpsons - The Simpsons Wiki
< User:Doh5678
Revision as of 10:40, September 10, 2011 by Doh5678 (talk | contribs) (moved User:Doh5678/Test.js to User:Doh5678/WhatLinksHere.js!)
*
This script adds new tabs to What Links Here pages. To use this
script, put the following in your [[Special:Mypage/vector.js]]
(or <skin>.js) file:
importScript('User:Doh5678/WhatLinksHere.js'); // [[User:Doh5678/WhatLinksHere.js]]
{{TOCright}}
This script maybe buggy
<code>
==Chris Griffin's WhatLinksHere select script for Wikisimpsons==
by Chris Griffin [[User:Doh5678]]
version 1.2 GPL GFDL February 2007
Contains chunks of {{W|User:Barticus88/WhatLinksHere.js}}.
On What links here pages, this script adds these tabs:
Mode: # All DPL T PTCI R W U 5000 All-Redirect
Each selection mode filters the list of pages
Hover over each letter to get a description
When selection mode is activated, a yellow banner appears at the top and
bottom of the page, with the mode description and counts, eg
Select Mode: Redirect (11 shown/687 hidden)
== Utility funcs ==
*/
//function getValueOf(varName) {defaultize(varName);
// return eval(varName);};
function getGetParamValue (param) {
window.location.href.match('[\?&]' + param + '=([^&]*)');
return RegExp.$1;
}
/*
== Selection funcs ==
*/
function sel_mode_DPL (linkHTML) {
return !(linkHTML.toLowerCase().indexOf( '</a> (redirect page' )
== -1 &&
( linkHTML.indexOf( 'href="/wiki/Talk:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/Category_talk:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/Template_talk:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/Help_talk:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/File:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/File_talk:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/Wikisimpsons:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/Wikisimpsons_talk:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/User:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/User_talk:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/MediaWiki:' ) != -1 ||
linkHTML.indexOf( 'href="/wiki/MediaWiki_talk:' ) != -1 ||
)
)
}
function sel_mode_Template (linkHTML) {
return linkHTML.indexOf( 'href="/wiki/Template:' ) != -1
}
function sel_mode_Portal (linkHTML) {
return linkHTML.indexOf( 'href="/wiki/Template:' ) != -1
|| linkHTML.indexOf( 'href="/wiki/Category:' ) != -1
|| linkHTML.indexOf( 'href="/wiki/File:' ) != -1
}
function sel_mode_User (linkHTML) {
return linkHTML.indexOf( 'href="/wiki/User:' ) != -1
|| linkHTML.indexOf( 'href="/wiki/User_talk:' ) != -1
}
function sel_mode_Wiki (linkHTML) {
return linkHTML.indexOf( 'href="/wiki/Wikisimpsons:' ) != -1
|| linkHTML.indexOf( 'href="/wiki/Wikisimpsons_talk:' ) != -1
}
function sel_mode_Redir (linkHTML) {
return linkHTML.toLowerCase().indexOf( '</a> (redirect page' ) != -1
}
function sel_mode_All (linkHTML) {
return true
}
/*
==Da Main func==
*/
function select_pages(select_this, mode_name){
body = document.getElementById('bodyContent');
if( !body ){ return; }
banner = document.getElementById('dpl_banner')
if (banner && banner.innerHTML.indexOf(mode_name) != -1) {
open(document.URL, "_self"); //refresh the page
return;
}
lists = body.getElementsByTagName( "ul" );
for( j=0; j<lists.length; j++ ){
lists[j].style.listStyleType = 'decimal';
}
links = body.getElementsByTagName( "li" );
dpl_in = 0;
dpl_ex = 0;
for( i=0; i<links.length; i++ ){
if( select_this(links[i].innerHTML) ) {
links[i].style.display = ''; // clear prior style
dpl_in++;
} else {
links[i].style.display = 'none'; // hide
dpl_ex++;
}
}
window.wlhCt = window.wlhCt || 0;
window.wlhCt ++;
banner_text = "Select Mode: " + mode_name + " ("
+ dpl_in.toFixed() + " shown/" + dpl_ex.toFixed() + " hidden)";
if (banner) {
banner.innerHTML = banner_text;
banner = document.getElementById('dpl_footer');
banner.innerHTML = banner_text;
}else{
banner = document.createElement("div");
banner.id = "dpl_banner";
banner.style.backgroundColor = "yellow";
banner.style.fontSize = 'larger';
banner.innerHTML = banner_text;
body.insertBefore(banner,body.childNodes[0]);
body = document.getElementById('footer');
if( !body ){ return; }
banner = document.createElement("div");
banner.id = "dpl_footer";
banner.style.backgroundColor = "yellow";
banner.style.fontSize = 'larger';
banner.innerHTML = banner_text;
body.insertBefore(banner,body.childNodes[0]);
}
}/* end function select_pages
==Da tabbar fiddler==
*/
addOnloadHook(function (){
if (wgPageName.toLowerCase() != 'special:whatlinkshere') { return; }
// only add toolbox link on 'whatlinkshere' pages
target = document.getElementById('p-cactions').getElementsByTagName( "ul" );
if( target.length == 0 ){ return; } //no action bar to hook into
wlhCmd = getGetParamValue ('wlhCmd');
if( wlhCmd == 'r' ) select_pages(sel_mode_Redir,"Redirect (auto)");
target = target[0];
newTool = document.createElement("li");
target.appendChild( newTool );
function ptool(btn,func,desc){
return '<a href="" onclick="select_pages(sel_mode_'
+ func + ',\'' + desc + '\');return false;" title="'
+ desc + '">' + btn + '</a>'
}
newTool.innerHTML = 'Filter mode:'
+ ptool ('All', 'All', 'Show all')
+ ptool ('DPL', 'DPL', 'Main Space and Template')
+ ptool ('T', 'Template', 'Template Only')
+ ptool ('TCF', 'TCF', 'Template, Category, File')
+ ptool ('R', 'Redir', 'Redirect')
+ ptool ('W', 'Wiki', 'Wikisimpsons')
+ ptool ('U', 'User', 'User and User Talk')
;
document.getElementById('bodyContent').innerHTML
.match(/href="([^"]*)&limit=500/);
url500 = RegExp.$1;
addPortletLink('p-cactions',url500 + '&limit=5000'
,'5000',null,'Show up to 5000 links');
addPortletLink('p-cactions',url500 + '&limit=5000&wlhCmd=r'
,'All Redirects',null,'Show ALL Redirects (up to 5000 links)');
});