No edit summary Tag: Reverted |
Tag: Undo |
||
| Line 7: | Line 7: | ||
// on page load we want to run this: | // on page load we want to run this: | ||
// ------------------------------------------------------------ | // ------------------------------------------------------------ | ||
var containers = document.getElementsByClassName("ts-inner"); | |||
// check if we have anything set in session | |||
var sessionToggleWidth = sessionStorage.getItem("setToggleWidth"); | |||
// if we do have session width then we want to apply it to all containers | |||
if(sessionToggleWidth) { | |||
Object.keys(containers).forEach(function (key) { | |||
containers[key].style.maxWidth = sessionToggleWidth; | |||
}); | |||
} | |||
console.log("bla bla") | |||
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" ? "115em" : "none"; | |||
sessionStorage.setItem("setToggleWidth", toggleWidth); | |||
Object.keys(containers).forEach(function (key) { | |||
containers[key].style.maxWidth = toggleWidth; | |||
}); | |||
} | |||
}); | |||
}); | |||
// </nowiki> | // </nowiki> | ||
Revision as of 20:49, 15 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>
// on page load we want to run this:
// ------------------------------------------------------------
var containers = document.getElementsByClassName("ts-inner");
// check if we have anything set in session
var sessionToggleWidth = sessionStorage.getItem("setToggleWidth");
// if we do have session width then we want to apply it to all containers
if(sessionToggleWidth) {
Object.keys(containers).forEach(function (key) {
containers[key].style.maxWidth = sessionToggleWidth;
});
}
console.log("bla bla")
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" ? "115em" : "none";
sessionStorage.setItem("setToggleWidth", toggleWidth);
Object.keys(containers).forEach(function (key) {
containers[key].style.maxWidth = toggleWidth;
});
}
});
});
// </nowiki>