User:Najzere/common.js

//Common library functions used by many of the scripts below importScript('User:Ryan Schmidt/Scripts/library.js');

//Find and replace script //by Zocky importScript('User:Ryan Schmidt/Scripts/SearchBox.js');

//AJAX Patrol script //Uncomment the following line if you wish to have this script //automatically load the next diff when the patrol is finished (if applicable). var AjaxPatrolAutoNext = true; importScript('User:Ryan Schmidt/Scripts/AjaxPatrol.js');

/* Adding cleanup button */ addOnloadHook( function {  addPersonalItem('cleanup', '/wiki/StrategyWiki:Cleanup project/Daily tasks', 'Cleanup', 'preferences'); });

/* Add source URL to summary when uploading from URL */ if (wgPageName == "Special:Upload") { addOnloadHook(get_URL); }

function get_URL { var URL_form=document.getElementById('wpUploadFileURL'); addHandler(URL_form, 'change', insert_URL); }

function insert_URL(event) { var URL = document.getElementById('wpUploadFileURL').value; var summary = document.getElementById('wpUploadDescription'); var re = /\[http.*? Source URL\]/; if(summary.value.match(re)) { summary.value = summary.value.replace(re, '[' + URL + ' Source URL]'); } else { summary.value = summary.value + '\n\n[' + URL + ' Source URL]'; } }

/* Removes link from Template:AlphabetTOC if there is no corresponding heading for that letter */

addOnloadHook(alphabet_links);

function alphabet_links { if (document.getElementById('alphabetTOC_table')) { var alphaTable = document.getElementById('alphabetTOC_table').getElementsByTagName('td'); var cellLetter; for (i=0; i < alphaTable.length; i++) { cellLetter = alphaTable[i].childNodes[0].innerHTML; if (!document.getElementById(cellLetter)) { alphaTable[i].innerHTML = cellLetter; }         }     } }