User:Manishearth/imports.js

Source: Wikipedia, the free encyclopedia.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* My Imports, kept here for purger.js to work


*/

//Developing:
importScript("User:Manishearth/GadgetUS.js")

//Tabs etc
importScript("User:Manishearth/tabs.js")

//Right-click menus
var RightClickMenuKey = 'ctrl';
//importScript('User:Subh83/JavaScriptTools/RightclickMenus.js');


//My mini-toolbox containing useful functions (usually used when I potter about the JS console)
importScript('User:Manishearth/toolbox.js')

//ImgAnnotator
importScript("MediaWiki:Gadget-ImageAnnotator.js");

//Adds links in script boxes
importScript('User:Manishearth/scriptlinks.js')

//Sidebar translate links, really useful for research...
importScript('User:Manishearth/sidebartranslinks.js');

//Just a bit of code to spruce up the search box with some pseudo-namespaces(typing Edit:Example will go to the edit page)
importScript('User:Manishearth/editns.js')

//OrphanTabs (my de-orphaning script), I don't use it but anyways i've kept it here. I'm obsoleting the script anyways with an application
//importScript('User:Manishearth/orphantabs.js')

//Ambassador stuff
importScript('User:Sross_(Public_Policy)/ambassadorwikilove.js');
//Mark as patrolled tab
importScript('User:Manishearth/patroltab.js')

//RefTools for beta in beta
//importScript('User:Mr.Z-man/refToolbar 2.0.js');

//Tinyfy cleanup templates:
importScript('User:Gary King/smaller templates.js');
/*
for(k in _("collapseButton")){ _("collapseButton")[k].childNodes[1].onclick=function(evt){collapseTable(_("collapseButton")[k].childNodes[1].id.replace("collapseButton",""));return killEvt( evt );}}
*/
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

var _ = getElementsByClass
/*
$(function(){
//Hack for collapse buttons which don't work for some reason.....

var collapseHack=new Array();
for(k in getElementsByClass("collapseButton")){
	collapseHack[k] =_("collapseButton")[k].childNodes[1];
	collapseHack[k].onclick=function(evt){
		collapseTable(this.id.replace("collapseButton",""));
		return killEvt( evt );
	}
}
});
*/
function intercept(e){
	if(e.keyCode == 9) { // U+0009 CHARACTER TABULATION
		insertTags("\t", "", "");
		return false;		
		}		
	else return true;
	}
 
function literal_tab_in_textarea() {
	t = document.getElementById("wpTextbox1");
	if(t) t.onkeydown = intercept;
	}
 
$(literal_tab_in_textarea);