你现在正在访问的是萌娘百科用于保存和管理图片、音频等媒体文件的子项目萌娘共享,想要回到萌娘百科,请使用浏览器上的返回按钮、或点击这里
“MediaWiki:Gadget-registerToDelete.js”的版本间的差异
第1行: | 第1行: | ||
$(function() { | $(function() { | ||
var self = $('#p-cactions .menu ul'); | var self = $('#p-cactions .menu ul'); | ||
− | if (!self.find('li')[0] | + | if (!self.find('li')[0] || mw.config.get('wgUserGroups').indexOf('patroller') === -1) return; |
− | + | $('<a/>', { | |
− | |||
attr: { | attr: { | ||
href: "#", | href: "#", | ||
第9行: | 第8行: | ||
accesskey: 'd' | accesskey: 'd' | ||
}, | }, | ||
− | text: '挂删' | + | text:'挂删' |
}).on('click', function() { | }).on('click', function() { | ||
var reason = prompt('挂删的理由【将会替换全文内容】\n【空白则使用默认理由(不在收录范围内或潜在价值较低)】\n【取消则不进行挂删】:'), | var reason = prompt('挂删的理由【将会替换全文内容】\n【空白则使用默认理由(不在收录范围内或潜在价值较低)】\n【取消则不进行挂删】:'), | ||
self = $(this); | self = $(this); | ||
if (reason === null) return; | if (reason === null) return; | ||
− | + | var loadingPic = $('<div/>', { | |
− | }).appendTo($('<li/>' | + | css: { |
+ | position: 'fixed', | ||
+ | top: '0', | ||
+ | left: '0', | ||
+ | height: '100vh', | ||
+ | width: '100vw', | ||
+ | transition: 'all .73s linear', | ||
+ | color: 'black', | ||
+ | 'padding-top':'49vh', | ||
+ | 'background-color': 'rgba(255,255,255,0.73)', | ||
+ | 'text-align': 'center' | ||
+ | } | ||
+ | }).append('<img src="https://common.moegirl.org/extensions/FancyBoxThumbs/modules/fancyBox/source/fancybox_loading.gif" />正在挂删中……'), | ||
+ | reasonText = reason ? '|' + reason : ''; | ||
+ | $.ajax({ | ||
+ | url: 'https://common.moegirl.org/api.php?action=query&meta=tokens&format=json', | ||
+ | type: 'GET', | ||
+ | beforeSend: function() { | ||
+ | $(document.body).append(loadingPic); | ||
+ | }, | ||
+ | error: function() { | ||
+ | loadingPic.css('color', 'red').text('挂删失败……').delay(1000).queue(function() { | ||
+ | $(this).fadeOut(370); | ||
+ | $(this).dequeue(); | ||
+ | }); | ||
+ | }, | ||
+ | success: function(d) { | ||
+ | if (d.error) return loadingPic.css('color', 'red').text('挂删失败……').delay(1000).queue(function() { | ||
+ | $(this).fadeOut(370); | ||
+ | $(this).dequeue(); | ||
+ | }); | ||
+ | var token = d.query.tokens.csrftoken; | ||
+ | $.ajax({ | ||
+ | url: 'https://common.moegirl.org/api.php', | ||
+ | type: 'POST', | ||
+ | data: { | ||
+ | action: 'edit', | ||
+ | format: 'json', | ||
+ | title: mw.config.get('wgPageName'), | ||
+ | text: '{{即将删除' + reasonText + '}}', | ||
+ | summary: '挂删' + (reason ? ':' + reason : ''), | ||
+ | nocreate: true, | ||
+ | watchlist: 'preferences', | ||
+ | token: token | ||
+ | }, | ||
+ | error: function() { | ||
+ | loadingPic.css('color', 'red').text('挂删失败……').delay(1000).queue(function() { | ||
+ | $(this).fadeOut(370); | ||
+ | $(this).dequeue(); | ||
+ | }); | ||
+ | }, | ||
+ | success: function(d) { | ||
+ | if (d.error) return loadingPic.css('color', 'red').text('挂删失败……').delay(1000).queue(function() { | ||
+ | $(this).fadeOut(370); | ||
+ | $(this).dequeue(); | ||
+ | }); | ||
+ | loadingPic.css('color', 'green').text('挂删成功!即将刷新……'); | ||
+ | window.setTimeout(function(){ | ||
+ | window.location.reload(); | ||
+ | }, 730); | ||
+ | } | ||
+ | }); | ||
+ | } | ||
+ | }); | ||
+ | }).appendTo($('<li/>', { | ||
+ | attr: { | ||
+ | id: 'ca-registerToDelete' | ||
+ | } | ||
+ | }).prependTo(self)); | ||
}); | }); |
2017年1月15日 (日) 16:16的版本
$(function() { var self = $('#p-cactions .menu ul'); if (!self.find('li')[0] || mw.config.get('wgUserGroups').indexOf('patroller') === -1) return; $('<a/>', { attr: { href: "#", title: "挂删本页[alt-shift-d]", accesskey: 'd' }, text:'挂删' }).on('click', function() { var reason = prompt('挂删的理由【将会替换全文内容】\n【空白则使用默认理由(不在收录范围内或潜在价值较低)】\n【取消则不进行挂删】:'), self = $(this); if (reason === null) return; var loadingPic = $('<div/>', { css: { position: 'fixed', top: '0', left: '0', height: '100vh', width: '100vw', transition: 'all .73s linear', color: 'black', 'padding-top':'49vh', 'background-color': 'rgba(255,255,255,0.73)', 'text-align': 'center' } }).append('<img src="https://common.moegirl.org/extensions/FancyBoxThumbs/modules/fancyBox/source/fancybox_loading.gif" />正在挂删中……'), reasonText = reason ? '|' + reason : ''; $.ajax({ url: 'https://common.moegirl.org/api.php?action=query&meta=tokens&format=json', type: 'GET', beforeSend: function() { $(document.body).append(loadingPic); }, error: function() { loadingPic.css('color', 'red').text('挂删失败……').delay(1000).queue(function() { $(this).fadeOut(370); $(this).dequeue(); }); }, success: function(d) { if (d.error) return loadingPic.css('color', 'red').text('挂删失败……').delay(1000).queue(function() { $(this).fadeOut(370); $(this).dequeue(); }); var token = d.query.tokens.csrftoken; $.ajax({ url: 'https://common.moegirl.org/api.php', type: 'POST', data: { action: 'edit', format: 'json', title: mw.config.get('wgPageName'), text: '{{即将删除' + reasonText + '}}', summary: '挂删' + (reason ? ':' + reason : ''), nocreate: true, watchlist: 'preferences', token: token }, error: function() { loadingPic.css('color', 'red').text('挂删失败……').delay(1000).queue(function() { $(this).fadeOut(370); $(this).dequeue(); }); }, success: function(d) { if (d.error) return loadingPic.css('color', 'red').text('挂删失败……').delay(1000).queue(function() { $(this).fadeOut(370); $(this).dequeue(); }); loadingPic.css('color', 'green').text('挂删成功!即将刷新……'); window.setTimeout(function(){ window.location.reload(); }, 730); } }); } }); }).appendTo($('<li/>', { attr: { id: 'ca-registerToDelete' } }).prependTo(self)); });