User:Doc James/punctuation3.js

function cleanrefs{ var textbox = $("#Wikiplus-Quickedit"); if (!textbox) return; const oldContents = textbox.val; var contents = oldContents; var escaped = []; var i = 0; var replacements = []; var count = 0; var escape = function (text, regexString) {		if(!text) return; var regex = new RegExp(regexString, "g"); text = text.replace(			regex,			function (match)			{				escaped[i] = match;				var replacement = "%%" + i + "%%";				i += 1;				return replacement;			}		); return text; };	var puncRegex = /((?:%%\d+%%)+)([\؛\،\.\,\;\:\"]{1,3})/g;	var reorder = function (match, capture1, capture2)	{		count += 1;		var replacement = capture2 + capture1;		replacements.push(replacement);		return replacement;	};	var fixPunctuationPlacement = function (text)	{		while (puncRegex.test(text))			text = text.replace(				/((?:%%\d+%%)+)([\؛\،\.\,\;\:\"]{1,3})/g,				reorder			); return text; };	/* Escape various things: ref tags */ contents = escape(		contents,		"]*>[^<]+"	); contents = escape(		contents,		""	); // citation needed contents = escape(		contents,		"\\{\\{(?:[Cc]itation needed|[Cc]n|[Ff]act|[Cc]b|[Cc]tn|[Rr]ef\\?)\\|[^\}]+\\}\\}"	); contents = fixPunctuationPlacement(contents); // footnote templates /* Handles up to one level of nested templates. Any more, and there may be problems. */	contents = escape(		contents,		"\\{\\{(?:sfn|efn|rfn)\\|(?:[^\\}]*?(?:\\{\\{[^\\}]+\\}\\})?)+\\}\\}"	); if (i > 0) {		mw.notify(i + " refs found."); }	contents = fixPunctuationPlacement(contents); if (count > 0) {		mw.notify(count + " correction" + ((count > 1 && "s") || "") + " made: " + replacements.join); }	/* Unescape the various things escaped above. This has to be done twice, since escaping was done twice. */	contents = contents && contents.replace(		/%%(\d+)%%/g,		function (wholematch, number)		{			number = Number(number);			return escaped[number];		}	); contents = contents && contents.replace( // isn't this the same as above?		/%%(\d+)%%/g,		function (wholematch, number)		{			number = Number(number);			return escaped[number];		}	); var isUnchanged = (oldContents === contents); if (isUnchanged) {		mw.notify("No misplaced footnotes or tagging templates were found."); }	textbox.val(contents); $("#wpSummary").val(function (index, summary)	{		var addition = "تصويب مكان علامة المرجع";		const afterSectionName = summary.match(/^(?:\/\*[^\*]+\*\/)?\s*(.+)/);		if (afterSectionName && afterSectionName[1].length > 1)		{			addition = "; " + addition;		}		if (!isUnchanged && (!afterSectionName || !afterSectionName[1].includes(addition)))			return summary + addition;		else			return summary;	}); };

/* global mw */ ///  /** /** 'use strict';
 * Wikiplus
 * Author:+Eridanus Sora/@å¦¹ç©ºé…±
 * Github:https://github.com/Last-Order/Wikiplus
 * ä¾èµ–ç»„ä»¶:MoeNotification
 * https://github.com/Last-Order/MoeNotification

var _createClass = (function { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; });

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

function MoeNotification { var self = this; this.display = function (text, type, callback) { var _callback = callback || function {}; var _text = text || 'å–µ~'; var _type = type || 'success'; $("#MoeNotification").append($(" ").addClass('MoeNotification-notice').addClass('MoeNotification-notice-' + _type).append(' ' + _text + ' ')); $("#MoeNotification").find('.MoeNotification-notice').last.fadeIn(300); self.bind; self.clear; _callback($("#MoeNotification").find('.MoeNotification-notice').last); };   this.create = { success: function success(text, callback) { var _callback = callback || function {}; self.display(text, 'success', _callback); },       warning: function warning(text, callback) { var _callback = callback || function {}; self.display(text, 'warning', _callback); },       error: function error(text, callback) { var _callback = callback || function {}; self.display(text, 'error', _callback); }   };    this.clear = function  { if ($(".MoeNotification-notice").length >= 10) { $("#MoeNotification").children.first.fadeOut(150, function {                $(this).remove;            }); setTimeout(self.clear, 300); } else { return false; }   };    this.empty = function (f) { $(".MoeNotification-notice").each(function (i) {           if ($.isFunction(f)) {                var object = this;                setTimeout(function  { f($(object)); }, 200 * i);           } else {                $(this).delay(i * 200).fadeOut('fast', function  { $(this).remove; });           }        });    };    this.bind = function  { $(".MoeNotification-notice").mouseover(function {            self.slideRight($(this));        }); };   this.slideRight = function (object, speed) { object.css('position', 'relative'); object.animate({           right: "200%"        }, speed || 150, function  {            $(this).fadeOut('fast', function  { $(this).remove; });       });    };    this.init = function  { $("body").append(' '); };   if (!($("#MoeNotification").length > 0)) { this.init; } }

