查看“MediaWiki:Gadget-FlowThreadCheck.js”的源代码
←
MediaWiki:Gadget-FlowThreadCheck.js
跳转至:
导航
,
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于这些用户组的用户使用:
用户
,
管理员
,Editor
该页提供此wiki软件的界面文字,它已被保护以防止恶意修改。如欲修改所有wiki的翻译,请到
translatewiki.net
上的MediaWiki本地化计划。
您可以查看与复制此页面的源代码。
/* globals $ */ $(function() { var rules = [], checkBox = { node: $('<div id="flowthreadCheckBox"><div id="flowthreadCheckBoxTitle"><div id="flowthreadCheckBoxTitleContent">评论预览</div><span id="flowthreadCheckBoxCloseButton">×</span></div><div id="flowthreadCheckBoxContent"><div id="flowthreadCheckBoxContentBox"></div></div></div>').css('margin-left', ($(window).width() - 600) / 2 + 'px').appendTo(document.body), closeButton: $('#flowthreadCheckBoxCloseButton').on('click', checkBoxFadeOut), content: $('#flowthreadCheckBoxContentBox') }; function addCheckButton() { $('.comment-submit').each(function() { var submitButton = $(this); if (submitButton.data('addCheckButton') === true) return; var checkButton = $('<button/>').text('评论检查').addClass('comment-check').css('right', submitButton.width() + parseInt(submitButton.css('right')) - parseInt(submitButton.css('border-width'))); checkButton.on('click', showCheckBox); submitButton.before(checkButton).data('addCheckButton', true); }); } function checkBoxFadeIn() { return checkBox.node.fadeIn(370).delay(370); } function checkBoxFadeOut() { return checkBox.node.fadeOut(370).delay(370); } function showError(text) { checkBoxFadeIn().queue(function() { $(this).text(text).dequeue(); }); } function showCheckBox() { var self = this, text = $(this).closest('.comment-replybox').find('textarea').val(); if (/\s{1307,}/.test(text)) return alert('输入内容有误,请不要输入那么多空格'); if (!text) return alert('请输入评论内容后检查'); if (checkBox.content.text()) checkBox.content.empty(); if (!rules[0]) $.ajax({ url: '//zh.moegirl.org/MediaWiki:Flowthread-blacklist?action=raw', type: 'GET', success: function(data) { rules = data.split('\n'); rules.splice(0, 5); rules.forEach(function(v, i) { var length = v.lastIndexOf(' #') == -1 ? i.length : v.lastIndexOf(' #'), regexp = v.slice(0, length); if (!/^ *\#/.test(v) && regexp) rules[i] = RegExp(regexp); else rules[i] = /\s{1307,}/; }); checkText(text); }, error: function() { showCheckBox.call(self); } }); else checkText(text); } function checkText(text) { var errorText = []; rules.forEach(function(v) { var r = RegExp(v, 'g'); if (r.test(text)) errorText.push([v, text.match(r)]); }); checkBoxFadeIn(); if (!errorText[0]) checkBox.content.append('您的评论没有触发黑名单机制。'); else { var table = checkBox.content.append('您的评论触发以下黑名单(使用正则表达式<sup><a rel="nofollow" target="_blank" class="external text" href="http://baike' + '.baidu.com/view/94238.htm">解释</a></sup>):').append($('<table/>')).find('table'); table.append('<tr><th>No.</th><th>黑名单</th><th>命中字符串</th></tr>'); errorText.forEach(function(n) { table.append( $('<tr/>').append($('<td/>').addClass('first').text(table.find('tr').length)) .append($('<td/>').text(n[0])) .append($('<td/>').append(n[1].map(function(t) { return '<code>' + $('<span/>').text(t).html() + '</code>'; }).join('<br/>'))) ); }); } } addCheckButton(); $('.comment-container').on('click', function(e) { if ($(e.target).hasClass("comment-reply")) window.setTimeout(function() { addCheckButton(); }, 0); }); });
返回至
MediaWiki:Gadget-FlowThreadCheck.js
。
导航菜单
个人工具
创建账户
登录
命名空间
消息
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
讨论版
提问求助区
帮助
帮助
沙盒
编辑教程
创建新条目
工具
链入页面
相关更改
特殊页面
页面信息
返回顶部
评论预览
×