User:Gary/insect templates.js

/*	INSECT TEMPLATES Description: Responding to request at		http://en.wikipedia.org/w/index.php?title=Wikipedia:WikiProject_User_scripts/Requests&oldid=424952973#Insect_pages if (typeof(unsafeWindow) != 'undefined') {	var mw = unsafeWindow.mw; }

function insertInsectTemplate(data) {	$('#wpTextbox1').attr('value', data); }

var createInsectTemplate = function(type) {	var title; if (type == 'family') title = '/sandbox1'; else if (type == 'genus') title = '/sandbox2'; else if (type == 'species') title = '/sandbox4'; var url = mw.config.get('wgScript') + '?title=User:Bugboy52.40' + title + '&action=raw'; $.get(url, insertInsectTemplate); }

function insectTemplates {	mw.util.addPortletLink('p-tb', 'javascript:createInsectTemplate(\'family\')', 'Family', 't-family', 'Family template'); mw.util.addPortletLink('p-tb', 'javascript:createInsectTemplate(\'genus\')', 'Genus', 't-genus', 'Genus template'); mw.util.addPortletLink('p-tb', 'javascript:createInsectTemplate(\'species\')', 'Species', 't-species', 'Species template'); }

if (mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') $(insectTemplates); if (typeof(unsafeWindow) != 'undefined') {	unsafeWindow.createInsectTemplate = createInsectTemplate; }