User:A1Cafel/common.js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
mw.loader.load('//zh.wikipedia.org/w/index.php?title=User:Vozhuo/Tool/MOSNUM dates.js&action=raw&ctype=text/javascript');
mw.loader.load('https://wikiplus-app.smartgslb.com/Main.js');
importScript('User:Alexander_Misel/admin.js');
importScript('User:Chiefwei/rater/rater-t.js'); // [[User:Chiefwei/rater]],作者:[[:en:User:Kephir/gadgets/rater]]
importScript('User:Vozhuo/Tool/MOSNUM dates.js');
importScript("User:94rain/js/Gadget-afchelper.js");
mw.util.addPortletLink(
"p-tb",
"http://dispenser.homenet.org/~dispenser/cgi-bin/webchecklinks.py?page=" + mw.config.get('wgContentLanguage') + ":" + encodeURIComponent(mw.config.get('wgPageName')),
"CHECKLINKS"
);
mw.loader.load('https://cdn.jsdelivr.net/npm/wikiplus-core');
importScript("user:bluedeck/serve/easy-archive.js");
mw.loader.load('ext.gadget.npp');
$(document).ready(function() {
if (mw.config.get('wgAction') !== 'view') {
return;
}
var apiPrefix = '/w/api.php';
var newPageMax = 50;
var timeEvent;
var writeCountNum = function(pages, plus) {
var strCount = '';
if (pages.length !== 0) {
var vNum = Math.round( Math.random() * (pages.length-1));
var page = pages[vNum];
var link = '/wiki/' + page['title'] + '?redirect=no&rcid=' + page['rcid'];
strCount = pages.length.toString();
if (plus) {
strCount += '+';
}
var title = page.title;
if (!page.confidence) {
title += '" class="patrollListNotConfident';
}
strCount = '(<a id="unpatrollArticle" href="' + link + '" title="' + title + '">' + strCount + '</a>)';
ptPatrollLink.attr('href', '/wiki/Special:最新页面?hidepatrolled=1');
}
else {
ptPatrollLink.attr('href', '/wiki/Special:最新页面?hidepatrolled=0');
}
$("span#not-patrolled-count").html(strCount);
generateList(pages);
return page;
};
var showAllUnbind = [];
var showAll = false;
var prepareList = function(pages, countMax) {
var $list = $("#patrollTooltipList").empty();
var addItem = function(istart, iend) {
for (var idx=istart; idx<iend; ++idx) {
var page = pages[idx];
var link = '/wiki/' + page.title + '?redirect=no&rcid=' + page.rcid;
var shortTitle = page.title;
if (shortTitle.length > 8) {
shortTitle = shortTitle.slice(0, 7) + '...';
}
var item = $("<li></li>").html('<a href="' + link + '" title="' + page.title + '">' + shortTitle + '</a>').appendTo($list);
if (!page.confidence) {
item.addClass('patrollListNotConfident');
}
}
};
var length = pages.length;
if (length > countMax && !showAll) {
addItem(0, countMax);
var $showAll = $("#patrollListShowAll");
if ($showAll.length === 0) {
$showAll = $("<div></div>", {
id: "patrollListShowAll",
}).css({
"text-align": "right",
"font-weight": "bold",
"margin-bottom": "10px"
}).append($("<a></a>", {
text: "more...",
href: "#patrollListShowAll",
title: "Show all unpatrolled articles"}));
$list.after($showAll);
}
else {
$showAll.show();
}
$showAll.unbind("click");
$showAll.click(function() {
addItem(countMax, length);
$showAll.hide();
for (var idx = 0; idx< showAllUnbind.length; ++idx) {
showAllUnbind[idx].unbind("mouseover.autohide mouseout");
}
showAll = true;
});
}
else {
addItem(0, pages.length);
}
};
var ttListShow = false;
var generateList = function(pages) {
if (ttListShow) {
prepareList(pages, 10);
}
else {
var timer = null;
var $ptPatroll = $("#pt-patroll").unbind("mouseover mouseover.autohide mouseout");
$ptPatroll.mouseover(function() {
if (timer) {
return;
}
timer = setTimeout(function() {
timer = null;
if (pages.length !== 0 && !ttListShow) {
if (typeof($.fn.cvtooltip) === 'undefined') {
loadCvtooltip();
}
prepareList(pages, 10);
ttListShow = true;
var ctt = $("#patrollTooltip").cvtooltip({
left: 60,
top: 45,
callback: function() {
ttListShow = false;
showAll = false;
$ptPatroll.unbind("mouseover.autohide mouseout");
}
});
var tipCloseTimer;
var clearHideTimer = function() {
if (tipCloseTimer) {
clearTimeout(tipCloseTimer);
tipCloseTimer = null;
}
};
ctt.body.bind("mouseover.autohide", clearHideTimer);
$ptPatroll.bind("mouseover.autohide", clearHideTimer);
var setHideTimer = function() {
if (!tipCloseTimer) {
tipCloseTimer = setTimeout(ctt.hide, 1000);
}
};
ctt.body.mouseout(setHideTimer);
$ptPatroll.mouseout(setHideTimer);
showAllUnbind = [ctt.body, $ptPatroll];
}
}, 500);
$ptPatroll.mouseout(function() {
if (timer) {
clearTimeout(timer);
timer = null;
}
});
});
}
};
var missingPage = {};
var checkMissing = function(pages, plus) {
var missingQuery = [];
for (var idx=0; idx<pages.length; ++idx) {
var title = pages[idx].title;
if (typeof(title) === 'undefined') {
continue;
}
var isMissing = missingPage[title];
if (typeof(isMissing) === 'undefined') {
missingQuery.push(title);
}
else if (isMissing) {
pages.splice(idx, 1);
}
}
//查询删除状态
if (missingQuery.length !== 0) {
var pagesStr = missingQuery.join('|');
var checkMissingURI = apiPrefix + '?action=query&format=xml&prop=info';
$.post(checkMissingURI, {titles: pagesStr}, function(result) {
var regenerate = false;
$(result).find("pages page").each(function() {
var isMissing = (typeof($(this).attr('missing')) !== 'undefined');
var title = $(this).attr('title');
missingPage[title] = isMissing;
if (isMissing) {
for (var idx=0; idx<pages.length; ++idx) {
if (pages[idx].title === title) {
pages.splice(idx, 1);
break;
}
}
if (title === $("#unpatrollArticle").attr("title")) {
regenerate = true;
}
}
});
if (regenerate) {
writeCountNum(pages, plus);
}
});
}
};
//加入标记巡查按钮
var addPatrollLink = (function() {
var checked = false;
var addlink = function(page) {
var $patrollinks = $("<a></a>", {
href: ("/w/index.php?title=" + encodeURIComponent(page.title) + "&rcid=" + encodeURIComponent(page.rcid)),
text: "标记此页面为已巡查"
});
var $divPatrolllink = $("<div></div>", {
'class': 'patrollink'
}).append('[').append($patrollinks).append(']');
$("div.printfooter").before($divPatrolllink);
var markAsPatrol = function (e) {
e.preventDefault();
var data = {
rcid: page.rcid,
token: page.rctoken
};
var uri = apiPrefix + '?format=xml&action=patrol';
$patrollinks.text('Marking as patrolled...');
$patrollinks = $patrollinks.parent();
$.post(uri, data, function( data, status, request ) {
//window.data = [data, status, request]; // DEBUG
if ( status == 'success' ) {
$patrollinks.html('<span style="color:green">Marked as patrolled</span>');// MediaWiki:Markedaspatrolled
if (typeof kAjaxPatrolLinks_closeafter !== 'undefined' && kAjaxPatrolLinks_closeafter == true){
window.close();
// Firefox 2+ doesn't allow closing normal windows. If we're still here, open up the selfclosing page.
window.open("http://toolserver.org/~krinkle/close.html", "_self");
}
} else {
$patrollinks.html('<span style="color:red">Cannot mark as patrolled</span>');// MediaWiki:Markedaspatrollederror
}
});
};
$patrollinks.click(markAsPatrol);
};
return (function(pages) {
if (!checked && ($("div.patrollink").length === 0)) {
var pageName = mediaWiki.config.get('wgPageName');
for (var idx=0; idx<pages.length; ++idx) {
var page = pages[idx];
if (page.title === pageName) {
addlink(page);
break;
}
}
checked = true;
}
});
})();
//定时抓取未巡查的页面数量
var updateUnpatrolled = function() {
var d = new Date();
var requestid = d.getTime();
var newPages = apiPrefix + '?action=query&format=xml&list=recentchanges&rctype=new&rcnamespace=0&rcshow=!redirect|!patrolled&meta=tokens&type=patrol&rcprop=title|ids|user|tags';
$.get(newPages, {rclimit: newPageMax, requestid: requestid}, function(result){
var pages = [];
var jqResult = $(result);
jqResult.find("rc").each(function() {
var $self = $(this);
var confidence = (typeof($self.attr('anon')) === 'undefined') && ($self.find('tag').length == 0);
var t = {'title': $self.attr('title'),
'rcid': $self.attr('rcid'),
'rctoken': jqResult.find('tokens').attr('patroltoken'),
'confidence': confidence};
pages.push(t);
});
addPatrollLink(pages);
var plus = (jqResult.find('query-continue').length !== 0);
if (pages.length !== 0) {
checkMissing(pages, plus);
}
writeCountNum(pages, plus);
});
};
setInterval(updateUnpatrolled, 10000);
updateUnpatrolled();
//在"监视列表"右边加入"最新页面"以便巡查
var ptPatrollLink = $('<a></a>', {
'href': "/wiki/Special:最新页面?hidepatrolled=1",
'title': '最新页面',
'text': '最新页面'
});
$("body div#mw-head div#p-personal ul li#pt-watchlist").after($('<li></li>', {
'id': 'pt-patroll'
}).append(ptPatrollLink).append($('<span></span>', {
'id': "not-patrolled-count"
})));
});
var loadCvtooltip = function() {
$("body").append($("<div></div>", {
id: "patrollTooltip",
style: "display: none;"
}).css({
"font-size": "0.75em",
"margin-right": "30px"
}).append($("<ul></ul>", {
id: "patrollTooltipList"
})));
/*
* JQuery.cvtooltip.js
* http://www.chinavalue.net
*
* J.Wang
* http://0417.cnblogs.ocm
*
* 2010.11.17
*/
(function($) {
$.fn.cvtooltip = function(options) {
var self = $(this);
var defaults = {
panel: "body", //该参数是加载气泡提示的容器,值不同可能会导致计算的位置不同,默认为添加至body容器
selector: "", //用于计算定位的控件
width: 0, //气泡提示宽度,完全手动设置
left: 0, //距离panel参数的左边距
top: 0, //距离panel参数的上边距
delay: -1, //延迟关闭,单位毫秒,值为0时表示立刻关闭
speed: 600, //关闭时的效果,淡出速度
close: true, //是否显示关闭按钮
callback: function() {
$.noop(); //点击关闭后的事件
}
};
var param = $.extend({}, defaults, options || {});
var controlID = self.attr("ID");
//气泡样式
var cvToolTipCssBtm = 'position: absolute; border-color: transparent transparent #F9E98E transparent; border-style: dashed dashed solid dashed; border-width: 12px 12px 12px 12px; width: 0; overflow: hidden; right:40px; top:-24px;';
var cvToolTipCssTop = 'position: absolute; border-color: transparent transparent #FBF7AA transparent; border-style: dashed dashed solid dashed; border-width: 12px 12px 12px 12px; width: 0; overflow: hidden; right:40px; top:-19px;';
var cvToolTipCss = 'z-index:99998; display:none; position: absolute; border: 3px solid #F9E98E; background-color: #FBF7AA; line-height:14px; border-radius: 10px; right:' + param.left + 'px; top:' + param.top + 'px;';
if (param.width !== 0) {
cvToolTipCss += 'width: ' + param.width + 'px;';
}
//气泡显示
var cvTipsElement = '';
cvTipsElement += '<div id="' + controlID + 'Body" class="cvToolTip" style="' + cvToolTipCss + '">';
cvTipsElement += '<span style="' + cvToolTipCssBtm + '"></span><span style="' + cvToolTipCssTop + '"></span>';
cvTipsElement += '<span id="' + controlID + 'Content" style="float:left;"></span>';
if(param.close){
cvTipsElement += '<a id="' + controlID + 'Close" style="display:none;"><span style="float:right; font-family:verdana; position: absolute; top:1px; right:5px; font-size:12px; cursor:pointer;">x</span></a>';
}
cvTipsElement += '</div>';
if ($("#" + controlID + "Body").length == 0) {
$(param.panel).append(cvTipsElement);
}
//气泡容器、装载内容的容器
var cttBody = $("#" + controlID + "Body");
var cttContent = $("#" + controlID + "Content");
var cttClose = $("#" + controlID + "Close");
cttBody.show();
var ctt = {
body: cttBody,
content: function() {
self.show();
return self;
},
position: function() {
var p = $(param.selector).position();
cttBody.css({top: p.top + param.top,
left: p.left + param.left});
},
hide: function() {
cttClose.hide();
cttBody.unbind();
cttContent.slideUp(param.speed, function(){
ctt.content().hide().appendTo($(param.panel));
cttBody.remove();
});
param.callback();
},
timer: null,
show: function() {
var timer;
if (cttContent.html() == "") {
cttContent.append(ctt.content()).css("height",cttContent[0].scrollHeight + 'px').hide().slideDown(param.speed, function() {
cttContent.css("height", "");
cttBody.mouseover(function(){
cttClose.show();
});
cttBody.mouseout(function(){
cttClose.hide();
});
});
}
if(param.selector != ""){
ctt.position();
}
if (param.delay >= 0) {
timer = setTimeout(ctt.hide, param.delay);
}
}
};
ctt.show();
//关闭气泡
cttClose.click(ctt.hide);
return ctt;
}
})(jQuery);
}
importScript('User:Chiefwei/rater/rater-t.js'); // [[User:Chiefwei/rater]],作者:[[:en:User:Kephir/gadgets/rater]]
importScript("User:Bluedeck/serve/ar-auto-h.js");
importScript("User:Bluedeck/serve/edit-conflict.js");
importScript("user:bluedeck/serve/blib.js"); /*貢獻藍桌圖書館*/
importScript("User:WhitePhosphorus/js/rrd.js");
/*
目前版本:Eager_VT-0.0.1.k
發行者:小躍
*/
var 投票按鈕;
var 投票child編號;
var 投票編輯編號=0;
if(mw.config.get('wgPageName')=='Wikipedia:新条目推荐/候选'){
var 選擇投票='<option value=支持>支持'+'<option value=中立>中立'+'<option value=反對>反對';
}
if(mw.config.get('wgPageName')=="Wikipedia:優良條目評選"||(/^Wikipedia:優良條目評選\//i.test(mw.config.get('wgPageName')))){
var 選擇投票='<option value=yesGA>優秀條目支持'+'<option value=中立>中立'+'<option value=noGA>優秀條目反對';
}
if(mw.config.get('wgPageName')=="Wikipedia:典范条目评选"||(/^Wikipedia:典范条目评选\//i.test(mw.config.get('wgPageName')))){
var 選擇投票='<option value=yesFA>典範條目支持'+'<option value=中立>中立'+'<option value=noFA>典範條目反對';
}
if(mw.config.get('wgPageName')=="Wikipedia:特色列表评选"||(/^Wikipedia:特色列表评选\//i.test(mw.config.get('wgPageName')))){
var 選擇投票='<option value=yesFL>特色列表支持'+'<option value=中立>中立'+'<option value=noFL>特色列表反對';
}
if(mw.config.get('wgPageName')=="Wikipedia:新条目推荐/候选"){
for(投票child編號=1;投票child編號<200;投票child編號++){
$('div:nth-child('+投票child編號.toString()+') > h4 > span.mw-editsection').append('<input id="VoteBtn_'+投票child編號.toString()+'" class="oo-ui-inputWidget-input oo-ui-buttonElement-button" style="background-color:green;color:#fff" value="投票" title="投票" type="button" onclick="voteedit('+投票child編號+')"/>');
}//索取投票child編號
}
if(mw.config.get('wgPageName')=="Wikipedia:優良條目評選"||mw.config.get('wgPageName')=="Wikipedia:典范条目评选"||mw.config.get('wgPageName')=="Wikipedia:特色列表评选"||(/^Wikipedia:(優良條目評選|典范条目评选|特色列表评选)\//i.test(mw.config.get('wgPageName')))){
for(投票child編號=1;投票child編號<200;投票child編號++){
$('h3:nth-child('+投票child編號.toString()+') > span.mw-editsection').append('<input id="VoteBtn_'+投票child編號.toString()+'" class="oo-ui-inputWidget-input oo-ui-buttonElement-button" style="background-color:green;color:#fff" value="投票" title="投票" type="button" onclick="voteedit('+投票child編號+')"/>');
}//索取投票child編號
}//#mw-content-text > div > h3:nth-child(11) > span.mw-editsection #mw-content-text > div > h3:nth-child(15) > span.mw-editsection
function voteedit(childid){
event.preventDefault();
if(mw.config.get('wgPageName')=='Wikipedia:新条目推荐/候选'){
if($('div:nth-child('+childid.toString()+') > h4 > span.mw-editsection > a').attr('href').match('editsource')){
投票編輯編號=$('div:nth-child('+childid.toString()+') > h4 > span.mw-editsection > a').attr('href').split("&")[1].split("=")[1];
}else{
投票編輯編號=$('div:nth-child('+childid.toString()+') > h4 > span.mw-editsection > a').attr('href').split("&")[2].split("=")[1];
}
}
if(mw.config.get('wgPageName')=="Wikipedia:優良條目評選"||mw.config.get('wgPageName')=="Wikipedia:典范条目评选"||mw.config.get('wgPageName')=="Wikipedia:特色列表评选"){
if($('h3:nth-child('+childid.toString()+') > span.mw-editsection > a').attr('href').match('editsource')){
投票編輯編號=$('h3:nth-child('+childid.toString()+') > span.mw-editsection > a').attr('href').split("&")[1].split("=")[1].substring(2);
}else{
投票編輯編號=$('h3:nth-child('+childid.toString()+') > span.mw-editsection > a').attr('href').split("&")[2].split("=")[1].substring(2);
}
}
if((/^Wikipedia:(優良條目評選|典范条目评选|特色列表评选)\//i.test(mw.config.get('wgPageName')))){
if($('h3:nth-child('+childid.toString()+') > span.mw-editsection > a').attr('href').match('editsource')){
投票編輯編號=$('h3:nth-child('+childid.toString()+') > span.mw-editsection > a').attr('href').split("&")[1].split("=")[1];
}else{
投票編輯編號=$('h3:nth-child('+childid.toString()+') > span.mw-editsection > a').attr('href').split("&")[2].split("=")[1];
}
}
mw.notify(投票編輯編號.toString());
$('<div id="投票編輯器' + 投票編輯編號.toString() + '" title="Section ID:' + 投票編輯編號.toString() + '">' +
'<p><label for="選擇投票' + 投票編輯編號.toString() + '">選擇投票:</label> ' +
'<select id="選擇投票' + 投票編輯編號.toString() + '" style="padding:1px;vertical-align:baseline;">'+
選擇投票+
'</select></p>'+
'<label for="投票理由' + 投票編輯編號.toString() + '">投票理由:</label> <br/>' +
'<input id="投票理由' + 投票編輯編號.toString() + '" type="text" size="50" maxlength="100" /><br /></div>'
).dialog({
modal: false,
autoOpen: true,
width: 500,
buttons:{
"投票儲存按鈕": function() { VoteEdit(投票編輯編號,childid);$(this).close(); }
}
});
}
function VoteEditNB( tracePage,destinationPage,EditSection,edittext,editsummary) {
var api = new mw.Api();
api.get( {
'action' : 'query',
'titles' : tracePage,
'prop' : 'revisions|info',
'intoken' : 'edit',
'rvprop' : 'content',
'indexpageids' : 1
} ).done( function (result) {
result = result.query;
var page = result.pages[result.pageids[0]];
api.post( {
'action' : 'edit',
'title' : destinationPage,
'appendtext' :'\n'+edittext,
'section':EditSection,
'summary' :editsummary,
'token' : page.edittoken
} ).done( function () {
mw.notify('編輯成功');
} );
} );
}
function VoteEdit(sectionid,childid){
event.preventDefault();
投票編輯編號=sectionid;
var VTReason='{{'+$('#選擇投票' + 投票編輯編號.toString()).val()+'}}:'+$('#投票理由' + 投票編輯編號.toString()).val()+'--~~'+'~~';
var VTsummary='加速投票:'+$('#選擇投票' + 投票編輯編號.toString()).val()+'【[[User:小躍/Vote-Template/Vote.js|Eager_VT-0.0.1.k]] VIP】';
if(mw.config.get('wgPageName')=='Wikipedia:新条目推荐/候选'){
VoteEditNB(mw.config.get('wgPageName'),mw.config.get('wgPageName'),投票編輯編號,'**'+VTReason,VTsummary);
}
if(mw.config.get('wgPageName')=="Wikipedia:優良條目評選"){
VoteEditNB(mw.config.get('wgPageName'),mw.config.get('wgPageName')+'/提名區',投票編輯編號,'*'+VTReason,VTsummary);
}
if(mw.config.get('wgPageName')=="Wikipedia:典范条目评选"||mw.config.get('wgPageName')=="Wikipedia:特色列表评选"){
VoteEditNB(mw.config.get('wgPageName'),mw.config.get('wgPageName')+'/提名区',投票編輯編號,'*'+VTReason,VTsummary);
}
if((/^Wikipedia:(優良條目評選|典范条目评选|特色列表评选)\//i.test(mw.config.get('wgPageName')))){
VoteEditNB(mw.config.get('wgPageName'),mw.config.get('wgPageName'),投票編輯編號,'*'+VTReason,VTsummary);
}
if(mw.config.get('wgPageName')=='Wikipedia:新条目推荐/候选'){
setTimeout(function(){voteF5()},6000);
}else{
setTimeout(function(){voteF5()},4000);
}
}
function voteF5(){window.location.href=mw.util.getUrl(mw.config.get('wgPageName'));}
function get(obj, attr, defret) {
return obj.hasAttribute(attr) ? obj.getAttribute(attr) : defret;
}
mw.loader.using(['jquery.ui', 'mediawiki.util'], function() {
var RRDPage = 'Wikipedia:修订版本删除请求',
ids = [],
dl = null,
config = {'checkboxes': {}, 'others': {}},
msg,
log = false;
function loadIDs() {
boxes = document.getElementsByTagName("input");
for (i = 0; i < boxes.length; ++i) {
if (get(boxes[i], "type") === "checkbox" && boxes[i].checked) {
var idRe = /ids\[(\d+)\]/,
idArr = idRe.exec(get(boxes[i], "name", ""));
if (idArr !== null)
ids.push(idArr[1]);
}
}
}
function submit(toHide, reason, otherReasons) {
ids = [...new Set(ids)]; // remove duplicate (eg. diff=54972164, don't know why)
var rrdArr = [
'{{Revdel',
'|status = ',
'|article = ' + mw.config.get('wgPageName'),
'|set = ' + toHide,
'|reason = ' + reason + otherReasons
];
for (i = 0; i < ids.length; ++i)
rrdArr.push('|id' + (i+1) + ' = ' + ids[i]);
rrdArr.push('}}\n--~~'+'~~');
$.ajax({
url: mw.util.wikiScript('api'),
data: {
action: 'query',
prop: 'revisions',
titles: RRDPage,
rvprop: 'content',
format: 'json'
}
}).done(function(data) {
var content = null;
if (data.query) {
if (data.query.pages) {
for (var id in data.query.pages) {
if (data.query.pages[id]) {
var page = data.query.pages[id];
if (page.revisions && page.revisions.length) {
if (page.revisions[0]['*']) {
content = page.revisions[0]['*'];
}
}
}
}
}
}
if (content !== null) {
$.ajax({
url: mw.util.wikiScript('api'),
dataType: 'json',
type: 'POST',
data: {
action: 'edit',
title: RRDPage,
summary: msg.edit_summary,
text: content + '\n\n' + rrdArr.join("\n"),
token: mw.user.tokens.get('csrfToken'),
format: 'json'
}
}).done(function(data) {
if (data && data.edit && data.edit.result === 'Success') {
window.location = mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace('$1', RRDPage);
} else {
alert('Some errors occured while saving page: ' + data.error.code ? data.error.code : 'unknown');
}
}).fail(function(jqXHR, textStatus, errorThrown) {
console.log('Error when editing page ' + RRDPage + ': ' + errorThrown);
});
} else {
console.log('Error when loading page ' + RRDPage + ': missing');
}
}).fail(function(jqXHR, textStatus, errorThrown) {
console.log('Error when loading page ' + RRDPage + ': ' + errorThrown);
});
}
function updateConfig() {
if ($('#rrdHideContent').prop("checked")) config.checkboxes.rrdHideContent = 1;
if ($('#rrdHideUsername').prop("checked")) config.checkboxes.rrdHideUsername = 1;
if ($('#rrdHideSummary').prop("checked")) config.checkboxes.rrdHideSummary = 1;
config.others.rrdReason = $('#rrdReason').val();
config.others.rrdOtherReasons = $('#rrdOtherReasons').val();
}
function loadConfig() {
for (var k in config.others)
if (config.others.hasOwnProperty(k))
$('#' + k).val(config.others[k]);
for (k in config.checkboxes)
$('#' + k).prop('checked', config.checkboxes.hasOwnProperty(k));
}
function showWindow() {
loadIDs();
if (ids.length === 0) {
alert(msg.err_no_revision_provided);
return null;
}
var html =
'<div id="rrdConfig">' +
msg.hide_items + '<br />' +
'<div style="float:left;padding:0 5px;">' +
'<input name="content" id="rrdHideContent" type="checkbox" value="content" checked>' +
'<label for="rrdHideContent" id="rrd-content">' + (log ? msg.hide_log : msg.hide_content) + '</label>' +
'</div><div style="float:left;padding:0 5px;">' +
'<input name="username" id="rrdHideUsername" type="checkbox" value="username">' +
'<label for="rrdHideUsername" id="rrd-username">' + msg.hide_username + '</label>' +
'</div><div style="float:left;padding:0 5px;">' +
'<input name="summary" id="rrdHideSummary" type="checkbox" value="summary">' +
'<label for="rrdHideSummary" id="rrd-summary">' + msg.hide_summary + '</label>' +
'</div><br /><br />' +
msg.hide_reason + '<br />' +
'<select name="rrdReason" id="rrdReason">' +
'<option value=' + msg.hide_reason_rd1 + '>' + 'RD1:' + msg.hide_reason_rd1 + '</option>' +
'<option value=' + msg.hide_reason_rd2 + '>' + 'RD2:' + msg.hide_reason_rd2 + '</option>' +
'<option value=' + msg.hide_reason_rd3 + '>' + 'RD3:' + msg.hide_reason_rd3 + '</option>' +
'<option value=' + msg.hide_reason_rd4 + '>' + 'RD4:' + msg.hide_reason_rd4 + '</option>' +
'<option value=' + msg.hide_reason_rd5 + '>' + 'RD5:' + msg.hide_reason_rd5 + '</option>' +
'<option value=' + msg.hide_reason_rd6 + '>' + 'RD6:' + msg.hide_reason_rd6 + '</option>' +
'<option value="">' + msg.hide_reason_other + '</option>' +
'</select>' +
'<br /><br />' +
msg.other_reasons + '<br />' +
'<textarea name="otherReasons" id="rrdOtherReasons" rows=4></textarea>' +
'</div>';
if (dl) {
dl.html(html).dialog("open");
loadConfig();
return null;
}
dl = $(html).dialog({
title: msg.dialog_title,
minWidth: 515,
minHeight: 150,
close: updateConfig,
buttons: [
{
text: msg.dialog_button_submit,
click: function() {
$(this).dialog('close');
var reason = config.others.rrdReason;
var otherReasons = config.others.rrdOtherReasons;
if (otherReasons && reason) otherReasons = ',' + otherReasons;
var toHide = [];
if (config.checkboxes.hasOwnProperty('rrdHideContent'))
toHide.push(log ? msg.hide_log : msg.hide_content);
if (config.checkboxes.hasOwnProperty('rrdHideUsername'))
toHide.push(msg.hide_username);
if (config.checkboxes.hasOwnProperty('rrdHideSummary'))
toHide.push(msg.hide_summary);
var cont = true;
if (toHide.length === 0) {
alert(msg.err_no_item_provided);
return null;
}
if (!reason && !otherReasons)
cont = confirm(msg.warn_no_reason_provided);
if (cont)
submit(toHide.join('、'), reason, otherReasons);
}
},
{
text: msg.dialog_button_cancel,
click: function() { $(this).dialog('close'); }
}
]
});
}
function main() {
var $report = $('<button />', {
'name': 'reportRRD',
'type': 'button',
'class': 'historysubmit mw-history-rrd mw-ui-button',
'title': msg.report_button_title + RRDPage,
'text': log ? msg.report_button_log_text : msg.report_button_text
});
$report.on('click', showWindow);
// For action=history
$(".historysubmit.mw-history-compareselectedversions-button").after($report);
// For Special:Log
$(".editchangetags-log-submit.mw-log-editchangetags-button").after($report);
}
function init() {
loadMessages();
if (mw.config.get('wgAction') === "history" || mw.config.get('wgCanonicalSpecialPageName') === "Log") {
log = (mw.config.get('wgCanonicalSpecialPageName') === "Log");
main();
}
}
$(document).ready(init);
function loadMessages() {
switch (mw.config.get('wgUserLanguage')) {
case 'zh-cn':
case 'zh-hans':
case 'zh-my':
case 'zh-sg':
msg = {
edit_summary: '[[User:WhitePhosphorus/js/rrd.js|半自动提报]]修订版本删除',
err_no_revision_provided: '您没有选择需隐藏的版本!',
err_no_item_provided: '您没有选择需隐藏的项目!',
warn_no_reason_provided: '您没有输入任何理由!确定要继续吗?',
hide_items: '需隐藏的项目:',
hide_content: '编辑内容',
hide_log: '日志目标与参数',
hide_username: '编辑者用户名/IP地址',
hide_summary: '编辑摘要',
hide_reason: '理据:',
hide_reason_rd1: '侵犯版权',
hide_reason_rd2: '针对个人、团体或组织的严重侮辱、贬低或攻击性材料',
hide_reason_rd3: '扰乱性内容',
hide_reason_rd4: '非公开的私人信息',
hide_reason_rd5: '删除守则里的有效删除,使用修订版本删除执行',
hide_reason_rd6: '版本删除矫正',
hide_reason_other: '仅使用下方的附加理由',
other_reasons: '附加理由(可选,不用签名)',
dialog_title: '提报修订版本删除',
dialog_button_submit: '提报',
dialog_button_cancel: '取消',
report_button_title: '将选中的版本提报到',
report_button_text: '请求删除被选版本',
report_button_log_text: '请求删除被选日志'
};
break;
default:
msg = {
edit_summary: '[[User:WhitePhosphorus/js/rrd.js|半自動提報]]修訂版本刪除',
err_no_revision_provided: '您沒有選擇需隱藏的版本!',
err_no_item_provided: '您沒有選擇需隱藏的項目!',
warn_no_reason_provided: '您沒有輸入任何理由!確定要繼續嗎?',
hide_items: '需隱藏的項目:',
hide_content: '編輯內容',
hide_log: '日誌目標與參數',
hide_username: '編輯者用戶名/IP位址',
hide_summary: '編輯摘要',
hide_reason: '理據:',
hide_reason_rd1: '侵犯版權',
hide_reason_rd2: '針對個人、團體或組織的嚴重侮辱、貶低或攻擊性材料',
hide_reason_rd3: '擾亂性內容',
hide_reason_rd4: '非公開的私人信息',
hide_reason_rd5: '刪除守則下的有效刪除,使用修訂版本刪除執行',
hide_reason_rd6: '版本刪除校正',
hide_reason_other: '僅使用下方的附加理由',
other_reasons: '附加理由(可選,不用簽名)',
dialog_title: '提報修訂版本刪除',
dialog_button_submit: '提報',
dialog_button_cancel: '取消',
report_button_title: '將選中的版本提報到',
report_button_text: '請求刪除被選版本',
report_button_log_text: '請求刪除被選日誌'
};
}
}
});