No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
*/ | */ | ||
// <nowiki> | // <nowiki> | ||
mw.config.set('userjs- | mw.config.set('userjs-templatescriptthe', { regexEditor: false }); | ||
$.ajax('//themidnight.wiki/templatescript.js', { dataType:'script', cache:true }).then(function() { | $.ajax('//themidnight.wiki/templatescript.js', { dataType:'script', cache:true }).then(function() { | ||
pathoschild.TemplateScript.add({ | pathoschild.TemplateScript.add({ | ||
Line 13: | Line 13: | ||
var toggleWidth = containers[0].style.maxWidth === "none" ? "15em" : "none"; | var toggleWidth = containers[0].style.maxWidth === "none" ? "15em" : "none"; | ||
sessionStorage.setItem("setToggleWidth", toggleWidth); | sessionStorage.setItem("setToggleWidth", toggleWidth); | ||
Object.keys(containers).forEach(function (key) { | |||
containers[key].style.maxWidth = toggleWidth; | |||
}); | |||
} | } | ||
}); | }); | ||
}); | }); | ||
// </nowiki> | // </nowiki> |
Revision as of 14:26, 14 July 2023
/** * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor. * @see https://meta.wikimedia.org/wiki/TemplateScript * @update-token [[File:Pathoschild/templatescript.js]] */ // <nowiki> mw.config.set('userjs-templatescriptthe', { regexEditor: false }); $.ajax('//themidnight.wiki/templatescript.js', { dataType:'script', cache:true }).then(function() { pathoschild.TemplateScript.add({ name:'Toggle width', forActions: '*', script: function myFunction() { var toggleWidth = containers[0].style.maxWidth === "none" ? "15em" : "none"; sessionStorage.setItem("setToggleWidth", toggleWidth); Object.keys(containers).forEach(function (key) { containers[key].style.maxWidth = toggleWidth; }); } }); }); // </nowiki>