MediaWiki:TemplateTypeButtons/code.js

/**
 * @author: Noreplyz
 * @version: 1.0
 * @description: Adds quick buttons for all templatetypes. Dodgy, but does the job.

if (mw.config.get( 'wgNamespaceNumber' ) !== 10) { return; }   function waitForElement(elementPath, callBack){ window.setTimeout(function{       if($(elementPath).length){          callBack(elementPath, $(elementPath));        }else{          waitForElement(elementPath, callBack);        }      },500) }
 * (function(window, $, mw) {

temptypes = ['Infobox', 'Quote', 'Navbox', 'Notice', 'Context-link', 'Infoicon', 'Scrollbox', 'Citation', 'Image', 'Data', 'Design', 'Navigation', 'Non-article', 'Unknown'];

$.each(temptypes, function(i,tt) {       $('' + tt + ' ').insertAfter('#WikiaPageHeader');    });

$('.temptype-button').click(function {       var currtype = $('.template-classification-type-label').text;        if (currtype === 'Citation or reference') {            currtype = 'Citation';        } else if (currtype === 'Image, video, or gallery') {            currtype = 'Image';        }       var wanttype = $(this).text;       if (currtype !== wanttype) {           $('.template-classification-type-text').click;           $('#TemplateClassificationEditModal').css("visibility", "hidden");           waitForElement("#TemplateClassificationEditModal", function { $("span.tc-type-name:contains('" + wanttype + "')").click; $('#TemplateClassificationEditModal footer button.button.normal.primary').click; });      }    }); })(window, jQuery, mediaWiki);