User:OlEnglish/vector.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:OlEnglish/vector.css. |
importScript('User:NuclearWarfare/Mark-blocked script.js');
importScript('User:CBM/quickpreview.js');
importScript('User:Tim Song/afchelper4.js');
importScript('User:Ale_jrb/Scripts/userhist.js');
// importScript('user:js/watchlist.js'); //
// importScript('User:King of Hearts/closexfd.js); //
// importScript('User:Lupin/recent2.js'); //
// importScript('User:Manishearth/orphantabs.js'); //
// importScript('User:Ale_jrb/Scripts/statusCheck.js'); //
// importScript('User:Ale_jrb/Scripts/igloo.js'); //
// importScript('User:M/reword.js'); //
// Random pages links in the menu bar //
randomPages = {
addToolboxLink: function(url, name, id) {
var tb = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
randomPages.addlilink(tb, url, name, id);
},
addlilink: function(tabs, url, name, id, title, key) {
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);
tabs.appendChild(li);
if(id) {
if(key && title) ta[id] = [key, title];
else if(key) ta[id] = [key, ''];
else if(title) ta[id] = ['', title];
}
akeytt();
return li;
},
}
addOnloadHook(function() {
randomPages.addToolboxLink("http://en.wikipedia.org/wiki/Special:RandomRedirect", 'Random redirect', 'random-redirect');
randomPages.addToolboxLink("http://en.wikipedia.org/wiki/Special:Random/Talk", 'Random talk', 'random-talk');
randomPages.addToolboxLink("http://en.wikipedia.org/wiki/Special:Random/Wikipedia", 'Random wikipedia', 'random-wikipedia');
randomPages.addToolboxLink("http://en.wikipedia.org/wiki/Special:Random/File", 'Random file', 'random-file');
randomPages.addToolboxLink("http://en.wikipedia.org/wiki/Special:Random/User", 'Random user', 'random-user');
}
);
// Link to admin dashboard //
function addDash() {
loLogoutNode = document.getElementById("pt-logout");
loDashNode = addPortletLink( "p-personal"
, wgServer + wgScriptPath + "/index.php?title=User:" + wgUserName + "/Dashboard"
, "My dashboard"
, "pt-admindash"
, "Link to dashboard"
, "d"
, loLogoutNode );
}
addOnloadHook(addDash);
// Watchlist unwatch button //
var wlUnwatch = new function(){
var unWatchLinks = [];
var watchMsg = window.wgAjaxWatch ? wgAjaxWatch.watchMsg : 'Watch';
var unwatchMsg = window.wgAjaxWatch ? wgAjaxWatch.unwatchMsg : 'Unwatch';
var wlForm;
var inProgress = null;
var timeoutID = null;
this.onLoad = function() { //public method
if (!(wlForm = document.forms[0]) || !wlForm.namespace) return;
var content = document.getElementById('content') || document.getElementById('mw_content')
var links = content.getElementsByTagName('a');
for (var i = 0; i < links.length; i++){ //append (x) links after history links
if (!links[i].href.match(/[?&]action=history([&#]|$)/)) continue;
var unwatch = document.createElement('a');
unwatch.href = wgServer+wgScript+'?action=unwatch&title='+encodeURIComponent(links[i].title);
unwatch.onclick = onClick;
unWatchLinks.push(unwatch);
var nextEl = links[i].nextSibling.nextSibling; //item after )
nextEl.parentNode.insertBefore(document.createTextNode(' ('), nextEl);
nextEl.parentNode.insertBefore(unwatch, nextEl);
nextEl.parentNode.insertBefore(document.createTextNode(') '), nextEl);
setUnwatchLink(unwatch, false);
}
}
function setUnwatchLink (unwatchLink, state) {
unwatchLink.innerHTML = state ? '+' : 'x';
unwatchLink.title = state ? watchMsg : unwatchMsg;
}
function getPgName (unwatchLink){
return decodeURIComponent(unwatchLink.href.match(/&title=(.+)/)[1]);
}
function onClick(e) {
if (inProgress) return false;
if (!e) var e = window.event;
if (e.target) var targ = e.target; else if (e.srcElement) var targ = e.srcElement;
inProgress = getPgName(targ);
timeoutID = window.setTimeout( function() {inProgress = null}, 10000 );
//call server
var action = (targ.innerHTML == 'x') ? 'u' : 'w';
sajax_do_call('wfAjaxWatch', [inProgress, action], showResult);
return false;
}
function showResult (request) {
if (timeoutID) window.clearTimeout(timeoutID);
var response = request.responseText;
if (window.wlUnwatchShowMsg) jsMsg (response.substr(4), 'watch');
var name = inProgress, name2 = name, state, prefix, idx, ns = 0, pg, i, el;
inProgress = null;
if (response.match(/^<u#>/))
state = true
else if (response.match(/^<w#>/))
state = false
else return; //unrecognized response
//find the name of "other page"
if ((idx = name.indexOf(':')) != -1){ //not main namespace
prefix = name.substring(0,idx);
name2 = name.substring(idx + 1)
for (i=2; i < wlForm.namespace.options.length; i++)
if (wlForm.namespace.options[i].text == prefix)
ns = i - 1;
if (ns == 0) name2 = name; // guess : was a part of the page name
}
if (ns % 2) ns--; else ns++; //switch to "other" namespace
if (ns > 0) name2 = wlForm.namespace.options[ns+1].text + ':' + name2;
//now mark all pages that are either name or name2
for (i=0; i<unWatchLinks.length; i++)
if ((pg = getPgName(unWatchLinks[i])) && (pg==name || pg==name2)) {
setUnwatchLink (unWatchLinks[i], state);
el = unWatchLinks[i]; //now mark the whole line
while ((el=el.previousSibling) && (el.nodeName!='DIV') && (el.nodeName!='BR'))
if (el.style) el.style.textDecoration = state ? 'line-through' : '';
}
}
}//obj
if (wgCanonicalSpecialPageName && wgCanonicalSpecialPageName=='Watchlist' && wgAction=='view') {
if (doneOnloadHook) wlUnwatch.onLoad(); //if imported dynamically
else addOnloadHook (wlUnwatch.onLoad)
}