User:Cohesion/vector.js

/* */

/*Returns the name of the page. For example, if you were browsing the "foo" WP page, getPname would return "foo".*/ function getPname { return wgPageName.replace(/_/g, ' '); }

//A helper function to add a button to one of the toolbars in the interface. //An improved(I hope) version of addlilink. //JesseW, the juggling janitor 05:33, 8 November *2005 (UTC)

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", "p-navigation", or "p-tb". //   //* 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; }

/**************************************************************/

function addlilink(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]; }   }    // re-render the title and accesskeys from existing code in wikibits.js    akeytt; return li; }

/**************************************************************/

function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key) };

/**************************************************************/

// addPurge $( function {   var x = document.getElementById('ca-history');    if(!x) return;    if(x.children) x = x.children[0].href;    else x = x.childNodes[0].href;    addLink("p-cactions", x.replace(/=history/, "=purge"), 'purge', 'ca-purge', 'Purge the internal cache for this page', 0); });

/**************************************************************/

// Please leave the following line // user:Where/usertabs $(function { if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1)  //no subpages or history     return;  if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {     var username = encodeURIComponent( wgTitle );     mw.util.addPortletLink("p-cactions", wgServer + "/wiki/Special:Contributions/" + username, "Contribs", "ca-contrib", "User contributions");     mw.util.addPortletLink("p-cactions", "http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "Edit count", "ca-editcount", "Edit count from Interiot's Tool1");     mw.util.addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=move&user=" + username, "Page moves", "ca-pagemoves", "Page moves by this user");     mw.util.addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&page=User:" + username, "Blocks received", "ca-blog", "Blocks received by this user"); mw.util.addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Prefixindex&from=" + username + "&namespace=2", "Userspace", "", "List of pages in this user's userspace"); mw.util.addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&user=" + username, "Blocks given", "", "Blocks by this user"); mw.util.addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=protect&user=" + username, "Protections", "", "Protections by this user"); mw.util.addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=delete&user=" + username, "Deletions", "", "Deletions by this user"); } });

//

/**************************************************************/

function tnaddlilink(url, name) { var na = document.createElement('a'); na.setAttribute('href', url);

var txt = document.createTextNode(name); na.appendChild(txt);

var li = document.createElement('li'); li.appendChild(na); return li; }

function testn(number) { var page = prompt("Vandalism to which article?") var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += "" + page + " ~" + "~" + "~" + "~"; f.wpSummary.value = "Vandalism to " + page + " - warning " + number; }

function add_testn_tabs { var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

// Only add for pages with "Editing User talk:" somewhere in the title if (document.title.indexOf("Editing User talk:") != -1) {     tabs.appendChild(tnaddlilink('javascript:testn(1)',"t1")); tabs.appendChild(tnaddlilink('javascript:testn(2)',"t2")); tabs.appendChild(tnaddlilink('javascript:testn(3)',"t3")); tabs.appendChild(tnaddlilink('javascript:testn(4)',"t4")); } }

$(add_testn_tabs);

/**************************************************************/ /* this doesn't work anymore, but maybe one day, leaving in... */ // User:Jsimlo/shortcuts.js document.write(' '); function shortcutsInit { shortcutsAddLink ('Deletes', 'Category:Candidates for speedy deletion'); shortcutsAddLink ('Questions', 'Wikipedia:Media copyright questions'); shortcutsAddLink ('Tags', 'Wikipedia:Image copyright tags'); shortcutsAddLink ('Log', 'Special:Log'); shortcutsAddLink ('Stats', 'Special:Statistics'); shortcutsAddLink ('Templates', 'Wikipedia:Template messages'); shortcutsAddLink ('Untagged', 'Special:Uncategorizedimages'); shortcutsAddLink ('Disambiguation', 'Wikipedia:Disambiguation pages with links'); shortcutsAddLink ('New pages', 'Special:Newpages'); }

/**************************************************************/

// Add date and time to your monobook "personal menu" list at the very top of the page. // Created by User:Mathwiz2020

// Indicate where you would like the time to appear: // 1 is first (before username), 2 is second (before talk link), ... 7 is last (after log out link) insertBeforeNum = 7;

// Do NOT edit below this line unless you're experiened in javascript insertBeforeArr = new Array("","pt-userpage","pt-mytalk","pt-preferences","pt-watchlist","pt-mycontris","pt-logout",""); insertBefore = insertBeforeArr[insertBeforeNum];

function makeTime { var li = document.createElement( 'li' ); li.id = 'pt-time';

var mySpan = document.createElement( 'span' ); mySpan.appendChild( document.createTextNode( 'date and time' ) );

li.appendChild( mySpan );

if ( insertBefore ) {   var before = document.getElementById( insertBefore ); before.appendChild( li, before ); } else // append to end (right) of list {   document.getElementById( 'pt-logout' ).parentNode.appendChild( li ); }

getTime; }

if     ( window.addEventListener ) window.addEventListener ( 'load', makeTime, false ); else if ( window.attachEvent     ) window.attachEvent      ( 'onload', makeTime      );

function getTime {   var time    = new Date; var date   = time.getUTCDate; var months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' '); month  = months[time.getUTCMonth]; var year   = time.getUTCFullYear; var hours  = '0' + time.getUTCHours; hours  = hours.substr(hours.length-2, hours.length); var minutes = '0' + time.getUTCMinutes; minutes = minutes.substr(minutes.length-2, minutes.length); var seconds = '0' + time.getUTCSeconds; seconds = seconds.substr(seconds.length-2, seconds.length); var curTime = hours + ":" + minutes + ":" + seconds + ", " + date + " " + month + " " + year + " (UTC)"; datePlace  = document.getElementById('pt-time').childNodes[0].childNodes[0]; datePlace.replaceData(0, datePlace.length, curTime); doTime     = window.setTimeout("getTime", 1000); } //

