User:Politicaljunkie/monobook.js

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

$(function {	if(document.forms.editform) {		var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];		addlilink(tabs, 'javascript:softRedirect;', 'Soft redirect', 'ca-redirect');	} });

function softRedirect{ var txt = document.editform.wpTextbox1; var r = txt.value.replace(new RegExp("[\\S\\s]*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt][_ ]?(\\[\\^\\*\\]\\])[\\S\\s]*|[\\s\\S]*", "g"), "$1"); if (r==""){ var r = ""+prompt('What page should the redirect point to?')+""; }	txt.value = ""+r+""; var summary = document.editform.wpSummary; summary.value = "Converted to soft redirect"; }

/* Add author template */ if (window.addEventListener) { window.addEventListener("load",addAuthorTemplateLink,false); }   else if (window.attachEvent) { window.attachEvent("onload",addAuthorTemplateLink); }

//    function addAuthorTemplateLink { if(document.getElementById) { var loc = '' + window.location; if(loc.indexOf("action=edit") > -1 || loc.indexOf("action=submit") > -1) { var toolbar = document.getElementById('toolbar'); var a = document.createElement('a'); a.setAttribute('href',"javascript:insertTags(,,'');"); var img = document.createElement('img'); img.setAttribute('src', "/skins-1.5/common/images/button_headline.png"); img.setAttribute('alt', "Author Template"); img.setAttribute('title', "Author Template"); img.setAttribute('border', "0"); img.setAttribute('height', "22"); img.setAttribute('width', "23"); a.appendChild(img); toolbar.appendChild(a); }      }    } //

/* Add header template */ function addHeaderTemplateLink { if(document.getElementById) { var loc = '' + window.location; if(loc.indexOf("action=edit") > -1 || loc.indexOf("action=submit") > -1) { var toolbar = document.getElementById('toolbar'); var a = document.createElement('a'); a.setAttribute('href',"javascript:insertTags(,,'');"); var img = document.createElement('img'); img.setAttribute('src', "/skins-1.5/common/images/button_headline.png"); img.setAttribute('alt', "Header Template"); img.setAttribute('title', "Header Template"); img.setAttribute('border', "0"); img.setAttribute('height', "22"); img.setAttribute('width', "23"); a.appendChild(img); toolbar.appendChild(a); }   } }

if (window.addEventListener) window.addEventListener("load",addHeaderTemplateLink,false) else if (window.attachEvent) window.attachEvent("onload",addHeaderTemplateLink)

/* hide wikipedia links */ function hideextiw { var i = 0; var k = document.links.length; for (i=0;i<k;i++) { if (document.links[i].className == 'extiw') { document.links[i].className='hiddenextiw'; }   }    var a = document.getElementById('hideshow'); a.onclick = function { showextiw; }; }

/* show wikipedia links */ function showextiw { var i = 0; var k = document.links.length; for (i=0;i<k;i++) { if (document.links[i].className == 'hiddenextiw') { document.links[i].className='extiw'; }   }    var a = document.getElementById('hideshow'); a.onclick = function { hideextiw; }; }

/* add hide tab */ function addthetab { var a = document.createElement('a'); a.setAttribute('href', 'javascript:;'); a.onclick = function { hideextiw; }; a.setAttribute('id', 'hideshow'); a.appendChild(document.createTextNode('hide/show')); var tab = document.createElement('li'); tab.appendChild(a); var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; tabs.appendChild(tab); }

if (window.addEventListener) window.addEventListener("load",addthetab,false); else if (window.attachEvent) window.attachEvent("onload",addthetab);

/*  */ /* Instaview */ /* See WS:SCRIPTS; adds instant preview to edit page. */      document.write(' '); InstaView.conf.user.name = 'Zhaladshar'; /* */

/* Add soft redirect template */ function addSoftRedirectTemplateLink { if(document.getElementById) { var loc = '' + window.location; if(loc.indexOf("action=edit") > -1 || loc.indexOf("action=submit") > -1) { var toolbar = document.getElementById('toolbar'); var a = document.createElement('a'); a.setAttribute('href',"javascript:insertTags(,,'');"); var img = document.createElement('img'); img.setAttribute('src', "/skins-1.5/common/images/template_button.png"); img.setAttribute('alt', "Soft redirect"); img.setAttribute('title', "Soft redirect"); img.setAttribute('border', "0"); img.setAttribute('height', "22"); img.setAttribute('width', "23"); a.appendChild(img); toolbar.appendChild(a); }   } }

if (window.addEventListener) window.addEventListener("load",addSoftRedirectTemplateLink,false); else if (window.attachEvent) window.attachEvent("onload",addSoftRedirectTemplateLink);

/* */