User:Mike Dillon/Scripts/preloadNewArticle.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
// Requires: [[User:Mike Dillon/Scripts/easydom.js]] /* <pre><nowiki> */ var preloadNewArticleOptions; addOnloadHook(function () { if (preloadNewArticleOptions == null) return; var newarticletext = document.getElementById("newarticletext"); if (!newarticletext) return; with (easyDom) { var preloadSelect = select({ name: "preload" }); for (var label in preloadNewArticleOptions) { var template = preloadNewArticleOptions[label]; preloadSelect.appendChild(option({ value: template }, label)); } if (preloadSelect.childNodes.length == 0) { return; } newarticletext.appendChild(hr()); newarticletext.appendChild(form( { method: "GET", action: wgScriptPath + "/index.php" }, input({ type: "hidden", name: "title", value: wgPageName }), input({ type: "hidden", name: "action", value: "edit" }), div(strong("Article template: "), preloadSelect, " ", input({ type: "submit", value: "Preload article template" })) )); } }); /* </nowiki></pre> */