User:Clubclubclub/monobook.js

{\rtf1\ansi\ansicpg1252 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;} \deftab720 \pard\pardeftab720\sl320\partightenfactor0

\f0\fs22 \cf2 \cb3 \expnd0\expndtw0\kerning0 \outl0\strokewidth0 \strokec2 ////////////////////////////////////////////////////////////////\ // =-=-=- HELPER FUNCTIONS -=-=-=-\ 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);\ return li;\ \}\ \ function addToolboxLink(url, name, id, title)\{\ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];\ addlilink(tb, url, name, id, title);\ \}\ \ function addTab(url, name, id, title, key) \{\ return mw.util.addPortletLink('p-cactions', url, name, id, title, key);\ \}\ \ function addLink(where, url, name, id, title, key, after)\{\ 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);\ \}\   return li;\ \}\ \ 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;\ \}\ \ function addnavbox_link(URL,Name,ID)\ \{\ var portlet = document.getElementById('p-navigation');\ var links = portlet.getElementsByTagName('ul')[0];\ links.innerHTML += '' + Name + '';\ \}\ /////////////////////////////////////////////\ } importScript('User:VoA/monobook.js');

// {\rtf1\ansi\ansicpg1252 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;} \deftab720 \pard\pardeftab720\sl320\partightenfactor0

\f0\fs22 \cf2 \cb3 \expnd0\expndtw0\kerning0 \outl0\strokewidth0 \strokec2 //Manual replace\ function replacetxt\ \{\ withw = '';\ what = prompt("What text do you want to replace?" + "\\n" + "You can even use regex commands." + "\\n" + "Put '//' before and after the phrase to use regex.");\ if (what == '')\{alert("Invalid command."); return;\}\ else if (what == null)\{alert("Action cancelled."); return;\}\ what_GUI = what;\ if (what.replace('//',).replace('//',) == what.split('//')[1])\ \{\ what = what.split('//')[1]\ replacetxtdone(what.split('//')[0],1,what);\ \}\ else\ \{\ what = what.replace(/\\\\/g,"\\\\\\\\");\ what = what.replace(/\\(/g,"\\\\(").replace(/\\)/g,"\\\\)");\ what = what.replace(/\\\{/g,"\\\\\{").replace(/\\\}/g,"\\\\\}");\ what = what.replace(/\\[/g,"\\\\[").replace(/\\]/g,"\\\\]");\ what = what.replace(/\\|/g,"\\\\|");\ what = what.replace(/\\./g,"\\\\.");\ what = what.replace(/\\$/g,"\\\\$");\ what = what.replace(/\\+/g,"\\\\+");\ what = what.replace(/\\^/g,"\\\\^");\ what = what.replace(/\\?/g,"\\\\?");\ what = what.replace(/\\*/g,"\\\\*");\ what = what.replace(/\\//g,"\\\\/");\ replacetxtdone(what,0,what_GUI);\ \}\ \}\ //END\ \ //Manual replace\ function replacetxtdone(s,regexon,what_GUI)\ \{\ var original = document.editform.wpTextbox1.value;\ if(s) \ \{ \ if (regexon==1)\ \{var r = prompt('Replace "' + what_GUI + '" with what? (Regex)');\}\ else\ \{var r = prompt('Replace "' + what_GUI + '" with what?');\}\ if(!r && r != '') \{alert('Action cancelled.'); return;\} \ if (r == '')\{alert("All such appearances of text will be removed.");\}\ var txt = document.editform.wpTextbox1;\ var rep = RegExp(s,"g");\ txt.value = txt.value.replace(rep, r); \ form = document.getElementById('bodyContent');\ l = form.getElementsByTagName('input');\ for (i = 0; i < l.length; i++)\ \{\   if (l[i].name == 'wpMinoredit')\ \{l[i].value = '1'; l[i].checked=true;\}\ \}\ if (document.editform.wpTextbox1.value == original)\{alert('The word or phrase was not found on this page.'); return;\}\ document.editform.wpSummary.value += 'JS: Replacing "' + what_GUI + '" with "' + r + '". ';\ \}\ \}\ //END\ \ //---\ //add tab\ addOnloadHook(replacetab)\ function replacetab\ \{\ if (document.title.indexOf("Editing ") != -1)\ \{\   addToolboxLink("javascript:replacetxt","Text replacer","txt-repl");\ \}\ \}\ //END\ \ ////////////REDIRECTS////////////\ addOnloadHook(redir_other_add)\ function redir_other_add\ \{\ if (document.title.search(/Editing |Edit conflict/) != 0)\ \{addToolboxLink('javascript:redire_other','Redirect to here','redir-hr','`');\}\ if (location.href.indexOf('&action=edit&jsaction=Redirect&target=') != -1)\ \{\ var page = unescape(location.href.split('&target=')[1]);\ var redirect = '#REDIRECT ' + page + '';\ var message = 'Note: Page already exists. Override?';\ if (document.editform.wpTextbox1.value != '')\ \{\ var override = confirm(message);\ if (!override)\{return;\}\ \}\ document.editform.wpTextbox1.value = redirect;\ document.editform.wpSummary.value = 'Redirect to ' + page + '';\ var form = document.getElementById('bodyContent');\ l = form.getElementsByTagName('input');\ for (var i = 0; i < l.length; i++)\ \{\    if (l[i].name == 'wpMinoredit')\ \{l[i].value = '1'; l[i].checked=true; break;\}\ \}\ \}\ \}\ \ function redire_other\ \{\ var page = document.title.replace('Editing ',).replace('Edit Conflict',).replace('Edit conflict','').split(' - ')[0];\ var txt = new String; \ var foundIn = ''; \ if (window.getSelection) \ \{ \ txt = window.getSelection; \ foundIn = 'window.getSelection'; \ \} \ else if (document.getSelection) \ \{ \ txt = document.getSelection; \ foundIn = 'document.getSelection'; \ \} \ else if (document.selection) \ \{ \ txt = document.selection.createRange.text;\ foundIn = 'document.selection.createRange'; \ \} \ else \ \{var txt = prompt('No selected text found. Enter the page name:');\}\ if (!txt || txt == '')\ \{var txt = prompt('No selected text found. Enter the page name:');\}\ if (!txt || txt == '')\{return;\}\ URL = wgServer + '/w/index.php?title=' + txt + '&action=edit&jsaction=Redirect&target=' + page;\ URL = URL.replace(' &action','&action');\ location.href = URL;\ \}\ } {\rtf1\ansi\ansicpg1252 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;} \deftab720 \pard\pardeftab720\sl320\partightenfactor0

