User:Rcsprinter123/motdtools.js

/////////////////////////////////////////////////////////////////////////////////////////////////////////// //Created by User:Magnus animum to make MOTD maintenance work more easy. // //Edited by: Hi878 and Smaug123                                                                         // /////////////////////////////////////////////////////////////////////////////////////////////////////////// function closeapprovednom { reason = prompt("Why? Explain using the points that people made in their comments."); which = prompt("Which version?"); day = prompt("List the month and date for which this is scheduled, format Month Day, eg. June 20"); year = prompt("Which year is it scheduled for?"); document.editform.wpTextbox1.value += "\n" + ":" + "{" + "{" + "Approved" + "}" + "} - " + "" + which + "" + " for " + "" + day + ", " + year + ". " + reason + " ~\~\~\~"; document.editform.wpSummary.value = document.editform.wpSummary.value + "Closing. Result was: Approved. (MotD Tools)"; document.editform.wpMinoredit.checked = false; }

function closeapprovednomtab { mw.util.addPortletLink( 'p-cactions', "javascript:closeapprovednom", "Approve", "ca-close approved nom", "Approve", "Approve"); }

function closedeclinednom { reason = prompt("Why? Explain using the points that people made in their comments."); document.editform.wpTextbox1.value += "\n" + ":" + "{" + "{" + "Declined" + "}" + "} - " + reason + " ~\~\~\~"; document.editform.wpSummary.value = document.editform.wpSummary.value + "Closing. Result was: Declined. (MotD Tools)"; document.editform.wpMinoredit.checked = false; }

function closethrownnom { reason = prompt("Why? Note: This should only be used when the nomination is withdrawn, it was used on another day, or it obviously won't work."); document.editform.wpTextbox1.value += "\n" + ":" + "{" + "{" + "Thrown out" + "}" + "} - " + reason + " ~\~\~\~"; document.editform.wpSummary.value = document.editform.wpSummary.value + "Closing. Result was: Thrown out. (MotD Tools)"; document.editform.wpMinoredit.checked = false; }

function closedeclinednomtab { mw.util.addPortletLink( 'p-cactions', "javascript:closedeclinednom", "Decline", "ca-close declined nom", "Decline", "Decline"); }

function closethrownnomtab { mw.util.addPortletLink( 'p-cactions', "javascript:closethrownnom", "Throw", "ca-close thrown nom", "Throw", "Throw"); }

function reopennom { reason = prompt("Why? Be very clear in your reasoning. Point out specific points that still need to be addressed before consensus can be reached."); document.editform.wpTextbox1.value += "\n" + ":" + "{" + "{" + "Reopened" + "}" + "} - " + reason + " ~\~\~\~"; document.editform.wpSummary.value = document.editform.wpSummary.value + "Reopened nomination. (MotD Tools)"; document.editform.wpMinoredit.checked = false; }

function reopenednomtab { mw.util.addPortletLink( 'p-cactions', "javascript:reopennom", "Reopen", "ca-reopen nom", "Reopen", "Reopen"); }

function comment { comment = prompt("What is your !vote?"); reason = prompt("Why?"); document.editform.wpTextbox1.value += "*\'\'\'" + comment + "\'\'\' - " + reason + " ~"+""+"~"; document.editform.wpSummary.value = document.editform.wpSummary.value + comment + ". (MotD Tools)"; document.editform.wpMinoredit.checked = false; }

function commenttab { mw.util.addPortletLink( 'p-cactions', "javascript:comment", "Comment", "ca-comment", "Comment", "Comment"); }

function insertStrAtPos(pos, newstr) { var result = document.editform.wpTextbox1.value.slice(0,pos) + "\n"+ newstr + document.editform.wpTextbox1.value.slice(pos,document.editform.wpTextbox1.value.length); return result; }

function nomnom { nomination = prompt("What is your nomination? Remember to include all appropriate wikilinks."); where = prompt("Where did this nomination come from? Leave blank if you made it up."); reason = prompt("Why are you nominating it?"); var commentStr = " " var posOfComment = document.editform.wpTextbox1.value.search(commentStr); var nomstr; if (where == null) {  nomstr = "===" + nomination + "===\n" + reason + " ~\~\~\~"; } else {  nomstr = "===" + "[" + "[" + where + "|→]" + "] " + nomination + "===\n" + reason + " ~\~\~\~"; } if (posOfComment >= 0) {   document.editform.wpTextbox1.value = insertStrAtPos(posOfComment+commentStr.length, nomstr) } else {  document.editform.wpTextbox1.value = nomstr + document.editform.wpTextbox1.value; } document.editform.wpSummary.value = document.editform.wpSummary.value + "New nomination. (MotD Tools)"; document.editform.wpMinoredit.checked = false; }

function nomnomtab { mw.util.addPortletLink( 'p-cactions', "javascript:nomnom", "Nominate", "ca-nominate", "Nominate", "Nominate"); }

$( function { if(document.title.indexOf("Editing Wikipedia:Motto of the day/Nominations") != -1) { var commentStr = " " var posOfComment = document.editform.wpTextbox1.value.search(commentStr); if (posOfComment <= -1)  {     addOnloadHook(closeapprovednomtab);     addOnloadHook(closedeclinednomtab);     addOnloadHook(reopenednomtab);     addOnloadHook(closethrownnomtab);     addOnloadHook(commenttab);   }     addOnloadHook(nomnomtab);   } });