增加moderation审核状态显示
parent
eb48326265
commit
42af7babc4
@ -0,0 +1,87 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var isMobile = (mw.config.get('skin') === 'minerva');
|
||||
|
||||
/* Display mobile/desktop version */
|
||||
function show($div) {
|
||||
|
||||
var $d = $.Deferred(),
|
||||
module = (isMobile ? 'ext.moderation.mf.notify' : 'ext.moderation.notify.desktop');
|
||||
|
||||
mw.loader.using(module, function () {
|
||||
mw.moderation.notifyCb($div, function () {
|
||||
$d.resolve();
|
||||
});
|
||||
});
|
||||
|
||||
return $d;
|
||||
}
|
||||
|
||||
/* Get edit URL of the current page */
|
||||
function getEditUrl() {
|
||||
var returnto = new mw.Uri().query.returnto;
|
||||
if (returnto) {
|
||||
/* Custom edit form requested, e.g. Special:FormEdit
|
||||
or ?action=formedit from Extension:PageForms */
|
||||
return mw.util.getUrl.apply(null, JSON.parse(returnto));
|
||||
}
|
||||
|
||||
var q = {};
|
||||
if (!isMobile && mw.cookie.get('VEE', '') === 'visualeditor') {
|
||||
q.veaction = 'edit';
|
||||
} else {
|
||||
q.action = 'edit';
|
||||
}
|
||||
return mw.util.getUrl(null, q);
|
||||
}
|
||||
|
||||
/* Show "your edit was queued for moderation" to user.
|
||||
May be called from [ext.moderation.ajaxhook.js].
|
||||
*/
|
||||
function notifyQueued(options) {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
var $div = $('<div>').attr('id', 'postedit-modqueued');
|
||||
|
||||
/* "Pending review" icon */
|
||||
$div.append($('<div>')
|
||||
.attr('id', 'pending-review')
|
||||
.append(mw.msg('moderation-pending-review')));
|
||||
|
||||
/* "Success: your edit has been sent to moderation" */
|
||||
$div.append($('<p>').append(
|
||||
mw.message(
|
||||
'moderation-edit-queued',
|
||||
getEditUrl()
|
||||
).plain()
|
||||
));
|
||||
|
||||
/* "To skip moderation in the future, please sign up" */
|
||||
if (mw.user.getId() === 0) {
|
||||
$div.append($('<p>').append(
|
||||
mw.message('moderation-suggest-signup').parse()
|
||||
));
|
||||
}
|
||||
|
||||
show($div);
|
||||
};
|
||||
|
||||
// 检查是否有审核中的项目
|
||||
console.log('Checking for moderation preload status...');
|
||||
if (mw.config.get('wgAction') === 'view') {
|
||||
let api = new mw.Api();
|
||||
api.get({
|
||||
action: 'query',
|
||||
prop: 'moderationpreload',
|
||||
mptitle: mw.config.get('wgPageName'),
|
||||
}).done(function (res) {
|
||||
if (res.query && res.query.moderationpreload && !('missing' in res.query.moderationpreload)) {
|
||||
// 页面有审核中的项目
|
||||
notifyQueued();
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
Loading…
Reference in New Issue