\f0\fs22 \cf2 \cb3 \expnd0\expndtw0\kerning0 \outl0\strokewidth0 \strokec2 // \ \ /////////////////////Google search tabs/////////////////////\ addOnloadHook(googletab)\ function googletab\ \{\ if(document.getElementById('ca-nstab-main'))\ \{\ if (document.title.indexOf('Editing ') == -1)\ \{\     if (location.href.search('\\\\&action=') == -1)\ \{\    addTab("javascript:googlesrch('regular')", "?", "ca-google", "Google search", "");\ \}\   \} \  \}\ \}\ \ //Google search\ function googlesrch(type)\ \{\ var rest = '';\ var target = wgTitle;\ //for disambigged stuff\ if (target.indexOf("(") !=-1 && target.indexOf(")") !=-1)\ \{\ rest = target.split(" (")[1].split(")")[0];\ target = target.split(" (")[0];\ \}\ if (type == 'regular')\ \{\  srch_window = window.open('http://www.google.com/search?hl=en&lr=&safe=on&q=%22' + escape(target) + '%22+' + escape(rest) + '&btnG=Search',\ 'Googlesearch' + target,\ 'status,toolbar,location,menubar,directories,resizeable,scrollbars,fullscreen=yes');\ \}\ \}\ /////////////////////\ \ ////////////////////////Reference (cite.php) Toggling////////////////////////\ addOnloadHook(toggle_refs_add)\ function toggle_refs_add\ \{\ if (document.title.indexOf('Editing ') == 0 && document.title.search('(Image:|Template:| talk:|Category:|Portal:|Wikipedia:|MediaWiki:|Help:|Talk:|User:|View and restore deleted pages)') == -1)\  \{addToolboxLink("javascript:toggle_refs","Toggle references","toggle-ref");\}\ \}\ \ function zreplace_refs\ \{\  z_auto_ref_countup += 1;\  var string = '<>';\  return string;\ \}\ \ function zreturn_refs(match,number)\ \{\  if (ref_return_js_cache[number-1] != undefined)\  \{var string = ref_return_js_cache[number-1];\}\  else \  \{alert('Error parsing reference #' + number + '.'); var string = match;\}\ return string;\ \}\ \ function toggle_refs\ \{\ if (document.editform.wpTextbox1.value.indexOf('< ]/) != -1)\ \{\ txt = document.editform.wpTextbox1.value;\ ref_return_js_cache = txt.match(/<[Rr]ef[> ].+/gm);\ z_auto_ref_countup = 0;\ document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/<[Rr]ef[> ].+/gm,zreplace_refs);\ if (edit_input) \{lock_input;\}\ else \{unlock_input;\}\ \}\ else if (document.editform.wpTextbox1.value.indexOf('<>/gm,zreturn_refs);\ \}\ else if (document.getElementById('wpSummary'))\ \{lock_input;\}\ else\ \{unlock_input;\}\ \}\ \ //\ var input_locked_message=' References abbreviated - (PRESS "TOGGLE REFERENCES" AGAIN TO BE ABLE SAVE/PREVIEW THE PAGE) ';\ var edit_input=true;\ function lock_input\ \{\ edit_input=false;\ document.getElementById('contentSub').innerHTML += input_locked_message;\ var divs = document.getElementById('bodyContent').getElementsByTagName('div');\ input_help_js_return_cache = document.getElementById('wpSummaryLabel').innerHTML;\ document.getElementById('wpSummaryLabel').innerHTML = '';\ for (i=0; i <divs.length; i++)\ \{\  if (divs[i].className == 'editOptions')\ \{input_form_js_return_cache = divs[i].innerHTML; divs[i].innerHTML = '';\}\ \}\ \}\ \ function unlock_input\ \{\ document.getElementById('contentSub').innerHTML = document.getElementById('contentSub').innerHTML.replace(input_locked_message,'');\ edit_input=true;\ var page = document.title.replace('Editing ',).replace('Edit Conflict',).replace('Edit conflict','').split(' - ')[0];\ var divs = document.getElementById('bodyContent').getElementsByTagName('div');\ for (i=0; i <divs.length; i++)\ \{\  if (divs[i].className == 'editOptions')\ \{divs[i].innerHTML = input_form_js_return_cache;\}\ \}\ document.getElementById('wpSummaryLabel').innerHTML = input_help_js_return_cache;\ \}\ ////////////////////////\ // \ } {\rtf1\ansi\ansicpg1252 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;} \deftab720 \pard\pardeftab720\sl320\partightenfactor0

\f0\fs22 \cf2 \cb3 \expnd0\expndtw0\kerning0 \outl0\strokewidth0 \strokec2 importScript('User:Voice_of_All/Revert.js');\ }