User:Lar/monobook.js

// //---

///////////////////////////////////////////////////////////////////////////////////////////////////////// // Script loading function by Quarl (http://en.wikipedia.org/wiki/User:Quarl) /////////////////////////////////////////////////////////////////////////////////////////////////////////

// loads from en...

function winc(s) { s = s.replace(/^\[\[/, ).replace(/\]\]$/, ); document.write(' '); }

// loads from commons...

/*** en:User:Lightdarkness's include function ***/ function co_inc (file) { var lt = String.fromCharCode(60); var gt = String.fromCharCode(62); document.writeln(lt+'script type="text/javascript" src="http://commons.wikimedia.org/w/index.php?title='+file+'&amp;action=raw&amp;ctype=text/javascript&amp;dontcountme=s"'+gt+lt+'/script'+gt); }

function cur_date_year { var months2 = new Array('January', 'February', 'March', 'April', 'May', 'June',                         'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date; var yearStr = date.getUTCFullYear; var MoDayStr = months2[date.getUTCMonth]+" "+date.getUTCDate; var t = MoDayStr+", "+yearStr; return t; }

// for image upload page to automate the image information template insertion function imageInfo {

// a page edit box is called wpTextbox1 // the description box on an upload page is called wpUploadDescription

// works for edit box but not here, wrong form and field // var txt = document.editform.wpTextbox1;

// upload is the ID but not the name... so this fails // var txt = document.upload.wpUploadDescription;

// this works but it is brittle // var txt=document.forms[0].wpUploadDescription; var txt=document.getElementById('upload').wpUploadDescription;

if(txt.value.length > 0) txt.value += '\n'; txt.value += "" +'\n' + "== Licensing ==" +'\n' + "" +'\n'; txt.focus; }

// add a 00:49, 27 May 2006 // at the end of the current edit contents. // will have problems at the change in years since it depends on date.getUTCFullYear

function addUnsigned2 { // sample string to paste in is "18:32, 18 June 2006 FredUser" or "00:49, 27 May 2006 Timothy Usher " var date = new Date; var idString = prompt("ID string?"); var f = document.editform, t = f.wpTextbox1;

// a regexp for the date part of the string would be a better way to do this...  //... but slicing on year should almost always work

var pipeLoc= idString.indexOf(date.getUTCFullYear); // assume 4 digit year, breaks after 9999 var idStringPiped= idString.substr(0,pipeLoc+4)+'|'+idString.substr(pipeLoc+5,idString.length);

t.value += "" + idStringPiped + ""; f.wpSummary.value = "add Unsigned2 using string:" + idString; }

// **** Add generic tab ****

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; }

// there is a version of the above in en:User:Voice_of_All/Addtabs/monobook.js

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; }

// UTC clock winc('User:Voice_of_All/UTCclock.js');

//--- /* like submitting the URL http://en.wikipedia.org/w/index.php?title=&action=purge */

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

//--- //Toolbox links // changes top links function changelinks { if(!document.getElementById) return; document.getElementById('pt-mytalk').firstChild.innerHTML = 'my Talk'; document.getElementById('pt-preferences').firstChild.innerHTML = 'Change Prefs'; document.getElementById('pt-watchlist').firstChild.innerHTML = 'My Watchlist'; document.getElementById('pt-mycontris').firstChild.innerHTML = 'My Contribs'; document.getElementById('pt-logout').firstChild.innerHTML = 'Log out'; } // adds useful links function addtoolboxlinks { var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, '/wiki/Special:Newpages', 'New pages', ''); addlilink(tb, '/wiki/Special:Log/newusers', 'New users', ''); addlilink(tb, '/wiki/Special:Log', 'Log', ''); addlilink(tb, '/wiki/Special:Log/delete', 'Delete log', ''); addlilink(tb, '/wiki/Special:Log/block', 'Block log', ''); addlilink(tb, '/wiki/Special:Ipblocklist', 'IPBlocklist', ''); } // adds various tabs and menu tabs function add_more_tabs { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; var username=document.getElementById("pt-userpage").textContent;

if (document.title.indexOf("Upload file") != -1) { addlimenu(tabs, 'upTags', 'upFm'); var upFm = document.getElementById('upFm').getElementsByTagName('ul')[0]; addlilink(upFm,'javascript:imageInfo','ImageInfo'); addlilink(upFm,'javascript:addUnsigned2','Unsigned2'); }

// Only add for pages with "Editing User talk:" somewhere in the title if (document.title.indexOf("Editing User talk:") != -1) { addlimenu(tabs, 'artTalk msgs', 'talkm'); var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0]; addlilink(talkm,'javascript:addUnsigned2','Unsigned2'); }

if (document.title.indexOf("Editing") != 0) {  }

} //END

$(Mainfast) function Mainfast { //  changemovetab; changelinks; addpurge; addtoolboxlinks; add_more_tabs;

}

window.onload = Main; function Main {  // addtoplink; // LivePreviewInstall; // if(addSinceTab) // {addSinceTab;} }

// slow load tools

//includes

// popups co_inc ("User:Kylu/popups.js");; //Tool2 (localized) co_inc ("User:Kylu/Tool2/code.js"); //editcount toolbox link (not localized, just username adjusted) co_inc ("User:Kylu/editcount.js");

// Popups options: simplePopups = false;

popupFixRedirs = true;

popupSubpopups = false; popupNavLinkSeparator = ' &bull; '; popupRedirAutoClick = 'wpPreview';

//Beta! popupLiveOptions=true;         //Lets you change frequently-changed Popups options while in-use popupLiveOptionsExpanded=false; //Starts with the options tab open on popover (annoying)

// I am not an admin so do not use this

popupAdminLinks=false;  // optional: enable admin links popupSubpopups=false; popupStructure='shortmenus'; popupDelay=1.0;         // optional: time in s before popup happens (slowed down from default of .5s popupEditCounterTool='interiot';  // other value is 'kate' but I prefer interiot's as it has more features popupOnEditSelection=false; // I do not want popups for links that I select while editing. popupFixDabs=true;          // I do want to be able to fix disambigs

popupExtendedRevertSummary='Revert to version $1 by $2 using popups';

//

//END //