User:Ricewind/common.js: Difference between revisions
From Melvor Idle
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
document.addEventListener("DOMContentLoaded", function() { | document.addEventListener("DOMContentLoaded", function() { | ||
function MMGForm() { | |||
var button = document.createElement('input'); | |||
button.type = 'button'; | |||
button.value = 'Create Subpage'; | |||
button.onclick = function() { | |||
var subpageTitle = prompt('Enter subpage title:'); | var subpageTitle = prompt('Enter subpage title:'); | ||
if (!subpageTitle) return; | if (!subpageTitle) return; | ||
Line 16: | Line 10: | ||
var link = mw.config.get('wgScriptPath') + '/index.php?title=' + mw.config.get('wgPageName') + '/' + encodedTitle + '&action=edit&preload=Template:MoneyMakingGuide'; | var link = mw.config.get('wgScriptPath') + '/index.php?title=' + mw.config.get('wgPageName') + '/' + encodedTitle + '&action=edit&preload=Template:MoneyMakingGuide'; | ||
window.location.href = link; | window.location.href = link; | ||
} | }; | ||
this.appendChild(button); | |||
} | } | ||
var elements = document.getElementsByTagName('mmgform'); | |||
for (var i = 0; i < elements.length; i++) { | |||
MMGForm.call(elements[i]); | |||
} | |||
}); | }); |
Revision as of 18:08, 15 June 2024
document.addEventListener("DOMContentLoaded", function() {
function MMGForm() {
var button = document.createElement('input');
button.type = 'button';
button.value = 'Create Subpage';
button.onclick = function() {
var subpageTitle = prompt('Enter subpage title:');
if (!subpageTitle) return;
var encodedTitle = encodeURIComponent(subpageTitle.trim());
var link = mw.config.get('wgScriptPath') + '/index.php?title=' + mw.config.get('wgPageName') + '/' + encodedTitle + '&action=edit&preload=Template:MoneyMakingGuide';
window.location.href = link;
};
this.appendChild(button);
}
var elements = document.getElementsByTagName('mmgform');
for (var i = 0; i < elements.length; i++) {
MMGForm.call(elements[i]);
}
});