Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
// Add Templates section to 2010 wikitext editor// Place this code in your common.js file$(document).ready(function(){// Only run on edit pages with the 2010 wikitext editor during preview and submitvaraction=mw.config.get('wgAction');if((action==='edit'||action==='submit')&&$('#wpTextbox1').length){// Create the Templates sectionvartemplatesSection=$('<div>').attr('id','templates-section').css({'border':'1px solid #a2a9b1','margin':'10px 0','padding':'10px','background-color':'#f8f9fa'});// Add section titlevarsectionTitle=$('<h3>').text('Templates').css({'margin':'0 0 10px 0','font-size':'14px','font-weight':'bold'});// Create the uw-3rr buttonvaruw3rrButton=$('<button>').attr('type','button').text('{{uw-3rr}}').css({'margin':'5px','padding':'5px 10px','background-color':'#0645ad','color':'white','border':'none','border-radius':'3px','cursor':'pointer'}).hover(function(){$(this).css('background-color','#0b0080');},function(){$(this).css('background-color','#0645ad');});// Add click handler to insert templateuw3rrButton.click(function(){vartextArea=$('#wpTextbox1')[0];vartemplate='{{uw-3rr}}';// Get current cursor positionvarstartPos=textArea.selectionStart;varendPos=textArea.selectionEnd;// Insert template at cursor positionvartextBefore=textArea.value.substring(0,startPos);vartextAfter=textArea.value.substring(endPos);textArea.value=textBefore+template+textAfter;// Set cursor position after the inserted templatetextArea.selectionStart=textArea.selectionEnd=startPos+template.length;// Focus back on the text areatextArea.focus();});// Assemble the sectiontemplatesSection.append(sectionTitle);templatesSection.append(uw3rrButton);// Insert the section above the edit form$('#editform').before(templatesSection);}});