User:Chubit/common.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/* global mw */
/// <reference path="../typings/jquery/jquery.d.ts"/>
/**
* Wikiplus
* Author: +Eridanus Sora/@憒寧征��
* Github: https://github.com/Last-Order/Wikiplus
*/
/**
* 靘肽�𣇉�隞�: MoeNotification
* https://github.com/Last-Order/MoeNotification
*/
'use strict';
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 () {
var text = arguments.length <= 0 || arguments[0] === undefined ? '�鮟~' : arguments[0];
var type = arguments.length <= 1 || arguments[1] === undefined ? 'success' : arguments[1];
var callback = arguments.length <= 2 || arguments[2] === undefined ? function () {} : arguments[2];
$('#MoeNotification').append($('<div>').addClass('MoeNotification-notice').addClass('MoeNotification-notice-' + type).append('<span>' + text + '</span>'));
$('#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) {
var isFunction = function isFunction(f) {
if (typeof f === 'function') return true;
var t = Object.prototype.toString(f);
return t === '[object Function]' || t === '[object GeneratorFunction]';
};
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.slideLeft($(this));
});
};
this.slideLeft = function (object, speed) {
object.css('position', 'relative');
object.animate({
left: '-200%'
}, speed || 150, function () {
$(this).fadeOut('fast', function () {
$(this).remove();
});
});
};
this.init = function () {
$('body').append('<div id="MoeNotification"></div>');
};
if (!($('#MoeNotification').length > 0)) {
this.init();
}
}
$(function () {
var i18nData = {};
var scriptPath = location.protocol + '//wikiplus-app.com';
i18nData['zh-cn'] = {
"__language": "zh-cn",
"__author": ["Eridanus Sora"],
"__version": "212",
"unknown_error_name": "�𧊋�䰻����躰秤���",
"api_unaccessiable": "��惩虾�鍂��API",
"api_unwriteable": "��惩虾�鍂���坔�丕PI",
"fail_to_get_timestamp": "��䭾�閗繮敺烾△�𢒰蝻𤥁�𤏸絲憪𧢲𧒄�𡢿��",
"fail_to_get_edittoken": "��䭾�閗繮敺烾△�𢒰蝻𤥁�烐����",
"fail_to_get_pageinfo": "��䭾�閗繮敺烾△�𢒰靽⊥��",
"not_autoconfirmed_user": "��噼䌊�𢆡蝖株恕�鍂��",
"hit_abusefilter": "鋡恍俈皛亦鍂餈�誘�膥�㜃�⏛",
"unknown_edit_error": "�𧊋�䰻蝻𤥁�煾�躰秤",
"unknown_edit_error_message": "�𧊋�䰻蝻𤥁�煾�躰秤($1)",
"notitle": "��䭾�閧�𤥁�𤑳征����㗛△�𢒰",
"notext": "蝻箏�煾△�𢒰��摰�",
"notoken": "蝛箇�𤥁�烐����",
"invalidsection": "畾菔氜蝻硋噡��墧��",
"protectedtitle": "霂交���䁅◤靽脲擪嚗峕�䭾�訫�𥕦遣",
"cantcreate": "��䭾鰵撱粹△�𢒰�����",
"cantcreate_anon": "�鈡��滨鍂����䭾鰵撱粹△�𢒰�����",
"articleexists": "��䭾�訫�𥕦遣撌脩�誩�睃銁��憿菟𢒰",
"noimageredirect_anon": "�鈡��滨鍂����䭾鰵撱箸��辣��滚�𡁜�烐����",
"noimageredirect": "��䭾鰵撱箸��辣��滚�𡁜�烐����",
"spamdetected": "���𧋦�鉄��㗇�𤩺�笔��摰對�諹◤SPAM餈�誘�膥�㜃�⏛",
"filtered": "蝻𤥁�𤏸◤餈�誘�膥�㜃�⏛",
"contenttoobig": "���𧋦頞�餈��憭折鵭摨阡�𣂼�",
"noedit_anon": "�鈡��滨鍂����删�𤥁�煾△�𢒰�����",
"noedit": "��删�𤥁�煾△�𢒰�����",
"pagedeleted": "蝻𤥁�烐𧒄嚗峕迨憿菟𢒰鋡怠�𣳇膄",
"emptypage": "��䭾�閙鰵撱箇征��摰寥△�𢒰",
"emptynewsection": "��䭾�閙鰵撱箇征��摰寞挾�氜",
"editconflict": "蝻𤥁�穃�脩�嚗諹窈��见極璉��䰻憿菟𢒰敶枏�滚��摰嫣�擧�𣂷漱��摰孵榆撘�撟嗡耨甇��𠬍����鰵憿菟𢒰��𣂷漱",
"revwrongpage": "蝻𤥁�𤑳�靽株恥���𧋦銝𡒊�𤥁�𤑳�憿菟𢒰銝滚龪��",
"undofailure": "�眏鈭𤾸�睃銁�脩���銝剝𡢿���𧋦嚗峕�䭾�閙伃��蝻𤥁��",
"missingtitle": "��䭾�訫�𥕦遣��𣇉�𤥁�𤑳征����㗛△�𢒰",
"mustbeposted": "敹�憿颱蝙�鍂POST�䲮撘𤩺�𣂷漱蝻𤥁��",
"readapidenied": "��㰘粉��䨝PI雿輻鍂�����",
"writeapidenied": "��𣳇�朞�䰲PI蝻𤥁�煾△�𢒰�����",
"noapiwrite": "�𧋦Wiki�𧊋撘��鍳�虾�鍂���坔�丕PI",
"badtoken": "��墧�閧�蝻𤥁�烐����",
"missingparam": "蝻箏�穃�閬����㺭嚗屸△�𢒰��滚�屸△�𢒰ID銝滩�賢��蛹蝛�",
"invalidparammix": "���㺭��滚�㵪�屸△�𢒰��滚�屸△�𢒰ID銝滩�賢�峕𧒄蝏坔��",
"invalidtitle": "��墧�閧������",
"nosuchpageid": "銝滚�睃銁��憿菟𢒰ID",
"pagecannotexist": "霂亙�滨妍蝛粹𡢿銝滚��霈豢鰵撱箔���憿菟𢒰",
"nosuchrevid": "銝滚�睃銁��靽株恥���𧋦",
"badmd5": "��墧�閧�MD5��",
"hookaborted": "蝻𤥁�𤏸◤��撅𠁎ook�㜃�⏛",
"parseerror": "��䭾�閗圾��鞾△�𢒰���𧋦",
"summaryrequired": "蝻𤥁�烐�䁅�銝滩�賭蛹蝛�",
"blocked": "撌脰◤撠�蝳�",
"ratelimited": "颲曉���滢�𣈯�毺���𢠃�琜�諹窈蝔滚�𡡞�滩��",
"unknownerror": "�𧊋�䰻��躰秤",
"nosuchsection": "��䭾�閧�𤥁�睲�滚�睃銁��畾菔氜",
"sectionsnotsupported": "霂仿△�𢒰銝齿𣈲��畾菔氜蝻𤥁��",
"editnotsupported": "霂仿△�𢒰銝齿𣈲���朞�䰲PI蝻𤥁��",
"appendnotsupported": "霂仿△�𢒰��䭾�訫銁��滚�擧�鍦�交��𧋦",
"redirect_appendonly": "�銁�萄儐��滚�𡁜�𤑳����萎�页��蘨�質�𥡝���滚�擧�鍦�交�硋�𥕦遣�鰵畾菔氜",
"badformat": "���𧋦�聢撘誯�躰秤",
"customcssprotected": "��䭾�閧�𤥁�𤑳鍂��CSS憿�",
"customjsprotected": "��䭾�閧�𤥁�𤑳鍂��JS憿�",
"cascadeprotected": "霂仿△�𢒰鋡怎漣�𥪯�脲擪",
"network_edit_error": "�眏鈭𡒊�𤑳�𨅯�笔�删�𤥁�穃仃韐�",
"redirect_to_summary": "��滚�𡁜�煾△�𢒰�秐[[$1]] \/\/ Wikiplus",
"redirect_from_summary": "撠�[[$1]]��滚�𡁜�𤏸秐[[$2]] \/\/ Wikiplus",
"need_init": "憿菟𢒰蝐餅𧊋��㰘蝸摰峕��",
"fail_to_get_wikitext": "��䭾�閗繮敺烾△�𢒰���𧋦",
"quickedit_topbtn": "敹恍�毺�𤥁��",
"quickedit_sectionbtn": "敹恍�毺�𤥁��",
"fail_to_init_quickedit": "��䭾�訫�㰘蝸敹恍�毺�𤥁��",
"back": "餈𥪜��",
"goto_editbox": "��蝻𤥁�烐�",
"summary_placehold": "霂瑁�枏�亦�𤥁�烐�䁅�",
"submit": "��𣂷漱",
"publish_page": "��穃�憿菟𢒰",
"publish_change": "��穃��凒�㺿",
"preview": "憸�閫�",
"cancel": "��𡝗��",
"mark_minoredit": "���扇銝箏�讐�𤥁��",
"onclose_confirm": "[Wikiplus] �函&霈方��喲𡡒/���鰵憿菟𢒰��梹�蠘�嗘�𡁜紡�稲�函�蝻𤥁�烐㺭�旿銝W仃",
"fail_to_get_wikitext_when_edit": "��䭾�閗繮敺烾△�𢒰���𧋦隞亦�𤥁��",
"cant_parse_wikitext": "��䭾�閗圾��鞟輕�抅���𧋦",
"loading_preview": "甇�銁霂餃�㚚�閫�",
"submitting_edit": "甇�銁��𣂷漱蝻𤥁��",
"edit_success": "蝻𤥁�烐�𣂼�� �鍂�𧒄$1ms",
"empty_page_confirm": "�典�𤑳�𤥁�穃遆�㺭隡惩�乩�蝛箏��摰孵��㺭 餈坔�皜�蝛粹△�𢒰\r\n�眏鈭舘砲銵䔶蛹�暒�埯 霂瑕�config���㺭��empty�睸�潸挽摰帋蛹true�䔉蝖株恕",
"cross_page_edit": "蝻𤥁�𤑳𤌍����滢�𤾸�嗡�㚚△�𢒰 甇�銁�繮��硋抅蝖�靽⊥��",
"cross_page_edit_submit": "�抅蝖�靽⊥�航繮��𡝗�𣂼�� 甇�銁��𣂷漱蝻𤥁��",
"cross_page_edit_error": "��䭾�閗繮敺堒抅蝖�靽⊥��>.<",
"install_tip": "�冽糓�炏��霈稜ikiplus������墧�𤩺��㺭�旿�鍂鈭擧㺿餈𢫕ikiplus��𠹺蛹敶枏�䱻iki嚗�$1��𣂷�𥟇㺿餈𥕦遣霈殷��",
"accept": "�𦻖���",
"decline": "��垍��",
"install_finish": "Wikiplus摰㕑�摰峕��",
"loading": "甇�銁頧賢��",
"cant_add_funcbtn": "��䭾�訫�𧼮�惩�蠘�賣�厰僼",
"wikiplus_settings": "Wikiplus霈曄蔭",
"wikiplus_settings_desc": "霂瑕銁銝𧢲䲮��㕑���靽格㺿Wikiplus霈曄蔭",
"wikiplus_settings_placeholder": "敶枏�滩挽蝵桐蛹蝛� 霂瑕銁甇文���㕑���靽格㺿Wikiplus霈曄蔭",
"wikiplus_settings_grammar_error": "霈曄蔭摮睃銁霂剜�閖�躰秤 霂瑟��䰻��𡡞�滩��",
"wikiplus_settings_saved": "霈曄蔭撌脖�嘥��",
"redirect_from": "撠�憿菟𢒰��滚�𡁜�𤏸秐甇�",
"redirect_desc": "霂瑁�枏�亥���滚�𡁜�𤏸秐甇斤�憿菟𢒰���",
"empty_input": "颲枏�乩�滩�賭蛹蝛�",
"redirect_saved": "��滚�𡁜�穃�峕��",
"uninited": "Wikiplus�𧊋��㰘蝸摰峕�� 霂瑕��鰵��滩��",
"cant_parse_i18ncache": "��䭾�閗圾��𣂼�朞祗閮�摰帋�㗇��辣蝻枏��",
"cant_load_language": "��䭾�閗繮��硋�朞祗閮�摰帋�㗇��辣",
"history_edit_warning": " // 甇��訫㦛蝻𤥁�穃��蟮���𧋦 餈坔�隡𡁜�𠉛鍂���𧋦憿菟𢒰�����鰵���𧋦 霂瑟�𡡞�齿�𣂷漱",
"create_page_tip": "<!-- 甇�銁��𥕦遣�鰵憿菟𢒰 霂瑕�惩縧甇方�峕釣��𠰴�𡒊誧蝏� -->",
"continue": "隞滨�嗥誧蝏�",
"default_summary_suffix": "// Edit via Wikiplus",
'cross_page_history_revision_edit_warning': '��銝齿𣈲�����蟮���𧋦頝券△�𢒰蝻𤥁��'
};
i18nData['en-us'] = {
"__language": "en-us",
"__author": ["Eridanus Sora", "AnnAngela", "YinYan"],
"__version": "212",
"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": "No summary in your edit",
"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": "Redirect to [[$1]] \/\/ Wikiplus",
"redirect_from_summary": "Redirect [[$1]] to [[$2]] \/\/ Wikiplus",
"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",
"quickedit_sectionbtn": "QuickEdit",
"fail_to_init_quickedit": "Failed to initialize Wikiplus",
"back": "Back",
"goto_editbox": "Jump to editbox",
"summary_placehold": "Edit summary",
"submit": "Submit",
"publish_page": "Publish Page",
"publish_change": "Publish Changes",
"preview": "Preview",
"cancel": "Cancel",
"mark_minoredit": "Mark this edit as a minor edit",
"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": "Loading the preview",
"submitting_edit": "Submitting your edit",
"edit_success": "Your edit is submitted within $1ms",
"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": "Submitting your edit...",
"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": "Yes",
"decline": "No",
"install_finish": "Wikiplus is installed, enjoy it",
"loading": "Loading",
"cant_add_funcbtn": "Failed to add buttons for Wikiplus",
"wikiplus_settings": "Wikiplus Setting",
"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": "Your settings have been saved",
"redirect_from": "Redirect from",
"redirect_desc": "Which page do you want to redirect here?",
"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": "<!-- You are now creating a new page. Please delete this line and be careful. -->",
"continue": "Continue anyway",
"default_summary_suffix": "// Edit via Wikiplus",
"cross_page_history_revision_edit_warning": "Cross-page edit in history revision is not supported yet."
};
/**
* ��㰘蝸�嗡�𤥁祗閮����辣
* @param {string} language 霂剛����
*/
function loadLanguage(language) {
$.ajax({
url: 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 = 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;
}
}
/**
* �繮敺烾�躰秤靽⊥��
* @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} 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頧賢�乩�滚���冽�𤥁�嗘�齿糓銝�銝杯ediaWiki蝡嗵��');
return;
}
if (!window.mw.config.get('wgUserGroups').includes('autoconfirmed') && !window.mw.config.get('wgUserGroups').includes('confirmed')) {
throwError('not_autoconfirmed_user');
return;
}
//隞穽ediaWiki摰帋�厩��典���㗛�譍葉�繮敺𦯀縑��
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';
//隞垾PI�繮敺㛖�𤥁�睲誘����諹絲憪𧢲𧒄�𡢿��
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(request) {
request.setRequestHeader('Api-User-Agent', 'Wikiplus/2 (' + mw.config.get('wgWikiID') + ')');
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 撠肽�閖�朞�䰲PI
$.ajax({
url: self.API,
type: 'GET',
dataType: 'json',
data: {
'action': 'query',
'meta': 'tokens',
'format': 'json'
},
beforeSend: function beforeSend(request) {
request.setRequestHeader('Api-User-Agent', 'Wikiplus/2 (' + mw.config.get('wgWikiID') + ')');
},
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) {
// 憒���𨀣糓蝛粹△�𢒰撠勗蘨�嚉銝�銝河dittoken
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),
beforeSend: function beforeSend(request) {
request.setRequestHeader('Api-User-Agent', 'Wikiplus/2 (' + mw.config.get('wgWikiID') + ')');
},
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', '') + '<br><small>' + data.edit.warning + '</small>'));
} 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(request) {
request.setRequestHeader('Api-User-Agent', 'Wikiplus/2 (' + mw.config.get('wgWikiID') + ')');
console.time('�繮敺烾△�𢒰���𧋦�埈𧒄');
},
success: function success(data) {
console.timeEnd('�繮敺烾△�𢒰���𧋦�埈𧒄');
callback.success(data);
},
error: function error(e) {
callback.fail(throwError('fail_to_get_wikitext'));
}
});
}
/**
* 閫��𨔽ikitext
* @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),
beforeSend: function beforeSend(request) {
request.setRequestHeader('Api-User-Agent', 'Wikiplus/2 (' + mw.config.get('wgWikiID') + ')');
},
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 = $('<li>').attr('id', 'Wikiplus-Edit-TopBtn').append($('<span>').append($('<a>').attr('href', 'javascript:void(0)').text('' + i18n('quickedit_topbtn')))).data({
number: -1,
target: self.kotori.pageName
});
if (mw.config.get('skin') === 'minerva') {
$(topBtn).css({ 'align-items': 'center', 'display': 'flex' });
$(topBtn).find('span').addClass('page-actions-menu__list-item');
$(topBtn).find('a').addClass('mw-ui-icon mw-ui-icon-element mw-ui-icon-wikimedia-edit-base20 mw-ui-icon-with-label-desktop').css('vertical-align', 'middle');
}
if ($('#ca-edit').length > 0 && $('#Wikiplus-Edit-TopBtn').length === 0) {
mw.config.get('skin') === 'minerva' ? $('#ca-edit').parent().after(topBtn) : $('#ca-edit').after(topBtn);
} else if ($('#ca-edit').length === 0) {
throwError('fail_to_init_quickedit');
}
if ($('.mw-editsection').length > 0) {
self.sectionMap = {};
//畾菔氜敹恍�毺�𤥁�烐�厰僼
var sectionBtn = mw.config.get('skin') === 'minerva' ? $('<span>').append($('<a>').addClass('Wikiplus-Edit-SectionBtn mw-ui-icon mw-ui-icon-element mw-ui-icon-wikimedia-edit-base20 edit-page mw-ui-icon-flush-right').css('margin-left', '0.75em').attr('href', 'javascript:void(0)').attr('title', i18n('quickedit_sectionbtn'))) : $('<span>').append($('<span>').addClass('mw-editsection-divider').text(' | ')).append($('<a>').addClass('Wikiplus-Edit-SectionBtn').attr('href', 'javascript:void(0)').text(i18n('quickedit_sectionbtn')));
$('.mw-editsection').each(function (i) {
try {
var editURL = $(this).find('a').first().attr('href');
var sectionNumber = editURL.match(/&[ve]*section\=([^&]+)/)[1].replace(/T-/ig, '');
var sectionTargetName = decodeURIComponent(editURL.match(/title=(.+?)&/)[1]);
var cloneNode = $(this).prev().clone();
cloneNode.find('.mw-headline-number').remove();
var sectionName = cloneNode.text().trim();
self.sectionMap[sectionNumber] = {
name: sectionName,
target: sectionTargetName
};
var _sectionBtn = sectionBtn.clone();
_sectionBtn.find('.Wikiplus-Edit-SectionBtn').data({
number: sectionNumber,
name: sectionName,
target: sectionTargetName
});
mw.config.get('skin') === 'minerva' ? $(this).append(_sectionBtn) : $(this).find('.mw-editsection-bracket').last().before(_sectionBtn);
} catch (e) {
throwError('fail_to_init_quickedit');
}
});
}
$('.Wikiplus-Edit-SectionBtn').click(function () {
self.initQuickEditInterface($(this)); //�凒�𦻖��𠴕OM隡𣳇�垍�嗘�衤�甇�
});
$('#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 (sectionTargetName !== self.kotori.pageName && mw.config.get('wgCurRevisionId') !== mw.config.get('wgRevisionId')) {
// �銁���蟮���𧋦蝻𤥁�穃�嗡�㚚△�𢒰��厰䔮憸� ���𧒄銝齿𣈲��
this.notice.create.error(i18n('cross_page_history_revision_edit_warning'));
return;
}
if ($('.noarticletext').length > 0) {
//餈蹱糓銝�銝芰征憿菟𢒰
this.preloadData[sectionTargetName + '.-1'] = i18n('create_page_tip');
}
if (mw.config.get('wgCurRevisionId') === mw.config.get('wgRevisionId')) {
var additionalConfig = {};
if (this.preloadData[sectionTargetName + '.' + sectionNumber] === undefined) {
if (sectionTargetName === this.kotori.pageName) {
additionalConfig.oldid = mw.config.get('wgRevisionId');
}
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');
}
}, additionalConfig);
} 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 = $('<span>').attr('id', 'Wikiplus-Quickedit-Back').addClass('Wikiplus-Btn').text('' + i18n('back')); //餈𥪜�墧�厰僼
var jumpBtn = $('<span>').attr('id', 'Wikiplus-Quickedit-Jump').addClass('Wikiplus-Btn').append($('<a>').attr('href', '#Wikiplus-Quickedit').text('' + i18n('goto_editbox'))); //��蝻𤥁�烐�
var inputBox = $('<textarea>').attr('id', 'Wikiplus-Quickedit'); //銝餌�𤥁�烐�
var previewBox = $('<div>').attr('id', 'Wikiplus-Quickedit-Preview-Output'); //憸�閫��枏枂
var summaryBox = $('<input>').attr('id', 'Wikiplus-Quickedit-Summary-Input').attr('placeholder', '' + i18n('summary_placehold')); //蝻𤥁�烐�䁅�颲枏��
var editSubmitBtn = $('<button>').attr('id', 'Wikiplus-Quickedit-Submit').text(i18n(isNewPage ? 'publish_page' : 'publish_change') + '(Ctrl+S)'); //��𣂷漱��厰僼
var previewSubmitBtn = $('<button>').attr('id', 'Wikiplus-Quickedit-Preview-Submit').text('' + i18n('preview')); //憸�閫��厰僼
var isMinorEdit = $('<div>').append($('<input>').attr({ 'type': 'checkbox', 'id': 'Wikiplus-Quickedit-MinorEdit' })).append($('<label>').attr('for', 'Wikiplus-Quickedit-MinorEdit').text(i18n('mark_minoredit') + '(Ctrl+Shift+S)')).css({ 'margin': '5px 5px 5px -3px', 'display': 'inline' });
//DOM摰帋�厩�𤘪��
var editBody = $('<div>').append(backBtn, jumpBtn, previewBox, inputBox, summaryBox, $('<br>'), isMinorEdit, editSubmitBtn, previewSubmitBtn);
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 = $('<div>').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('<hr><div class="mw-body-content">' + data + '</div><hr>');
$('#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 = $('<div>').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�朖雿輻�𤥁�穃仃韐� 銋煺�滢�帋腺憭望㺭�旿 �𣈲銝�銝W仃�㺭�旿���虾�賣�扳糓��𧢲�穃�喃�憿菟𢒰
//蝚砌� �喲𡡒憿菟𢒰蝖株恕
$('#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 = $('<textarea>').attr('id', 'Wikiplus-Setting-Input').attr('rows', '10');
var applyBtn = $('<div>').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-Setting-Apply').text(i18n('submit'));
var cancelBtn = $('<div>').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-Setting-Cancel').text(i18n('cancel'));
var content = $('<div>').append(input).append($('<hr>')).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($('<div>').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 = $('<input>').addClass('Wikiplus-InterBox-Input');
var applyBtn = $('<div>').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-SR-Apply').text(i18n('submit'));
var cancelBtn = $('<div>').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-SR-Cancel').text(i18n('cancel'));
var continueBtn = $('<div>').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-SR-Continue').text(i18n('continue'));
var content = $('<div>').append(input).append($('<hr>')).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('<div class="Wikiplus-Banner">' + i18n('submitting_edit') + '</div>');
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($('<hr>')).append(continueBtn).append(cancelBtn);
continueBtn.click(function () {
$('.Wikiplus-InterBox-Content').html('<div class="Wikiplus-Banner">' + i18n('submitting_edit') + '</div>');
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();
});
});
});
});
}
/**
* 憸�霂餃�𣇉㮾�喃�衤辣蝏穃��
*/
}, {
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) {
// cannot decode
params[match[2]] = match[3];
}
}
if (params.action === 'edit' && params.title !== undefined && params.section !== 'new') {
$(this).after($('<a>').attr({
'href': 'javascript:void(0)',
'class': 'Wikiplus-Edit-EveryWhereBtn'
}).text('(' + i18n('quickedit_sectionbtn') + ')').data({
'target': decodeURIComponent(params.title),
'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 ? $('<div>') : 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 = window.innerWidth;
var clientHeight = window.innerHeight;
var dialogWidth = Math.min(clientWidth, width);
var diglogBox = $('<div>').addClass('Wikiplus-InterBox').css({
'margin-left': clientWidth / 2 - dialogWidth / 2,
'top': $(document).scrollTop() + clientHeight * 0.2,
'display': 'none'
}).append($('<div>').addClass('Wikiplus-InterBox-Header').html(title)).append($('<div>').addClass('Wikiplus-InterBox-Content').append(content)).append($('<span>').text('��').addClass('Wikiplus-InterBox-Close'));
$('body').append(diglogBox);
$('.Wikiplus-InterBox').width(dialogWidth);
$('.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().left;
var baseOffsetY = element.parent().offset().top;
$(document).mousemove(function (e) {
element.parent().css({
'margin-left': 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 = mw.config.get('skin') === 'minerva' ? $('<li>').attr('id', id).addClass('toggle-list-item').append($('<a>').addClass('mw-ui-icon mw-ui-icon-before toggle-list-item__anchor').append($('<span>').attr('href', 'javascript:void(0);').addClass('toggle-list-item__label').text(text))) : $('<li>').attr('id', id).append($('<a>').attr('href', 'javascript:void(0);').text(text));
if (mw.config.get('skin') === 'minerva' && $('#p-tb').length > 0) {
$('#p-tb').append(button);
$('#' + id).click(clickEvent);
} else if ($('#p-cactions').length > 0) {
$('#p-cactions ul').append(button);
$('#' + id).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 隡睃���� 憿菟𢒰���
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);
},
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 = $('<div>').text(i18n('install_tip').replace(/\$1/ig, mw.config.get('wgSiteName'))).attr('id', 'Wikiplus-InterBox-Content');
var applyBtn = $('<div>').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-Setting-Apply').text(i18n('accept'));
var cancelBtn = $('<div>').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-Setting-Cancel').text(i18n('decline'));
var content = $('<div>').append(notice).append($('<hr>')).append(applyBtn).append(cancelBtn); //�𣄽�𦻖
self.createDialogBox('摰㕑�Wikiplus', content, 600, function () {
$('#Wikiplus-InterBox-Content').css('text-align', 'left');
$('#Wikiplus-Setting-Apply').click(function () {
localStorage.Wikiplus_SendStatistics = 'True';
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() {
var self = this;
mw.hook('wikipage.content').add(function (item) {
if (item.attr('id') === 'mw-content-text') {
self.initQuickEdit(); //��㰘蝸敹恍�毺�𤥁��
!self.getSetting('disableEditEveryWhere') && self.editEveryWhere(); //隞餅�讐�𤥁��
}
});
this.editSettings(); //蝻𤥁�𤏸挽蝵�
this.simpleRedirector(); //敹恍�罸�滚�𡁜��
this.preloadEventBinding(); //憸�霂餃��
}
}, {
key: 'initRecentChangesPageFunctions',
value: function initRecentChangesPageFunctions() {}
}, {
key: 'initAdvancedFunctions',
value: function initAdvancedFunctions() {}
}]);
function Wikiplus() {
_classCallCheck(this, Wikiplus);
this.version = '2.3.6';
this.langVersion = '212';
this.releaseNote = '靽格迤銝�鈭偦䔮憸�';
this.notice = new MoeNotification();
this.inValidNameSpaces = [-1, 8964];
this.defaultSettings = {
'key': 'value',
'documatation': 'https://zh.moegirl.org.cn/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);
//頧賢�丘SS
$('head').append('<link>');
$('head').children(':last').attr({
rel: 'stylesheet',
type: 'text/css',
href: scriptPath + '/wikiplus.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 (!this.inValidNameSpaces.includes(mw.config.get('wgNamespaceNumber')) && 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();
});
});