/**************************************************************/

/**** quick image delete ****/ document.write(' ');

/* This is to keep track of who is using this extension: User:Howcheng/quickimgdelete.js */

/**************************************************************/

// tagger function commonsOK { document.editform.wpTextbox1.value += "\n"; document.editform.wpSummary.value = ""; document.editform.submit; } function addCommonsOK{ if (document.editform && wgCanonicalNamespace == "Image") { mw.util.addPortletLink("p-cactions", "javascript:commonsOK", "", ""); } } $(addCommonsOK);

/**************************************************************/

// User:Krimpet/CH2.js importScript('User:Krimpet/CH2.js');

// ================================================== // Image Redlink Toolkit // ================================================== $(redImageTools); function redImageTools { var img = getElementsByClassName(document.getElementById('bodyContent'),'a','new'); for(var i=0;i<img.length;i++) { var iu = img[i].href; if(iu.search(/Special\:Upload/i)!=-1) { var it = 'Image:' + iu.substring(iu.indexOf('wpDestFile=')+11,iu.length); insertWrappedLinkAfter(img[i], wgScriptPath + '/index.php?title=Special:Log&page=' + it,'logs'); insertWrappedLinkAfter(img[i], wgScriptPath + '/index.php?title=' + it + '&action=edit','edit'); insertWrappedLinkAfter(img[i], wgScriptPath + '/index.php?title=' + it,'view'); img[i].className = 'new newimage'; } else if(iu.search(/title\=Image\:/i)!=-1) { var it = iu.substring(iu.indexOf('title=')+6,iu.indexOf('&action=edit')); insertWrappedLinkAfter(img[i], wgScriptPath + '/index.php?title=Special:Upload&wpDestFile=' + it,'upload'); insertWrappedLinkAfter(img[i], wgScriptPath + '/index.php?title=Special:Log&page=' + it,'logs'); insertWrappedLinkAfter(img[i], wgScriptPath + '/index.php?title=' + it,'view'); img[i].className = 'new newimage'; } } } function insertWrappedLinkAfter(object,link,text) { var sm = document.createElement('small'); var li = document.createElement('a'); li.href = link; var tx = document.createTextNode(text); var po = document.createTextNode(' ('); var pc = document.createTextNode(')'); li.appendChild(tx); sm.appendChild(po); sm.appendChild(li); sm.appendChild(pc); object.nextSibling && object.parentNode.insertBefore(sm,object.nextSibling) || object.parentNode.appendChild(sm) } // ================================================== // End Image Redlink Toolkit // ==================================================

/* */