Usuário:!Silent/archiveMergingProposals.js

Nota: Depois de publicar, poderá ter de contornar a cache do seu navegador para ver as alterações.

  • Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
  • Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
  • Internet Explorer / Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5
  • Opera: Pressione Ctrl-F5.
/**
 * Archives merging proposals in Wikipédia:Fusão/Central de fusões page on ptwikipedia
 *
 * @author [[w:pt:User:!Silent]]
 * @date 03/aug/2016
 * @update 28/dec/2019
 * @source https://github.com/Nevallem/ptwikipedia-archiveMergingProposals
 */
/* jshint laxbreak: true */
/* global $, mw */

!function(){"use strict";var e,i=new mw.Api;mw.messages.set({"amp-summary":"Arquivando proposta de fusão encerrada, com um [[Usuário:!Silent/archiveMergingProposals.js|script]]","amp-archiveButton":"Arquivar","amp-filing":"Arquivando...","amp-filing-finished":"Arquivamento terminado.","amp-archiveButton-title":"Arquiva a proposta de fusão","amp-dialog-title":"Arquivar proposta de fusão","amp-dialog-result":"Resultado da proposta","amp-dialog-result-1":"Aprovada","amp-dialog-result-2":"Reprovada","amp-dialog-commentLabel":"Comentário de encerramento da proposta","amp-dialog-commentPlaceholder":"Não precisa assinar"}),(e={message:function(){return mw.message.apply(this,arguments).plain()},editPage:function(t){var a=$.Deferred(),o=function(o){$.isFunction(t.text)&&(t.text=t.text(o)),t.watchlist="preferences",t.summary=e.message("amp-summary"),t.minor=!0,i.editPage(t).done(function(){a.resolve(o)})};return"string"==typeof t.getText||$.isFunction(t.text)?i.getCurrentPageText(t.getText||t.title).done(function(e){o(e)}):o(),a.promise()},doEdits:function(){return $.when.apply(this,Array.prototype.slice.call(arguments,1))}}).filing=function(i,t){var a=0,o="1"===$("#amp-result").val(),n=function(){e.editPage({title:i[a++],text:function(e){return e.replace(/\{\{fusão ?(de|com)?(\|.+)?\}\}\n?/i,"")}}).done(function(){a<i.length?n():($("#amp-filing").text(e.message("amp-filing-finished")),location.reload())})};$("#amp-dialog label").after('<br /><br /><div style="text-align: center;" id="amp-filing">'+e.message("amp-filing")+"</div>"),$(".ui-dialog-buttonset button").eq(0).remove(),$("#amp-result").prop("disabled",!0),$("#amp-comment").prop("disabled",!0),e.doEdits(e.editPage({title:"Wikipédia:Fusão/Central_de_fusões",text:function(e){return e.replace("\{\{fusões a avaliar|"+i.join("|")+"}}","")}}),e.editPage({title:"Wikipédia:Fusão/Central de fusões/"+i.join("; "),text:function(e){return e.replace(/(\|resultado ?=)/,"$1 "+(o?"fundido":"não fundir"))+(""!==$("#amp-comment").val()?"\n\n"+$("#amp-comment").val()+" \~\~\~\~":"")}}),e.editPage({title:"Wikipédia:Fusão/Central_de_fusões/Arquivo_de_"+(o?"":"não_")+"fundidas/"+(new Date).getFullYear(),appendtext:"\n* [[Wikipédia:Fusão/Central de fusões/"+i.join("; ")+"]]"})).done(function(){if(o)return $("#amp-filing").text(e.message("amp-filing-finished")),void location.reload();n()})},e.prompt=function(i){$('<div id="amp-dialog" class="ui-widget"></div>').dialog({title:e.message("amp-dialog-title"),width:"auto",height:"auto",modal:!0,buttons:{OK:e.filing.bind(void 0,i),Cancelar:function(){$("#amp-dialog").dialog("close")}},open:function(){$(".ui-dialog-titlebar-close").hide()},close:function(){$("#amp-dialog").dialog("destroy").remove()}}).append(e.message("amp-dialog-result")+': <select id="amp-result"><option value="1">'+e.message("amp-dialog-result-1")+'</option><option value="2">'+e.message("amp-dialog-result-2")+"</option></select><br /><br /><label>"+e.message("amp-dialog-commentLabel")+': <br /><textarea id="amp-comment" style="width: 300px;height: 200px;" placeholder="'+e.message("amp-dialog-commentPlaceholder")+'" /></label>')},e.init=function(){$("h2").each(function(i){$(this).next().find("p").append(" [",$("<a />",{class:"amp-archiveButton",title:e.message("amp-archiveButton-title"),text:e.message("amp-archiveButton")}).click(e.prompt.bind(void 0,$(this).text().trim().split(/; ?/))).css("cursor","pointer"),"]")}),$(".amp-archiveButton").tipsy()},"Wikipédia:Fusão/Central_de_fusões"===mw.config.get("wgPageName")&&mw.loader.using(["ext.gadget.mediawiki.api.ptwiki","jquery.ui","jquery.tipsy"],function(){$(e.init)})}();