From 48c338c5614c0595a3fb9e1342e617c0f61bd0f0 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:44:11 +0800 Subject: [PATCH 01/13] refactor(i18n.js): pull code from Qiuwen upstream --- src/Gadgets/Compatibility/i18n/i18n.js | 114 ++++++++++++++++--------- 1 file changed, 76 insertions(+), 38 deletions(-) diff --git a/src/Gadgets/Compatibility/i18n/i18n.js b/src/Gadgets/Compatibility/i18n/i18n.js index 9e1fc52..9def74a 100644 --- a/src/Gadgets/Compatibility/i18n/i18n.js +++ b/src/Gadgets/Compatibility/i18n/i18n.js @@ -18,37 +18,73 @@ */ /* */ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } -(function i18n(_ref, _document$documentEle) { +(function i18n() { + var FALLBACK_TABLE = { + zh: ['zh', 'zh-hans', 'zh-hant', 'zh-cn', 'zh-tw', 'zh-hk', 'zh-sg', 'zh-mo', 'zh-my'], + 'zh-hans': ['zh-hans', 'zh-cn', 'zh-sg', 'zh-my', 'zh', 'zh-hant', 'zh-tw', 'zh-hk', 'zh-mo'], + 'zh-hant': ['zh-hant', 'zh-tw', 'zh-hk', 'zh-mo', 'zh', 'zh-hans', 'zh-cn', 'zh-sg', 'zh-my'], + 'zh-cn': ['zh-cn', 'zh-hans', 'zh-sg', 'zh-my', 'zh', 'zh-hant', 'zh-tw', 'zh-hk', 'zh-mo'], + 'zh-sg': ['zh-sg', 'zh-hans', 'zh-cn', 'zh-my', 'zh', 'zh-hant', 'zh-tw', 'zh-hk', 'zh-mo'], + 'zh-my': ['zh-my', 'zh-hans', 'zh-cn', 'zh-sg', 'zh', 'zh-hant', 'zh-tw', 'zh-hk', 'zh-mo'], + 'zh-tw': ['zh-tw', 'zh-hant', 'zh-hk', 'zh-mo', 'zh', 'zh-hans', 'zh-cn', 'zh-sg', 'zh-my'], + 'zh-hk': ['zh-hk', 'zh-hant', 'zh-mo', 'zh-tw', 'zh', 'zh-hans', 'zh-cn', 'zh-sg', 'zh-my'], + 'zh-mo': ['zh-mo', 'zh-hant', 'zh-hk', 'zh-tw', 'zh', 'zh-hans', 'zh-cn', 'zh-sg', 'zh-my'] + }; var isValidKey = function isValidKey(object, key) { return key in object; }; - var i18nMessages = function i18nMessages(defaultFallbackList) { - var FallbackTable = { - zh: ['zh', 'zh-hans', 'zh-hant', 'zh-cn', 'zh-tw', 'zh-hk', 'zh-sg', 'zh-mo', 'zh-my', 'en'], - 'zh-hans': ['zh-hans', 'zh-cn', 'zh-sg', 'zh-my', 'zh', 'zh-hant', 'zh-tw', 'zh-hk', 'zh-mo', 'en'], - 'zh-hant': ['zh-hant', 'zh-tw', 'zh-hk', 'zh-mo', 'zh', 'zh-hans', 'zh-cn', 'zh-sg', 'zh-my', 'en'], - 'zh-cn': ['zh-cn', 'zh-hans', 'zh-sg', 'zh-my', 'zh', 'zh-hant', 'zh-tw', 'zh-hk', 'zh-mo', 'en'], - 'zh-sg': ['zh-sg', 'zh-hans', 'zh-cn', 'zh-my', 'zh', 'zh-hant', 'zh-tw', 'zh-hk', 'zh-mo', 'en'], - 'zh-my': ['zh-my', 'zh-hans', 'zh-cn', 'zh-sg', 'zh', 'zh-hant', 'zh-tw', 'zh-hk', 'zh-mo', 'en'], - 'zh-tw': ['zh-tw', 'zh-hant', 'zh-hk', 'zh-mo', 'zh', 'zh-hans', 'zh-cn', 'zh-sg', 'zh-my', 'en'], - 'zh-hk': ['zh-hk', 'zh-hant', 'zh-mo', 'zh-tw', 'zh', 'zh-hans', 'zh-cn', 'zh-sg', 'zh-my', 'en'], - 'zh-mo': ['zh-mo', 'zh-hant', 'zh-hk', 'zh-tw', 'zh', 'zh-hans', 'zh-cn', 'zh-sg', 'zh-my', 'en'] + var getDefaultFallbackList = function getDefaultFallbackList() { + var defaultLanguageCode = 'en'; + var getLanguageCodeSplitArray = function getLanguageCodeSplitArray(_languageCode) { + return _languageCode.split('-').map(function (value) { + return value.toLowerCase(); + }); }; + var documentLanguageSplitArray = getLanguageCodeSplitArray(document.documentElement.lang); + var navigatorLanguageSplitArray = getLanguageCodeSplitArray(navigator.language); + var languageCode = defaultLanguageCode; + for (var _i = 0, _arr = [documentLanguageSplitArray, navigatorLanguageSplitArray]; _i < _arr.length; _i++) { + var languageCodeSplitArray = _arr[_i]; + switch (languageCodeSplitArray.length) { + case 2: + languageCode = "".concat(languageCodeSplitArray[0], "-").concat(languageCodeSplitArray[1]); + break; + case 3: + languageCode = "".concat(languageCodeSplitArray[0], "-").concat(languageCodeSplitArray[2]); + break; + default: + languageCode = languageCodeSplitArray[0]; + break; + } + if (isValidKey(FALLBACK_TABLE, languageCode)) { + break; + } + } + return _toConsumableArray(new Set([languageCode, defaultLanguageCode])); + }; + var i18nMessages = function i18nMessages(_defaultFallbackList) { var elect = function elect(candidates, locale) { - var _FallbackTableList; - var FallbackTableList; - if (isValidKey(FallbackTable, locale)) { - FallbackTableList = FallbackTable[locale]; + var fallbackList = _defaultFallbackList; + for (var _i2 = 0, _arr2 = [locale].concat(_toConsumableArray(fallbackList)); _i2 < _arr2.length; _i2++) { + var key = _arr2[_i2]; + if (isValidKey(FALLBACK_TABLE, key)) { + fallbackList = FALLBACK_TABLE[key]; + break; + } } - var _iterator = _createForOfIteratorHelper((_FallbackTableList = FallbackTableList) !== null && _FallbackTableList !== void 0 ? _FallbackTableList : defaultFallbackList), + var _iterator = _createForOfIteratorHelper(new Set([locale].concat(_toConsumableArray(fallbackList), _toConsumableArray(_defaultFallbackList)))), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { - var key = _step.value; - if (isValidKey(candidates, key)) { - return candidates[key]; + var _key = _step.value; + if (isValidKey(candidates, _key)) { + return candidates[_key]; } } } catch (err) { @@ -72,14 +108,16 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } }; }; - var i18nMethods = i18nMessages([(_ref = (_document$documentEle = document.documentElement.lang) !== null && _document$documentEle !== void 0 ? _document$documentEle : navigator.language.split('-')[0]) !== null && _ref !== void 0 ? _ref : navigator.language.toLowerCase(), 'en']); + var defaultFallbackList = getDefaultFallbackList(); + var i18nMethods = i18nMessages(defaultFallbackList); window.i18n = i18nMethods; + /* Deprecated window.wgU*S */ var wgUXS = function wgUXS(hans, hant, cn, tw, hk, sg, zh, mo, my, en, method) { - var _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _zh, _ref10, _ref11, _ref12, _hans, _ref13, _ref14, _ref15, _hant, _cn, _sg, _tw, _hk, _mo, _my, _en; - zh = String((_ref2 = (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_ref7 = (_ref8 = (_ref9 = (_zh = zh) !== null && _zh !== void 0 ? _zh : hans) !== null && _ref9 !== void 0 ? _ref9 : hant) !== null && _ref8 !== void 0 ? _ref8 : cn) !== null && _ref7 !== void 0 ? _ref7 : tw) !== null && _ref6 !== void 0 ? _ref6 : hk) !== null && _ref5 !== void 0 ? _ref5 : sg) !== null && _ref4 !== void 0 ? _ref4 : mo) !== null && _ref3 !== void 0 ? _ref3 : my) !== null && _ref2 !== void 0 ? _ref2 : en); - hans = String((_ref10 = (_ref11 = (_ref12 = (_hans = hans) !== null && _hans !== void 0 ? _hans : cn) !== null && _ref12 !== void 0 ? _ref12 : sg) !== null && _ref11 !== void 0 ? _ref11 : my) !== null && _ref10 !== void 0 ? _ref10 : zh); - hant = String((_ref13 = (_ref14 = (_ref15 = (_hant = hant) !== null && _hant !== void 0 ? _hant : tw) !== null && _ref15 !== void 0 ? _ref15 : hk) !== null && _ref14 !== void 0 ? _ref14 : mo) !== null && _ref13 !== void 0 ? _ref13 : zh); + var _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _zh, _ref9, _ref10, _ref11, _hans, _ref12, _ref13, _ref14, _hant, _cn, _sg, _tw, _hk, _mo, _my, _en; + zh = String((_ref = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_ref7 = (_ref8 = (_zh = zh) !== null && _zh !== void 0 ? _zh : hans) !== null && _ref8 !== void 0 ? _ref8 : hant) !== null && _ref7 !== void 0 ? _ref7 : cn) !== null && _ref6 !== void 0 ? _ref6 : tw) !== null && _ref5 !== void 0 ? _ref5 : hk) !== null && _ref4 !== void 0 ? _ref4 : sg) !== null && _ref3 !== void 0 ? _ref3 : mo) !== null && _ref2 !== void 0 ? _ref2 : my) !== null && _ref !== void 0 ? _ref : en); + hans = String((_ref9 = (_ref10 = (_ref11 = (_hans = hans) !== null && _hans !== void 0 ? _hans : cn) !== null && _ref11 !== void 0 ? _ref11 : sg) !== null && _ref10 !== void 0 ? _ref10 : my) !== null && _ref9 !== void 0 ? _ref9 : zh); + hant = String((_ref12 = (_ref13 = (_ref14 = (_hant = hant) !== null && _hant !== void 0 ? _hant : tw) !== null && _ref14 !== void 0 ? _ref14 : hk) !== null && _ref13 !== void 0 ? _ref13 : mo) !== null && _ref12 !== void 0 ? _ref12 : zh); cn = String((_cn = cn) !== null && _cn !== void 0 ? _cn : hans); sg = String((_sg = sg) !== null && _sg !== void 0 ? _sg : hans); tw = String((_tw = tw) !== null && _tw !== void 0 ? _tw : hant); @@ -110,31 +148,29 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len return wgUXS(hans, hant, cn, tw, hk, sg, zh, mo, my, en, 'vary'); }; })(); - +/** 本小工具来自求闻百科,采用CC-BY-SA 4.0协议授权,原用法见下。 **/ /* 用法 // 定义多条消息 // 支持多语言,可选值定义在index.d.ts#L-1,可直接添加其他值(RFC 5646) const i18nMessages = (): i18nMessages => { const {localize} = i18n; - // i18n的三个方法会匹配当前语言(不含中文)和它所接收对象中的键,若匹配失败,则返回en键的值。若此键同样没被定义,则返回空字符串 - // 对于localize来说,假设传递给其的语言(wgUserLanguage ?? wgContentLanguage ?? HTML的lang属性 ?? 浏览器语言)最终为fr,则 - // Cancel: localize({ - // ja: 'キャンセル', - // zh: '取消', - // }), - // 的返回值为空字符串,而非Cancel + // i18n的三个方法会匹配当前语言和它所接收对象中的键,对于localize来说,假设已定义zh、en和ja,则 + // 当页面语言(wgUserLanguage ?? wgContentLanguage)为中文/英语/日语时,返回页面语言所对应的值 + // 当页面语言为法语,浏览器语言为中文/英语/日语时,返回浏览器语言所对应的值 + // 当页面语言为法语,且不存在浏览器语言所对应的键,返回L-25定义的键所对应的值。若此键同样没被定义,则返回空字符串 return { - // 若调用message(key)时,key和此处定义的目标英语文本一致,可跳过定义en的值 Cancel: localize({ + en: 'Cancel', ja: 'キャンセル', zh: '取消', }), QiuWen: localize({ + en: 'QiuWen', ja: 'ちゅううん', 'zh-cn': '求闻', 'zh-hk': '求聞', }), - longText: localize({ + LongText: localize({ en: 'This is a very long text', ja: 'これは非常に長いテキストです', 'zh-hans': '这是一段非常长的文本', @@ -143,11 +179,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }; }; const messages = i18nMessages(); - const message = (key: string): string => messages[key] || key; + const message = (key: string): string => { + return messages[key] || key; + }; // 调用 message('Cancel'); // en: Cancel, ja: キャンセル, zh: 取消, zh-hans: 取消, zh-hant: 取消, zh-cn: 取消, zh-hk: 取消, zh-tw: 取消 message('QiuWen'); // en: QiuWen, ja: ちゅううん, zh: 求闻, zh-hans: 求闻, zh-hant: 求聞, zh-cn: 求闻, zh-hk: 求聞, zh-tw: 求聞 - message('longText'); + message('LongText'); // en: This is a very long text // ja: これは非常に長いテキストです // zh: 这是一段非常长的文本 @@ -162,4 +200,4 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len wgULS('求闻', '求聞'); // en: 求闻, ja: 求闻, zh: 求闻, zh-hans: 求闻, zh-hant: 求聞, zh-cn: 求闻, zh-hk: 求聞, zh-tw: 求聞 wgULS('求闻', '求聞'); // en: 求闻, ja: 求闻, zh: 求闻, zh-hans: 求闻, zh-hant: 求聞, zh-cn: 求闻, zh-hk: 求聞, zh-tw: 求聞 */ -/* */ \ No newline at end of file +/* */ From c6f0ff875a9dbf3111a9df14521802da49c4a3ff Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:51:47 +0800 Subject: [PATCH 02/13] refactor(Ding.js): pull code from Qiuwen upstream --- src/Gadgets/Compatibility/Ding/Ding.js | 32 +++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/Gadgets/Compatibility/Ding/Ding.js b/src/Gadgets/Compatibility/Ding/Ding.js index 609e8cb..3d34f20 100644 --- a/src/Gadgets/Compatibility/Ding/Ding.js +++ b/src/Gadgets/Compatibility/Ding/Ding.js @@ -3,6 +3,7 @@ * _addText: '{{Gadget Header|license=CC-BY-SA-4.0}}' * * @base + * @base * @source */ /** @@ -12,36 +13,45 @@ * | All changes should be made in the repository, | * | otherwise they will be lost. | * +--------------------------------------------------------+ - * | Changes to this page affect many users. | - * | Please discuss changes at Talk page before editing. | + * | Changes to this page may affect many users. | + * | Please discuss changes at talk page before editing. | * +--------------------------------------------------------+ */ /* */ -'use strict'; - window.DingExposedInterface = function ding() { var dingMain = function dingMain(message) { var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'info'; var ttl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3600; var persist = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; if (!document.querySelector('#ding')) { - document.body.insertAdjacentHTML('afterbegin', ''); + var dingDiv = document.createElement('div'); + dingDiv.id = 'ding'; + dingDiv.className = 'noprint'; + document.body.insertAdjacentElement('afterbegin', dingDiv); } var dingElement = document.querySelector('#ding'); var previousMessage = dingElement.lastChild; if (previousMessage) { var previousMessageStyle = previousMessage.style; - previousMessageStyle.transform = 'translateY(-130%)'; + previousMessageStyle.transform = 'translateY(125%)'; setTimeout(function () { previousMessage.remove(); }, 500); } - dingElement.insertAdjacentHTML('beforeend', "").concat(message, "")); + var dingInnerElement = document.createElement('div'); + // The following classes are used here: + // * ding_inner + // * ding_info + // * ding_success + // * ding_warning + dingInnerElement.className = "ding_inner ding_".concat(type); + dingInnerElement.innerHTML = message; + dingElement.insertAdjacentElement('beforeend', dingInnerElement); var noticeElement = dingElement.lastChild; var noticeElementStyle = noticeElement.style; if (persist) { - noticeElement === null || noticeElement === void 0 ? void 0 : noticeElement.addEventListener('click', function () { - noticeElementStyle.transform = 'translateY(-130%)'; + noticeElement === null || noticeElement === void 0 || noticeElement.addEventListener('click', function () { + noticeElementStyle.transform = 'translateY(125%)'; setTimeout(function () { noticeElement.remove(); }, 500); @@ -52,10 +62,10 @@ window.DingExposedInterface = function ding() { }, 10); if (ttl !== 'long') { setTimeout(function () { - noticeElementStyle.transform = 'translateY(-130%)'; + noticeElementStyle.transform = 'translateY(125%)'; }, ttl + 10); setTimeout(function () { - noticeElement === null || noticeElement === void 0 ? void 0 : noticeElement.remove(); + noticeElement === null || noticeElement === void 0 || noticeElement.remove(); }, ttl + 510); } }; From df9abbb46b5eea1d3e82bba418ca43eb005c7034 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:53:05 +0800 Subject: [PATCH 03/13] refactor(Ding.css): pull code from Qiuwen Upstream --- src/Gadgets/Compatibility/Ding/Ding.css | 47 ++++++++++++++++++------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/src/Gadgets/Compatibility/Ding/Ding.css b/src/Gadgets/Compatibility/Ding/Ding.css index 2ed655b..5238e8c 100644 --- a/src/Gadgets/Compatibility/Ding/Ding.css +++ b/src/Gadgets/Compatibility/Ding/Ding.css @@ -3,6 +3,7 @@ * _addText: '{{Gadget Header|license=CC-BY-SA-4.0}}' * * @base + * @base * @source */ /** @@ -12,8 +13,8 @@ * | All changes should be made in the repository, | * | otherwise they will be lost. | * +--------------------------------------------------------+ - * | Changes to this page affect many users. | - * | Please discuss changes at Talk page before editing. | + * | Changes to this page may affect many users. | + * | Please discuss changes at talk page before editing. | * +--------------------------------------------------------+ */ /* */ @@ -29,8 +30,7 @@ } #ding button:active { - background: hsla(0deg 0% 100%/60%); - background: rgb(255 255 255 / 20%); + background: rgba(255, 255, 255, 0.2); } .ding_inner { @@ -39,19 +39,28 @@ right: 0; bottom: 0; left: 0; + width: 75%; height: auto; - padding: 0.6em 2em; - margin: 0 0 auto; - box-shadow: 0 2px 5px rgb(0 0 0 / 20%); - font-size: 86%; - font-weight: 700; - line-height: 1.4em; + min-height: 3.75%; + padding: 0.75em 1.5em; + border-radius: 1em 1em 0 0; + margin: 0 auto; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); + font-size: 92.5%; + font-weight: bold; + line-height: 1.25em; opacity: 1; text-align: center; - transform: translateY(-130%); + -webkit-transform: translateY(125%); + -moz-transform: translateY(125%); + -ms-transform: translateY(125%); + -o-transform: translateY(125%); + transform: translateY(125%); transition: all 0.2s; + word-break: break-word; } +/* Font and background colors */ .ding_default { background-color: #eaecf0; color: #000; @@ -72,7 +81,21 @@ } .ding_warning { - background-color: #d33; + background-color: #b32424; +} + +.ding_inner a, +.ding_inner a:visited, +.ding_inner a:hover { + color: #f4ff7f !important; +} + +/* Avoid overlapping the blue bar with the limited width control */ +@media all and (min-width: 1000px) { + .ding_inner { + width: 800px !important; + margin: auto !important; + } } /* */ From ed902f97633e17be126a96b9811f7ce8cafcc109 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:59:02 +0800 Subject: [PATCH 04/13] refactor(EasyArchive.js): pull code from Qiuwen upstream --- .../EditButton/EasyArchive/EasyArchive.js | 274 +++++++----------- 1 file changed, 97 insertions(+), 177 deletions(-) diff --git a/src/Gadgets/EditButton/EasyArchive/EasyArchive.js b/src/Gadgets/EditButton/EasyArchive/EasyArchive.js index 095e7ff..991343d 100644 --- a/src/Gadgets/EditButton/EasyArchive/EasyArchive.js +++ b/src/Gadgets/EditButton/EasyArchive/EasyArchive.js @@ -14,122 +14,42 @@ * | All changes should be made in the repository, | * | otherwise they will be lost. | * +--------------------------------------------------------+ - * | Changes to this page affect many users. | - * | Please discuss changes at Talk page before editing. | + * | Changes to this page may affect many users. | + * | Please discuss changes at talk page before editing. | * +--------------------------------------------------------+ */ /* */ -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } +var _objectHasOwn = function (object, property) { + if (typeof object === 'undefined' || object === null) { + throw new TypeError('Cannot convert undefined or null to object'); + } + return Object.prototype.hasOwnProperty.call(Object(object), property); +}; +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } -function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } +function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +/* eslint-disable no-template-curly-in-string, prefer-destructuring */ (function easyArchive() { - if (!('external_config' in window)) { - window.external_config = {}; - } - if (!('easy_archive' in window.external_config)) { - window.external_config.easy_archive = {}; + if (mw.config.get('wgNamespaceNumber') < 0 || mw.config.get('wgPageName') === '有兽档案馆:首页') { + return; } - window.external_config.easy_archive.never_enable_on_these_pages_regex = []; - window.external_config.easy_archive.never_enable_on_these_namespaces_int = [0]; if (!window.easy_archive) { window.easy_archive = {}; - (function (object) { - var x = 2019; - var y = 3; - var z = 2; - var more = 0; - var status = 'se'; - var build = 89; - var version_delim = '.'; - var version = x.toString(10) + version_delim + y.toString(10) + version_delim + z.toString(10) + (more ? version_delim + more.toString(10) : ''); - var iteration = status + build.toString(10); - var ver = "".concat(version, " / ").concat(iteration); - object.version = version; - object.iteration = iteration; - object.build = build; - object.ver = ver; - object.version_parsed = { - x: x, - y: y, - z: z, - more: more, - status: status, - build: build - }; - })(window.easy_archive); - (function (easy) { - // Go repo - var Go = function () { - var _Go; - try { - _Go = function () { - var _chain = function chain(_go, fn) { - var f2 = function f2(_x) { - return 0; - }; - var promise = new Promise(function (reso, reje) { - f2 = function f2(_x) { - return fn(reso, reje); - }; - }); - _go.task.then(f2); - _go.task = promise; - }; - var GoClass = /*#__PURE__*/function () { - function GoClass() { - _classCallCheck(this, GoClass); - this.task = Promise.resolve(); - this.chain.apply(this, arguments); - } - _createClass(GoClass, [{ - key: "chain", - value: function chain() { - var _len = arguments.length; - var fns = Array.from({ - length: _len - }); - for (var _key = 0; _key < _len; _key++) { - fns[_key] = _key < 0 || arguments.length <= _key ? undefined : arguments[_key]; - } - for (var _i2 = 0, _fns = fns; _i2 < _fns.length; _i2++) { - var fn = _fns[_i2]; - if (typeof fn === 'function') { - _chain(this, fn); - } else if (_typeof(fn) === 'object' && fn !== null && fn.constructor === Array) { - this.chain.apply(this, _toConsumableArray(fn)); - } else { - throw new TypeError('Cannot chain non-function and non-arrays to a Go instance.'); - } - } - return this; - } - }]); - return GoClass; - }(); - return GoClass; - }(); - } catch (_unused) { - _Go = function _Go() {}; - _Go.prototype.chain = function (f) { - f(); - }; - } - return _Go; - }(); - var go = new Go(); - if (!('mw' in window)) { - throw new Error('Easy Archive cannot function without mw object.'); - } + (function (easy, _window$easy_archive$) { // minified code dependency functions var Pare_str = function () { var _intep = function intep(celldata) { @@ -185,7 +105,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == key: "update", value: function update(lookup_key, new_value) { if (this.find(lookup_key) === null) { - this["new"](lookup_key, new_value); + this.new(lookup_key, new_value); } else { var new_str = this.str.split(this.left + lookup_key + this.delim); new_str[1] = new_str[1].split(this.right); @@ -209,14 +129,13 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == // common repo. var expose = function () { var glb = { - url: mw.config.get('wgServer'), p: mw.config.get('wgPageName'), un: mw.config.get('wgUserName'), u: "User:".concat(mw.config.get('wgUserName')), ut: "User_talk:".concat(mw.config.get('wgUserName')), t: null }; - glb.a = "".concat(glb.url).concat(mw.config.get('wgScriptPath'), "/api.php"); + glb.a = "".concat(mw.config.get('wgScriptPath'), "/api.php"); var asyncPost = function asyncPost(url, body, fn) { var z1 = 'Content-Type'; var z2 = 'application/x-www-form-urlencoded'; @@ -260,8 +179,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == if (typeof a === 'string') { var b = JSON.parse(a); if (_typeof(b) === 'object') { - // eslint-disable-next-line no-unreachable-loop for (var x in b.query.pages) { + if (!_objectHasOwn(b.query.pages, x)) { + continue; + } var c = b.query.pages[x]; return c.revisions[0]['*']; } @@ -276,7 +197,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == var tellPageExist = function tellPageExist(a) { try { a = JSON.parse(a); - } catch (_unused2) { + } catch (_unused) { return false; } if (_typeof(a) !== 'object') { @@ -360,14 +281,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == easy.settings_string = '#set%|? \n' + 'display section delete link %sec-del|1? \n' + 'display section archive line %sec-arc|1? \n' + 'display control bar at top %top-bar|0? \n' + 'archive location %arc-loc|? \n' + 'subsection effectiveness %sub-sec|2? \n' + 'confirm action %confirm|0? \n' + 'is this data initialized %data-init|0? \n'; easy.settings = new Pare_str(easy.settings_string); easy.my_user_talk = null; - try { - easy.never_enable_on_these_pages_regex = window.external_config.easy_archive.never_enable_on_these_pages_regex; - } catch (_unused3) { - easy.never_enable_on_these_pages_regex = []; - } + easy.never_enable_on_these_pages_regex = (_window$easy_archive$ = window.easy_archive.never_enable_on_these_pages_regex) !== null && _window$easy_archive$ !== void 0 ? _window$easy_archive$ : []; easy.dis_support_these_pages_regex = [/^File:.*$/, /^MediaWiki:.*$/, /^Module:.*$/, /^Category:.*$/, /^Template:.*$/, /^Special:.*$/, /^User:.*\/?.*\.js$/, /^User:.*\/?.*\.css$/, /^User:.*\/?.*\.json$/]; var settings_span_collection = document.querySelectorAll('.easy_archive_data_point_collection'); - var settings_span = settings_span_collection[0]; + var _settings_span_collec = _slicedToArray(settings_span_collection, 1), + settings_span = _settings_span_collec[0]; var settings = settings_span ? new Pare_str(settings_span.innerHTML) : new Pare_str(''); if (settings.find('data-init') === '1') { easy.settings_string = settings_span.innerHTML; @@ -445,8 +363,8 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == for (var i = 0; i < this.languages.length; i++) { all_codes = [].concat(_toConsumableArray(all_codes), _toConsumableArray(this.languages[i])); } - for (var _i3 = 0; _i3 < this.sub_groups.length; _i3++) { - all_codes = [].concat(_toConsumableArray(all_codes), _toConsumableArray(this.sub_groups[_i3].all())); + for (var _i2 = 0; _i2 < this.sub_groups.length; _i2++) { + all_codes = [].concat(_toConsumableArray(all_codes), _toConsumableArray(this.sub_groups[_i2].all())); } return all_codes; } @@ -467,11 +385,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == }, { key: "add", value: function add() { - for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - for (var _i4 = 0, _args = args; _i4 < _args.length; _i4++) { - var arg = _args[_i4]; + for (var _i3 = 0, _args = args; _i3 < _args.length; _i3++) { + var arg = _args[_i3]; this.add_one(arg); } return this; @@ -521,7 +439,8 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == var group_asian = new Language_proximity_group('asian').add(group_cjk); var group_world = new Language_proximity_group('world').add(group_asian, group_european); var accepted_languages = function accepted_languages(_raw_lang_code) { - var all_acceptable_codes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + var _ref; + var all_acceptable_codes = (_ref = arguments.length <= 2 ? undefined : arguments[2]) !== null && _ref !== void 0 ? _ref : null; var processed_lang_code = String(_raw_lang_code).toLowerCase().replace(/[^a-z]/g, '').slice(0, 4); var processed_lang_code_short = processed_lang_code.slice(0, 2); var best_match = accepted_languages_dict[_raw_lang_code] || accepted_languages_dict[processed_lang_code] || accepted_languages_dict[processed_lang_code_short] || null; @@ -572,7 +491,9 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == var page_name = mw.config.get('wgPageName').split(':'); page_name[0] = ''; page_name = page_name.join(''); - page_name = page_name.split('/')[0]; + var _page_name$split = page_name.split('/'); + var _page_name$split2 = _slicedToArray(_page_name$split, 1); + page_name = _page_name$split2[0]; var user_name = mw.config.get('wgUserName'); return user_name.split('_').join('').split(' ').join('') === page_name.split('_').join('').split(' ').join(''); }(); @@ -585,7 +506,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == if (!easy.lang) { easy.lang = {}; } - easy.lang["delete"] = { + easy.lang.delete = { en_us: 'delete', zh_cn: '删除', zh_hk: '刪除', @@ -600,38 +521,38 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == easy.lang.supports = { en_us: 'Easy Archive is enabled on this talk page', zh_cn: '本讨论页面使用 Easy Archive 快速存档', - zh_hk: '本頁使用 Easy Archive', - zh_tw: '本頁使用 Easy Archive' + zh_hk: '此頁面使用 Easy Archive', + zh_tw: '此頁面使用 Easy Archive' }; easy.lang.others_page = { en_us: 'Easy Archive is not enabled.', - zh_cn: '本页面是他人的用户讨论页面,因此不支持 Easy Archive 快速存档。', - zh_hk: '本頁為他人用戶討論頁面,故不支援 Easy Archive 快速存檔。', - zh_tw: '本頁為他人用戶討論頁面,故不支援 Easy Archive 快速存檔。' + zh_cn: '此页面是他人的用户讨论页面,因此不支持 Easy Archive 快速存档。', + zh_hk: '此頁面為他人用戶討論頁面,故不支援 Easy Archive 快速存檔。', + zh_tw: '此頁面為他人用戶討論頁面,故不支援 Easy Archive 快速存檔。' }; easy.lang.to_enable = { en_us: 'This page is not using Easy Archive.', - zh_cn: '本页面没有启用 Easy Archive。', + zh_cn: '此页面没有启用 Easy Archive。', zh_hk: '本頁没有啟用 Easy Archive。', zh_tw: '本頁没有啟用 Easy Archive。' }; easy.lang.enable_on_generic_page = { - en_us: 'This page is not your user talk page. However Easy Archive still can be used if needed.To enable it, add {{Easy Archive|to=[Archive location]}} to this page.', - zh_cn: '本页面不是您的用户讨论页面。不过,如果需要,本页面是可以使用 Easy Archive 的。如果要在本页面使用 Easy Archive,请加入 {{Easy Archive|to=存档位置}}。', - zh_hk: '本頁面不是您的用戶討論頁面。不過,如果需要,本頁面是可以使用 Easy Archive 的。如果要在本頁面使用 Easy Archive,請加入 {{Easy Archive|to=存檔位置}}。', - zh_tw: '本頁面不是您的用戶討論頁面。不過,如果需要,本頁面是可以使用 Easy Archive 的。如果要在本頁面使用 Easy Archive,請加入 {{Easy Archive|to=存檔位置}}。' + en_us: 'This page is not your user talk page. However Easy Archive still can be used if needed.To enable it, add {{Easy Archive|to=[Archive location]}} template to this page.', + zh_cn: '此页面不是您的用户讨论页面。不过,若需要,此页面可以启用 Easy Archive。若要在此页面使用 Easy Archive,请在页面上添加模板 {{Easy Archive|to=存档位置}}。', + zh_hk: '此頁面不是您的用戶討論頁面。不過,若需要,此頁面可以啟用 Easy Archive。若要在此頁面使用 Easy Archive,請在頁面上添加模板 {{Easy Archive|to=存檔位置}}。', + zh_tw: '此頁面不是您的用戶討論頁面。不過,若需要,此頁面可以啟用 Easy Archive。若要在此頁面使用 Easy Archive,請在頁面上添加模板 {{Easy Archive|to=存檔位置}}。' }; easy.lang.please_enable = { en_us: 'Add {{Easy Archive|to=[Archive location]}} to this page to start using Easy Archive.', - zh_cn: '请在本页面加入 {{Easy Archive|to=存档地址}} 来启用 Easy Archive。', - zh_hk: '請在本頁加入 {{Easy Archive|to=存檔位置}} 來啟用 Easy Archive。', - zh_tw: '請在本頁加入 {{Easy Archive|to=存檔位置}} 來啟用 Easy Archive。' + zh_cn: '请在此页面加入 {{Easy Archive|to=存档地址}} 来启用 Easy Archive。', + zh_hk: '請在此頁面加入 {{Easy Archive|to=存檔位置}} 來啟用 Easy Archive。', + zh_tw: '請在此頁面加入 {{Easy Archive|to=存檔位置}} 來啟用 Easy Archive。' }; easy.lang.please_enable_elaborate = { en_us: "You have the Easy Archive functionality enabled but your talk page hasn't been configured yet. To take advantage of Easy Archive, add {{Easy Archive|to=[Archive location]}} template to this page.", - zh_cn: '您的帐户已经支持 Easy Archive,但是,为了开始使用该功能,您还需要在自己的用户讨论页面上添加模板 {{Easy Archive|to=存档位置}}。', - zh_hk: '您的帳戶已經支持 Easy Archive,但是,為了開始使用該功能,您還需要在自己的用戶討論頁面上添加模板 {{Easy Archive|to=存檔位置}}。', - zh_tw: '您的帳戶已經支持 Easy Archive,但是,為了開始使用該功能,您還需要在自己的用戶討論頁面上添加模板 {{Easy Archive|to=存檔位置}}。' + zh_cn: '您的账号已经支持 Easy Archive,但是,为了开始使用该功能,您还需要在自己的用户讨论页面上添加模板 {{Easy Archive|to=存档位置}}。', + zh_hk: '您的賬號已經支持 Easy Archive,但是,為了開始使用該功能,您還需要在自己的用戶討論頁面上添加模板 {{Easy Archive|to=存檔位置}}。', + zh_tw: '您的賬號已經支持 Easy Archive,但是,為了開始使用該功能,您還需要在自己的用戶討論頁面上添加模板 {{Easy Archive|to=存檔位置}}。' }; easy.lang.arc_all = { en_us: 'Archive all topics', @@ -709,7 +630,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == }; easy.lang.stop_manually = { en_us: 'Cannot turn off Easy Archive automatically. To manually discontinue use, delete the template {{Easy Archive|to=[Archive location]}} from this page.', - zh_cn: '经过尝试,无法自动停用 Easy Archive。请手动停用。请从本页面删除如下模版:{{Easy Archive|to=存档位置}}。', + zh_cn: '经过尝试,无法自动停用 Easy Archive。请手动停用。请从此页面删除如下模版:{{Easy Archive|to=存档位置}}。', zh_hk: '經過嘗試,恕無法自動停用 Easy Archive。請手動停用。請從本頁刪除以下模板︰{{Easy Archive|to=存檔位置}}。', zh_tw: '經過嘗試,恕無法自動停用 Easy Archive。請手動停用。請從本頁刪除以下模板︰{{Easy Archive|to=存檔位置}}。' }; @@ -721,7 +642,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == }; easy.lang.change_manually = { en_us: 'Cannot update Easy Archive location automatically. To update manually, find the template {{Easy Archive|to=[Archive location]}} and update the location.', - zh_cn: '无法自动更改 Easy Archive 存档地址。请手动更改。请在本页面找到如下模版:{{Easy Archive|to=存档位置}},并更改存档位置。', + zh_cn: '无法自动更改 Easy Archive 存档地址。请手动更改。请在此页面找到如下模版:{{Easy Archive|to=存档位置}},并更改存档位置。', zh_hk: '恕無法自動更改 Easy Archive 存檔地址。請手動更改。請在本頁找到以下模板︰{{Easy Archive|to=存檔位置}},并更改存檔位置。', zh_tw: '恕無法自動更改 Easy Archive 存檔地址。請手動更改。請在本頁找到以下模板︰{{Easy Archive|to=存檔位置}},并更改存檔位置。' }; @@ -793,9 +714,9 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == }; easy.lang.page_not_supported = { en_us: 'This page is not supported by Easy Archive.', - zh_cn: '本页面不支持 Easy Archive。', - zh_hk: '本頁面不支持 Easy Archive。', - zh_tw: '本頁面不支持 Easy Archive。' + zh_cn: '此页面不支持 Easy Archive。', + zh_hk: '此頁面不支持 Easy Archive。', + zh_tw: '此頁面不支持 Easy Archive。' }; easy.lang.page_not_supported_elaborate = { en_us: 'These pages are not supported by Easy Archive: File, Template, Module, MediaWiki, Category, Special, JavaScript, CSS, JSON.', @@ -823,15 +744,15 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == }; easy.lang.problem_with_archive_location_main_space = { en_us: 'Currently the archive location of this page, "${1}", is under the article namespace, where archives should not be normally directed to. Please check if you have the correct archive location.', - zh_cn: '本页面目前的存档地址是“${1}”,在条目名称空间之下。一般而言不应向条目名称空间进行存档,请检查存档地址。', - zh_hk: '本頁面當前的存檔地址是「${1}」,在條目名稱空間之下。一般而言不應向條目名稱空間進行存檔,請檢查存檔地址。', - zh_tw: '本頁面當前的存檔地址是「${1}」,在條目名稱空間之下。一般而言不應向條目名稱空間進行存檔,請檢查存檔地址。' + zh_cn: '此页面目前的存档地址是“${1}”,在条目名称空间之下。一般而言不应向条目名称空间进行存档,请检查存档地址。', + zh_hk: '此頁面當前的存檔地址是「${1}」,在條目名稱空間之下。一般而言不應向條目名稱空間進行存檔,請檢查存檔地址。', + zh_tw: '此頁面當前的存檔地址是「${1}」,在條目名稱空間之下。一般而言不應向條目名稱空間進行存檔,請檢查存檔地址。' }; easy.lang.problem_with_archive_location_same_page = { en_us: 'Currently the archive location of this page, "${1}", is this page itself, Easy archive cannot operate like this. ', - zh_cn: '本页面目前的存档地址是“${1}”,和本页面名称相同。Easy Archive 无法按此地址存档。', - zh_hk: '本頁面當前的存檔地址是「${1}」,和本頁面名稱相同。Easy Archive 無法按此地址存檔。', - zh_tw: '本頁面當前的存檔地址是「${1}」,和本頁面名稱相同。Easy Archive 無法按此地址存檔。' + zh_cn: '此页面目前的存档地址是“${1}”,和此页面名称相同。Easy Archive 无法按此地址存档。', + zh_hk: '此頁面當前的存檔地址是「${1}」,和此頁面名稱相同。Easy Archive 無法按此地址存檔。', + zh_tw: '此頁面當前的存檔地址是「${1}」,和此頁面名稱相同。Easy Archive 無法按此地址存檔。' }; easy.lang.archive_summary = { en_us: 'archive section', @@ -847,7 +768,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == }; easy.lang.turn_off_summary = { en_us: 'Disable Easy Archive on this page.', - zh_cn: '在本页面停用 Easy Archive。', + zh_cn: '在此页面停用 Easy Archive。', zh_hk: '在本頁停用 Easy Archive。', zh_tw: '在本頁停用 Easy Archive。' }; @@ -872,8 +793,8 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == } return object; }; - var arc_sum = looker_upper(window, ['external_config.easy_archive.user_custom_archive_summary']); - var del_sum = looker_upper(window, ['external_config.easy_archive.user_custom_delete_summary']); + var arc_sum = looker_upper(window, ['easy_archive.user_custom_archive_summary']); + var del_sum = looker_upper(window, ['easy_archive.user_custom_delete_summary']); var sanitize_html = function sanitize_html(string) { return string.replace(/&/g, '&').replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); }; @@ -899,7 +820,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == } } return lang_content; - } catch (_unused4) { + } catch (_unused2) { return '(!) undefined language content'; } }; @@ -958,35 +879,32 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == _ding(ml(tag_ding, [section_number.toString(), to]), ding_type, ding_ttl, false, false); }, section_link: function section_link() { - var node = document.querySelectorAll(".easy-archive-section-id-span-order-".concat(section_number))[0]; + var node = document.querySelector(".easy-archive-section-id-span-order-".concat(section_number)); var pnode = node.parentNode; for (var _i = 1; _i < pnode.childNodes.length - 2; _i++) { pnode.childNodes[_i].style.display = 'none'; } node.innerHTML = ml(tag_section); node.style.display = 'inline'; - node.style.color = 'rgba(0,0,0,0.5)'; + node.style.color = 'rgb(0 0 0/.5)'; } }; return actions; }; - var delete_section_core = function delete_section_core(section_number, _nominal, callback) { + var delete_section_core = function delete_section_core(section_number, _nominal) { var actual_section_number = actual_section(section_number); report_doneness_ui(_nominal, 'delete', '', 'ongoing').ding(); expose.d(mw.config.get('wgPageName'), actual_section_number, function () { report_doneness_ui(_nominal, 'delete', '', 'done').ding(); report_doneness_ui(_nominal, 'delete', '', 'done').section_link(); nominal_sections[section_number] = true; - typeof callback === 'function' ? callback() : undefined; }, del_sum || ml('delete_summary')); }; easy.delete_section = function (section_number, _nominal) { report_doneness_ui(_nominal, 'delete', '', 'ongoing').section_link(); - go.chain(function (reso) { - delete_section_core(section_number, _nominal, reso); - }); + delete_section_core(section_number, _nominal); }; - var archive_section_core = function archive_section_core(section_number, _nominal, callback) { + var archive_section_core = function archive_section_core(section_number, _nominal) { var actual_section_number = actual_section(section_number); var to = easy.settings.find('arc-loc'); report_doneness_ui(_nominal, 'archive', to, 'ongoing').ding(); @@ -994,15 +912,12 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == report_doneness_ui(_nominal, 'archive', to, 'done').ding(); report_doneness_ui(_nominal, 'archive', to, 'done').section_link(); nominal_sections[section_number] = true; - typeof callback === 'function' ? callback() : undefined; }, arc_sum || ml('archive_summary')); }; easy.archive_section = function (section_number, _nominal) { var to = easy.settings.find('arc-loc'); report_doneness_ui(_nominal, 'archive', to, 'ongoing').section_link(); - go.chain(function (reso) { - archive_section_core(section_number, _nominal, reso); - }); + archive_section_core(section_number, _nominal); }; easy.archive_sections = function (starting_section_number, count) { if (starting_section_number < 1) { @@ -1075,14 +990,6 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == easy.ding(ml(ntag, nsubst), ntype, nttl, nhist, npersist); } }; - // ding and its prerequisites. - if (!document.querySelector('#ding')) { - document.querySelectorAll('body')[0].insertAdjacentHTML('afterbegin', ''); - document.querySelectorAll('body')[0].insertAdjacentHTML('afterbegin', ''); - } - if (!document.querySelector('#ding_history')) { - document.querySelectorAll('body')[0].insertAdjacentHTML('afterbegin', ''); - } // real deal here // interface injection - prepare var i = 0; @@ -1095,7 +1002,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == var section_archive_interface_inhibit = easy.settings.find('sec-arc') === '0' || easy.settings.find('data-init') === '0'; var section_delete_interface_html; var section_archive_interface_html; - var section_id_span_html = 'section'; + var section_id_span_html = 'section'; var footer_info_ele; var position_of_insertion; if (document.querySelector('#footer-info') || document.querySelectorAll('.page-info')) { @@ -1110,8 +1017,8 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == // ... interface injection - logic if (easy.on_article || easy.on_hist_version) { // insert no interface on an article page or a history version. - } else if (function (black_list) { - var _iterator3 = _createForOfIteratorHelper(black_list), + } else if (function (blacklist) { + var _iterator3 = _createForOfIteratorHelper(blacklist), _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { @@ -1128,8 +1035,8 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == return false; }(easy.never_enable_on_these_pages_regex)) { // insert no interface if the page name is blacklisted. - } else if (function (black_list) { - var _iterator4 = _createForOfIteratorHelper(black_list), + } else if (function (blacklist) { + var _iterator4 = _createForOfIteratorHelper(blacklist), _step4; try { for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { @@ -1146,7 +1053,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == return false; }(easy.dis_support_these_pages_regex)) { // insert not supported notice if the page name indicates that it is not supported. - footer_info_ele.insertAdjacentHTML(position_of_insertion, "".concat(ml('page_not_supported'), "")); + footer_info_ele.insertAdjacentHTML(position_of_insertion, "".concat(ml('page_not_supported'), "")); } else if (mw.config.get('wgPageName') === easy.settings.find('arc-loc')) { easy.elaborate_notice(9220); } else if (easy.has_template && !easy.others_user_talk) { @@ -1162,7 +1069,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == var ve = /[&?]veaction=edit/.test(ele.childNodes[1].href); var child_node_number = ve ? 3 : 1; if (ele.parentNode.tagName.toLowerCase() === 'h2' && ele.parentNode.id !== 'firstHeading' && decodeURIComponent(ele.childNodes[child_node_number].href.split(/[&?]title=/)[1].split('&')[0]) === mw.config.get('wgPageName')) { - actual = Number.parseInt(ele.childNodes[child_node_number].href.split(/[&?]section=/)[1].split('&')[0]); + actual = Number.parseInt(ele.childNodes[child_node_number].href.split(/[&?]section=/)[1].split('&')[0], 10); nominal = i - j + 1; section_delete_interface_html = section_delete_interface_inhibit ? '' : "".concat(pipe_html, "").concat(ml('delete'), ""); section_archive_interface_html = section_archive_interface_inhibit ? '' : "".concat(pipe_html, "").concat(ml('archive'), ""); @@ -1186,6 +1093,19 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == // my user talk -- installed easy archive but lacking template. footer_info_ele.insertAdjacentHTML(position_of_insertion, "".concat(ml('please_enable'), "")); } + if (mw.config.get('skin') === 'citizen') { + $('#easy_archive_enable_notice').replaceWith(function () { + var $this = $(this); + return $('').addClass('page-info__item').attr('id', $this.attr('id')).html($this.html()); + }); + mw.util.addCSS('.easy-archive-section-id-span{font-size:.875rem}'); + } + if (['vector', 'vector-2022'].indexOf(mw.config.get('skin')) !== -1) { + $('#easy_archive_enable_notice').replaceWith(function () { + var $this = $(this); + return $('').attr('id', $this.attr('id')).html($this.html()); + }); + } })(); })(window.easy_archive); } From 5d846c31ed42d9318603476ceebc2f595165b0a0 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:02:07 +0800 Subject: [PATCH 05/13] refactor(Hotcatcheck.js): pull code from Qiuwen Upstream --- src/Gadgets/EditButton/HotCat/Hotcatcheck.js | 453 ++++++++++--------- 1 file changed, 227 insertions(+), 226 deletions(-) diff --git a/src/Gadgets/EditButton/HotCat/Hotcatcheck.js b/src/Gadgets/EditButton/HotCat/Hotcatcheck.js index a8be380..992f302 100644 --- a/src/Gadgets/EditButton/HotCat/Hotcatcheck.js +++ b/src/Gadgets/EditButton/HotCat/Hotcatcheck.js @@ -1,3 +1,11 @@ +/** + * SPDX-License-Identifier: CC-BY-SA-4.0 + * _addText: '{{Gadget Header|license=CC-BY-SA-4.0}}' + * + * @base + * @source + * @dependency jquery.ui, mediawiki.storage, mediawiki.util, mediawiki.user + */ /** * +--------------------------------------------------------+ * | === WARNING: GLOBAL GADGET FILE === | @@ -5,19 +13,11 @@ * | All changes should be made in the repository, | * | otherwise they will be lost. | * +--------------------------------------------------------+ - * | Changes to this page affect many users. | - * | Please discuss changes at Talk page before editing. | + * | Changes to this page may affect many users. | + * | Please discuss changes at talk page before editing. | * +--------------------------------------------------------+ */ /* */ -/** - * SPDX-License-Identifier: CC-BY-SA-4.0 - * _addText: '{{Gadget Header|license=CC-BY-SA-4.0}}' - * - * @base - * @source - * @dependency jquery.ui, mediawiki.storage, mediawiki.util, mediawiki.user - */ /** * CheckCategories HotCat Extension – * removes the template when categorizing (prompts before) with HotCat and @@ -26,219 +26,220 @@ * @rev 2 (2014-03-20) * @author Rillke, 2012 */ -(function hotCatCheck($, mw) { - if (mw.config.get('wgNamespaceNumber') !== 6 || window.HotCatAutoRemoveCheckCatOptOut || !$('.checkcategories')[0]) { - return; - } - var chCatRE = /{{[Cc]heck[ _]categories[^{}]*}}/g; - var selfName = '([[MediaWiki:Gadget-Hotcatcheck.js|Script]]): '; - var storageItemName = 'checkCat'; - var storageItem = mw.storage.get(storageItemName); - /** - * A few styling helper functions - * - * @return {undefined} - */ - var createjIcon = function createjIcon(iconClass) { - return $('').attr('class', "ui-icon ".concat(iconClass, " catcheck-inline-icon")).text(' '); - }; - var createNotifyArea = function createNotifyArea(textNode, icon, state) { - return $('').addClass('ui-widget').append($('').attr('class', "".concat(state, " ui-corner-all")).css({ - 'margin-top': '20px', - padding: '0.7em' - }).append($('').append(createjIcon(icon).css('marginRight', '0.3em'), textNode))); - }; - mw.util.addCSS('.catcheck-inline-icon{display:inline-block;position:relative;top:2px}'); - // Remove "check categories" when using HotCat - // Only executed on first submit - $('body').one('submit.checkCatListener', '#hotcatCommitForm', function (e) { - if (storageItem === 'disabled') { - return true; - } - var self = this; - var newVal = self.wpTextbox1.value.replace(chCatRE, ''); - var dlgButtons = {}; - var $dlgCheckStorage; - var $permaSaveHint; - var $textHintNode; - var $dlg; - var doRemove = function doRemove() { - self.wpSummary.value = "Removing [[Template:Check categories|{".concat("{Check categories}}]] ".concat(self.wpSummary.value)); - self.wpTextbox1.value = newVal; - }; - var writeStorage = function writeStorage(val) { - mw.storage.set(storageItemName, val, 6048e2); // 7 days - }; - - dlgButtons['Yes, Remove'] = function () { - doRemove(); - if ($dlgCheckStorage[0].checked) { - writeStorage('auto'); - } - $(this).dialog('close'); - }; - dlgButtons['No, keep it'] = function () { - if ($dlgCheckStorage[0].checked) { - writeStorage('disabled'); - } - $(this).dialog('close'); - }; - var _addToJS = function _addToJS(_e) { - _e.preventDefault(); - if ($permaSaveHint.hasClass('ui-state-disabled')) { - return; - } - var $el = $(this); - $el.off('click').text('Please wait.'); - $permaSaveHint.addClass('ui-state-disabled'); - var params = { - action: 'edit', - title: "User:".concat(mw.config.get('wgUserName'), "/common.js"), - summary: "".concat(selfName, "Saving HotCat configuration."), - appendtext: $el.data('addText'), - token: window['wikilove-edittoken'] || mw.user.tokens.get('csrfToken'), - format: 'json' - }; - var editDone = function editDone(editStat) { - if (!editStat) { - return; - } - if (editStat.error) { - mw.notify("Unable to save to your common.js using the API\n".concat(editStat.error.code, "\n").concat(editStat.error.info), { - type: 'error' - }); - $el.text('Edit-Error!'); - } else { - $el.text('Done.'); - $permaSaveHint.fadeOut(); - } - }; - $.post(mw.util.wikiScript('api'), params, editDone); - }; - /** - * On Wikimedia Commons there were people who said: - * "Categorizing with HotCat does legit automated removal of the check-cat-message" - * So we invented a dialog that should be readable by users even with very few English skills. - */ - var prompt = function prompt() { - $dlgCheckStorage = $('').attr({ - type: 'checkbox', - id: 'hotCatAutoRemoveCheckCatStorage' - }).on('change', function () { - if (this.checked) { - $permaSaveHint.fadeIn(); - } else { - $permaSaveHint.fadeOut(); - } - }); - $textHintNode = $(''); - $('').append($('').attr('href', '#').text('Disable this feature.').data('addText', '\nwindow.HotCatAutoRemoveCheckCatOptOut = true;').on('click', _addToJS)).appendTo($textHintNode); - $('').append($('').attr('href', '#').text('Remove {{check categories}} when editing using HotCat without prompting.').data('addText', '\nwindow.HotCatAutoRemoveCheckCat = true;').on('click', _addToJS)).appendTo($textHintNode); - $permaSaveHint = createNotifyArea($('').text('Save these setting in your common.js: ').append($textHintNode), 'ui-icon-info', 'ui-state-highlight'); - $dlg = $('').append($('').css({ - 'font-size': '2em', - 'line-height': '1.8em' - }).append($('').text(' {{check categories}} ').css({ - 'background-color': '#F8CCB0', - 'text-decoration': 'line-through !important', - display: 'inline-block' - }), $('').text(' ?'))).append('', $dlgCheckStorage, $('').attr('for', 'hotCatAutoRemoveCheckCatStorage').text("Don't ask again"), '').append(mw.user.isAnon() ? '' : $permaSaveHint.hide()); - $dlg.dialog({ - modal: true, - closeOnEscape: true, - title: '{{check categories}} (−)?', - width: 450, - buttons: dlgButtons, - close: function close() { - $('#hotcatCommitForm').trigger('submit'); - }, - open: function open() { - var $buttons = $(this).parent().find('.ui-dialog-buttonpane button'); - $buttons.eq(0).button({ - icons: { - primary: 'ui-icon-circle-check' - } - }); - $buttons.eq(1).button({ - icons: { - primary: 'ui-icon-cancel' - } - }); - } - }); - }; - if (newVal !== self.wpTextbox1.value) { - if (window.HotCatAutoRemoveCheckCat || storageItem === 'auto') { - doRemove(); - return true; - } - e.preventDefault(); - prompt(); - } - return true; - }); - // Add OK-Link to the cats panel - var $okLink = $('').attr({ - href: '#', - title: 'Categories are OK! Immediately remove the template.' - }).append('').text('{{Check categories}}'); - $okLink.on('click', function (e) { - e.preventDefault(); - var $el = $(this); - $el.off('click'); - var doEdit = function doEdit(result) { - if (!result) { - return; - } - $el.text('Doing.'); - var text = result.replace(chCatRE, ''); - if (text === result) { - $el.text('Template not found!'); - return; - } - var params = { - action: 'edit', - title: mw.config.get('wgPageName'), - nocreate: 1, - summary: "".concat(selfName, "Categories are checked and OK. You can help [[Category:Media needing category review|reviewing]]!"), - text: text, - token: window['wikilove-edittoken'] || mw.user.tokens.get('csrfToken'), - format: 'json' - }; - var editDone = function editDone(editStat) { - if (!editStat) { - return; - } - if (editStat.error) { - mw.notify("Unable to remove \"Check categories\" with the API\n".concat(editStat.error.code, "\n").concat(editStat.error.info)); - $el.text('Edit-Error!'); - } else { - $el.text('Edit Done.'); - } - $('.checkcategories').fadeOut(); - }; - $el.text('Doing..'); - $.post(mw.util.wikiScript('api'), params, editDone); - }; - $el.text('Doing'); - $.ajax({ - url: mw.config.get('wgScript'), - data: { - action: 'raw', - title: mw.config.get('wgPageName').replace(/ /g, '_') - }, - dataType: 'text', - error: function error() { - $el.text('Error!'); - }, - success: doEdit, - type: 'GET', - cache: false - }); - }); - $(function () { - $('#catlinks').find('ul:first').append($('').append($okLink)); - }); - })($, mw); - /* */ - \ No newline at end of file +(function hotCatCheck() { + if (mw.config.get('wgNamespaceNumber') !== 6 || window.HotCatAutoRemoveCheckCatOptOut || !$('.checkcategories')[0]) { + return; + } + var checkCategoriesRegExp = /{{[Cc]heck[ _]categories[^{}]*}}/g; + var selfName = '([[MediaWiki:Gadget-HotCat-check.js|Script]]): '; + var storageItemName = 'checkCat'; + var storageItem = mw.storage.get(storageItemName); + /** + * A few styling helper functions + * + * @return {undefined} + */ + var createjIcon = function createjIcon(iconClass) { + return $('').attr('class', "ui-icon ".concat(iconClass, " catcheck-inline-icon")).text(' '); + }; + var createNotifyArea = function createNotifyArea(textNode, icon, state) { + return $('').addClass('ui-widget').append($('').attr('class', "".concat(state, " ui-corner-all")).css({ + 'margin-top': '20px', + padding: '0.7em' + }).append($('').append(createjIcon(icon).css('marginRight', '0.3em'), textNode))); + }; + mw.util.addCSS('.catcheck-inline-icon{display:inline-block;position:relative;top:2px}'); + // Remove "check categories" when using HotCat + // Only executed on first submit + $('body').one('submit.checkCatListener', '#hotcatCommitForm', function (e) { + if (storageItem === 'disabled') { + return true; + } + var self = this; + var newVal = self.wpTextbox1.value.replace(checkCategoriesRegExp, ''); + var dlgButtons = {}; + var $dialogCheckStorage; + var $permaSaveHint; + var $textHintNode; + var $dialog; + var doRemove = function doRemove() { + self.wpSummary.value = "Removing [[Template:Check categories|{".concat("{Check categories}}]] ".concat(self.wpSummary.value)); + self.wpTextbox1.value = newVal; + }; + var writeStorage = function writeStorage(val) { + mw.storage.set(storageItemName, val, 6048e2); // 7 days + }; + + dlgButtons['Yes, Remove'] = function () { + doRemove(); + if ($dialogCheckStorage[0].checked) { + writeStorage('auto'); + } + $(this).dialog('close'); + }; + dlgButtons['No, keep it'] = function () { + if ($dialogCheckStorage[0].checked) { + writeStorage('disabled'); + } + $(this).dialog('close'); + }; + var _addToJS = function _addToJS(_e) { + _e.preventDefault(); + if ($permaSaveHint.hasClass('ui-state-disabled')) { + return; + } + var $el = $(this); + $el.off('click').text('Please wait.'); + $permaSaveHint.addClass('ui-state-disabled'); + var params = { + action: 'edit', + title: "User:".concat(mw.config.get('wgUserName'), "/common.js"), + summary: "".concat(selfName, "Saving HotCat configuration."), + appendtext: $el.data('addText'), + token: mw.user.tokens.get('csrfToken') + }; + var editDone = function editDone(editStat) { + if (!editStat) { + return; + } + if (editStat.error) { + mw.notify("Unable to save to your common.js using the API\n".concat(editStat.error.code, "\n").concat(editStat.error.info), { + tag: 'hotCatCheck', + type: 'error' + }); + $el.text('Edit-Error!'); + } else { + $el.text('Done.'); + $permaSaveHint.fadeOut(); + } + }; + $.post(mw.util.wikiScript('api'), params, editDone); + }; + /** + * On Wikimedia Commons there were people who said: + * "Categorizing with HotCat does legit automated removal of the check-cat-message" + * So we invented a dialog that should be readable by users even with very few English skills. + */ + var prompt = function prompt() { + $dialogCheckStorage = $('').attr({ + type: 'checkbox', + id: 'hotCatAutoRemoveCheckCatStorage' + }).on('change', function () { + if (this.checked) { + $permaSaveHint.fadeIn(); + } else { + $permaSaveHint.fadeOut(); + } + }); + $textHintNode = $(''); + $('').append($('').attr('href', '#').text('Disable this feature.').data('addText', '\nwindow.HotCatAutoRemoveCheckCatOptOut = true;').on('click', _addToJS)).appendTo($textHintNode); + $('').append($('').attr('href', '#').text('Remove {{check categories}} when editing using HotCat without prompting.').data('addText', '\nwindow.HotCatAutoRemoveCheckCat = true;').on('click', _addToJS)).appendTo($textHintNode); + $permaSaveHint = createNotifyArea($('').text('Save these setting in your common.js: ').append($textHintNode), 'ui-icon-info', 'ui-state-highlight'); + $dialog = $('').append($('').css({ + 'font-size': '2em', + 'line-height': '1.8em' + }).append($('').text(' {{check categories}} ').css({ + 'background-color': '#F8CCB0', + 'text-decoration': 'line-through !important', + display: 'inline-block' + }), $('').text(' ?'))).append('', $dialogCheckStorage, $('').attr('for', 'hotCatAutoRemoveCheckCatStorage').text("Don't ask again"), '').append(mw.user.isAnon() ? '' : $permaSaveHint.hide()); + $dialog.dialog({ + modal: true, + closeOnEscape: true, + title: '{{check categories}} (−)?', + width: 450, + buttons: dlgButtons, + close: function close() { + $('#hotcatCommitForm').trigger('submit'); + }, + open: function open() { + var $buttons = $(this).parent().find('.ui-dialog-buttonpane button'); + $buttons.eq(0).button({ + icons: { + primary: 'ui-icon-circle-check' + } + }); + $buttons.eq(1).button({ + icons: { + primary: 'ui-icon-cancel' + } + }); + } + }); + }; + if (newVal !== self.wpTextbox1.value) { + if (window.HotCatAutoRemoveCheckCat || storageItem === 'auto') { + doRemove(); + return true; + } + e.preventDefault(); + prompt(); + } + return true; + }); + // Add OK-Link to the cats panel + var $okLink = $('').attr({ + href: '#', + title: 'Categories are OK! Immediately remove the template.' + }).append('').text('{{Check categories}}'); + $okLink.on('click', function (e) { + e.preventDefault(); + var $el = $(this); + $el.off('click'); + var doEdit = function doEdit(result) { + if (!result) { + return; + } + $el.text('Doing.'); + var text = result.replace(checkCategoriesRegExp, ''); + if (text === result) { + $el.text('Template not found!'); + return; + } + var params = { + action: 'edit', + title: mw.config.get('wgPageName'), + nocreate: 1, + summary: "".concat(selfName, "Categories are checked and OK. You can help [[Category:Media needing category review|reviewing]]!"), + text: text, + token: mw.user.tokens.get('csrfToken') + }; + var editDone = function editDone(editStat) { + if (!editStat) { + return; + } + if (editStat.error) { + mw.notify("Unable to remove \"Check categories\" with the API\n".concat(editStat.error.code, "\n").concat(editStat.error.info), { + tag: 'hotCatCheck', + type: 'error' + }); + $el.text('Edit-Error!'); + } else { + $el.text('Edit Done.'); + } + $('.checkcategories').fadeOut(); + }; + $el.text('Doing..'); + $.post(mw.util.wikiScript('api'), params, editDone); + }; + $el.text('Doing'); + $.ajax({ + url: mw.config.get('wgScript'), + data: { + action: 'raw', + title: mw.config.get('wgPageName').replace(/ /g, '_') + }, + dataType: 'text', + error: function error() { + $el.text('Error!'); + }, + success: doEdit, + type: 'GET', + cache: false + }); + }); + $(function () { + $('#catlinks').find('ul:first').append($('').append($okLink)); + }); +})(); +/* */ From 4c49ec3acd0252f0e16958eebc24b8d59b2ed152 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:02:50 +0800 Subject: [PATCH 06/13] Update .options --- src/Gadgets/Compatibility/Ding/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/Compatibility/Ding/.options b/src/Gadgets/Compatibility/Ding/.options index f345999..a464c60 100644 --- a/src/Gadgets/Compatibility/Ding/.options +++ b/src/Gadgets/Compatibility/Ding/.options @@ -1 +1 @@ -Ding[ResourceLoader|hidden|targets=desktop,mobile]|Ding.css|Ding.js \ No newline at end of file +Ding[ResourceLoader|hidden]|Ding.css|Ding.js From 9123d58bc3b7c4faf2e17369e0e2b05401e8ce83 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:07:01 +0800 Subject: [PATCH 07/13] refactor(HotCat.js): pull code from Qiuwen upstream --- src/Gadgets/EditButton/HotCat/HotCat.js | 243 ++++++++++++------------ 1 file changed, 124 insertions(+), 119 deletions(-) diff --git a/src/Gadgets/EditButton/HotCat/HotCat.js b/src/Gadgets/EditButton/HotCat/HotCat.js index 87cb768..2f7ef2a 100644 --- a/src/Gadgets/EditButton/HotCat/HotCat.js +++ b/src/Gadgets/EditButton/HotCat/HotCat.js @@ -1,3 +1,11 @@ +/** + * SPDX-License-Identifier: CC-BY-SA-4.0 + * _addText: '{{Gadget Header|license=CC-BY-SA-4.0}}' + * + * @base + * @source + * @dependency ext.gadget.i18n, jquery.ui, mediawiki.storage, mediawiki.util, mediawiki.user, user + */ /** * +--------------------------------------------------------+ * | === WARNING: GLOBAL GADGET FILE === | @@ -5,26 +13,30 @@ * | All changes should be made in the repository, | * | otherwise they will be lost. | * +--------------------------------------------------------+ - * | Changes to this page affect many users. | - * | Please discuss changes at Talk page before editing. | + * | Changes to this page may affect many users. | + * | Please discuss changes at talk page before editing. | * +--------------------------------------------------------+ */ /* */ +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +var _objectHasOwn = function (object, property) { + if (typeof object === 'undefined' || object === null) { + throw new TypeError('Cannot convert undefined or null to object'); + } + return Object.prototype.hasOwnProperty.call(Object(object), property); +}; function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } -/** - * SPDX-License-Identifier: CC-BY-SA-4.0 - * _addText: '{{Gadget Header|license=CC-BY-SA-4.0}}' - * - * @base - * @source - * @dependency user - */ +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, _toPropertyKey(descriptor.key), descriptor); } } +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * HotCat V2.43 * @@ -41,7 +53,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len * * Choose whichever license of these you like best :-) */ -(function hotCat($, mw) { +(function hotCat() { // Don't use mw.config.get() as that takes a copy of the config, and so doesn't // account for values changing, e.g. wgCurRevisionId after a VE edit var conf = mw.config.values; @@ -50,7 +62,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len return; // Not on edit mode } // Configuration stuff. - var HC = window.HotCat = { + window.HotCat = { // Localize these messages to the main language of your wiki. messages: { cat_removed: 'removed [[Category:$1]]', @@ -217,7 +229,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } (_a = window.HotCat).shortcuts || (_a.shortcuts = {}); for (var k in map) { - if (!Object.prototype.hasOwnProperty.call(map, k) || typeof k !== 'string') { + if (!_objectHasOwn(map, k) || typeof k !== 'string') { continue; } var v = map[k]; @@ -233,13 +245,15 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } } }; + var HC = window.HotCat; // More backwards compatibility. We have a few places where we test for the browser: once for // Safari < 3.0, and twice for WebKit (Chrome or Safari, any versions) var ua = navigator.userAgent.toLowerCase(); var is_webkit = /applewebkit\/\d+/.test(ua) && !(ua.indexOf('spoofer') !== -1); var cat_prefix = null; var noSuggestions = false; - var LoadTrigger = function LoadTrigger(needed) { + var LoadTrigger = /*#__PURE__*/_createClass(function LoadTrigger(needed) { + _classCallCheck(this, LoadTrigger); // Define methods in a closure so that self reference is available, // also allows method calls to be detached. var self = this; @@ -262,58 +276,45 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len self.queue = []; } }; - }; - // Used to delay running the HotCat setup until /local-defaults and localizations have been loaded. + }); // Used to delay running the HotCat setup until local-defaults and localizations have been loaded. var loadTrigger = new LoadTrigger(2); - var load = function load(uri, callback) { - var s = document.createElement('script'); - s.src = uri; - var called = false; - s.onload = function () { - if (!called && callback) { - called = true; - callback(); - } - if (s.parentNode) { - s.remove(); - } - }; - s.onerror = s.onload; - document.head.append(s); - }; - var loadJS = function loadJS(page, callback) { - load("".concat(conf.wgServer + conf.wgScript, "?title=").concat(encodeURIComponent(page), "&action=raw&ctype=text/javascript&maxage=86400&smaxage=86400"), callback); - }; - var loadURI = function loadURI(href, callback) { - var url = href; - if (url.slice(0, 2) === '//') { - url = window.location.protocol + url; - } else if (url.slice(0, 1) === '/') { - url = conf.wgServer + url; - } - load(url, callback); - }; // Load local configurations, overriding the pre-set default values in the HotCat object above. This is always loaded // from the wiki where this script is executing, even if this script itself is hotlinked from Commons. This can // be used to change the default settings, or to provide localized interface texts for edit summaries and so on. - loadJS('MediaWiki:Gadget-HotCat-local-defaults.js', loadTrigger.loaded); + $.ajax({ + url: mw.config.get('wgScript'), + dataType: 'script', + data: { + title: 'MediaWiki:Gadget-HotCat-local-defaults.js', + action: 'raw', + ctype: 'text/javascript', + maxage: 3600, + smaxage: 3600 + }, + cache: true + }).always(function () { + loadTrigger.loaded(); + }); // Load localized UI texts. These are the texts that HotCat displays on the page itself. Texts shown in edit summaries - // should be localized in /local-defaults above. + // should be localized in local-defaults above. if (conf.wgUserLanguage === 'en') { loadTrigger.loaded(); } else { - // Lupo: somebody thought it would be a good idea to add this. So the default is true, and you have to set it to false - // explicitly if you're not on Commons and don't want that. - if (window.hotcat_translations_from_commons === undefined) { - window.hotcat_translations_from_commons = true; - } - // Localization hook to localize HotCat messages, tooltips, and engine names for wgUserLanguage. - if (window.hotcat_translations_from_commons && !(conf.wgServer.indexOf('//commons') !== -1)) { - loadURI("".concat(mw.config.get('wgScript'), "?title=MediaWiki:Gadget-HotCat-").concat(conf.wgUserLanguage, ".js&action=raw&ctype=text/javascript&maxage=86400&smaxage=86400"), loadTrigger.loaded); - } else { - // Load translations locally - loadJS("MediaWiki:Gadget-HotCat-".concat(conf.wgUserLanguage, ".js"), loadTrigger.loaded); - } + // Load translations locally + $.ajax({ + url: mw.config.get('wgScript'), + dataType: 'script', + data: { + title: 'MediaWiki:Gadget-HotCat-messages.js', + action: 'raw', + ctype: 'text/javascript', + maxage: 3600, + smaxage: 3600 + }, + cache: true + }).always(function () { + loadTrigger.loaded(); + }); } // No further changes should be necessary here. // The following regular expression strings are used when searching for categories in wikitext. @@ -422,12 +423,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } return str.slice(0, 1).toUpperCase() + str.slice(1); }; - var wikiPagePath = function wikiPagePath(pageName) { - return ( - // Note: do not simply use encodeURI, it doesn't encode '&', which might break if wgArticlePath actually has the $1 in - // a query parameter. - conf.wgArticlePath.replace('$1', encodeURIComponent(pageName).replace(/%3A/g, ':').replace(/%2F/g, '/')) - ); + var wikiPagePath = function wikiPagePath(pageName) + // Note: do not simply use encodeURI, it doesn't encode '&', which might break if wgArticlePath actually has the $1 in + // a query parameter. + { + return conf.wgArticlePath.replace('$1', encodeURIComponent(pageName).replace(/%3A/g, ':').replace(/%2F/g, '/')); }; var escapeRE = function escapeRE(str) { return str.replace(/([$()*+.?[\\\]^])/g, '\\$1'); @@ -748,7 +748,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } if (HC.capitalizePageNames === null) { // ResourceLoader's JSParser doesn't like .case, so override eslint. - HC.capitalizePageNames = json.query.general["case"] === 'first-letter'; + HC.capitalizePageNames = json.query.general.case === 'first-letter'; } } serverTime = startTime; @@ -787,7 +787,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len failure.apply(this, args); }; // Must use Ajax here to get the user options and the edit token. - $.getJSON("".concat(conf.wgServer + conf.wgScriptPath, "/api.php?format=json&action=query&rawcontinue=&titles=").concat(encodeURIComponent(conf.wgPageName), "&prop=info%7Crevisions%7Clanglinks&inprop=watched&rvprop=content%7Ctimestamp%7Cids%7Cuser&lllimit=500&rvlimit=2&rvdir=newer&rvstartid=").concat(conf.wgCurRevisionId, "&meta=siteinfo%7Cuserinfo%7Ctokens&type=csrf&uiprop=options"), function (json) { + $.getJSON("".concat(conf.wgScriptPath, "/api.php?format=json&action=query&rawcontinue=&titles=").concat(encodeURIComponent(conf.wgPageName), "&prop=info%7Crevisions%7Clanglinks&inprop=watched&rvprop=content%7Ctimestamp%7Cids%7Cuser&lllimit=500&rvlimit=2&rvdir=newer&rvstartid=").concat(conf.wgCurRevisionId, "&meta=siteinfo%7Cuserinfo%7Ctokens&type=csrf&uiprop=options"), function (json) { setPage(json); doEdit(fail); }).fail(function (_ref3) { @@ -845,12 +845,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len commitForm.wpEditToken.value = editToken; action = commitForm.wpDiff; if (action) { - action.name = action.value = 'wpSave'; + action.value = 'wpSave'; + action.name = action.value; } } else { action = commitForm.wpSave; if (action) { - action.name = action.value = 'wpDiff'; + action.value = 'wpDiff'; + action.name = action.value; } } var result = { @@ -895,7 +897,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len // Do not commit if there were errors action = commitForm.wpSave; if (action) { - action.name = action.value = 'wpDiff'; + action.value = 'wpDiff'; + action.name = action.value; } } // Fill in the form and submit it @@ -1063,7 +1066,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len return; } for (var p in params.query.pages) { - if (Object.prototype.hasOwnProperty.call(params.query.pages, p)) { + if (_objectHasOwn(params.query.pages, p)) { resolveOne(params.query.pages[p], toResolve); } } @@ -1090,7 +1093,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len args += '%7C'; } } - $.getJSON("".concat(conf.wgServer + conf.wgScriptPath, "/api.php?").concat(args), function (json) { + $.getJSON("".concat(conf.wgScriptPath, "/api.php?").concat(args), function (json) { resolveRedirects(toResolve, json); callback(toResolve); }).fail(function (req) { @@ -1123,7 +1126,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len // cursor at the end of the category, and do not display the old suggestion list. which.showsList = false; var v = actualValue.split('|'); - which.lastRealInput = which.lastInput = v[0]; + which.lastInput = v[0]; + which.lastRealInput = which.lastInput; if (v.length > 1) { which.currentKey = v[1]; } @@ -1170,7 +1174,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len initiateEdit(function (failure) { performChanges(failure); }, function (msg) { - mw.notify(msg); + mw.notify(msg, { + tag: 'hotCat' + }); }); return; } @@ -1187,10 +1193,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (!firstDab) { firstDab = element; } - } else { - if (element.acceptCheck(true)) { - element.commit(); - } + } else if (element.acceptCheck(true)) { + element.commit(); } } else { // We didn't disable all the open editors, but we did asynchronous calls. It is @@ -1209,7 +1213,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len initiateEdit(function (failure) { performChanges(failure); }, function (msg) { - mw.notify(msg); + mw.notify(msg, { + tag: 'hotCat' + }); }); } }); @@ -1244,7 +1250,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }; var suggestionEngines = { opensearch: { - uri: '/api.php?format=json&action=opensearch&namespace=14&limit=30&search=Category:$1', + uri: "".concat(mw.config.get('wgScriptPath'), "/api.php?format=json&action=opensearch&namespace=14&limit=30&search=Category:$1"), // $1 = search term // Function to convert result of uri into an array of category names handler: function handler(queryResult, queryKey) { @@ -1279,7 +1285,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } }, internalsearch: { - uri: '/api.php?format=json&action=query&list=allpages&apnamespace=14&aplimit=30&apfrom=$1&apprefix=$1', + uri: "".concat(mw.config.get('wgScriptPath'), "/api.php?format=json&action=query&list=allpages&apnamespace=14&aplimit=30&apfrom=$1&apprefix=$1"), handler: function handler(queryResult) { if (queryResult && queryResult.query && queryResult.query.allpages) { var titles = queryResult.query.allpages; @@ -1292,12 +1298,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } }, exists: { - uri: '/api.php?format=json&action=query&prop=info&titles=Category:$1', + uri: "".concat(mw.config.get('wgScriptPath'), "/api.php?format=json&action=query&prop=info&titles=Category:$1"), handler: function handler(queryResult, queryKey) { if (queryResult && queryResult.query && queryResult.query.pages && !queryResult.query.pages[-1]) { // Should have exactly 1 for (var p in queryResult.query.pages) { - if (Object.prototype.hasOwnProperty.call(queryResult.query.pages, p)) { + if (_objectHasOwn(queryResult.query.pages, p)) { var _title = queryResult.query.pages[p].title; _title = _title.slice(Math.max(0, _title.indexOf(':') + 1)); var titles = [_title]; @@ -1314,7 +1320,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } }, subcategories: { - uri: '/api.php?format=json&action=query&list=categorymembers&cmtype=subcat&cmlimit=max&cmtitle=Category:$1', + uri: "".concat(mw.config.get('wgScriptPath'), "/api.php?format=json&action=query&list=categorymembers&cmtype=subcat&cmlimit=max&cmtitle=Category:$1"), handler: function handler(queryResult) { if (queryResult && queryResult.query && queryResult.query.categorymembers) { var titles = queryResult.query.categorymembers; @@ -1327,7 +1333,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } }, parentcategories: { - uri: '/api.php?format=json&action=query&prop=categories&titles=Category:$1&cllimit=max', + uri: "".concat(mw.config.get('wgScriptPath'), "/api.php?format=json&action=query&prop=categories&titles=Category:$1&cllimit=max"), handler: function handler(queryResult) { if (queryResult && queryResult.query && queryResult.query.pages) { for (var p in queryResult.query.pages) { @@ -1874,13 +1880,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (this.catLink) { this.catLink.style.backgroundColor = 'transparent'; } - } else { - if (!onUpload) { - try { - this.catLink.style.backgroundColor = HC.bg_changed; - } catch (_unused3) { - /* empty */ - } + } else if (!onUpload) { + try { + this.catLink.style.backgroundColor = HC.bg_changed; + } catch (_unused3) { + /* empty */ } } checkMultiInput(); @@ -1979,10 +1983,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len resolveMulti(toResolve, function (resolved) { if (resolved[0].dab) { showDab(resolved[0]); - } else { - if (resolved[0].acceptCheck(true)) { - resolved[0].commit(resolved[0].currentCategory === original ? null : HC.messages.cat_resolved.replace(/\$1/g, original)); - } + } else if (resolved[0].acceptCheck(true)) { + resolved[0].commit(resolved[0].currentCategory === original ? null : HC.messages.cat_resolved.replace(/\$1/g, original)); } }); } @@ -2059,7 +2061,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len initiateEdit(function (failure) { performChanges(failure, self); }, function (msg) { - mw.notify(msg); + mw.notify(msg, { + tag: 'hotCat' + }); }); } }, @@ -2096,22 +2100,22 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len this.normalLinks.style.display = 'none'; this.undelLink.style.display = ''; checkMultiInput(); + } else if (onUpload) { + // Remove this editor completely + this.removeEditor(); } else { - if (onUpload) { - // Remove this editor completely - this.removeEditor(); - } else { - this.originalState = this.state; - this.state = CategoryEditor.DELETED; - this.noCommit = noCommit || HC.del_needs_diff; - var self = this; - initiateEdit(function (failure) { - performChanges(failure, self); - }, function (msg) { - self.state = self.originalState; - mw.notify(msg); + this.originalState = this.state; + this.state = CategoryEditor.DELETED; + this.noCommit = noCommit || HC.del_needs_diff; + var self = this; + initiateEdit(function (failure) { + performChanges(failure, self); + }, function (msg) { + self.state = self.originalState; + mw.notify(msg, { + tag: 'hotCat' }); - } + }); } }, restore: function restore(event) { @@ -2282,7 +2286,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var engine_ = _step3.value; var engine = suggestionEngines[engine_]; - var url = conf.wgServer + conf.wgScriptPath + engine.uri.replace(/\$1/g, encodeURIComponent(cleanKey)); + var url = conf.wgScriptPath + engine.uri.replace(/\$1/g, encodeURIComponent(cleanKey)); this.makeCall(url, cb, engine, v, cleanKey); } } catch (err) { @@ -2316,10 +2320,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (!this.engineSelector) { this.engineName = null; } - } else { - if (this.engineSelector) { - this.engineSelector.style.display = 'none'; - } + } else if (this.engineSelector) { + this.engineSelector.style.display = 'none'; } if (queryKey) { if (this.lastInput.indexOf(queryKey)) { @@ -3020,6 +3022,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len newRow.append(labelCell); newRow.append(lineCell); form.onsubmit = function (oldSubmit) { + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } return function () { var do_submit = true; if (oldSubmit) { @@ -3027,7 +3032,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len // eslint-disable-next-line security/detect-eval-with-expression, no-eval do_submit = eval(oldSubmit); } else if (oldSubmit instanceof Function) { - do_submit = oldSubmit.apply(form, arguments); + do_submit = oldSubmit.apply(form, [oldSubmit].concat(args)); } } if (!do_submit) { @@ -3219,7 +3224,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var getPage = function getPage() { // We know we have an article here. if (conf.wgArticleId) { - var url = "".concat(conf.wgServer + conf.wgScriptPath, "/api.php?format=json&callback=HotCat.start&action=query&rawcontinue=&titles=").concat(encodeURIComponent(conf.wgPageName), "&prop=info%7Crevisions&rvprop=content%7Ctimestamp%7Cids&meta=siteinfo&rvlimit=1&rvstartid=").concat(conf.wgCurRevisionId); + var url = "".concat(conf.wgScriptPath, "/api.php?format=json&callback=HotCat.start&action=query&rawcontinue=&titles=").concat(encodeURIComponent(conf.wgPageName), "&prop=info%7Crevisions&rvprop=content%7Ctimestamp%7Cids&meta=siteinfo&rvlimit=1&rvstartid=").concat(conf.wgCurRevisionId); var s = make('script'); s.src = url; HC.start = function (json) { @@ -3368,5 +3373,5 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len $(function () { run(); }); -})($, mw); +})(); /* */ From 6f65a413e55fb42d68c6063c68e0b22666c42aac Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:22:19 +0800 Subject: [PATCH 08/13] refactor(GeoLocation): pull & use shortword for provinces --- .../Compatibility/GeoLocation/GeoLocation.js | 187 ++++++++++-------- 1 file changed, 101 insertions(+), 86 deletions(-) diff --git a/src/Gadgets/Compatibility/GeoLocation/GeoLocation.js b/src/Gadgets/Compatibility/GeoLocation/GeoLocation.js index ae4f0bf..d36c94b 100644 --- a/src/Gadgets/Compatibility/GeoLocation/GeoLocation.js +++ b/src/Gadgets/Compatibility/GeoLocation/GeoLocation.js @@ -12,20 +12,24 @@ * | All changes should be made in the repository, | * | otherwise they will be lost. | * +--------------------------------------------------------+ - * | Changes to this page affect many users. | - * | Please discuss changes at Talk page before editing. | + * | Changes to this page may affect many users. | + * | Please discuss changes at talk page before editing. | * +--------------------------------------------------------+ */ /* */ -'use strict'; - -function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } -function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; } +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } +function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } (function () { var _geoLocation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() { - var i18nMessages, messages, message, _yield$Geo, country, region, countryList, regionList, _countryList, _regionList, getCountryName, getRegionName, scriptPath, getLocation, storeLocation, relevantUserPageName, pageName; + var i18nMessages, messages, message, _yield$Geo, country, region, countryList, regionList, _countryList, _regionList, getCountryName, getRegionName, scriptPath, getLocation, storeLocation, wgRelevantUserName, relevantUserPageName, pageName; return _regeneratorRuntime().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: @@ -33,30 +37,36 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar var _i18n = i18n, localize = _i18n.localize; return { - ': ': localize({ + ':': localize({ + en: ': ', ja: ':', zh: ':' }), - 'IP Location': localize({ - ja: 'IP地域', - 'zh-hans': 'IP属地', - 'zh-hant': 'IP屬地' - }), Bot: localize({ + en: 'Bot', ja: 'ボット', 'zh-hans': '机器人', 'zh-hant': '機械人' }), Unknown: localize({ + en: 'Unknown', ja: '未知', zh: '未知' }), Webmaster: localize({ + en: 'Webmaster', ja: 'ウェブマスター', 'zh-hans': '站长', 'zh-hant': '站長' }), - 'Update IP location information': localize({ + Location: localize({ + en: 'IP Location', + ja: 'IP地域', + 'zh-hans': 'IP属地', + 'zh-hant': 'IP屬地' + }), + Update: localize({ + en: 'Update IP location information', ja: 'IP地域の情報を更新', 'zh-hans': '更新IP属地信息', 'zh-hant': '更新IP屬地資訊' @@ -120,7 +130,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar CF: '中非', TD: '乍得', CL: '智利', - CN: '中国', + CN: '中国·', CX: '圣诞岛', CC: '科科斯(基林)群岛', CO: '哥伦比亚', @@ -175,7 +185,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar HM: '赫德岛和麦克唐纳群岛', VA: '梵蒂冈', HN: '洪都拉斯', - HK: '中国香港', + HK: '中国·香港', HU: '匈牙利', IS: '冰岛', IN: '印度', @@ -206,7 +216,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar LI: '列支敦士登', LT: '立陶宛', LU: '卢森堡', - MO: '中国澳门', + MO: '中国·澳门', MG: '马达加斯加', MW: '马拉维', MY: '马来西亚', @@ -292,7 +302,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar SE: '瑞典', CH: '瑞士', SY: '叙利亚', - TW: '中国臺湾', + TW: '中国·台湾', TJ: '塔吉克斯坦', TZ: '坦桑尼亚', TH: '泰国', @@ -328,37 +338,37 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar }; regionList = function regionList() { return { - AH: '安徽', - BJ: '北京', - CQ: '重庆', - FJ: '福建', - GD: '广东', - GS: '甘肃', - GX: '广西', - GZ: '贵州', - HA: '河南', - HB: '湖北', - HE: '河北', - HI: '海南', - HL: '黑龙江', - HN: '湖南', - JL: '吉林', - JS: '江苏', - JX: '江西', - LN: '辽宁', + AH: '徽', + BJ: '京', + CQ: '渝', + FJ: '闽', + GD: '粤', + GS: '甘', + GX: '桂', + GZ: '贵', + HA: '豫', + HB: '鄂', + HE: '冀', + HI: '琼', + HL: '黑', + HN: '湘', + JL: '吉', + JS: '苏', + JX: '赣', + LN: '辽', NM: '内蒙古', - NX: '宁夏', - QH: '青海', - SC: '四川', - SD: '山东', - SH: '上海', - SN: '陕西', - SX: '山西', - TJ: '天津', - XJ: '新疆', - XZ: '西藏', - YN: '云南', - ZJ: '浙江' + NX: '宁', + QH: '青', + SC: '川', + SD: '鲁', + SH: '沪', + SN: '陕', + SX: '晋', + TJ: '津', + XJ: '新', + XZ: '藏', + YN: '云', + ZJ: '浙' }; }; _countryList = countryList(); @@ -369,14 +379,14 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar getRegionName = function getRegionName(key) { return _regionList[key] || key; }; - scriptPath = mw.config.get('wgServer') + mw.config.get('wgScriptPath'); + scriptPath = mw.config.get('wgScriptPath'); getLocation = /*#__PURE__*/function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { - var IPGeolocationDesc, appendIcon, getUserGeoIP, response, groups; + var IPGeolocationDesc, appendIcon, getUserGeoIP, response, _response$query$users, groups; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: - IPGeolocationDesc = message('IP Location'); + IPGeolocationDesc = message('Location'); appendIcon = function appendIcon(indicatorText, spanClass, icon) { var $indicator = $('').addClass("mw-indicator mw-indicator-geolocation mw-geolocation-".concat(spanClass)).attr('id', 'mw-indicator-geolocation').append($('').addClass("mw-geolocation-filter-".concat(spanClass, " mw-geolocation-icon mw-geolocation-icon-").concat(icon !== null && icon !== void 0 ? icon : 'globe')).attr({ alt: indicatorText !== null && indicatorText !== void 0 ? indicatorText : IPGeolocationDesc, @@ -387,15 +397,18 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar }); }; getUserGeoIP = function getUserGeoIP() { - $.getJSON("".concat(scriptPath, "/index.php?title=User:").concat(mw.config.get('wgRelevantUserName'), "/GeoIP.json&action=raw&ctype=application/json")).done(function (response) { + $.getJSON(mw.util.getUrl("User:".concat(mw.config.get('wgRelevantUserName'), "/GeoIP.json"), { + action: 'raw', + ctype: 'application/json' + })).done(function (response) { var _getCountryName, _getRegionName; var countryText = (_getCountryName = getCountryName(response.country)) !== null && _getCountryName !== void 0 ? _getCountryName : '未知'; var regionText = response.country === 'CN' ? (_getRegionName = getRegionName(response.region)) !== null && _getRegionName !== void 0 ? _getRegionName : '' : ''; - var indicatorText = "".concat(IPGeolocationDesc).concat(message(': ')).concat(countryText).concat(regionText); + var indicatorText = "".concat(IPGeolocationDesc).concat(message(':')).concat(countryText).concat(regionText); var spanClass = 'green'; appendIcon(indicatorText, spanClass, 'globe'); }).fail(function () { - var indicatorText = "".concat(IPGeolocationDesc).concat(message(': ')).concat(message('Unknown')); + var indicatorText = "".concat(IPGeolocationDesc).concat(message(':')).concat(message('Unknown')); var spanClass = 'orange'; appendIcon(indicatorText, spanClass, 'helpNotice'); }); @@ -404,7 +417,6 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar _context.next = 6; return $.get("".concat(scriptPath, "/api.php"), { action: 'query', - format: 'json', formatversion: '2', list: 'users', ususers: mw.config.get('wgRelevantUserName'), @@ -412,7 +424,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar }); case 6: response = _context.sent; - groups = response['query'].users[0].groups; + _response$query$users = _slicedToArray(response['query'].users, 1), groups = _response$query$users[0].groups; if ((groups.indexOf('autoconfirmed') !== -1 || groups.indexOf('confirmed') !== -1) && !(groups.indexOf('bot') !== -1)) { getUserGeoIP(); } else if (groups.indexOf('bot') !== -1) { @@ -437,60 +449,62 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar }(); storeLocation = /*#__PURE__*/function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { - var response; + var _mw$config$get; + var wgUserGroups, response; return _regeneratorRuntime().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: - if (!(country === '' || mw.config.get('wgUserGroups').indexOf('bot') !== -1 || mw.config.get('wgUserGroups').indexOf('qiuwen') !== -1 || !mw.config.get('wgUserName') || !(mw.config.get('wgUserGroups').indexOf('autoconfirmed') !== -1 || mw.config.get('wgUserGroups').indexOf('confirmed') !== -1))) { - _context2.next = 2; + wgUserGroups = (_mw$config$get = mw.config.get('wgUserGroups')) !== null && _mw$config$get !== void 0 ? _mw$config$get : []; + if (!(country === '' || wgUserGroups.indexOf('bot') !== -1 || wgUserGroups.indexOf('qiuwen') !== -1 || !mw.config.get('wgUserName') || !(wgUserGroups.indexOf('autoconfirmed') !== -1 || wgUserGroups.indexOf('confirmed') !== -1))) { + _context2.next = 3; break; } return _context2.abrupt("return"); - case 2: - _context2.prev = 2; - _context2.next = 5; - return $.getJSON("".concat(mw.config.get('wgServer') + mw.config.get('wgScriptPath'), "/wiki/User:").concat(mw.config.get('wgUserName'), "/GeoIP.json?action=raw&ctype=application/json")); - case 5: + case 3: + _context2.prev = 3; + _context2.next = 6; + return $.getJSON("".concat(scriptPath, "/wiki/User:").concat(mw.config.get('wgUserName'), "/GeoIP.json?action=raw&ctype=application/json")); + case 6: response = _context2.sent; - if (!(response.country === country && response.region === region)) { - _context2.next = 8; + if (!(response.country === country && (response.region === region || response.region !== '' && region === ''))) { + _context2.next = 9; break; } return _context2.abrupt("return"); - case 8: - _context2.next = 12; + case 9: + _context2.next = 13; break; - case 10: - _context2.prev = 10; - _context2.t0 = _context2["catch"](2); - case 12: - _context2.prev = 12; - _context2.next = 15; + case 11: + _context2.prev = 11; + _context2.t0 = _context2["catch"](3); + case 13: + _context2.prev = 13; + _context2.next = 16; return $.post("".concat(scriptPath, "/api.php"), { action: 'edit', - format: 'json', formatversion: '2', contentformat: 'application/json', contentmodel: 'json', title: "User:".concat(mw.config.get('wgUserName'), "/GeoIP.json"), text: "{\"country\":\"".concat(country, "\",\"region\":\"").concat(region, "\"}"), - summary: message('Update IP location information'), + summary: message('Update'), + tags: 'GeoLocation', minor: 1, recreate: 1, watchlist: 'unwatch', token: mw.user.tokens.get('csrfToken') }); - case 15: - _context2.next = 19; + case 16: + _context2.next = 20; break; - case 17: - _context2.prev = 17; - _context2.t1 = _context2["catch"](12); - case 19: + case 18: + _context2.prev = 18; + _context2.t1 = _context2["catch"](13); + case 20: case "end": return _context2.stop(); } - }, _callee2, null, [[2, 10], [12, 17]]); + }, _callee2, null, [[3, 11], [13, 18]]); })); return function storeLocation() { return _ref2.apply(this, arguments); @@ -499,14 +513,15 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar _context3.next = 19; return storeLocation(); case 19: - if (mw.config.get('wgRelevantUserName') && mw.config.get('wgNamespaceNumber') === 2 && mw.config.get('wgAction') === 'view') { - relevantUserPageName = new mw.Title(mw.config.get('wgRelevantUserName'), 2).toText(); + wgRelevantUserName = mw.config.get('wgRelevantUserName'); + if (wgRelevantUserName && mw.config.get('wgNamespaceNumber') === 2 && mw.config.get('wgAction') === 'view') { + relevantUserPageName = new mw.Title(wgRelevantUserName, 2).toText(); pageName = new mw.Title(mw.config.get('wgPageName')).toText(); if (relevantUserPageName === pageName) { getLocation(); } } - case 20: + case 21: case "end": return _context3.stop(); } From 32d5e056ceddfa5877eb08a8bf799992b833e4dc Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:23:07 +0800 Subject: [PATCH 09/13] Update GeoLocation.css --- .../Compatibility/GeoLocation/GeoLocation.css | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/Gadgets/Compatibility/GeoLocation/GeoLocation.css b/src/Gadgets/Compatibility/GeoLocation/GeoLocation.css index 477a9b1..d377e5a 100644 --- a/src/Gadgets/Compatibility/GeoLocation/GeoLocation.css +++ b/src/Gadgets/Compatibility/GeoLocation/GeoLocation.css @@ -1,15 +1,10 @@ /** - * SPDX-License-Identifier: CC BY-SA-4.0 + * SPDX-License-Identifier: CC-BY-SA-4.0 * _addText: '{{Gadget Header|license=CC-BY-SA-4.0}}' * * @base * @source */ -/** - * Including icons from OOUI Project - * Licensed under MIT License - * See for contributors. - */ /** * +--------------------------------------------------------+ * | === WARNING: GLOBAL GADGET FILE === | @@ -17,8 +12,8 @@ * | All changes should be made in the repository, | * | otherwise they will be lost. | * +--------------------------------------------------------+ - * | Changes to this page affect many users. | - * | Please discuss changes at Talk page before editing. | + * | Changes to this page may affect many users. | + * | Please discuss changes at talk page before editing. | * +--------------------------------------------------------+ */ /* */ @@ -37,8 +32,8 @@ } .mw-geolocation-green { - border-color: #14866d; - color: #14866d; + border-color: #00af89; + color: #00af89; } .mw-geolocation-orange { @@ -62,24 +57,44 @@ } .mw-geolocation-icon-globe::before { + /** + * @description globe Icon from OOjs UI + * @base + * @license MIT + */ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Cpath fill='%2314866d' d='M12.2 17.94c1.26-2 2-4.45 2.14-7.06h3.86a8.26 8.26 0 01-6 7.06M1.8 10.88h3.86c.14 2.6.88 5.06 2.14 7.06a8.26 8.26 0 01-6-7.06m6-8.82c-1.26 2-2 4.45-2.14 7.07H1.8a8.26 8.26 0 016-7.07m4.79 8.82A12.5 12.5 0 0110 18a12.51 12.51 0 01-2.59-7.13zM7.4 9.13A12.51 12.51 0 0110 1.99a12.5 12.5 0 012.59 7.14zm10.8 0h-3.87a14.79 14.79 0 00-2.14-7.07 8.26 8.26 0 016 7.07M10 0a10 10 0 100 20 10 10 0 000-20'/%3E%3C/svg%3E"); } .mw-geolocation-icon-helpNotice::before { + /** + * @description helpNotice Icon (ltr) from OOjs UI + * @base + * @license MIT + */ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Cpath fill='%23a60' d='M10 0a10 10 0 1010 10A10 10 0 0010 0zm1 16H9v-2h2zm2.71-7.6a2.64 2.64 0 01-.33.74 3.16 3.16 0 01-.48.55l-.54.48c-.21.18-.41.35-.58.52a2.54 2.54 0 00-.47.56A2.3 2.3 0 0011 12a3.79 3.79 0 00-.11 1H9.08a8.9 8.9 0 01.07-1.25 3.28 3.28 0 01.25-.9 2.79 2.79 0 01.41-.67 4 4 0 01.58-.58c.17-.16.34-.3.51-.44a3 3 0 00.43-.44 1.83 1.83 0 00.3-.55 2 2 0 00.11-.72 2.06 2.06 0 00-.17-.86 1.71 1.71 0 00-1-.9 1.7 1.7 0 00-.5-.1 1.77 1.77 0 00-1.53.68 3 3 0 00-.5 1.82H6.16a4.74 4.74 0 01.28-1.68 3.56 3.56 0 01.8-1.29 3.88 3.88 0 011.28-.83A4.59 4.59 0 0110.18 4a4.44 4.44 0 011.44.23 3.51 3.51 0 011.15.65 3.08 3.08 0 01.78 1.06 3.54 3.54 0 01.29 1.45 3.39 3.39 0 01-.13 1.01z'/%3E%3C/svg%3E"); } .mw-geolocation-icon-settings::before { + /** + * @description settings Icon (ltr) from OOjs UI + * @base + * @license MIT + */ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='20' height='20' fill='%2336c'%3E%3Cg transform='translate(10 10)'%3E%3Cpath id='a' d='M1.5-10h-3l-1 6.5h5m0 7h-5l1 6.5h3'/%3E%3Cuse xlink:href='%23a' transform='rotate(45)'/%3E%3Cuse xlink:href='%23a' transform='rotate(90)'/%3E%3Cuse xlink:href='%23a' transform='rotate(135)'/%3E%3C/g%3E%3Cpath d='M10 2.5a7.5 7.5 0 000 15 7.5 7.5 0 000-15v4a3.5 3.5 0 010 7 3.5 3.5 0 010-7'/%3E%3C/svg%3E"); } .mw-geolocation-icon-userAvatar::before { + /** + * @description userAvatar Icon (ltr) from OOjs UI + * @base + * @license MIT + */ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='%2336c'%3E%3Cpath d='M10 11c-5.92 0-8 3-8 5v3h16v-3c0-2-2.08-5-8-5z'/%3E%3Ccircle cx='10' cy='5.5' r='4.5'/%3E%3C/svg%3E"); } .mw-geolocation-text { - font-size: 13px; + font-size: 0.8125em; vertical-align: middle; } -/* */ \ No newline at end of file +/* */ From 4f885cfc3b917d47f036d087699b5a0fc2581af3 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:28:01 +0800 Subject: [PATCH 10/13] refactor(Wikicache):pull from Qiuwen --- .../EditButton/Wikicache/Wikicache-load.js | 153 +++++++++--------- 1 file changed, 81 insertions(+), 72 deletions(-) diff --git a/src/Gadgets/EditButton/Wikicache/Wikicache-load.js b/src/Gadgets/EditButton/Wikicache/Wikicache-load.js index c2fe17c..c388957 100644 --- a/src/Gadgets/EditButton/Wikicache/Wikicache-load.js +++ b/src/Gadgets/EditButton/Wikicache/Wikicache-load.js @@ -4,7 +4,7 @@ * * @base * @source - * @dependency jquery.ui, mediawiki.storage, mediawiki.util + * @dependency ext.gadget.i18n, jquery.ui, mediawiki.storage, mediawiki.util */ /** * +--------------------------------------------------------+ @@ -13,57 +13,63 @@ * | All changes should be made in the repository, | * | otherwise they will be lost. | * +--------------------------------------------------------+ - * | Changes to this page affect many users. | - * | Please discuss changes at Talk page before editing. | + * | Changes to this page may affect many users. | + * | Please discuss changes at talk page before editing. | * +--------------------------------------------------------+ */ /* */ -$(function wikicache() { +var _objectHasOwn = function (object, property) { + if (typeof object === 'undefined' || object === null) { + throw new TypeError('Cannot convert undefined or null to object'); + } + return Object.prototype.hasOwnProperty.call(Object(object), property); +}; +(function wikicache() { window.wikiCache = { - version: '0.2.0', + version: '0.3.0', _msgs: { 'no-reminder': '不再提醒', - more: '更多信息', - ok: '确定', - load: '载入', - ignore: '忽略', + more: wgULS('更多信息', '更多資訊'), + ok: wgULS('确定', '確認'), + load: wgULS('载入', '載入'), + ignore: wgULS('忽略', '忽略'), 'bracket-left': '(', 'bracket-right': ')', - 'not-support': '抱歉,您的浏览器无法支持WikiCache,如果您打算使用WikiCache,请更新您的浏览器。', - 'not-support-title': '浏览器过旧', + 'not-support': wgULS('抱歉,您的浏览器无法支持WikiCache,若您打算使用WikiCache,请更新您的浏览器。', '抱歉,您的瀏覽器無法支援WikiCache,若您打算使用WikiCache,請升級您的瀏覽器。'), + 'not-support-title': wgULS('浏览器过旧', '瀏覽器過舊'), 'not-support-more-link': 'H:IE', - 'notice-init': '自动保存已启用。', - 'notice-more': '配置', - 'notice-load': '载入上次存档', - 'notice-autosave-success': '自动保存成功。', - 'notice-autosave-failed': '自动保存失败,可能是由于已超出浏览器所允许空间上限', - 'notice-autosave-failed-clear': '清理', - 'notice-load-available': '发现自动保存结果,请选择是否载入。', - 'notice-load-available-confirm': '载入', - 'notice-load-available-ignore': '忽略', - 'settings-title': 'WikiCache配置', - 'settings-autosave-interval': '自动保存间隔:', - 'settings-autosave-interval-suffix': '秒', - 'settings-autosave-interval-too-small': '错误:“自动保存间隔”所设间隔过小(<10秒),请重新设置', - 'settings-autosave-interval-invalid': '错误:请在“自动保存间隔”输入框中输入数字' + 'notice-init': wgULS('自动保存已启用。', '自動存檔已啟用。'), + 'notice-more': wgULS('配置', '設定'), + 'notice-load': wgULS('载入上次存档', '載入上次存檔'), + 'notice-autosave-success': wgULS('自动保存成功。', '自動存檔成功。'), + 'notice-autosave-failed': wgULS('自动保存失败,可能是由于已超出浏览器所允许空间上限。', '自動存檔失敗,可能是由於已超過瀏覽器所許可空間上限。'), + 'notice-autosave-failed-clear': wgULS('清理', '清理'), + 'notice-load-available': wgULS('发现自动保存结果,是否载入?', '發現自動存檔,是否載入?'), + 'notice-load-available-confirm': wgULS('载入', '載入'), + 'notice-load-available-ignore': wgULS('忽略', '忽略'), + 'settings-title': wgULS('WikiCache配置', 'WikiCache設定'), + 'settings-autosave-interval': wgULS('自动保存间隔:', '自動保存間隔:'), + 'settings-autosave-interval-suffix': wgULS('秒', '秒'), + 'settings-autosave-interval-too-small': wgULS('错误:“自动保存间隔”所设间隔过小(<10秒),请重新设置', '錯誤:「自動保存間隔」所設間隔過小(<10秒),請重新設定'), + 'settings-autosave-interval-invalid': wgULS('错误:请在“自动保存间隔”输入框中输入数字', '錯誤:請在「自動保存間隔」輸入框輸入數字') }, _settings: { - 'autosave-interval': 120 + 'autosave-interval': 60 }, - _style: '.wikicache-dialog{font-size:1em}.wikicache-notice{position:fixed;bottom:0;left:0;z-index:99;display:none;height:1.6em;border-right:1px solid #a7d7f9;border-bottom:1px solid #a7d7f9;white-space:nowrap;font-size:.8em;line-height:1.6em}.wikicache-notice .ui-dialog-titlebar-close{float:right;display:inline-block}.wikicache-dialog a,.wikicache-notice a{color:#0645ad}.wikicache-dialog a:visited,.wikicache-notice a:visited{color:#0b0080}.wikicache-error-message{padding-left:60px;min-height:48px;background:url("//wiki.zorua.top/images/thumb/0/09/Cross_Mark_%28Red%29.svg/50px-Cross_Mark_%28Red%29.svg.png") no-repeat 0}', + _style: '.wikicache-dialog{font-size:1em}.wikicache-notice{position:fixed;bottom:0;left:0;z-index:99;display:none;height:1.6em;border-right:1px solid #a7d7f9;border-bottom:1px solid #a7d7f9;white-space:nowrap;font-size:.8em;line-height:1.6em}.wikicache-notice .ui-dialog-titlebar-close{float:right;display:inline-block}.wikicache-dialog a,.wikicache-notice a{color:#0645ad}.wikicache-dialog a:visited,.wikicache-notice a:visited{color:#0b0080}.wikicache-error-message{padding-left:60px;min-height:48px;background:url("//tu.zhongwen.wiki/images/qiuwen/thumb/0/09/Cross_Mark_(Red).svg/48px-Cross_Mark_(Red).svg.png") no-repeat 0}', _autoSaveArea: { - '#wpTextbox1': function wpTextbox1(element, value) { - if (value) { - element.val(value); + '#wpTextbox1': function wpTextbox1(el, val) { + if (val) { + el.val(val); } else { - return element.val(); + return el.val(); } }, - '#wpSummary': function wpSummary(element, value) { - if (value) { - element.val(value); + '#wpSummary': function wpSummary(el, val) { + if (val) { + el.val(val); } else { - return element.val(); + return el.val(); } } }, @@ -77,12 +83,12 @@ $(function wikicache() { }, _initView: function _initView() { if (window.localStorage) { - window.wikiCache._loadStyle(); + mw.util.addCSS(window.wikiCache._style); window.wikiCache._loadSettings(); } }, _initEdit: function _initEdit() { - window.wikiCache._loadStyle(); + mw.util.addCSS(window.wikiCache._style); var errorDialog = window.wikiCache._errorDialog; var msgs = window.wikiCache._msgs; if (!window.localStorage) { @@ -98,9 +104,6 @@ $(function wikicache() { window.wikiCache._initLoad(); } }, - _loadStyle: function _loadStyle() { - mw.util.addCSS(window.wikiCache._style); - }, _loadSettings: function _loadSettings() { var settings = mw.storage.getObject('wikicache-settings'); if (settings instanceof Object) { @@ -119,7 +122,7 @@ $(function wikicache() { } var msgs = window.wikiCache._msgs; var buttons = {}; - buttons[msgs.ok] = function () { + buttons[msgs['ok']] = function () { $(this).dialog('close').remove(); }; $('').addClass('wikicache-dialog wikicache-error').attr('title', title).append($('').addClass('wikicache-error-message').html("".concat(msg, " ").concat(msgs['bracket-left'])).append($('').attr('href', more).html(msgs.more)).append(msgs['bracket-right'])).append($('').append($('').attr({ @@ -127,7 +130,6 @@ $(function wikicache() { type: 'checkbox', name: 'noreminder' })).append($('').attr('for', noreminderid).html(msgs['no-reminder']))).appendTo($('body')).dialog({ - buttons: buttons, draggable: false, modal: true, width: 450, @@ -135,7 +137,8 @@ $(function wikicache() { if ($("#".concat(noreminderid), this).attr('checked')) { mw.storage.set(noreminderid, '1'); } - } + }, + buttons: buttons }); }, _defaultNotice: function _defaultNotice() { @@ -160,11 +163,11 @@ $(function wikicache() { var first = true; element.appendTo(notice); for (var message in more) { - if (Object.prototype.hasOwnProperty.call(more, message)) { - if (!first) { - element.append(' | '); - } else { + if (_objectHasOwn(more, message)) { + if (first) { first = false; + } else { + element.append(' | '); } element.append($('').attr('href', '#').html(message).on('click', more[message])); } @@ -179,38 +182,39 @@ $(function wikicache() { var msgs = window.wikiCache._msgs; var settings = window.wikiCache._settings; var buttons = {}; - buttons[msgs.ok] = function () { + buttons[msgs['ok']] = function () { $(this).dialog('close'); }; - var dia = $('').addClass('wikicache-dialog').attr('title', msgs['settings-title']).append($('').append($('').attr('for', 'autosave-interval').html(msgs['settings-autosave-interval'])).append($('').attr({ + var dialog = $('').addClass('wikicache-dialog').attr('title', msgs['settings-title']).append($('').append($('').attr('for', 'autosave-interval').html(msgs['settings-autosave-interval'])).append($('').attr({ id: 'autosave-interval', type: 'text', size: 5 }).val(settings['autosave-interval'])).append(" ".concat(msgs['settings-autosave-interval-suffix']))); - dia.appendTo($('body')).dialog({ - buttons: buttons, + dialog.appendTo($('body')).dialog({ draggable: false, modal: true, width: 400, beforeClose: function beforeClose() { - var interval = $('#autosave-interval', dia).val(); - if (!Number.isNaN(interval)) { - interval = Number.parseInt(interval); - if (interval < 10) { - mw.notify(msgs['settings-autosave-interval-too-small'], { - type: 'error' - }); - return false; - } - settings['autosave-interval'] = interval; - } else { + var interval = $('#autosave-interval', dialog).val(); + if (Number.isNaN(interval)) { mw.notify(msgs['settings-autosave-interval-invalid'], { + tag: 'wikiCache', type: 'error' }); return false; } + interval = Number.parseInt(interval, 10); + if (interval < 10) { + mw.notify(msgs['settings-autosave-interval-too-small'], { + tag: 'wikiCache', + type: 'error' + }); + return false; + } + settings['autosave-interval'] = interval; window.wikiCache._saveSettings(); - } + }, + buttons: buttons }); return false; }, @@ -229,9 +233,10 @@ $(function wikicache() { _date: new Date() }; for (var sele in asarea) { - if (Object.prototype.hasOwnProperty.call(asarea, sele)) { - autosave[sele] = asarea[sele]($(sele)); + if (!_objectHasOwn(asarea, sele)) { + continue; } + autosave[sele] = asarea[sele]($(sele)); } var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); @@ -243,7 +248,7 @@ $(function wikicache() { }, _initLoad: function _initLoad() { var msgs = window.wikiCache._msgs; - var thekey = "autosave-".concat(mw.config.get('wgPageName')); + var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); if (section) { thekey += "_".concat(section); @@ -265,19 +270,23 @@ $(function wikicache() { } }, _load: function _load(autosave) { - if (!(autosave instanceof Object)) { - var thekey = "autosave-".concat(mw.config.get('wgPageName')); + var _autosave; + if (autosave instanceof Object) { + _autosave = autosave; + } else { + var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); if (section) { thekey += "_".concat(section); } - autosave = mw.storage.getObject(thekey); + _autosave = mw.storage.getObject(thekey); } var asarea = window.wikiCache._autoSaveArea; for (var sele in asarea) { - if (Object.prototype.hasOwnProperty.call(asarea, sele)) { - asarea[sele]($(sele), autosave[sele]); + if (!_objectHasOwn(asarea, sele)) { + continue; } + asarea[sele]($(sele), _autosave[sele]); } window.wikiCache._defaultNotice(); window.wikiCache._autoSave(); @@ -293,5 +302,5 @@ $(function wikicache() { } }; $(window.wikiCache.init); -}); +})(); /* */ From 825b77be501133bd8e1e0590412aa9a0ce22954a Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:30:43 +0800 Subject: [PATCH 11/13] Update .options --- src/Gadgets/EditButton/Wikicache/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/EditButton/Wikicache/.options b/src/Gadgets/EditButton/Wikicache/.options index e03637b..556f812 100644 --- a/src/Gadgets/EditButton/Wikicache/.options +++ b/src/Gadgets/EditButton/Wikicache/.options @@ -1 +1 @@ -Wikicache[ResourceLoader|default|dependencies=jquery.ui,mediawiki.storage,mediawiki.util|rights=edit|targets=desktop,mobile]|Wikicache-load.js \ No newline at end of file +Wikicache[ResourceLoader|default|dependencies=ext.gadget.i18n,jquery.ui,mediawiki.storage,mediawiki.util|rights=edit]|Wikicache-load.js From 364d1007c28f5755d3f051c49685d7735d8eb851 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:31:28 +0800 Subject: [PATCH 12/13] Update .options --- src/Gadgets/EditButton/HotCat/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/EditButton/HotCat/.options b/src/Gadgets/EditButton/HotCat/.options index d9b471a..098569a 100644 --- a/src/Gadgets/EditButton/HotCat/.options +++ b/src/Gadgets/EditButton/HotCat/.options @@ -1 +1 @@ -HotCat[ResourceLoader|default|dependencies= jquery.ui, mediawiki.storage, mediawiki.util,mediawiki.user,user|rights=skipcaptcha|targets=desktop,mobile]|HotCat.js|Hotcatcheck.js \ No newline at end of file +HotCat[ResourceLoader|default|dependencies=ext.gadget.i18n,jquery.ui,mediawiki.storage,mediawiki.util,mediawiki.user,user|rights=skipcaptcha]|HotCat.js|HotCatcheck.js From 717e7ab7b4c5cc04b546ceba2704db0f15710e3d Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:32:20 +0800 Subject: [PATCH 13/13] Update .options --- src/Gadgets/Compatibility/GeoLocation/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/Compatibility/GeoLocation/.options b/src/Gadgets/Compatibility/GeoLocation/.options index fd7b855..9c34fcf 100644 --- a/src/Gadgets/Compatibility/GeoLocation/.options +++ b/src/Gadgets/Compatibility/GeoLocation/.options @@ -1 +1 @@ -GeoLocation[ResourceLoader|default|dependencies=ext.gadget.Geo,ext.gadget.i18n,mediawiki.Title,mediawiki.api|targets=desktop,mobile]|GeoLocation.css|GeoLocation.js \ No newline at end of file +GeoLocation[ResourceLoader|dependencies=ext.gadget.Geo,ext.gadget.i18n,mediawiki.Title,mediawiki.api]|GeoLocation.css|GeoLocation.js
').append(createjIcon(icon).css('marginRight', '0.3em'), textNode))); - }; - mw.util.addCSS('.catcheck-inline-icon{display:inline-block;position:relative;top:2px}'); - // Remove "check categories" when using HotCat - // Only executed on first submit - $('body').one('submit.checkCatListener', '#hotcatCommitForm', function (e) { - if (storageItem === 'disabled') { - return true; - } - var self = this; - var newVal = self.wpTextbox1.value.replace(chCatRE, ''); - var dlgButtons = {}; - var $dlgCheckStorage; - var $permaSaveHint; - var $textHintNode; - var $dlg; - var doRemove = function doRemove() { - self.wpSummary.value = "Removing [[Template:Check categories|{".concat("{Check categories}}]] ".concat(self.wpSummary.value)); - self.wpTextbox1.value = newVal; - }; - var writeStorage = function writeStorage(val) { - mw.storage.set(storageItemName, val, 6048e2); // 7 days - }; - - dlgButtons['Yes, Remove'] = function () { - doRemove(); - if ($dlgCheckStorage[0].checked) { - writeStorage('auto'); - } - $(this).dialog('close'); - }; - dlgButtons['No, keep it'] = function () { - if ($dlgCheckStorage[0].checked) { - writeStorage('disabled'); - } - $(this).dialog('close'); - }; - var _addToJS = function _addToJS(_e) { - _e.preventDefault(); - if ($permaSaveHint.hasClass('ui-state-disabled')) { - return; - } - var $el = $(this); - $el.off('click').text('Please wait.'); - $permaSaveHint.addClass('ui-state-disabled'); - var params = { - action: 'edit', - title: "User:".concat(mw.config.get('wgUserName'), "/common.js"), - summary: "".concat(selfName, "Saving HotCat configuration."), - appendtext: $el.data('addText'), - token: window['wikilove-edittoken'] || mw.user.tokens.get('csrfToken'), - format: 'json' - }; - var editDone = function editDone(editStat) { - if (!editStat) { - return; - } - if (editStat.error) { - mw.notify("Unable to save to your common.js using the API\n".concat(editStat.error.code, "\n").concat(editStat.error.info), { - type: 'error' - }); - $el.text('Edit-Error!'); - } else { - $el.text('Done.'); - $permaSaveHint.fadeOut(); - } - }; - $.post(mw.util.wikiScript('api'), params, editDone); - }; - /** - * On Wikimedia Commons there were people who said: - * "Categorizing with HotCat does legit automated removal of the check-cat-message" - * So we invented a dialog that should be readable by users even with very few English skills. - */ - var prompt = function prompt() { - $dlgCheckStorage = $('').attr({ - type: 'checkbox', - id: 'hotCatAutoRemoveCheckCatStorage' - }).on('change', function () { - if (this.checked) { - $permaSaveHint.fadeIn(); - } else { - $permaSaveHint.fadeOut(); - } - }); - $textHintNode = $('
').append(createjIcon(icon).css('marginRight', '0.3em'), textNode))); + }; + mw.util.addCSS('.catcheck-inline-icon{display:inline-block;position:relative;top:2px}'); + // Remove "check categories" when using HotCat + // Only executed on first submit + $('body').one('submit.checkCatListener', '#hotcatCommitForm', function (e) { + if (storageItem === 'disabled') { + return true; + } + var self = this; + var newVal = self.wpTextbox1.value.replace(checkCategoriesRegExp, ''); + var dlgButtons = {}; + var $dialogCheckStorage; + var $permaSaveHint; + var $textHintNode; + var $dialog; + var doRemove = function doRemove() { + self.wpSummary.value = "Removing [[Template:Check categories|{".concat("{Check categories}}]] ".concat(self.wpSummary.value)); + self.wpTextbox1.value = newVal; + }; + var writeStorage = function writeStorage(val) { + mw.storage.set(storageItemName, val, 6048e2); // 7 days + }; + + dlgButtons['Yes, Remove'] = function () { + doRemove(); + if ($dialogCheckStorage[0].checked) { + writeStorage('auto'); + } + $(this).dialog('close'); + }; + dlgButtons['No, keep it'] = function () { + if ($dialogCheckStorage[0].checked) { + writeStorage('disabled'); + } + $(this).dialog('close'); + }; + var _addToJS = function _addToJS(_e) { + _e.preventDefault(); + if ($permaSaveHint.hasClass('ui-state-disabled')) { + return; + } + var $el = $(this); + $el.off('click').text('Please wait.'); + $permaSaveHint.addClass('ui-state-disabled'); + var params = { + action: 'edit', + title: "User:".concat(mw.config.get('wgUserName'), "/common.js"), + summary: "".concat(selfName, "Saving HotCat configuration."), + appendtext: $el.data('addText'), + token: mw.user.tokens.get('csrfToken') + }; + var editDone = function editDone(editStat) { + if (!editStat) { + return; + } + if (editStat.error) { + mw.notify("Unable to save to your common.js using the API\n".concat(editStat.error.code, "\n").concat(editStat.error.info), { + tag: 'hotCatCheck', + type: 'error' + }); + $el.text('Edit-Error!'); + } else { + $el.text('Done.'); + $permaSaveHint.fadeOut(); + } + }; + $.post(mw.util.wikiScript('api'), params, editDone); + }; + /** + * On Wikimedia Commons there were people who said: + * "Categorizing with HotCat does legit automated removal of the check-cat-message" + * So we invented a dialog that should be readable by users even with very few English skills. + */ + var prompt = function prompt() { + $dialogCheckStorage = $('').attr({ + type: 'checkbox', + id: 'hotCatAutoRemoveCheckCatStorage' + }).on('change', function () { + if (this.checked) { + $permaSaveHint.fadeIn(); + } else { + $permaSaveHint.fadeOut(); + } + }); + $textHintNode = $('
').append($('').attr({ @@ -127,7 +130,6 @@ $(function wikicache() { type: 'checkbox', name: 'noreminder' })).append($('').attr('for', noreminderid).html(msgs['no-reminder']))).appendTo($('body')).dialog({ - buttons: buttons, draggable: false, modal: true, width: 450, @@ -135,7 +137,8 @@ $(function wikicache() { if ($("#".concat(noreminderid), this).attr('checked')) { mw.storage.set(noreminderid, '1'); } - } + }, + buttons: buttons }); }, _defaultNotice: function _defaultNotice() { @@ -160,11 +163,11 @@ $(function wikicache() { var first = true; element.appendTo(notice); for (var message in more) { - if (Object.prototype.hasOwnProperty.call(more, message)) { - if (!first) { - element.append(' | '); - } else { + if (_objectHasOwn(more, message)) { + if (first) { first = false; + } else { + element.append(' | '); } element.append($('').attr('href', '#').html(message).on('click', more[message])); } @@ -179,38 +182,39 @@ $(function wikicache() { var msgs = window.wikiCache._msgs; var settings = window.wikiCache._settings; var buttons = {}; - buttons[msgs.ok] = function () { + buttons[msgs['ok']] = function () { $(this).dialog('close'); }; - var dia = $('').addClass('wikicache-dialog').attr('title', msgs['settings-title']).append($('').append($('').attr('for', 'autosave-interval').html(msgs['settings-autosave-interval'])).append($('').attr({ + var dialog = $('').addClass('wikicache-dialog').attr('title', msgs['settings-title']).append($('').append($('').attr('for', 'autosave-interval').html(msgs['settings-autosave-interval'])).append($('').attr({ id: 'autosave-interval', type: 'text', size: 5 }).val(settings['autosave-interval'])).append(" ".concat(msgs['settings-autosave-interval-suffix']))); - dia.appendTo($('body')).dialog({ - buttons: buttons, + dialog.appendTo($('body')).dialog({ draggable: false, modal: true, width: 400, beforeClose: function beforeClose() { - var interval = $('#autosave-interval', dia).val(); - if (!Number.isNaN(interval)) { - interval = Number.parseInt(interval); - if (interval < 10) { - mw.notify(msgs['settings-autosave-interval-too-small'], { - type: 'error' - }); - return false; - } - settings['autosave-interval'] = interval; - } else { + var interval = $('#autosave-interval', dialog).val(); + if (Number.isNaN(interval)) { mw.notify(msgs['settings-autosave-interval-invalid'], { + tag: 'wikiCache', type: 'error' }); return false; } + interval = Number.parseInt(interval, 10); + if (interval < 10) { + mw.notify(msgs['settings-autosave-interval-too-small'], { + tag: 'wikiCache', + type: 'error' + }); + return false; + } + settings['autosave-interval'] = interval; window.wikiCache._saveSettings(); - } + }, + buttons: buttons }); return false; }, @@ -229,9 +233,10 @@ $(function wikicache() { _date: new Date() }; for (var sele in asarea) { - if (Object.prototype.hasOwnProperty.call(asarea, sele)) { - autosave[sele] = asarea[sele]($(sele)); + if (!_objectHasOwn(asarea, sele)) { + continue; } + autosave[sele] = asarea[sele]($(sele)); } var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); @@ -243,7 +248,7 @@ $(function wikicache() { }, _initLoad: function _initLoad() { var msgs = window.wikiCache._msgs; - var thekey = "autosave-".concat(mw.config.get('wgPageName')); + var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); if (section) { thekey += "_".concat(section); @@ -265,19 +270,23 @@ $(function wikicache() { } }, _load: function _load(autosave) { - if (!(autosave instanceof Object)) { - var thekey = "autosave-".concat(mw.config.get('wgPageName')); + var _autosave; + if (autosave instanceof Object) { + _autosave = autosave; + } else { + var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); if (section) { thekey += "_".concat(section); } - autosave = mw.storage.getObject(thekey); + _autosave = mw.storage.getObject(thekey); } var asarea = window.wikiCache._autoSaveArea; for (var sele in asarea) { - if (Object.prototype.hasOwnProperty.call(asarea, sele)) { - asarea[sele]($(sele), autosave[sele]); + if (!_objectHasOwn(asarea, sele)) { + continue; } + asarea[sele]($(sele), _autosave[sele]); } window.wikiCache._defaultNotice(); window.wikiCache._autoSave(); @@ -293,5 +302,5 @@ $(function wikicache() { } }; $(window.wikiCache.init); -}); +})(); /* */ From 825b77be501133bd8e1e0590412aa9a0ce22954a Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:30:43 +0800 Subject: [PATCH 11/13] Update .options --- src/Gadgets/EditButton/Wikicache/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/EditButton/Wikicache/.options b/src/Gadgets/EditButton/Wikicache/.options index e03637b..556f812 100644 --- a/src/Gadgets/EditButton/Wikicache/.options +++ b/src/Gadgets/EditButton/Wikicache/.options @@ -1 +1 @@ -Wikicache[ResourceLoader|default|dependencies=jquery.ui,mediawiki.storage,mediawiki.util|rights=edit|targets=desktop,mobile]|Wikicache-load.js \ No newline at end of file +Wikicache[ResourceLoader|default|dependencies=ext.gadget.i18n,jquery.ui,mediawiki.storage,mediawiki.util|rights=edit]|Wikicache-load.js From 364d1007c28f5755d3f051c49685d7735d8eb851 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:31:28 +0800 Subject: [PATCH 12/13] Update .options --- src/Gadgets/EditButton/HotCat/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/EditButton/HotCat/.options b/src/Gadgets/EditButton/HotCat/.options index d9b471a..098569a 100644 --- a/src/Gadgets/EditButton/HotCat/.options +++ b/src/Gadgets/EditButton/HotCat/.options @@ -1 +1 @@ -HotCat[ResourceLoader|default|dependencies= jquery.ui, mediawiki.storage, mediawiki.util,mediawiki.user,user|rights=skipcaptcha|targets=desktop,mobile]|HotCat.js|Hotcatcheck.js \ No newline at end of file +HotCat[ResourceLoader|default|dependencies=ext.gadget.i18n,jquery.ui,mediawiki.storage,mediawiki.util,mediawiki.user,user|rights=skipcaptcha]|HotCat.js|HotCatcheck.js From 717e7ab7b4c5cc04b546ceba2704db0f15710e3d Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:32:20 +0800 Subject: [PATCH 13/13] Update .options --- src/Gadgets/Compatibility/GeoLocation/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/Compatibility/GeoLocation/.options b/src/Gadgets/Compatibility/GeoLocation/.options index fd7b855..9c34fcf 100644 --- a/src/Gadgets/Compatibility/GeoLocation/.options +++ b/src/Gadgets/Compatibility/GeoLocation/.options @@ -1 +1 @@ -GeoLocation[ResourceLoader|default|dependencies=ext.gadget.Geo,ext.gadget.i18n,mediawiki.Title,mediawiki.api|targets=desktop,mobile]|GeoLocation.css|GeoLocation.js \ No newline at end of file +GeoLocation[ResourceLoader|dependencies=ext.gadget.Geo,ext.gadget.i18n,mediawiki.Title,mediawiki.api]|GeoLocation.css|GeoLocation.js
').append($('').attr('for', 'autosave-interval').html(msgs['settings-autosave-interval'])).append($('').attr({ + var dialog = $('').addClass('wikicache-dialog').attr('title', msgs['settings-title']).append($('').append($('').attr('for', 'autosave-interval').html(msgs['settings-autosave-interval'])).append($('').attr({ id: 'autosave-interval', type: 'text', size: 5 }).val(settings['autosave-interval'])).append(" ".concat(msgs['settings-autosave-interval-suffix']))); - dia.appendTo($('body')).dialog({ - buttons: buttons, + dialog.appendTo($('body')).dialog({ draggable: false, modal: true, width: 400, beforeClose: function beforeClose() { - var interval = $('#autosave-interval', dia).val(); - if (!Number.isNaN(interval)) { - interval = Number.parseInt(interval); - if (interval < 10) { - mw.notify(msgs['settings-autosave-interval-too-small'], { - type: 'error' - }); - return false; - } - settings['autosave-interval'] = interval; - } else { + var interval = $('#autosave-interval', dialog).val(); + if (Number.isNaN(interval)) { mw.notify(msgs['settings-autosave-interval-invalid'], { + tag: 'wikiCache', type: 'error' }); return false; } + interval = Number.parseInt(interval, 10); + if (interval < 10) { + mw.notify(msgs['settings-autosave-interval-too-small'], { + tag: 'wikiCache', + type: 'error' + }); + return false; + } + settings['autosave-interval'] = interval; window.wikiCache._saveSettings(); - } + }, + buttons: buttons }); return false; }, @@ -229,9 +233,10 @@ $(function wikicache() { _date: new Date() }; for (var sele in asarea) { - if (Object.prototype.hasOwnProperty.call(asarea, sele)) { - autosave[sele] = asarea[sele]($(sele)); + if (!_objectHasOwn(asarea, sele)) { + continue; } + autosave[sele] = asarea[sele]($(sele)); } var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); @@ -243,7 +248,7 @@ $(function wikicache() { }, _initLoad: function _initLoad() { var msgs = window.wikiCache._msgs; - var thekey = "autosave-".concat(mw.config.get('wgPageName')); + var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); if (section) { thekey += "_".concat(section); @@ -265,19 +270,23 @@ $(function wikicache() { } }, _load: function _load(autosave) { - if (!(autosave instanceof Object)) { - var thekey = "autosave-".concat(mw.config.get('wgPageName')); + var _autosave; + if (autosave instanceof Object) { + _autosave = autosave; + } else { + var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); if (section) { thekey += "_".concat(section); } - autosave = mw.storage.getObject(thekey); + _autosave = mw.storage.getObject(thekey); } var asarea = window.wikiCache._autoSaveArea; for (var sele in asarea) { - if (Object.prototype.hasOwnProperty.call(asarea, sele)) { - asarea[sele]($(sele), autosave[sele]); + if (!_objectHasOwn(asarea, sele)) { + continue; } + asarea[sele]($(sele), _autosave[sele]); } window.wikiCache._defaultNotice(); window.wikiCache._autoSave(); @@ -293,5 +302,5 @@ $(function wikicache() { } }; $(window.wikiCache.init); -}); +})(); /* */ From 825b77be501133bd8e1e0590412aa9a0ce22954a Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:30:43 +0800 Subject: [PATCH 11/13] Update .options --- src/Gadgets/EditButton/Wikicache/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/EditButton/Wikicache/.options b/src/Gadgets/EditButton/Wikicache/.options index e03637b..556f812 100644 --- a/src/Gadgets/EditButton/Wikicache/.options +++ b/src/Gadgets/EditButton/Wikicache/.options @@ -1 +1 @@ -Wikicache[ResourceLoader|default|dependencies=jquery.ui,mediawiki.storage,mediawiki.util|rights=edit|targets=desktop,mobile]|Wikicache-load.js \ No newline at end of file +Wikicache[ResourceLoader|default|dependencies=ext.gadget.i18n,jquery.ui,mediawiki.storage,mediawiki.util|rights=edit]|Wikicache-load.js From 364d1007c28f5755d3f051c49685d7735d8eb851 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:31:28 +0800 Subject: [PATCH 12/13] Update .options --- src/Gadgets/EditButton/HotCat/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/EditButton/HotCat/.options b/src/Gadgets/EditButton/HotCat/.options index d9b471a..098569a 100644 --- a/src/Gadgets/EditButton/HotCat/.options +++ b/src/Gadgets/EditButton/HotCat/.options @@ -1 +1 @@ -HotCat[ResourceLoader|default|dependencies= jquery.ui, mediawiki.storage, mediawiki.util,mediawiki.user,user|rights=skipcaptcha|targets=desktop,mobile]|HotCat.js|Hotcatcheck.js \ No newline at end of file +HotCat[ResourceLoader|default|dependencies=ext.gadget.i18n,jquery.ui,mediawiki.storage,mediawiki.util,mediawiki.user,user|rights=skipcaptcha]|HotCat.js|HotCatcheck.js From 717e7ab7b4c5cc04b546ceba2704db0f15710e3d Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:32:20 +0800 Subject: [PATCH 13/13] Update .options --- src/Gadgets/Compatibility/GeoLocation/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/Compatibility/GeoLocation/.options b/src/Gadgets/Compatibility/GeoLocation/.options index fd7b855..9c34fcf 100644 --- a/src/Gadgets/Compatibility/GeoLocation/.options +++ b/src/Gadgets/Compatibility/GeoLocation/.options @@ -1 +1 @@ -GeoLocation[ResourceLoader|default|dependencies=ext.gadget.Geo,ext.gadget.i18n,mediawiki.Title,mediawiki.api|targets=desktop,mobile]|GeoLocation.css|GeoLocation.js \ No newline at end of file +GeoLocation[ResourceLoader|dependencies=ext.gadget.Geo,ext.gadget.i18n,mediawiki.Title,mediawiki.api]|GeoLocation.css|GeoLocation.js
').append($('').attr('for', 'autosave-interval').html(msgs['settings-autosave-interval'])).append($('').attr({ id: 'autosave-interval', type: 'text', size: 5 }).val(settings['autosave-interval'])).append(" ".concat(msgs['settings-autosave-interval-suffix']))); - dia.appendTo($('body')).dialog({ - buttons: buttons, + dialog.appendTo($('body')).dialog({ draggable: false, modal: true, width: 400, beforeClose: function beforeClose() { - var interval = $('#autosave-interval', dia).val(); - if (!Number.isNaN(interval)) { - interval = Number.parseInt(interval); - if (interval < 10) { - mw.notify(msgs['settings-autosave-interval-too-small'], { - type: 'error' - }); - return false; - } - settings['autosave-interval'] = interval; - } else { + var interval = $('#autosave-interval', dialog).val(); + if (Number.isNaN(interval)) { mw.notify(msgs['settings-autosave-interval-invalid'], { + tag: 'wikiCache', type: 'error' }); return false; } + interval = Number.parseInt(interval, 10); + if (interval < 10) { + mw.notify(msgs['settings-autosave-interval-too-small'], { + tag: 'wikiCache', + type: 'error' + }); + return false; + } + settings['autosave-interval'] = interval; window.wikiCache._saveSettings(); - } + }, + buttons: buttons }); return false; }, @@ -229,9 +233,10 @@ $(function wikicache() { _date: new Date() }; for (var sele in asarea) { - if (Object.prototype.hasOwnProperty.call(asarea, sele)) { - autosave[sele] = asarea[sele]($(sele)); + if (!_objectHasOwn(asarea, sele)) { + continue; } + autosave[sele] = asarea[sele]($(sele)); } var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); @@ -243,7 +248,7 @@ $(function wikicache() { }, _initLoad: function _initLoad() { var msgs = window.wikiCache._msgs; - var thekey = "autosave-".concat(mw.config.get('wgPageName')); + var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); if (section) { thekey += "_".concat(section); @@ -265,19 +270,23 @@ $(function wikicache() { } }, _load: function _load(autosave) { - if (!(autosave instanceof Object)) { - var thekey = "autosave-".concat(mw.config.get('wgPageName')); + var _autosave; + if (autosave instanceof Object) { + _autosave = autosave; + } else { + var thekey = "wikicache-autosave-".concat(mw.config.get('wgPageName')); var section = $('input[name="wpSection"]:first').val(); if (section) { thekey += "_".concat(section); } - autosave = mw.storage.getObject(thekey); + _autosave = mw.storage.getObject(thekey); } var asarea = window.wikiCache._autoSaveArea; for (var sele in asarea) { - if (Object.prototype.hasOwnProperty.call(asarea, sele)) { - asarea[sele]($(sele), autosave[sele]); + if (!_objectHasOwn(asarea, sele)) { + continue; } + asarea[sele]($(sele), _autosave[sele]); } window.wikiCache._defaultNotice(); window.wikiCache._autoSave(); @@ -293,5 +302,5 @@ $(function wikicache() { } }; $(window.wikiCache.init); -}); +})(); /* */ From 825b77be501133bd8e1e0590412aa9a0ce22954a Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:30:43 +0800 Subject: [PATCH 11/13] Update .options --- src/Gadgets/EditButton/Wikicache/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/EditButton/Wikicache/.options b/src/Gadgets/EditButton/Wikicache/.options index e03637b..556f812 100644 --- a/src/Gadgets/EditButton/Wikicache/.options +++ b/src/Gadgets/EditButton/Wikicache/.options @@ -1 +1 @@ -Wikicache[ResourceLoader|default|dependencies=jquery.ui,mediawiki.storage,mediawiki.util|rights=edit|targets=desktop,mobile]|Wikicache-load.js \ No newline at end of file +Wikicache[ResourceLoader|default|dependencies=ext.gadget.i18n,jquery.ui,mediawiki.storage,mediawiki.util|rights=edit]|Wikicache-load.js From 364d1007c28f5755d3f051c49685d7735d8eb851 Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:31:28 +0800 Subject: [PATCH 12/13] Update .options --- src/Gadgets/EditButton/HotCat/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/EditButton/HotCat/.options b/src/Gadgets/EditButton/HotCat/.options index d9b471a..098569a 100644 --- a/src/Gadgets/EditButton/HotCat/.options +++ b/src/Gadgets/EditButton/HotCat/.options @@ -1 +1 @@ -HotCat[ResourceLoader|default|dependencies= jquery.ui, mediawiki.storage, mediawiki.util,mediawiki.user,user|rights=skipcaptcha|targets=desktop,mobile]|HotCat.js|Hotcatcheck.js \ No newline at end of file +HotCat[ResourceLoader|default|dependencies=ext.gadget.i18n,jquery.ui,mediawiki.storage,mediawiki.util,mediawiki.user,user|rights=skipcaptcha]|HotCat.js|HotCatcheck.js From 717e7ab7b4c5cc04b546ceba2704db0f15710e3d Mon Sep 17 00:00:00 2001 From: ZoruaFox <96456728+ZoruaFox@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:32:20 +0800 Subject: [PATCH 13/13] Update .options --- src/Gadgets/Compatibility/GeoLocation/.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gadgets/Compatibility/GeoLocation/.options b/src/Gadgets/Compatibility/GeoLocation/.options index fd7b855..9c34fcf 100644 --- a/src/Gadgets/Compatibility/GeoLocation/.options +++ b/src/Gadgets/Compatibility/GeoLocation/.options @@ -1 +1 @@ -GeoLocation[ResourceLoader|default|dependencies=ext.gadget.Geo,ext.gadget.i18n,mediawiki.Title,mediawiki.api|targets=desktop,mobile]|GeoLocation.css|GeoLocation.js \ No newline at end of file +GeoLocation[ResourceLoader|dependencies=ext.gadget.Geo,ext.gadget.i18n,mediawiki.Title,mediawiki.api]|GeoLocation.css|GeoLocation.js