User:Steven Crossin/RMclose.js
// closeRM by [[User:Andy M. Wang]], modified as PageMoverClosure by [[User:Flooded with them hundreds]]
// Copied to User:DannyS712/PageMoverClosure.js after FWTH retired, who took over as maintainer
//
// Forked by me to alter a few parameters.
//<nowiki>
$(document).ready(function() {
"use strict";
// Add only when editing section
// Assumes Requested move has a level 2 header, ends at end of section
if ((document.title.indexOf("Editing ") === -1)
|| (document.title.indexOf("(section)") === -1)) {
return;
}
function rmClick(e) {
e.preventDefault();
var closeStr = prompt("Closing statement for requested move:");
if (closeStr === null || closeStr === '') {
alert("Invalid closing statement. Aborted.");
return;
}
var editform = document.editform, t = editform.wpTextbox1;
var lines = t.value.split('\n');
var submitform = document.editform.submit();
var inReqMoveTemplate = false;
var foundReqMoveTemplate = false;
var acc = '';
for (var idx in lines) {
if (lines[idx].toLowerCase().includes("{{requested move/dated")) {
acc += '{{subst' + ':RM top|' + closeStr + ' {{subst' + ':RMpmc}}}}';
inReqMoveTemplate = !lines[idx].includes("}}");
foundReqMoveTemplate = true;
} else if (foundReqMoveTemplate && inReqMoveTemplate) {
inReqMoveTemplate = !lines[idx].includes("}}");
} else {
acc += lines[idx] + '\n';
}
}
if (!foundReqMoveTemplate) {
alert("{{requested move/dated}} NOT FOUND. Wikitext not updated\n\n"
+ "Possible reasons:\n"
+ "1. This edited section is not a requested move discussion.\n"
+ "2. The discussion was answered by another editor earlier.");
return;
}
t.value = acc + "{{subst:" + "RM bottom}}";
editform.wpSummary.value += "Closing RM discussion" + " " + 'as ';
document.editform.submit();
}
mw.loader.using( 'mediawiki.util' ).then( function(){
var portletLink = mw.util.addPortletLink("p-cactions", "#", "Close RM", "ca-rmclose", "Close a requested move discussion section");
$( portletLink ).click( rmClick );
} );
});
//</nowiki>
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.