$(function {    var i18nData = {};    var scriptPath = location.protocol + '//wikiplus-app.smartgslb.com';    i18nData['en-us'] = i18nData['fr-fr'] = i18nData['ar-sa'] = i18nData['ar'] = {        "__language": "en-us",        "__author": ["Eridanus Sora", "AnnAngela", "YinYan"],        "__version": "210",        "unknown_error_name": "Unknown error",        "api_unaccessiable": "API of this wiki is not available",        "api_unwriteable": "Write API of this wiki is not available",        "fail_to_get_timestamp": "Failed to get the timestamp of this page.",        "fail_to_get_edittoken": "Failed to get the EditToken of this page.",        "fail_to_get_pageinfo": "Failed to load infomation of this page",        "not_autoconfirmed_user": "You are not an autoconfiremd user",        "hit_abusefilter": "Your edit hit the abusefilter(s)",        "unknown_edit_error": "Unknown edit error",        "unknown_edit_error_message": "Unknown edit error($1)", "notitle": "The title parameter must be set", "notext": "The text parameter must be set", "notoken": "The token parameter must be set", "invalidsection": "The section parameter must be set to an integer or 'new'", "protectedtitle": "This title has been protected from creation", "cantcreate": "You don't have permission to create new pages", "cantcreate_anon": "Anonymous users can't create new pages", "articleexists": "The article you tried to create has already existed", "noimageredirect_anon": "Anonymous users can't create image redirects", "noimageredirect": "You don't have the permission to create image redirects", "spamdetected": "Your edit was rejected because it contained a spam fragment", "filtered": "The filter callback function rejected your edit", "contenttoobig": "The content you submitted exceeds the article size limit", "noedit_anon": "Anonymous users can't edit pages", "noedit": "You don't have the permission to edit pages", "pagedeleted": "The page was deleted during your edit", "emptypage": "Creating new, empty pages is not allowed", "emptynewsection": "Creating empty new sections is not possible.", "editconflict": "Edit Conflict! Don't panic. Please check the difference between your content below and the existing revision, then refresh the page to make another submit", "revwrongpage": "The revision you are editing now is not one a valid reversions of this page", "undofailure": "Undo failed due to conflicts.", "missingtitle": "Missing title in your edit/creation", "mustbeposted": "The edit must be submited by POST method", "readapidenied": "Read API Denied", "writeapidenied": "Write API Denied", "noapiwrite": "No available write API in this wiki", "badtoken": "Invalid EditToken", "missingparam": "One of the parameters title, pageid is required", "invalidparammix": "The parameters title, pageid can not be used together", "invalidtitle": "Invalid page title", "nosuchpageid": "Inexistent page ID", "pagecannotexist": "No access to create a new page in this namespace", "nosuchrevid": "Inexisting reversion ID", "badmd5": "Invalid MD5", "hookaborted": "Your edit was rejected by the hook(s)", "parseerror": "Failed to parse the wikitext of this page", "summaryrequired": "لم تكتب ملخصا", "blocked": "You have been already BLOCKED", "ratelimited": "You've exceeded your rate limit. Please have a tea and try again later", "unknownerror": "Unknown error", "nosuchsection": "There is no such section", "sectionsnotsupported": "Can't edit in this section", "editnotsupported": "Can't edit in this section by writing section", "appendnotsupported": "Can't append/prepend wikitext to this page", "redirect_appendonly": "Only append/prepend can be made to this page because of the rules of the redirect page", "badformat": "The requested serialization format can not be applied to the page's content model", "customcssprotected": "You're not allowed to edit custom CSS pages", "customjsprotected": "You're not allowed to edit custom JavaScript pages", "cascadeprotected": "This page is under a cascading protection", "network_edit_error": "Failed to edit this page because of network errors", "redirect_to_summary": "حول إلى $1 بالمحرر السريع", "redirect_from_summary": "حول $1 إلى $2 بالمحرر السريع", "need_init": "WikiPlus haven't been loaded completely. It's a rare occasion so you can try to refresh and try again.", "fail_to_get_wikitext": "Failed to load the wikitext of this page", "quickedit_topbtn": "صحح_مر", "quickedit_sectionbtn": "صحح_مر", "fail_to_init_quickedit": "Failed to initialize WikiPlus", "back": "رجوع", "goto_editbox": "انتقل لصندوق الكتابة", "summary_placehold": "الملخص", "submit": "احفظ", "publish_page": "احفظ الصفحة", "publish_change": "احفظ التعديل", "preview": "معاينة", "cancel": "إلغاء", "mark_minoredit": "التعديل طفيف", "onclose_confirm": "[Wikiplus] Do you really want to close this page when you are still editing it, as you will lose all your unsaved work?", "fail_to_get_wikitext_when_edit": "Failed to load wikitext for your edit", "cant_parse_wikitext": "Failed to parse the wikitext", "loading_preview": "المعاينة تحمل", "submitting_edit": "التعديل يحفظ", "edit_success": "التعديل حفظ في $1 جزء ثانية للألف", "empty_page_confirm": "The wikitext in your edit is empty, which will empty this page.\r\nPlease set the value of key \"empty\" true to allow this kind of edits. (This is a tip for developers)", "cross_page_edit": "The content you are editing belongs to another page, please wait...", "cross_page_edit_submit": "يحفظ...", "cross_page_edit_error": "Failed to load the infomation", "install_tip": "Do you allow WikiPlus to collect insensitive data to help us develop WikiPlus and provide feedback to current site: $1 ?", "accept": "نعم", "decline": "لا", "install_finish": "المحرر السريع مشغل", "loading": "تحميل...", "cant_add_funcbtn": "Failed to add buttons for WikiPlus", "wikiplus_settings": "إعدادات المحرر السريع", "wikiplus_settings_desc": "Please modify your setting according to the standards below", "wikiplus_settings_placeholder": "Your setting is empty, please modify your setting according to the documentation.", "wikiplus_settings_grammar_error": "Syntax error in your setting", "wikiplus_settings_saved": "حفظت الإعدادات", "redirect_from": "حول إلى هنا", "redirect_desc": "اكتب العنوان المرادف الذي تريد أن يحيل إلى هذه الصفحة", "empty_input": "Empty input", "redirect_saved": "Redirection is finished", "uninited": "Wikiplus is not completely initialized, please refeash this page", "cant_parse_i18ncache": "Failed to parse the cache of i18n file", "cant_load_language": "Failed to load i18n file", "history_edit_warning": " // You are trying to edit a history revision of this page. This will apply to the latest revision. Please be careful.", "create_page_tip": "", "continue": "كمل", "default_summary_suffix": "صحح_مر" };

/**    * åŠ è½½å…¶ä»–è¯­è¨€æ–‡ä»¶ * @param {string} language è¯­è¨€å */   function loadLanguage(language) { $.ajax({           url: "https://ar.wikipedia.org/w/index.php?title=MediaWiki:Gadget-QuickEdit/lang.js&action=raw&ctype=text/javascript", //scriptPath + '/languages/get.php?lang=' + language,            dataType: 'json',            success: function success(data) {                if (data.__language && data.__version) {                    if (i18nData[data.__language]) {                        if (data.__version >= i18nData[data.__language].__version) {                            i18nData[data.__language] = data;                            console.log('æ›´æ–°è¯­è¨€ç‰ˆæœ¬' + data.___language + 'è‡³' + data.___version);                        } else {                            // æœåŠ¡ç«¯æœªè·Ÿè¿›è¯­è¨€ç‰ˆæœ¬ ä¸æ›´æ–°æœ¬åœ°ç¼“å­˜                        }                    } else {                            i18nData[data.__language] = data;                        }                    localStorage.Wikiplus_i18nCache = JSON.stringify(i18nData); //æ›´æ–°ç¼“å­˜ }           },            error: function error(e) { console.log('æ— æ³•åŠ è½½è¯­è¨€' + language); }       });    }    /**     * å¤šè¯­è¨€è½¬æ¢     * @param {stirng} key å­—æ®µæ ‡è¯†å     * @return {string} ç»è¿‡è½¬æ¢çš„å†…å®¹ å¦‚æœªæ‰¾åˆ°å¯¹åº”çš„å¤šè¯­è¨€å­—æ®µ åˆ™è¿”å›žç®€ä½“ä¸­æ–‡     */    function i18n(key) {        var language;        try {            language = "ar-sa" // JSON.parse(localStorage.Wikiplus_Settings)['language'] || window.navigator.language.toLowerCase;        } catch (e) {            language = window.navigator.language.toLowerCase;        }        if (i18nData[language] && i18nData[language][key]) {            return i18nData[language][key];        } else if (i18nData['en-us'][key]) {            return i18nData['en-us'][key];        } else {            return 'undefined';        }    }    /**     * èŽ·å¾—é”™è¯¯ä¿¡æ¯     * @param {stirng} name     * @return {object} {number,message}     */    function getErrorInfo(name) {        var errorList = { unknown_error_name: { number: 1001, message: i18n('unknown_error_name') },           api_unaccessiable: { number: 1002 },           api_unwriteable: { number: 1003 },           fail_to_get_timestamp: { number: 1004 },           fail_to_get_edittoken: { number: 1005 },           fail_to_get_pageinfo: { number: 1006 },           not_autoconfirmed_user: { number: 1007 },           hit_abusefilter: { number: 1008 },           unknown_edit_error: { number: 1009 },           unknown_edit_error_message: { number: 1010 },           notitle: { number: 1011 },           notext: { number: 1012 },           notoken: { number: 1013 },           invalidsection: { number: 1014 },           protectedtitle: { number: 1015 },           cantcreate: { number: 1016 },           cantcreate_anon: { number: 1017 },           articleexists: { number: 1018 },           noimageredirect_anon: { number: 1019 },           noimageredirect: { number: 1020 },           spamdetected: { number: 1021 },           filtered: { number: 1022 },           contenttoobig: { number: 1023 },           noedit_anon: { number: 1025 },           noedit: { number: 1026 },           pagedeleted: { number: 1027 },           emptypage: { number: 1028 },           emptynewsection: { number: 1029 },           editconflict: { number: 1030 },           revwrongpage: { number: 1031 },           undofailure: { number: 1032 },           missingtitle: { number: 1033 },           mustbeposted: { number: 1034 },           readapidenied: { number: 1035 },           writeapidenied: { number: 1036 },           noapiwrite: { number: 1037 },           badtoken: { number: 1038 },           missingparam: { number: 1039 },           invalidparammix: { number: 1040 },           invalidtitle: { number: 1041 },           nosuchpageid: { number: 1042 },           pagecannotexist: { number: 1043 },           nosuchrevid: { number: 1044 },           badmd5: { number: 1045 },           hookaborted: { number: 1046 },           parseerror: { number: 1047 },           summaryrequired: { number: 1048 },           blocked: { number: 1049 },           ratelimited: { number: 1050 },           unknownerror: { number: 1051 },           nosuchsection: { number: 1052 },           sectionsnotsupported: { number: 1053 },           editnotsupported: { number: 1054 },           appendnotsupported: { number: 1055 },           redirect_appendonly: { number: 1056 },           badformat: { number: 1057 },           customcssprotected: { number: 1058 },           customjsprotected: { number: 1059 },           cascadeprotected: { number: 1060 },           network_edit_error: { number: 1061 },           need_init: { number: 1062 },           fail_to_get_wikitext: { number: 1063 },           fail_to_init_quickedit: { number: 1064 },           fail_to_get_wikitext_when_edit: { number: 1065 },           cant_parse_wikitext: { number: 1066 },           empty_page_confirm: { number: 1067 },           uninited: { number: 1068 },           cant_parse_i18ncache: { number: 1069 },           cant_load_language: { number: 1070 }       };        if (errorList[name]) { if (errorList[name].message) { return { number: errorList[name].number, message: errorList[name].message };           } else if (i18n(name) !== 'undefined') { return { number: errorList[name].number, message: i18n(name) };           } else { return { number: errorList[name].number, message: i18n('unknownerror') };           }        } else { return { number: errorList.unknown_error_name.number, message: errorList.unknown_error_name.message };       }    }    /**     * åˆ¤æ–­å€¼æ˜¯å¦å­˜åœ¨äºŽæ•°ç»„ * @param {string} value * @param {array} array * @return {boolean} whether the value is in the array */   function inArray(value) { var array = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];

return $.inArray(value, array) === -1 ? false : true; }   /**      * æŠ›å‡ºé”™è¯¯ * @param {string} name * @return boolean */   function throwError(name, message) { var errInfo = getErrorInfo(name); var e = new Error; e.number = errInfo.number; e.message = message || errInfo.message; console.log('%cè‡´å‘½é”™è¯¯[' + e.number + ']:' + e.message, 'color:red'); console.log(e); return e;   } /**    * å°†mwçš„æ®µè½çš„idè½¬æ¢ä¸ºå¯æ˜¾ç¤ºçš„æ–‡æœ¬ * @param {string} URL * @return string */

var Wikipage = (function {        function Wikipage {            var pageName = arguments.length <= 0 || arguments[0] === undefined ? window.mw.config.get('wgPageName') : arguments[0];

_classCallCheck(this, Wikipage);

console.log('é¡µé¢ç±»æž„å»ºä¸­'); //å¯ç”¨æ€§å’Œæƒé™æ£€æµ‹ if (!window.mw) { console.log('é¡µé¢Javascriptè½½å…¥ä¸å®Œå…¨æˆ–è¿™ä¸æ˜¯ä¸€ä¸ªMediawikiç«™ç‚¹'); return; }           if (!inArray('autoconfirmed', window.mw.config.get('wgUserGroups'))) { throwError('not_autoconfirmed_user'); return; }           //ä»ŽMediaWikiå®šä¹‰çš„å…¨å±€å˜é‡ä¸­èŽ·å¾—ä¿¡æ¯ this.pageName = pageName.replace(/ /ig, '_'); // Mediawikiå¤„ç†ç©ºæ ¼æ—¶å¯èƒ½ä¼šå‡ºé”™ this.revisionId = window.mw.config.get('wgRevisionId'); this.articleId = window.mw.config.get('wgArticleId'); this.API = location.protocol + '//' + location.host + window.mw.config.get('wgScriptPath') + '/api.php'; //ä»ŽAPIèŽ·å¾—ç¼–è¾‘ä»¤ç‰Œå’Œèµ·å§‹æ—¶é—´æˆ³ this.editToken = {}; this.timeStamp = {}; this.init(this.pageName, {               success: function success {                    console.log('WikiplusåŠ è½½å®Œæ¯•');                },                fail: function fail(e) {                    console.log('Wikiplusæœªèƒ½æ­£ç¡®åŠ è½½(' + e.message + ')');                }            }); }

/**        * é’ˆå¯¹éžæœ¬é¡µé¢çš„ç¼–è¾‘ æä¾›é‡å®šä¹‰æ—¶é—´æˆ³å’Œæƒæ ‡æŽ¥å£ * @param {string} titile æ ‡é¢˜ * @param {object} callback å›žè°ƒå‡½æ•° */

_createClass(Wikipage, [{           key: 'reConstruct',            value: function reConstruct(title) {                var callback = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

this.init(title, callback); }

/**            * èŽ·å–é¡µé¢åŸºç¡€ä¿¡æ¯å¹¶è®°å½• */       }, {            key: 'init', value: function init(title, callback, config) { if (title === undefined) title = this.pageName; if (callback === undefined) callback = {};

var self = this; callback.success = callback.success || new Function; callback.fail = callback.success || new Function; $.ajax({                   type: 'GET',                    dataType: 'json',                    url: this.API,                    data: {                        'action': 'query',                        'prop': 'revisions|info',                        'titles': title,                        'rvprop': 'timestamp',                        'format': 'json'                    },                    beforeSend: function beforeSend {                        console.time('الوقت ');                    },                    success: function success(data) {                        if (data && data.query && data.query.pages) {                            var info = data.query.pages;                            for (var key in info) {                                if (key !== '-1') {                                    if (info[key].revisions && info[key].revisions.length > 0) {                                        self.timeStamp[title] = info[key].revisions[0].timestamp; } else { callback.fail(throwError('fail_to_get_timestamp')); }                                   if (mw.user.tokens.get('csrfToken') && mw.user.tokens.get('csrfToken') !== '+\\') { self.editToken[title] = mw.user.tokens.get('csrfToken'); console.log('æˆåŠŸèŽ·å¾—ç¼–è¾‘ä»¤ç‰Œ æ¥è‡ªå‰ç«¯API'); } else { //å‰ç«¯æ‹¿ä¸åˆ°Token å°è¯•é€šè¿‡API $.ajax({                                           url: self.API,                                            type: "GET",                                            dataType: "json",                                            data: {                                                'action': 'query',                                                'meta': 'tokens',                                                'format': 'json'                                            },                                            success: function success(data) {                                                if (data.query && data.query.tokens && data.query.tokens.csrftoken && data.query.tokens.csrftoken !== '+\\') {                                                    self.editToken[title] = data.query.tokens.csrftoken;                                                    console.log('æˆåŠŸèŽ·å¾—ç¼–è¾‘ä»¤ç‰Œ é€šè¿‡åŽç«¯API'); } else { callback.fail(throwError('fail_to_get_edittoken')); }                                           },                                            error: function error(e) { callback.fail(throwError('fail_to_get_edittoken')); }                                       });                                        callback.fail(throwError('fail_to_get_edittoken'));                                    }                                } else {                                    if (mw.config.get('wgArticleId') === 0) {                                        // å¦‚æžœæ˜¯ç©ºé¡µé¢å°±åªæ‹¿ä¸€ä¸ªedittoken                                        if (mw.user.tokens.get('csrfToken') && mw.user.tokens.get('csrfToken') !== '+\\') {                                            self.editToken[title] = mw.user.tokens.get('csrfToken');                                            console.log('æˆåŠŸèŽ·å¾—ç¼–è¾‘ä»¤ç‰Œ æ¥è‡ªå‰ç«¯API');                                            self.inited = true;                                        } else {                                            self.inited = false; callback.fail(throwError('fail_to_get_edittoken')); }                                   } else { // å¦‚æžœä¸æ˜¯ é‚£å°±æ˜¯å¤±è´¥äº† æŠ›å‡ºé”™è¯¯ self.inited = false; callback.fail(throwError('fail_to_get_pageinfo')); }                               }                            }                        }                    }                }).done(function  { console.timeEnd('èŽ·å¾—é¡µé¢åŸºç¡€ä¿¡æ¯æ—¶é—´è€—æ—¶'); self.inited = self.inited === false ? false : true; callback.success; });           }

/**            * é¡µé¢ç¼–è¾‘ * @param {string} content é¡µé¢å†…å®¹ * @param {string} title é¡µé¢æ ‡é¢˜ é»˜è®¤ä¸ºå½“å‰é¡µé¢æ ‡é¢˜ * @param {object} callback å›žè°ƒå‡½æ•° * @param {object} config è®¾ç½® è¦†ç›–åˆ°é»˜è®¤çš„è®¾ç½® */       }, {            key: 'edit', value: function edit(content) { var title = arguments.length <= 1 || arguments[1] === undefined ? this.pageName : arguments[1]; var callback = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; var config = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];

var self = this; callback.success = callback.success || new Function; callback.fail = callback.fail || new Function; if (content === undefined) { if (!config.empty === true) { callback.fail(throwError('empty_page_confirm')); return false; }               }                if (self.inited) { $.ajax({                       type: 'POST',                        url: self.API,                        data: $.extend({ 'action': 'edit', 'format': 'json', 'text': content, 'title': title, 'token': self.editToken[title] || self.editToken[self.pageName], 'basetimestamp': self.timeStamp[title] }, config),                       success: function success(data) {                            if (data && data.edit) {                                if (data.edit.result && data.edit.result == 'Success') {                                    callback.success;                                } else {                                    if (data.edit.code) {                                        //é˜²æ»¥ç”¨è¿‡æ»¤å™¨                                        callback.fail(throwError('hit_abusefilter', i18n('hit_abusefilter') + ':' + data.edit.info.replace('/Hit AbuseFilter: /ig', '') + ' ' + data.edit.warning + ' '));                                    } else {                                        callback.fail(throwError('unknown_edit_error'));                                    }                                }                            } else if (data && data.error && data.error.code) { callback.fail(throwError(data.error.code.replace(/-/ig, '_')), i18n('unknown_edit_error_message').replace(/\$1/ig, data.error.code)); } else if (data.code) { callback.fail(throwError('unknown_edit_error'), i18n('unknown_edit_error_message').replace(/\$1/ig, data.code)); } else { callback.fail(throwError('unknown_edit_error')); }                       },                        error: function error(e) { callback.fail(throwError('network_edit_error')); }                   });                } else {                    callback.fail(throwError('uninited'));                }            }

/**            * ç¼–è¾‘æ®µè½ * @param {number} section æ®µè½ç¼–å· * @param {string} content å†…å®¹ * @param {string} title é¡µé¢æ ‡é¢˜ * @param {object} callback å›žè°ƒå‡½æ•° * @param {object} config è®¾ç½® */       }, {            key: 'editSection', value: function editSection(section, content) { var title = arguments.length <= 2 || arguments[2] === undefined ? this.pageName : arguments[2]; var config = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; var callback = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4];

callback.success = callback.success || new Function; callback.fail = callback.fail || new Function; this.edit(content, title, callback, $.extend({ 'section': section }, config)); }

/**            * é‡å®šå‘é¡µé¢è‡³ * @param {string} target ç›®æ ‡é¡µé¢æ ‡é¢˜ * @param {string} title é¡µé¢å é»˜è®¤ä¸ºå½“å‰é¡µé¢ * @param {object} callback å›žè°ƒå‡½æ•° */       }, {            key: 'redirectTo', value: function redirectTo(target) { var title = arguments.length <= 1 || arguments[1] === undefined ? this.pageName : arguments[1]; var callback = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

callback.success = callback.success || new Function; callback.fail = callback.fail || new Function; this.edit('#REDIRECT ' + target + '', title, callback, {                   'summary': i18n('redirect_to_summary').replace(/\$1/ig, target)                }); }

/**            * é‡å®šå‘è‡ª * @param {string} origin é‡å®šå‘é¡µæ ‡é¢˜ * @param {string} title é‡å®šå‘ç›®æ ‡é¡µæ ‡é¢˜ é»˜è®¤ä¸ºå½“å‰é¡µ * @param {object} callback */       }, {            key: 'redirectFrom', value: function redirectFrom(origin) { var title = arguments.length <= 1 || arguments[1] === undefined ? this.pageName : arguments[1]; var callback = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; var force = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];

callback.success = callback.success || new Function; callback.fail = callback.fail || new Function; var data = { summary: i18n('redirect_from_summary').replace(/\$1/ig, origin).replace(/\$2/ig, title) };               if (!force) { data.createonly = 'true'; }               this.edit('#REDIRECT ' + title + '', origin, callback, data); }

/**            * èŽ·å¾—é¡µé¢ç»´åŸºæ–‡æœ¬ * @param {object} callback å›žè°ƒå‡½æ•° * @param {string} title é¡µé¢æ ‡é¢˜ é»˜è®¤ä¸ºå½“å‰é¡µé¢ * @param {object} config è®¾ç½® */       }, {            key: 'getWikiText', value: function getWikiText { var callback = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; var title = arguments.length <= 1 || arguments[1] === undefined ? this.pageName : arguments[1]; var config = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

callback.success = callback.success || new Function; callback.fail = callback.fail || new Function; $.ajax({                   url: location.protocol + '//' + location.host + mw.config.get('wgScriptPath') + '/index.php',                    type: "GET",                    dataType: "text",                    cache: false,                    data: $.extend({ 'title': title, 'action': 'raw' }, config),                   beforeSend: function beforeSend {                        console.time('الوقت ');                    },                    success: function success(data) {                        console.timeEnd('نجاح ');                        callback.success(data);                    },                    error: function error(e) {                        callback.fail(throwError('fail_to_get_wikitext'));                    }                }); }

/**            * è§£æžWikitext * @param {string} wikitext ç»´åŸºæ–‡æœ¬ * @param {object} callback å›žè°ƒå‡½æ•° * @param {object} config è®¾ç½® */       }, {            key: 'parseWikiText', value: function parseWikiText(wikitext, callback, config) { if (wikitext === undefined) wikitext = ''; if (callback === undefined) callback = {};

callback.success = callback.success || new Function; callback.fail = callback.fail || new Function; $.ajax({                   type: 'POST',                    dataType: 'json',                    data: $.extend({ 'format': 'json', 'action': 'parse', 'text': wikitext, 'title': this.pageName, 'pst': 'true' }, config),                   url: this.API,                    success: function success(data) {                        if (data && data.parse && data.parse.text) {                            callback.success(data.parse.text['*']);                        } else {                            callback.fail(throwError('cant_parse_wikitext'));                        }                    }                }); }       }]);

return Wikipage; });

$(document).ready(function {        var Wikiplus = (function  { _createClass(Wikiplus, [{               key: 'initQuickEdit',

/**                * åŠ è½½å¿«é€Ÿç¼–è¾‘ ç¬¬ä¸€æ­¥ æ’å…¥é¡µé¢æŒ‰é’®å¹¶ç»‘å®šå…¥å£äº‹ä»¶ */               value: function initQuickEdit { var callback = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

var self = this; callback.success = callback.success || new Function; callback.fail = callback.fail || new Function; if (!(mw.config.get('wgIsArticle') && mw.config.get('wgAction') === "view" && mw.config.get('wgIsProbablyEditable'))) { console.log('è¯¥é¡µé¢æ— æ³•ç¼–è¾‘ å¿«é€Ÿç¼–è¾‘ç•Œé¢åŠ è½½ç»ˆæ­¢'); return; }                   //é¡¶éƒ¨ç¼–è¾‘å…¥å£ var topBtn = $('').attr('id', 'Wikiplus-Edit-TopBtn').append($(' ').append($('').attr('href', 'javascript:void(0)').text('' + i18n('quickedit_topbtn')))).data({                       number: -1,                        target: self.kotori.pageName                    }); if ($('#ca-edit').length > 0 && $('#Wikiplus-Edit-TopBtn').length == 0) { $('#ca-edit').before(topBtn); }                   if ($('.mw-editsection').length > 0) { self.sectionMap = {}; //æ®µè½å¿«é€Ÿç¼–è¾‘æŒ‰é’® var sectionBtn = $(' ').append($(' ').addClass('mw-editsection-divider').text(' | ')).append($('').addClass('Wikiplus-Edit-SectionBtn').attr('href', 'javascript:void(0)').text(i18n('quickedit_sectionbtn'))); $('.mw-editsection').each(function (i) {                           try {                                var editURL = $(this).find("a").last.attr('href');                                var sectionNumber = editURL.match(/&[ve]*section\=([^&]+)/)[1].replace(/T-/ig, '');                                var sectionTargetName = decodeURI(editURL.match(/title=(.+?)&/)[1]);                                var cloneNode = $(this).prev.clone;                                cloneNode.find('.mw-headline-number').remove;                                var sectionName = $.trim(cloneNode.text);                                self.sectionMap[sectionNumber] = {                                    name: sectionName,                                    target: sectionTargetName                                };                                var _sectionBtn = sectionBtn.clone; _sectionBtn.find('.Wikiplus-Edit-SectionBtn').data({                                   number: sectionNumber,                                    name: sectionName,                                    target: sectionTargetName                                }); $(this).find('.mw-editsection-bracket').last.before(_sectionBtn); } catch (e) { throwError('fail_to_init_quickedit'); }                       });                    }                    $('.Wikiplus-Edit-SectionBtn').click(function  { self.initQuickEditInterface($(this)); //ç›´æŽ¥æŠŠDOMä¼ é€’ç»™ä¸‹ä¸€æ­¥ });                   $('#Wikiplus-Edit-TopBtn').click(function  { self.initQuickEditInterface($(this)); });               }

/**                * åŠ è½½å¿«é€Ÿç¼–è¾‘ä¸»ç•Œé¢ç›¸å…³å†…å®¹ */           }, {                key: 'initQuickEditInterface', value: function initQuickEditInterface(obj) { var self = this; var sectionNumber = obj.data('number'); var sectionTargetName = obj.data('target'); if (this.kotori.inited) { if ($('.noarticletext').length > 0) { //è¿™æ˜¯ä¸€ä¸ªç©ºé¡µé¢ this.preloadData[sectionTargetName + '.-1'] = i18n('create_page_tip'); }                       if (mw.config.get('wgCurRevisionId') === mw.config.get('wgRevisionId')) { if (this.preloadData[sectionTargetName + '.' + sectionNumber] === undefined) { this.notice.create.success(i18n('loading')); this.preload(sectionNumber, sectionTargetName, {                                   success: function success(data) {                                        obj.data('content', data);                                        self.notice.empty;                                        self.displayQuickEditInterface(obj);                                    },                                    fail: function fail(e) {                                        throwError('fail_to_get_wikitext_when_edit');                                    }                                }); } else { obj.data('content', self.preloadData[sectionTargetName + '.' + sectionNumber]); self.displayQuickEditInterface(obj); }                       } else { this.notice.create.warning(i18n('history_edit_warning')); this.notice.create.success(i18n('loading')); this.preload(sectionNumber, sectionTargetName, {                               success: function success(data) {                                    obj.data('content', data);                                    self.notice.empty;                                    self.displayQuickEditInterface(obj, '' + i18n('history_edit_warning'));                                },                                fail: function fail(data) {                                    throwError('fail_to_get_wikitext_when_edit');                                }                            }, {                                'oldid': mw.config.get('wgRevisionId')                            }); }                   }                }

/**                * æ˜¾ç¤ºå¿«é€Ÿç¼–è¾‘ç•Œé¢å¹¶ç»‘å®šäº‹ä»¶ */           }, {                key: 'displayQuickEditInterface', value: function displayQuickEditInterface(obj) { var message = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];

var self = this; var isNewPage = $('.noarticletext').length > 0; var sectionNumber = obj.data('number'); var sectionName = obj.data('name'); var sectionTargetName = obj.data('target'); var sectionContent = obj.data('content'); var summary = self.getSetting('defaultSummary', {                       'sectionName': sectionName,                        'sectionNumber': sectionNumber,                        'sectionTargetName': sectionTargetName                    }); if (summary === undefined) { if (sectionName === undefined) { summary = i18n('default_summary_suffix'); } else { summary = '/* ' + sectionName + ' */ ' + i18n('default_summary_suffix'); }                   }                    //DOMå®šä¹‰ var heightBefore = $(document).scrollTop; //è®°ä½å½“å‰é«˜åº¦ var backBtn = $(' ').attr('id', 'Wikiplus-Quickedit-Back').addClass('Wikiplus-Btn').text('' + i18n('back')); //è¿”å›žæŒ‰é’® var jumpBtn = $(' ').attr('id', 'Wikiplus-Quickedit-Jump').addClass('Wikiplus-Btn').append($('').attr('href', '#Wikiplus-Quickedit').text('' + i18n('goto_editbox'))); //åˆ°ç¼–è¾‘æ¡† var inputBox = $(' ').attr('id', 'Wikiplus-Quickedit'); //ä¸»ç¼–è¾‘æ¡† var previewBox = $(' ').attr('id', 'Wikiplus-Quickedit-Preview-Output'); //é¢„è§ˆè¾“å‡º var summaryBox = $(' ').attr('id', 'Wikiplus-Quickedit-Summary-Input').attr('placeholder', '' + i18n('summary_placehold')); //ç¼–è¾‘æ‘˜è¦è¾“å…¥ var editSubmitBtn = $(' ').attr('id', 'Wikiplus-Quickedit-Submit').text(i18n(isNewPage ? 'publish_page' : 'publish_change') + ' - ctrl+s'); //æäº¤æŒ‰é’® var previewSubmitBtn = $(' ').attr('id', 'Wikiplus-Quickedit-Preview-Submit').text('' + i18n('preview')); //é¢„è§ˆæŒ‰é’® var isMinorEdit = $(' ').append($(' ').attr({ 'type': 'checkbox', 'id': 'Wikiplus-Quickedit-MinorEdit' })).append($(' ').attr('for', 'Wikiplus-Quickedit-MinorEdit').text(i18n('mark_minoredit') + ' - ctrl+shift+s')).css({ 'margin': '5px', 'display': 'inline' }); //DOMå®šä¹‰ç»“æŸ var editBody = $(' ').append(backBtn, jumpBtn, previewBox, inputBox, summaryBox, $(' '), editSubmitBtn, previewSubmitBtn, isMinorEdit); this.createDialogBox('' + i18n('quickedit_topbtn') + message, editBody, 1000, function {                        $('#Wikiplus-Quickedit').text(sectionContent);                        $('#Wikiplus-Quickedit-Summary-Input').val(summary);                        //äº‹ä»¶ç»‘å®š                        //è¿”å›ž                        $("#Wikiplus-Quickedit-Back").click(function  { $('.Wikiplus-InterBox').fadeOut('fast', function {                                window.onclose = window.onbeforeunload = undefined; //å–æ¶ˆé¡µé¢å…³é—­ç¡®è®¤                                $(this).remove;                            }); });                       //é¢„è§ˆ                        var onPreload = $(' ').addClass('Wikiplus-Banner').text('' + i18n('loading_preview'));                        $('#Wikiplus-Quickedit-Preview-Submit').click(function  { var wikiText = $('#Wikiplus-Quickedit').val; $(this).attr('disabled', 'disabled'); $('#Wikiplus-Quickedit-Preview-Output').fadeOut(100, function {                                $('#Wikiplus-Quickedit-Preview-Output').html('').append(onPreload);                                $('#Wikiplus-Quickedit-Preview-Output').fadeIn(100);                            }); $('html, body').animate({ scrollTop: heightBefore }, 200); //è¿”å›žé¡¶éƒ¨ self.kotori.parseWikiText(wikiText, {                               success: function success(data) {                                    $('#Wikiplus-Quickedit-Preview-Output').fadeOut('100', function  { $('#Wikiplus-Quickedit-Preview-Output').html(' ' + data + ' '); $('#Wikiplus-Quickedit-Preview-Output').fadeIn('100'); $('#Wikiplus-Quickedit-Preview-Submit').prop('disabled', false); });                               }                            });                        });                        //æäº¤                        $('#Wikiplus-Quickedit-Submit').click(function  { var wikiText = $('#Wikiplus-Quickedit').val; var summary = $('#Wikiplus-Quickedit-Summary-Input').val; var timer = new Date.valueOf; var onEdit = $(' ').addClass('Wikiplus-Banner').text('' + i18n('submitting_edit')); var addtionalConfig = { 'summary': summary };                           if (sectionNumber !== -1) { addtionalConfig['section'] = sectionNumber; }                           if ($('#Wikiplus-Quickedit-MinorEdit').is(':checked')) { addtionalConfig['minor'] = 'true'; } else { addtionalConfig['notminor'] = 'true'; }                           //å‡†å¤‡ç¼–è¾‘ ç¦ç”¨å„ç±»æŒ‰é’® è¿”å›žé¡¶éƒ¨ æ˜¾ç¤ºä¿¡æ¯ $('#Wikiplus-Quickedit-Submit,#Wikiplus-Quickedit,#Wikiplus-Quickedit-Preview-Submit').attr('disabled', 'disabled'); $('html, body').animate({ scrollTop: heightBefore }, 200);

//å¼€å§‹æäº¤ç¼–è¾‘ if (sectionTargetName === self.kotori.pageName) { $('#Wikiplus-Quickedit-Preview-Output').fadeOut(100, function {                                    $('#Wikiplus-Quickedit-Preview-Output').html('').append(onEdit);                                    $('#Wikiplus-Quickedit-Preview-Output').fadeIn(100);                                }); self.kotori.edit(wikiText, sectionTargetName, {                                   success: function success {                                        var useTime = new Date.valueOf - timer;                                        $('#Wikiplus-Quickedit-Preview-Output').find('.Wikiplus-Banner').css('background', 'rgba(6, 239, 92, 0.44)');                                        $('#Wikiplus-Quickedit-Preview-Output').find('.Wikiplus-Banner').text(('' + i18n('edit_success')).replace(/\$1/ig, useTime.toString));                                        self.sendStatistic(sectionTargetName, useTime);                                        window.onclose = window.onbeforeunload = undefined; //å–æ¶ˆé¡µé¢å…³é—­ç¡®è®¤                                        setTimeout(function  { location.reload; }, 500);                                   },                                    fail: function fail(e) {                                        console.log(e);                                        $('#Wikiplus-Quickedit-Submit,#Wikiplus-Quickedit,#Wikiplus-Quickedit-Preview-Submit').prop('disabled', false);                                        $('.Wikiplus-Banner').css('background', 'rgba(218, 142, 167, 0.65)');                                        $('.Wikiplus-Banner').html(e.message);                                    }                                }, addtionalConfig); } else { //ç¼–è¾‘ç›®æ ‡éžå½“å‰é¡µé¢ $('#Wikiplus-Quickedit-Preview-Output').fadeOut(100, function {                                    $('#Wikiplus-Quickedit-Preview-Output').html('').append(onEdit.text(i18n('cross_page_edit')));                                    $('#Wikiplus-Quickedit-Preview-Output').fadeIn(100);                                }); self.kotori.reConstruct(sectionTargetName, {                                   success: function success {                                        $('.Wikiplus-Banner').text(i18n('cross_page_edit_submit'));                                        self.kotori.edit(wikiText, sectionTargetName, { success: function success { var useTime = new Date.valueOf - timer; $('#Wikiplus-Quickedit-Preview-Output').find('.Wikiplus-Banner').css('background', 'rgba(6, 239, 92, 0.44)'); $('#Wikiplus-Quickedit-Preview-Output').find('.Wikiplus-Banner').text(( + i18n('edit_success')).replace(/\$1/ig,  + useTime)); self.sendStatistic(sectionTargetName, useTime); window.onclose = window.onbeforeunload = undefined; //å–æ¶ˆé¡µé¢å…³é—­ç¡®è®¤ setTimeout(function {                                                    location.reload;                                                }, 500); },                                           fail: function fail(e) { $('#Wikiplus-Quickedit-Submit,#Wikiplus-Quickedit,#Wikiplus-Quickedit-Preview-Submit').prop('disabled', false); $('.Wikiplus-Banner').css('background', 'rgba(218, 142, 167, 0.65)'); $('.Wikiplus-Banner').text(e.message); }                                       }, addtionalConfig);                                    },                                    fail: function fail(e) {                                        $('.Wikiplus-Banner').css('background', 'rgba(218, 142, 167, 0.65)');                                        $('.Wikiplus-Banner').text(i18n('cross_page_edit_error'));                                    }                                }); }                       });                        //å¿«æ·é”®                        //Ctrl+Sæäº¤ Ctrl+Shift+Så°ç¼–è¾‘                        $('#Wikiplus-Quickedit,#Wikiplus-Quickedit-Summary-Input,#Wikiplus-Quickedit-MinorEdit').keydown(function (e) { if (e.ctrlKey && e.which == 83) { if (e.shiftKey) { $('#Wikiplus-Quickedit-MinorEdit').click; }                               $('#Wikiplus-Quickedit-Submit').click; e.preventDefault; e.stopPropagation; }                       });                        //ç”±äºŽæ˜¯å¼‚æ­¥æäº¤ Wikipluså³ä½¿ç¼–è¾‘å¤±è´¥ ä¹Ÿä¸ä¼šä¸¢å¤±æ•°æ® å”¯ä¸€ä¸¢å¤±æ•°æ®çš„å¯èƒ½æ€§æ˜¯æ‰‹æ»‘å…³äº†é¡µé¢                        //ç¬¬ä¸€ å…³é—­é¡µé¢ç¡®è®¤                        $('#Wikiplus-Quickedit').keydown(function  { window.onclose = window.onbeforeunload = function { return '' + i18n('onclose_confirm'); };                       });

//Escé€€å‡º if (self.getSetting('esc_to_exit_quickedit') === 'true') { $(document).keydown(function (e) {                               if (e.which === 27) {                                    $("#Wikiplus-Quickedit-Back").click;                                }                            }); }                   });                }

/**                * ç¼–è¾‘è®¾ç½® */           }, {                key: 'editSettings', value: function editSettings { var self = this; self.addFunctionButton(i18n('wikiplus_settings'), 'Wikiplus-Settings-Intro', function {                        var input = $(' ').attr('id', 'Wikiplus-Setting-Input').attr('rows', '10');                        var applyBtn = $(' ').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-Setting-Apply').text(i18n('submit'));                        var cancelBtn = $(' ').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-Setting-Cancel').text(i18n('cancel'));                        var content = $(' ').append(input).append($(' ')).append(applyBtn).append(cancelBtn); //æ‹¼æŽ¥                        self.createDialogBox(i18n('wikiplus_settings_desc'), content, 600, function  { if (localStorage.Wikiplus_Settings) { $('#Wikiplus-Setting-Input').val(localStorage.Wikiplus_Settings); } else { $('#Wikiplus-Setting-Input').attr('placeholder', i18n('wikiplus_settings_placeholder')); }                           $('#Wikiplus-Setting-Apply').click(function  {                                var settings = $('#Wikiplus-Setting-Input').val;                                try {                                    settings = JSON.parse(settings);                                } catch (e) {                                    self.notice.create.error(i18n('wikiplus_settings_grammar_error'));                                    return;                                }                                localStorage.Wikiplus_Settings = JSON.stringify(settings);                                $('.Wikiplus-InterBox-Content').html('').append($(' ').addClass('Wikiplus-Banner').text(i18n('wikiplus_settings_saved')));

$('.Wikiplus-InterBox').fadeOut(300, function {                                    $(this).remove;                                }); });                           $('#Wikiplus-Setting-Cancel').click(function  { $('.Wikiplus-InterBox').fadeOut(300, function {                                    $(this).remove;                                }); });                       });                    });                }

/**                * å¿«é€Ÿé‡å®šå‘é¡µé¢è‡³æ­¤é¡µé¢ */           }, {                key: 'simpleRedirector', value: function simpleRedirector { var self = this; self.addFunctionButton(i18n('redirect_from'), 'Wikiplus-SR-Intro', function {                        var input = $(' ').addClass('Wikiplus-InterBox-Input');                        var applyBtn = $(' ').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-SR-Apply').text(i18n('submit') + " - ctrl+s");                        var cancelBtn = $(' ').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-SR-Cancel').text(i18n('cancel'));                        var continueBtn = $(' ').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-SR-Continue').text(i18n('continue'));                        var content = $(' ').append(input).append($(' ')).append(applyBtn).append(cancelBtn); //æ‹¼æŽ¥                        self.createDialogBox(i18n('redirect_desc'), content, 600, function  { applyBtn.click(function {                                if ($('.Wikiplus-InterBox-Input').val != '') {                                    var title = $('.Wikiplus-InterBox-Input').val;                                    $('.Wikiplus-InterBox-Content').html(' ' + i18n('submitting_edit') + ' ');                                    self.kotori.redirectFrom(title, self.kotori.pageName, { success: function success { $('.Wikiplus-Banner').text(i18n('redirect_saved')); $('.Wikiplus-InterBox').fadeOut(300); location.href = mw.config.get('wgArticlePath').replace(/\$1/ig, title); },                                       fail: function fail(e) { $('.Wikiplus-Banner').css('background', 'rgba(218, 142, 167, 0.65)'); $('.Wikiplus-Banner').text(e.message); if (e.number === 1018) { // ç›®æ ‡é¡µé¢å·²ç»å­˜åœ¨ ç¡®è®¤å“Ÿ $('.Wikiplus-InterBox-Content').append($(' ')).append(continueBtn).append(cancelBtn); continueBtn.click(function {                                                    $('.Wikiplus-InterBox-Content').html(' ' + i18n('submitting_edit') + ' ');                                                    self.kotori.redirectFrom(title, self.kotori.pageName, { success: function success { $('.Wikiplus-Banner').text(i18n('redirect_saved')); $('.Wikiplus-InterBox').fadeOut(300); location.href = mw.config.get('wgArticlePath').replace(/\$1/ig, title); },                                                       fail: function fail(e) { $('.Wikiplus-Banner').css('background', 'rgba(218, 142, 167, 0.65)'); $('.Wikiplus-Banner').text(e.message); }                                                   }, true);                                                }); cancelBtn.click(function {                                                    $('.Wikiplus-InterBox-Close').click;                                                }); }                                       }                                    });                                } else {                                    self.showNotice.create.warning(i18n('empty_input'));                                }                            }); $('#Wikiplus-SR-Cancel').click(function {                                $('.Wikiplus-InterBox').fadeOut(300, function  { $(this).remove; });                           });                            //اختصار تأكيد التحميل $('.Wikiplus-InterBox').keydown(function (e) {                           if (e.ctrlKey && e.which == 83) {                                $('#Wikiplus-SR-Apply').click;                                e.preventDefault;                                e.stopPropagation;                            }                        }); });                   });                }

/**                * é¢„è¯»å–ç›¸å…³äº‹ä»¶ç»‘å®š */           }, {                key: 'preloadEventBinding', value: function preloadEventBinding { var self = this; $("#toc").children("ul").find("a").each(function (i) {                       $(this).mouseover(function  { $(this).unbind('mouseover'); self.preload(i + 1); });                   });                }

/**                * æ£€æŸ¥å¤šè¯­è¨€å®šä¹‰ç¼“å­˜æ˜¯å¦è¿‡æœŸ */           }, {                key: 'checki18nCache', value: function checki18nCache { if (localStorage.Wikiplus_i18nCache) { try { var _i18nData = JSON.parse(localStorage.Wikiplus_i18nCache); for (var languages in _i18nData) { if (_i18nData[languages]['__version'] === this.langVersion) { i18nData[_i18nData[languages]['__language']] = _i18nData[languages]; } else { console.log('å¤šè¯­è¨€æ–‡ä»¶[' + languages + ']å·²ç»è¿‡æœŸ'); loadLanguage(_i18nData[languages]['__language']); //å°è¯•é‡æ–°å– }                           }                        } catch (e) { throwError('cant_parse_i18ncache'); }                   } else { localStorage.Wikiplus_i18nCache = JSON.stringify(i18nData); }               }

/**                * ä¸ºæ‰€æœ‰å¯èƒ½çš„ç¼–è¾‘é“¾æŽ¥åŠ ä¸Šå¿«é€Ÿç¼–è¾‘æŒ‰é’® */           }, {                key: 'editEveryWhere', value: function editEveryWhere { var self = this; $('#mw-content-text a.external').each(function (i) {                       var url = $(this).attr('href');                        var reg = /(([^?&=]+)(?:=([^?&=]*))*)/g;                        var params = {},                            match;                        while (match = reg.exec(url)) {                            try {                               params[match[2]] = decodeURIComponent(match[3]);                           } catch (e) {}                        }                        if (params.action === 'edit' && params.title !== undefined && params.section !== 'new') {                           var target;                           try {                             target = decodeURIComponent(params.title);                           } catch(e){}                            $(this).after($('').attr({                                'href': "javascript:void(0)", 'class': "Wikiplus-Edit-EveryWhereBtn" }).text('(' + i18n('quickedit_sectionbtn') + ')').data({ 'target': target, 'number': params.section || -1 }));                       }                    });                    $('.Wikiplus-Edit-EveryWhereBtn').click(function  { self.initQuickEditInterface($(this)); });               }

/**                * ===========================                 * ä»¥ä¸Šæ˜¯åŠŸèƒ½å‡½æ•° ä»¥ä¸‹æ˜¯é€šç”¨å‡½æ•° * ===========================                */

/**                * åˆ›å»ºå¯¹è¯æ¡† * @param {string} title å¯¹è¯æ¡†æ ‡é¢˜ * @param {HTML} content å†…å®¹ * @param {interger} width å®½åº¦ å•ä½åƒç´ é»˜è®¤600px * @param {function} callback å›žè°ƒå‡½æ•° */           }, {                key: 'createDialogBox', value: function createDialogBox { var title = arguments.length <= 0 || arguments[0] === undefined ? 'Dialog Box' : arguments[0]; var content = arguments.length <= 1 || arguments[1] === undefined ? $(' ') : arguments[1]; var width = arguments.length <= 2 || arguments[2] === undefined ? 600 : arguments[2]; var callback = arguments.length <= 3 || arguments[3] === undefined ? new Function : arguments[3];

if ($('.Wikiplus-InterBox').length > 0) { $('.Wikiplus-InterBox').each(function {                            $(this).remove;                        }); }                   var clientWidth = document.body.clientWidth; var clientHeight = document.body.clientHeight; var diglogBox = $(' ').addClass('Wikiplus-InterBox').css({                       'margin-right': clientWidth / 2 - width / 2,                        'top': $(document).scrollTop + clientHeight * 0.2,                        'display': 'none'                    }).append($(' ').addClass('Wikiplus-InterBox-Header').html(title)).append($(' ').addClass('Wikiplus-InterBox-Content').append(content)).append($(' ').text('×').addClass('Wikiplus-InterBox-Close')); $('body').append(diglogBox); $('.Wikiplus-InterBox').width(width); $('.Wikiplus-InterBox-Close').click(function {                        $(this).parent.fadeOut('fast', function  { window.onclose = window.onbeforeunload = undefined; //å–æ¶ˆé¡µé¢å…³é—­ç¡®è®¤ $(this).remove; });                   });                    //æ‹–æ›³ var bindDragging = function bindDragging(element) { element.mousedown(function (e) {                           var baseX = e.clientX;                            var baseY = e.clientY;                            var baseOffsetX = element.parent.offset.right;                            var baseOffsetY = element.parent.offset.top;                            $(document).mousemove(function (e) { element.parent.css({                                   'margin-right': baseOffsetX + e.clientX - baseX,                                    'top': baseOffsetY + e.clientY - baseY                                }); });                           $(document).mouseup(function  { element.unbind('mousedown'); $(document).unbind('mousemove'); $(document).unbind('mouseup'); bindDragging(element); });                       });                    };                    bindDragging($('.Wikiplus-InterBox-Header')); $('.Wikiplus-InterBox').fadeIn(500); callback; }

/**                * å¢žåŠ åŠŸèƒ½æŒ‰é’® * @param {string} text æŒ‰é’®å * @param {string} id æŒ‰é’®id * @param {function} clickEvent ç‚¹å‡»äº‹ä»¶ */           }, {                key: 'addFunctionButton', value: function addFunctionButton(text, id, clickEvent) { var button = $('').attr('id', id).append($('').attr('href', 'javascript:void(0);').text(text)); if ($('#p-cactions').length > 0) { $('#p-cactions ul').append(button); $('#p-cactions ul').find('li').last.click(clickEvent); } else { throwError('cant_add_funcbtn'); }               }

/**                * é¢„è¯»å–å†…å®¹ * @param {interger} section æ®µè½ç¼–å· é»˜è®¤ä¸º-1å³å…¨é¡µ * @param {string} title é¡µé¢å é»˜è®¤ä¸ºå½“å‰é¡µé¢ * @param {object} callback å›žè°ƒ */           }, {                key: 'preload', value: function preload { var section = arguments.length <= 0 || arguments[0] === undefined ? -1 : arguments[0]; var title = arguments.length <= 1 || arguments[1] === undefined ? this.kotori.pageName : arguments[1]; var callback = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; var config = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];

callback.success = callback.success || new Function; callback.fail = callback.fail || new Function; var self = this; if (config.oldid !== undefined) { // oldid ä¼˜å…ˆäºŽ é¡µé¢å console.log(typeof config.oldid); if (this.preloadData[config.oldid + '.' + section]) { console.log('[ä¿®è®¢ç‰ˆæœ¬' + config.oldid + '.' + section + ']å·²ç»é¢„è¯»å– è·³è¿‡æœ¬æ¬¡é¢„è¯»å–'); callback.success(this.preloadData[config.oldid + '.' + section]); return; }                   } else { if (this.preloadData[title + '.' + section]) { console.log('[' + title + '.' + section + ']å·²ç»é¢„è¯»å– è·³è¿‡æœ¬æ¬¡é¢„è¯»å–'); callback.success(this.preloadData[title + '.' + section]); return; }                   }                    this.kotori.getWikiText({                        success: function success(data) {                            if (config.oldid !== undefined) {                                self.preloadData[config.oldid + '.' + section] = data;                                console.log('é¢„è¯»å–[ä¿®è®¢ç‰ˆæœ¬' + config.oldid + '.' + section + ']æˆåŠŸ');                            } else {                                self.preloadData[title + '.' + section] = data;                                console.log('é¢„è¯»å–[' + title + '.' + section + ']æˆåŠŸ');                            }                            callback.success(data);                            cleanrefs;                            $('#Wikiplus-Quickedit-Submit').click;

},                       fail: function fail(e) { if (config.oldid !== undefined) { console.log('é¢„è¯»å–[ä¿®è®¢ç‰ˆæœ¬' + config.oldid + '.' + section + ']å¤±è´¥'); } else { console.log('é¢„è¯»å–[' + title + '.' + section + ']å¤±è´¥:' + e.message); }                           callback.fail(e); }                   }, title, $.extend({                        section: section === -1 ? '' : section                    }, config));                }

/**                * æäº¤ç»Ÿè®¡æ•°æ® * @param {string} title é¡µé¢å * @param {interger} useTime ç”¨æ—¶ å•ä½æ¯«ç§’ */           }, {                key: 'sendStatistic', value: function sendStatistic(title, useTime) { if (title === undefined) title = mw.config.get('wgPageName');

if (localStorage.Wikiplus_SendStatistics == 'True') { $.ajax({                           url: scriptPath + '/statistics/api/submit',                            type: 'POST',                            dataType: 'json',                            data: {                                'wikiname': mw.config.get('wgSiteName'),                                'usetime': useTime,                                'username': mw.config.get('wgUserName'),                                'pagename': title                            },                            success: function success(data) {                                //æäº¤æˆåŠŸ                            }                        }); }               }

/**                * æ£€æŸ¥å®‰è£… * @param {function} callback å›žè°ƒå‡½æ•° */           }, {                key: 'checkInstall', value: function checkInstall(callback) { var self = this; if (!localStorage.Wikiplus_Installed || localStorage.Wikiplus_Installed == 'False') { //å®‰è£… var install = function install { localStorage.Wikiplus_Installed = 'True'; //æ ‡è®°å·²å®‰è£… localStorage.Wikiplus_Version = self.version; localStorage.Wikiplus_StartUseAt = new Date.valueOf; localStorage.Wikiplus_SrartEditCount = mw.config.get('wgUserEditCount'); localStorage.Wikiplus_Settings = JSON.stringify(self.defaultSettings); $('.Wikiplus-InterBox').fadeOut('fast', function {                                self.notice.create.success(i18n('install_finish'));                                $(this).remove;                            }); };                       /*var notice = $(' ').text(i18n('install_tip').replace(/\$1/ig, mw.config.get('wgSiteName'))).attr('id', 'Wikiplus-InterBox-Content'); var applyBtn = $(' ').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-Setting-Apply').text(i18n('accept')); var cancelBtn = $(' ').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-Setting-Cancel').text(i18n('decline')); var content = $(' ').append(notice).append($(' ')).append(applyBtn).append(cancelBtn); //æ‹¼æŽ¥ self.createDialogBox('å®‰è£…Wikiplus', content, 600, function {                            $('#Wikiplus-InterBox-Content').css('display', 'none');                            $('#Wikiplus-Setting-Apply').click(function  { localStorage.Wikiplus_SendStatistics = 'False'; install; });                           $('#Wikiplus-Setting-Cancel').click(function  { localStorage.Wikiplus_SendStatistics = 'False'; install; });                       });*/                    }                }

/**                * èŽ·å–è®¾ç½®å€¼ * @param {string} key é”®å * @param {object} object ä¼ å…¥å¯ç”¨å‚æ•° */           }, {                key: 'getSetting', value: function getSetting(key, object) { var w = object; try { var settings = JSON.parse(localStorage.Wikiplus_Settings); } catch (e) { return localStorage.Wikiplus_Settings || ''; }                   try { var _setting = new Function('return ' + settings[key]); if (typeof _setting == 'function') { try { if (_setting(w) === true) { return undefined; } else { return _setting(w) || settings[key]; }                           } catch (e) { return settings[key]; }                       } else { return settings[key]; }                   } catch (e) { try { return settings[key]; } catch (e) { return undefined; }                   }                }            }, {                key: 'initBasicFunctions', value: function initBasicFunctions { this.initQuickEdit; //åŠ è½½å¿«é€Ÿç¼–è¾‘ this.editSettings; //ç¼–è¾‘è®¾ç½® this.simpleRedirector; //å¿«é€Ÿé‡å®šå‘ this.preloadEventBinding; //é¢„è¯»å– if (!this.getSetting('disableEditEveryWhere')) { this.editEveryWhere; //ä»»æ„ç¼–è¾‘ }               }            }, {                key: 'initRecentChangesPageFunctions', value: function initRecentChangesPageFunctions {} }, {               key: 'initAdvancedFunctions', value: function initAdvancedFunctions {} }]);

function Wikiplus { _classCallCheck(this, Wikiplus);

this.version = '2.2.14'; this.langVersion = '210'; this.releaseNote = 'Bug ä¿®æ­£'; this.notice = new MoeNotification; this.inValidNameSpaces = [-1, 8964]; this.defaultSettings = { 'key': 'value', 'documatation': 'http://zh.moegirl.org/User:%E5%A6%B9%E7%A9%BA%E9%85%B1/Wikiplus/%E8%AE%BE%E7%BD%AE%E8%AF%B4%E6%98%8E' };               console.log('æ­£åœ¨åŠ è½½Wikiplus ' + this.version); //è½½å…¥CSS $("head").append(" "); $("head").children(":last").attr({                   rel: "stylesheet",                    type: "text/css",                    href: "//ar.wikipedia.org/w/index.php?title=MediaWiki:Gadget-QuickEdit.css&action=raw&ctype=text/css"                }); //ä¸€äº›åˆå§‹åŒ–å·¥ä½œ this.preloadData = {}; this.checkInstall; //å®‰è£…æ£€æŸ¥ //è¯­è¨€æ£€æµ‹ var language = this.getSetting('language') && this.getSetting('language').toLowerCase || window.navigator.language.toLowerCase; //ç‰ˆæœ¬æ£€æŸ¥ /*if (!(this.version === localStorage.Wikiplus_Version)) { localStorage.Wikiplus_Version = this.version; this.notice.create.success('Wikiplus ' + this.version); this.notice.create.success(language === 'zh-cn' ? this.releaseNote : 'Minor bug fixes.'); // é¿å…ç»™å…¶ä»–è¯­è¨€ç”¨æˆ·ä¸å¿…è¦çš„ç†è§£å›°éš¾ }*/               if (i18nData[language] === undefined) { loadLanguage(language); }               //çœŸæ­£çš„åˆå§‹åŒ– if (!inArray(mw.config.get('wgNameSpaceNumber'), this.inValidNameSpaces) && mw.config.get('wgIsArticle') && mw.config.get('wgAction') === "view") { this.kotori = new Wikipage; this.checki18nCache; this.initBasicFunctions; } else { console.log('ä¸ç¬¦åˆåŠ è½½æ¡ä»¶ Wikiplusç»ˆæ­¢'); }           }

return Wikiplus; });

window.Wikiplus = new Wikiplus; }); });