/*
* Rater: dialog interface to add, remove, or modify WikiProject banners
* Author: Evad37
* Licence: MIT / CC-BY 4.0
*
* Built from source code at GitHub repository .
* All changes should be made in the repository, otherwise they will be lost.
*
* To update this script from github, you must have a local repository set up. Then
* follow the instructions at
*/
/* jshint esversion: 5, laxbreak: true, undef: true, eqnull: true, maxerr: 3000 */
/* globals console, document, window, $, mw, OO, extraJs */
/* <nowiki> */
! function r(e, n, t) {
function o(i, f) {
if (!n) {
if (!e) {
var c = "function" == typeof require && require;
if (!f && c) return c(i, !0);
if (u) return u(i, !0);
var a = new Error("Cannot find module '" + i + "'");
throw a.code = "MODULE_NOT_FOUND", a
}
var p = n = {
exports: {}
};
e.call(p.exports, function(r) {
return o(e || r)
}, p, p.exports, r, e, n, t)
}
return n.exports
}
for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) o(t);
return o
}({
1: [function(require, module, exports) {
module.exports = {
name: "rater",
version: "2.6.5",
description: "Wikipedia userscript that helps assess pages for WikiProjects",
homepage: "https://github.com/evad37/rater",
browser: "index.js",
scripts: {
test: 'echo "Error: no test specified" && exit 1',
"lint:es5": "jshint index.js",
"lint:es6": 'eslint index.js "rater-src/**"',
"lint:fix": 'eslint index.js "rater-src/**" --fix',
lint: "npm run lint:es6 && npm run lint:es5",
"build:bundle": "browserify rater-src/App.js --debug -t babelify --outfile dist/rater.js",
"build:minify": "uglifyjs dist/rater.js --compress -b ascii_only=true,beautify=false --output dist/rater.min.js",
"build:concat": 'concat-cli -f "comment-top.js" dist/rater.min.js "comment-bottom.js" -o dist/rater.min.js',
build: "npm run lint && npm run build:bundle && npm run build:minify && npm run build:concat"
},
author: {
name: "Evad37",
url: "https://en.wikipedia.orghttps://wiki95.com/en/User:Evad37"
},
repository: {
type: "git",
url: "https://github.com/evad37/rater.git"
},
license: "(MIT OR CC-BY-4.0)",
devDependencies: {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
babelify: "^10.0.0",
browserify: "^16.5.0",
"concat-cli": "^4.0.0",
eslint: "^6.8.0",
jshint: "^2.11.0",
"uglify-js": "^3.8.0"
}
}
}, {}],
2: [function(require, module, exports) {
"use strict";
var stylesheet, showSetupError, _setup = _interopRequireDefault(require("./setup")),
_autostart = _interopRequireDefault(require("./autostart")),
_css = _interopRequireDefault(require("./css.js")),
_api = require("./api"),
_windowManager = _interopRequireDefault(require("./windowManager"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
function showMainWindow(data) {
data && data.success && (stylesheet ? stylesheet.disabled = !1 : stylesheet = mw.util.addCSS(_css.default), document.getElementsByTagName("body").classList.add("rater-mainWindow-open"), _windowManager.default.openWindow("main", data).closed.then(function(result) {
if (stylesheet && (stylesheet.disabled = !0), document.getElementsByTagName("body").classList.remove("rater-mainWindow-open"), result && result.restart) _windowManager.default.removeWindows().then(_setup.default).then(showMainWindow, showSetupError);
else if (result && result.success) {
var $message = $("<span>").append($("<strong>").text("Ratings saved successfully."));
result.upgradedStub && $message.append($("<br>"), $("<span>").text("Note that the article appears to be tagged as a stub.")), mw.notify($message, {
autoHide: !0,
autoHideSeconds: "long",
tag: "Rater-saved"
})
}
}))
}
showSetupError = function(code, jqxhr) {
return OO.ui.alert((0, _api.makeErrorMsg)(code, jqxhr), {
title: "Rater failed to open"
})
}, mw.util.addPortletLink("p-cactions", "#", "Rater", "ca-rater", "Rate quality and importance", "5"), $("#ca-rater").click(function(event) {
event.preventDefault(), (0, _setup.default)().then(showMainWindow, showSetupError)
}), (0, _autostart.default)().then(showMainWindow)
}, {
"./api": 15,
"./autostart": 16,
"./css.js": 19,
"./setup": 22,
"./windowManager": 24
}],
3: [function(require, module, exports) {
"use strict";
function _typeof(obj) {
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
})(obj)
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.getWithRedirectTo = exports.parseTemplates = exports.Template = void 0;
var _api = _interopRequireDefault(require("./api")),
_util = require("./util"),
_config = _interopRequireDefault(require("./config")),
cache = function(obj) {
if (obj && obj.__esModule) return obj;
if (null === obj || "object" !== _typeof(obj) && "function" != typeof obj) return {
default: obj
};
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) return cache.get(obj);
var newObj = {},
hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj)
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj = obj
} newObj.default = obj, cache && cache.set(obj, newObj);
return newObj
}(require("./cache"));
function _getRequireWildcardCache() {
if ("function" != typeof WeakMap) return null;
var cache = new WeakMap;
return _getRequireWildcardCache = function() {
return cache
}, cache
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
function _toConsumableArray(arr) {
return function(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr)
}(arr) || function(iter) {
if ("undefined" != typeof Symbol && Symbol.iterator in Object(iter)) return Array.from(iter)
}(arr) || function(o, minLen) {
if (!o) return;
if ("string" == typeof o) return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
"Object" === n && o.constructor && (n = o.constructor.name);
if ("Map" === n || "Set" === n) return Array.from(n);
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen)
}(arr) || function() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a () method.")
}()
}
function _arrayLikeToArray(arr, len) {
(null == len || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2 = arr;
return arr2
}
var Template = function(wikitext) {
this.wikitext = wikitext, this.parameters = , this.pipeStyle = " |", this.equalsStyle = "=", this.endBracesStyle = "}}"
};
(exports.Template = Template).prototype.addParam = function(name, val, wikitext) {
this.parameters.push({
name: name,
value: val,
wikitext: "|" + wikitext
})
}, Template.prototype.getParam = function(paramName) {
return this.parameters.find(function(p) {
return p.name == paramName
})
}, Template.prototype.setName = function(name) {
this.name = name.trim()
}, Template.prototype.getTitle = function() {
return mw.Title.newFromText("Template:" + this.name)
};
exports.parseTemplates = function parseTemplates(wikitext, recursive) {
if (!wikitext) return ;
for (var startIdx, strReplaceAt = function(string, index, _char) {
return string.slice(0, index) + _char + string.slice(index + 1)
}, result = , processTemplateText = function(startIdx, endIdx) {
for (var text = wikitext.slice(startIdx, endIdx), template = new Template("{{" + text.replace(/\x01/g, "|") + "}}");
/(\]*?)\|(.*?\]\])/g.test(text);) text = text.replace(/(\]*?)\|(.*?\]\])/g, "$1\x01$2");
template.pipeStyle = (0, _util.mostFrequent)(text.match(/*\|*/g)) || " |", template.equalsStyle = (0, _util.mostFrequent)(text.replace(/(=*)=+/g, "$1").match(/*=*/g)) || "=";
var endSpacing = text.match(/*$/);
template.endBracesStyle = (endSpacing ? endSpacing : "") + "}}";
var chunks = text.split("|").map(function(chunk) {
return chunk.replace(/\x01/g, "|")
});
template.setName(chunks);
var parameterChunks = chunks.slice(1),
unnamedIdx = 1;
parameterChunks.forEach(function(chunk) {
var pName, pNum, pVal, indexOfEqualTo = chunk.indexOf("="),
indexOfOpenBraces = chunk.indexOf("{{"),
isWithoutEquals = !chunk.includes("="),
hasBracesBeforeEquals = chunk.includes("{{") && indexOfOpenBraces < indexOfEqualTo;
if (isWithoutEquals || hasBracesBeforeEquals) {
for (; template.getParam(unnamedIdx);) unnamedIdx++;
pNum = unnamedIdx, pVal = chunk.trim()
} else pName = chunk.slice(0, indexOfEqualTo).trim(), pVal = chunk.slice(indexOfEqualTo + 1).trim();
template.addParam(pName || pNum, pVal, chunk)
}), result.push(template)
}, n = wikitext.length, numUnclosed = 0, inComment = !1, inNowiki = !1, inParameter = !1, i = 0; i < n; i++) inComment || inNowiki || inParameter ? "|" === wikitext ? wikitext = strReplaceAt(wikitext, i, "\x01") : /^-->/.test(wikitext.slice(i, i + 3)) ? (inComment = !1, i += 2) : /^<\/nowiki ?>/.test(wikitext.slice(i, i + 10)) ? (inNowiki = !1, i += 8) : "}" === wikitext && "}" === wikitext && "}" === wikitext && (inParameter = !1, i += 2) : "{" === wikitext && "{" === wikitext && "{" === wikitext && "{" !== wikitext ? (inParameter = !0, i += 2) : "{" === wikitext && "{" === wikitext ? (0 === numUnclosed && (startIdx = i + 2), numUnclosed += 2, i++) : "}" === wikitext && "}" === wikitext ? (2 === numUnclosed && processTemplateText(startIdx, i), numUnclosed -= 2, i++) : "|" === wikitext && 2 < numUnclosed ? wikitext = strReplaceAt(wikitext, i, "\x01") : /^<!--/.test(wikitext.slice(i, i + 4)) ? (inComment = !0, i += 3) : /^<nowiki ?>/.test(wikitext.slice(i, i + 9)) && (inNowiki = !0, i += 7);
if (recursive) {
var subtemplates = (0, _util.filterAndMap)(result, function(template) {
return /\{\{(?:.|\n)*\}\}/.test(template.wikitext.slice(2, -2))
}, function(template) {
return parseTemplates(template.wikitext.slice(2, -2), !0)
});
return result.concat.apply(result, subtemplates)
}
return result
};
exports.getWithRedirectTo = function(templates) {
var templatesArray = Array.isArray(templates) ? templates : ;
return 0 === templatesArray.length ? $.Deferred().resolve() : _api.default.get({
action: "query",
format: "json",
titles: (0, _util.filterAndMap)(templatesArray, function(template) {
return null !== template.getTitle()
}, function(template) {
return template.getTitle().getPrefixedText()
}),
redirects: 1
}).then(function(result) {
return result && result.query ? (result.query.redirects && result.query.redirects.forEach(function(redirect) {
var i = templatesArray.findIndex(function(template) {
var title = template.getTitle();
return title && title.getPrefixedText() === redirect.from
}); - 1 !== i && (templatesArray.redirectTarget = mw.Title.newFromText(redirect.to))
}), Array.isArray(templates) ? templatesArray : templatesArray) : $.Deferred().reject("Empty response")
})
}, Template.prototype.getDataForParam = function(key, paraName) {
if (!this.paramData) return null;
var para = this.paramAliases || paraName;
if (this.paramData) {
var data = this.paramData;
return data && data.en && !Array.isArray(data) ? data.en : data
}
}, Template.prototype.isShellTemplate = function() {
var mainText = this.redirectTarget ? this.redirectTarget.getMainText() : this.getTitle().getMainText();
return _config.default.shellTemplates.includes(mainText)
}, Template.prototype.setParamDataAndSuggestions = function() {
var self = this,
paramDataSet = $.Deferred();
if (self.paramData) return paramDataSet.resolve();
var prefixedText = self.redirectTarget ? self.redirectTarget.getPrefixedText() : self.getTitle().getPrefixedText(),
cachedInfo = cache.read(prefixedText + "-params");
return cachedInfo && cachedInfo.value && cachedInfo.staleDate && null != cachedInfo.value.paramData && null != cachedInfo.value.parameterSuggestions && null != cachedInfo.value.paramAliases && (self.notemplatedata = cachedInfo.value.notemplatedata, self.paramData = cachedInfo.value.paramData, self.parameterSuggestions = cachedInfo.value.parameterSuggestions, self.paramAliases = cachedInfo.value.paramAliases, paramDataSet.resolve(), !(0, _util.isAfterDate)(cachedInfo.staleDate)) || _api.default.get({
action: "templatedata",
titles: prefixedText,
redirects: 1,
includeMissingTitles: 1
}).then(function(response) {
return response
}, function() {
return null
}).then(function(result) {
var id = result && $.map(result.pages, function(_value, key) {
return key
});
result && result.pages && !result.pages.notemplatedata && result.pages.params ? self.paramData = result.pages.params : (self.notemplatedata = !0, self.templatedataApiError = !result, self.paramData = _config.default.defaultParameterData), self.paramAliases = {}, $.each(self.paramData, function(paraName, paraData) {
if (paraData.aliases && paraData.aliases.length && paraData.aliases.forEach(function(alias) {
self.paramAliases = paraName
}), paraData.description && /\/.test(paraData.description.en)) try {
var allowedVals = JSON.parse(paraData.description.en.replace(/^.*\/, "]").replace(/].*$/, "]"));
self.paramData.allowedValues = allowedVals
} catch (e) {
console.warn(" Could not parse allowed values in description:\n " + paraData.description.en + "\n Check TemplateData for parameter |" + paraName + "= in " + self.getTitle().getPrefixedText())
}
});
var allParamsArray = !self.notemplatedata && result.pages.paramOrder || $.map(self.paramData, function(_val, key) {
return key
});
return self.parameterSuggestions = allParamsArray.filter(function(paramName) {
return paramName && "class" !== paramName && "importance" !== paramName
}).map(function(paramName) {
var optionObject = {
data: paramName
},
label = self.getDataForParam(label, paramName);
return label && (optionObject.label = label + " (|" + paramName + "=)"), optionObject
}), self.templatedataApiError || cache.write(prefixedText + "-params", {
notemplatedata: self.notemplatedata,
paramData: self.paramData,
parameterSuggestions: self.parameterSuggestions,
paramAliases: self.paramAliases
}, 1), !0
}).then(paramDataSet.resolve, paramDataSet.reject), paramDataSet
};
Template.prototype.addMissingParams = function() {
var thisTemplate = this;
if (("WikiProject Biography" === this.getTitle().getMainText() || this.redirectTarget && "WikiProject Biography" === this.redirectTarget.getMainText()) && !this.getParam("listas")) {
var subjectTitle = mw.Title.newFromText(_config.default.mw.wgPageName).getSubjectPage();
this.parameters.push({
name: "listas",
value: function(subjectTitle) {
var name = subjectTitle.getMainText().replace(/\s\(.*\)/, "");
if (-1 === name.indexOf(" ")) return name;
var generationalSuffix = "";
return / (?:r.?|+)$/.test(name) && (generationalSuffix = name.slice(name.lastIndexOf(" ")), -1 === (name = name.slice(0, name.lastIndexOf(" "))).indexOf(" ")) ? name + generationalSuffix : name.slice(name.lastIndexOf(" ") + 1).replace(/,$/, "") + ", " + name.slice(0, name.lastIndexOf(" ")) + generationalSuffix
}(subjectTitle),
autofilled: !0
})
}
return $.each(thisTemplate.paramData, function(paraName, paraData) {
if ((paraData.required || paraData.suggested) && !thisTemplate.getParam(paraName)) {
if (paraData.aliases.length)
if (thisTemplate.parameters.filter(function(p) {
var isAlias = paraData.aliases.includes(p.name),
isEmpty = !p.value;
return isAlias && !isEmpty
}).length) return;
thisTemplate.parameters.push({
name: paraName,
value: paraData.autovalue || null,
autofilled: !0
})
}
}), thisTemplate
}, Template.prototype.setClassesAndImportances = function() {
var _this = this,
parsed = $.Deferred();
if (this.classes && this.importances || this.isShellTemplate() || this.withoutRatings) return parsed.resolve();
var mainText = this.getTitle().getMainText(),
redirectTargetOrMainText = this.redirectTarget ? this.redirectTarget.getMainText() : mainText;
if (_config.default.customBanners) return this.classes = _config.default.customBanners.classes, this.importances = _config.default.customBanners.importances, parsed.resolve();
var cachedRatings = cache.read(mainText + "-ratings");
if (cachedRatings && cachedRatings.value && cachedRatings.staleDate && null != cachedRatings.value.classes && null != cachedRatings.value.importances && (this.classes = cachedRatings.value.classes, this.importances = cachedRatings.value.importances, parsed.resolve(), !(0, _util.isAfterDate)(cachedRatings.staleDate))) return parsed;
var wikitextToParse = "";
return _config.default.bannerDefaults.extendedClasses.forEach(function(classname, index) {
wikitextToParse += "{{" + mainText + "|class=" + classname + "|importance=" + (_config.default.bannerDefaults.extendedImportances || "") + "}}/n"
}), _api.default.get({
action: "parse",
title: "Talk:Sandbox",
text: wikitextToParse,
prop: "categorieshtml"
}).then(function(result) {
var catsHtml = result.parse.categorieshtml,
extendedClasses = _config.default.bannerDefaults.extendedClasses.filter(function(cl) {
return -1 !== catsHtml.indexOf(cl + "-Class")
});
return _this.classes = .concat(_toConsumableArray(_config.default.bannerDefaults.classes), _toConsumableArray(extendedClasses)), _this.importances = _config.default.bannerDefaults.extendedImportances.filter(function(imp) {
return -1 !== catsHtml.indexOf(imp + "-importance")
}), cache.write(mainText + "-ratings", {
classes: _this.classes,
importances: _this.importances
}, 1), !0
})
}
}, {
"./api": 15,
"./cache": 17,
"./config": 18,
"./util": 23
}],
4: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var _config = _interopRequireDefault(require("../../config")),
_BannerWidget = _interopRequireDefault(require("./BannerWidget")),
_util = require("../../util"),
_ParameterWidget = _interopRequireDefault(require("./ParameterWidget"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
function _slicedToArray(arr, i) {
return function(arr) {
if (Array.isArray(arr)) return arr
}(arr) || function(arr, i) {
if ("undefined" == typeof Symbol || !(Symbol.iterator in Object(arr))) return;
var _arr = ,
_n = !0,
_d = !1,
_e = void 0;
try {
for (var _s, _i = arr(); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0);
} catch (err) {
_d = !0, _e = err
} finally {
try {
_n || null == _i.return || _i.return()
} finally {
if (_d) throw _e
}
}
return _arr
}(arr, i) || function(o, minLen) {
if (!o) return;
if ("string" == typeof o) return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
"Object" === n && o.constructor && (n = o.constructor.name);
if ("Map" === n || "Set" === n) return Array.from(n);
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen)
}(arr, i) || function() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a () method.")
}()
}
function _arrayLikeToArray(arr, len) {
(null == len || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2 = arr;
return arr2
}
function BannerListWidget(config) {
config = config || {}, BannerListWidget.parent.call(this, config), OO.ui.mixin.GroupElement.call(this, {
$group: this.$element
}), this.$element.addClass("rater-bannerListWidget").css({
padding: "20px 10px 16px 10px"
}), this.preferences = config.preferences, this.oresClass = config.oresClass, this.changed = !1, this.aggregate({
remove: "bannerRemove"
}), this.connect(this, {
bannerRemove: "onBannerRemove"
}), this.aggregate({
changed: "bannerChanged"
}), this.connect(this, {
bannerChanged: "setChanged"
}), this.aggregate({
biographyBannerChange: "biographyBannerChanged"
}), this.connect(this, {
biographyBannerChanged: "syncShellTemplateWithBiographyBanner"
}), this.aggregate({
updatedSize: "bannerUpdatedSize"
}), this.connect(this, {
bannerUpdatedSize: "onUpdatedSize"
})
}
OO.inheritClass(BannerListWidget, OO.ui.Widget), OO.mixinClass(BannerListWidget, OO.ui.mixin.GroupElement), BannerListWidget.prototype.onUpdatedSize = function() {
this.emit("updatedSize")
}, BannerListWidget.prototype.setChanged = function() {
this.changed = !0
}, BannerListWidget.prototype.onBannerRemove = function(banner) {
this.removeItems(), this.setChanged()
}, BannerListWidget.prototype.syncShellTemplateWithBiographyBanner = function(biographyBanner) {
var bannerShellTemplate = this.items.find(function(banner) {
return banner.mainText === _config.default.shellTemplates || banner.redirectTargetMainText === _config.default.shellTemplates
});
if (bannerShellTemplate) {
.forEach(function(paramToSync) {
var _map2 = _slicedToArray(.map(function(banner) {
return banner.parameterList.getParameterItems().find(function(parameter) {
return parameter.name === paramToSync || banner.paramAliases === paramToSync
})
}), 2),
biographyParam = _map2,
shellParam = _map2;
if (biographyParam && !shellParam) {
var index = bannerShellTemplate.addParameterLayout.isVisible() ? -1 : bannerShellTemplate.parameterList.items.length - 1;
bannerShellTemplate.parameterList.addItems([new _ParameterWidget.default({
name: paramToSync,
value: (0, _util.normaliseYesNo)(biographyParam.value),
autofilled: !0
}, bannerShellTemplate.paramData && bannerShellTemplate.paramData)], index)
} else biographyParam && shellParam && (0, _util.normaliseYesNo)(shellParam.value) !== (0, _util.normaliseYesNo)(biographyParam.value) && (shellParam.setValue((0, _util.normaliseYesNo)(biographyParam.value)), shellParam.setAutofilled())
})
}
}, BannerListWidget.prototype.addItems = function(items, index) {
var _this = this;
return 0 === items.length || (OO.ui.mixin.GroupElement.prototype.addItems.call(this, items, index), this.items.length >= this.preferences.minForShell && !this.items.some(function(banner) {
return banner.isShellTemplate
}) && _BannerWidget.default.newFromTemplateName(_config.default.shellTemplates, {
withoutRatings: !0
}, {
preferences: this.preferences
}).then(function(shellBannerWidget) {
OO.ui.mixin.GroupElement.prototype.addItems.call(_this, , 0);
var biographyBanner = _this.items.find(function(banner) {
return "WikiProject Biography" === banner.mainText || "WikiProject Biography" === banner.redirectTargetMainText
});
biographyBanner && _this.syncShellTemplateWithBiographyBanner(biographyBanner), _this.onUpdatedSize()
}), this.autofillClassRatings(), this.autofillImportanceRatings(), this.onUpdatedSize()), this
}, BannerListWidget.prototype.autofillClassRatings = function() {
if (this.preferences.autofillClassFromOthers || this.preferences.autofillClassFromOres) {
var uniqueClassRatings = (0, _util.uniqueArray)((0, _util.filterAndMap)(this.items, function(banner) {
if (banner.isShellTemplate || !banner.hasClassRatings) return !1;
var classItem = banner.classDropdown.getMenu().findSelectedItem();
return classItem && classItem.getData()
}, function(banner) {
return banner.classDropdown.getMenu().findSelectedItem().getData()
}));
if (!(1 < uniqueClassRatings.length)) {
var autoClass;
if (1 === uniqueClassRatings.length && this.preferences.autofillClassFromOthers) autoClass = uniqueClassRatings;
else {
if (0 !== uniqueClassRatings.length || !this.preferences.autofillClassFromOres || !this.oresClass) return;
switch (this.oresClass) {
case "Stub":
case "Start":
case "C":
case "List":
autoClass = this.oresClass
}
}
this.items.forEach(function(banner) {
if (banner.hasClassRatings) {
var classItem = banner.classDropdown.getMenu().findSelectedItem();
classItem && classItem.getData() || (banner.classDropdown.getMenu().selectItemByData(autoClass), banner.classDropdown.setAutofilled(!0))
}
})
}
}
}, BannerListWidget.prototype.autofillImportanceRatings = function() {
if (this.preferences.autofillImportance && (this.pageInfo && this.pageInfo.isArticle && !this.pageInfo.redirect && !this.pageInfo.isDisambig)) {
this.items.forEach(function(banner) {
if (banner.hasImportanceRatings) {
var importanceItem = banner.importanceDropdown.getMenu().findSelectedItem();
importanceItem && importanceItem.getData() || (banner.importanceDropdown.getMenu().selectItemByData("Low"), banner.importanceDropdown.setAutofilled(!0))
}
})
}
}, BannerListWidget.prototype.setPreferences = function(prefs) {
this.preferences = prefs, this.items.forEach(function(banner) {
return banner.setPreferences(prefs)
}), this.autofillClassRatings(), this.autofillImportanceRatings()
}, BannerListWidget.prototype.makeWikitext = function() {
var bannersWikitext = (0, _util.filterAndMap)(this.items, function(banner) {
return !banner.isShellTemplate
}, function(banner) {
return banner.makeWikitext()
}).join("\n"),
shellTemplate = this.items.find(function(banner) {
return banner.isShellTemplate
});
if (!shellTemplate) return bannersWikitext;
var shellParam1 = new _ParameterWidget.default({
name: "1",
value: "\n" + bannersWikitext + "\n" + (shellTemplate.nonStandardTemplates ? shellTemplate.nonStandardTemplates + "\n" : "")
});
shellTemplate.parameterList.addItems();
var shellWikitext = shellTemplate.makeWikitext();
return shellTemplate.parameterList.removeItems(), shellWikitext
};
var _default = BannerListWidget;
exports.default = _default
}, {
"../../config": 18,
"../../util": 23,
"./BannerWidget": 5,
"./ParameterWidget": 9
}],
5: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var _ParameterListWidget = _interopRequireDefault(require("./ParameterListWidget")),
_ParameterWidget = _interopRequireDefault(require("./ParameterWidget")),
_DropdownParameterWidget = _interopRequireDefault(require("./DropdownParameterWidget")),
_SuggestionLookupTextInputWidget = _interopRequireDefault(require("./SuggestionLookupTextInputWidget")),
_util = require("../../util"),
_Template = require("../../Template"),
_HorizontalLayoutWidget = _interopRequireDefault(require("./HorizontalLayoutWidget"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
function _toConsumableArray(arr) {
return function(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr)
}(arr) || function(iter) {
if ("undefined" != typeof Symbol && Symbol.iterator in Object(iter)) return Array.from(iter)
}(arr) || function(o, minLen) {
if (!o) return;
if ("string" == typeof o) return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
"Object" === n && o.constructor && (n = o.constructor.name);
if ("Map" === n || "Set" === n) return Array.from(n);
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen)
}(arr) || function() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a () method.")
}()
}
function _arrayLikeToArray(arr, len) {
(null == len || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2 = arr;
return arr2
}
function BannerWidget(template, config) {
var _this = this;
if (config = config || {}, BannerWidget.super.call(this, config), this.$overlay = config.$overlay, this.preferences = config.preferences, this.paramData = template.paramData, this.paramAliases = template.paramAliases || {}, this.parameterSuggestions = template.parameterSuggestions, this.name = template.name, this.wikitext = template.wikitext, this.pipeStyle = template.pipeStyle, this.equalsStyle = template.equalsStyle, this.endBracesStyle = template.endBracesStyle, this.mainText = template.getTitle().getMainText(), this.redirectTargetMainText = template.redirectTarget && template.redirectTarget.getMainText(), this.isShellTemplate = template.isShellTemplate(), this.changed = template.parameters.some(function(parameter) {
return parameter.autofilled
}), this.hasClassRatings = template.classes && template.classes.length, this.hasImportanceRatings = template.importances && template.importances.length, this.inactiveProject = template.inactiveProject, this.removeButton = new OO.ui.ButtonWidget({
icon: "trash",
label: "Remove banner",
title: "Remove banner",
flags: "destructive",
$element: $('<div style="width:100%">')
}), this.clearButton = new OO.ui.ButtonWidget({
icon: "cancel",
label: "Clear parameters",
title: "Clear parameters",
flags: "destructive",
$element: $('<div style="width:100%">')
}), this.removeButton.$element.find("a").css("width", "100%"), this.clearButton.$element.find("a").css("width", "100%"), this.titleButtonsGroup = new OO.ui.ButtonGroupWidget({
items: ,
$element: $("<span style='width:100%;'>")
}), this.mainLabelPopupButton = new OO.ui.PopupButtonWidget({
label: "{{".concat(template.getTitle().getMainText(), "}}").concat(this.inactiveProject ? " (inactive)" : ""),
$element: $("<span style='display:inline-block;width:48%;margin-right:0;padding-right:8px'>"),
$overlay: this.$overlay,
indicator: "down",
framed: !1,
popup: {
$content: this.titleButtonsGroup.$element,
width: 200,
padded: !1,
align: "force-right",
anchor: !1
}
}), this.mainLabelPopupButton.$element.children("a").first().css({
"font-size": "110%"
}).find("span.oo-ui-labelElement-label").css({
"white-space": "normal"
}), this.hasClassRatings) {
this.classDropdown = new _DropdownParameterWidget.default({
label: new OO.ui.HtmlSnippet('<span style="color:#777">Class</span>'),
menu: {
items: [new OO.ui.MenuOptionWidget({
data: null,
label: new OO.ui.HtmlSnippet('<span style="color:#777">('.concat(config.isArticle ? "no class" : "auto-detect", ")</span>"))
})].concat(_toConsumableArray(template.classes.map(function(classname) {
return new OO.ui.MenuOptionWidget({
data: classname,
label: classname
})
})))
},
$overlay: this.$overlay
});
var classParam = template.parameters.find(function(parameter) {
return "class" === parameter.name
});
this.classDropdown.getMenu().selectItemByData(classParam && (0, _util.classMask)(classParam.value))
}
if (this.hasImportanceRatings) {
this.importanceDropdown = new _DropdownParameterWidget.default({
label: new OO.ui.HtmlSnippet('<span style="color:#777">Importance</span>'),
menu: {
items: [new OO.ui.MenuOptionWidget({
data: null,
label: new OO.ui.HtmlSnippet('<span style="color:#777">('.concat(config.isArticle ? "no importance" : "auto-detect", ")</span>"))
})].concat(_toConsumableArray(template.importances.map(function(importance) {
return new OO.ui.MenuOptionWidget({
data: importance,
label: importance
})
})))
},
$overlay: this.$overlay
});
var importanceParam = template.parameters.find(function(parameter) {
return "importance" === parameter.name
});
this.importanceDropdown.getMenu().selectItemByData(importanceParam && (0, _util.importanceMask)(importanceParam.value))
}
this.titleLayout = new OO.ui.HorizontalLayout({
items:
}), this.hasClassRatings && this.titleLayout.addItems(), this.hasImportanceRatings && this.titleLayout.addItems();
var parameterWidgets = (0, _util.filterAndMap)(template.parameters, function(param) {
return _this.isShellTemplate ? "1" != param.name || (_this.shellParam1Value = param.value, !1) : "class" !== param.name && "importance" !== param.name
}, function(param) {
return new _ParameterWidget.default(param, template.paramData, {
$overlay: _this.$overlay
})
});
this.parameterList = new _ParameterListWidget.default({
items: parameterWidgets,
preferences: this.preferences
}), this.addParameterNameInput = new _SuggestionLookupTextInputWidget.default({
suggestions: template.parameterSuggestions,
placeholder: "parameter name",
$element: $("<div style='display:inline-block;width:40%'>"),
validate: function(val) {
var _this$getAddParameter = this.getAddParametersInfo(val),
validName = _this$getAddParameter.validName,
name = _this$getAddParameter.name,
value = _this$getAddParameter.value;
return !name && !value || validName
}.bind(this),
allowSuggestionsWhenEmpty: !0,
$overlay: this.$overlay
}), this.updateAddParameterNameSuggestions(), this.addParameterValueInput = new _SuggestionLookupTextInputWidget.default({
placeholder: "parameter value",
$element: $("<div style='display:inline-block;width:40%'>"),
validate: function(val) {
var _this$getAddParameter2 = this.getAddParametersInfo(null, val),
validValue = _this$getAddParameter2.validValue,
name = _this$getAddParameter2.name,
value = _this$getAddParameter2.value;
return !name && !value || validValue
}.bind(this),
allowSuggestionsWhenEmpty: !0,
$overlay: this.$overlay
}), this.addParameterButton = new OO.ui.ButtonWidget({
label: "Add",
icon: "add",
flags: "progressive"
}).setDisabled(!0), this.addParameterControls = new _HorizontalLayoutWidget.default({
items: [this.addParameterNameInput, new OO.ui.LabelWidget({
label: "="
}), this.addParameterValueInput, this.addParameterButton]
}), this.addParameterLayout = new OO.ui.FieldLayout(this.addParameterControls, {
label: "Add parameter:",
align: "top"
}).toggle(!1), this.addParameterLayout.$element.find(".oo-ui-fieldLayout-messages").css({
clear: "both",
"padding-top": 0
}), this.$element.addClass("rater-bannerWidget").append(this.titleLayout.$element, this.parameterList.$element, this.addParameterLayout.$element), this.isShellTemplate || this.$element.append($("<hr>")), this.isShellTemplate && this.$element.css({
background: "#eee",
"border-radius": "10px",
padding: "0 10px 5px",
"margin-bottom": "12px",
"font-size": "92%"
}), this.hasClassRatings && this.classDropdown.connect(this, {
change: "onClassChange"
}), this.hasImportanceRatings && this.importanceDropdown.connect(this, {
change: "onImportanceChange"
}), this.parameterList.connect(this, {
change: "onParameterChange",
addParametersButtonClick: "showAddParameterInputs",
updatedSize: "onUpdatedSize"
}), this.addParameterButton.connect(this, {
click: "onParameterAdd"
}), this.addParameterNameInput.connect(this, {
change: "onAddParameterNameChange",
enter: "onAddParameterNameEnter",
choose: "onAddParameterNameEnter"
}), this.addParameterValueInput.connect(this, {
change: "onAddParameterValueChange",
enter: "onAddParameterValueEnter",
choose: "onAddParameterValueEnter"
}), this.removeButton.connect(this, {
click: "onRemoveButtonClick"
}), this.clearButton.connect(this, {
click: "onClearButtonClick"
}), this.preferences.bypassRedirects && this.bypassRedirect()
}
OO.inheritClass(BannerWidget, OO.ui.Widget), BannerWidget.newFromTemplateName = function(templateName, data, config) {
var template = new _Template.Template;
return template.name = templateName, data && data.withoutRatings && (template.withoutRatings = !0), (0, _Template.getWithRedirectTo)(template).then(function(template) {
return $.when(template.setClassesAndImportances(), template.setParamDataAndSuggestions()).then(function() {
return template.addMissingParams(), template
})
}).then(function(template) {
return new BannerWidget(template, config)
})
}, BannerWidget.prototype.onUpdatedSize = function() {
this.emit("updatedSize")
}, BannerWidget.prototype.setChanged = function() {
this.changed = !0, this.emit("changed")
}, BannerWidget.prototype.onParameterChange = function() {
this.setChanged(), "WikiProject Biography" !== this.mainText && "WikiProject Biography" !== this.redirectTargetMainText || this.emit("biographyBannerChange"), this.updateAddParameterNameSuggestions()
}, BannerWidget.prototype.onClassChange = function() {
this.setChanged(), this.classChanged = !0;
var classItem = this.classDropdown.getMenu().findSelectedItem();
classItem && null == classItem.getData() && this.classDropdown.getMenu().selectItem()
}, BannerWidget.prototype.onImportanceChange = function() {
this.setChanged(), this.importanceChanged = !0;
var importanceItem = this.importanceDropdown.getMenu().findSelectedItem();
importanceItem && null == importanceItem.getData() && this.importanceDropdown.getMenu().selectItem()
}, BannerWidget.prototype.showAddParameterInputs = function() {
this.addParameterLayout.toggle(!0), this.addParameterNameInput.focus(), this.onUpdatedSize()
}, BannerWidget.prototype.getAddParametersInfo = function(nameInputVal, valueInputVal) {
var name = nameInputVal && nameInputVal.trim() || this.addParameterNameInput.getValue().trim(),
paramAlreadyIncluded = "class" === name || "importance" === name || "1" === name && this.isShellTemplate || this.parameterList.getParameterItems().some(function(paramWidget) {
return paramWidget.name === name
}),
value = valueInputVal && valueInputVal.trim() || this.addParameterValueInput.getValue().trim(),
autovalue = name && this.paramData && this.paramData.autovalue || null;
return {
validName: !(!name || paramAlreadyIncluded),
validValue: !(!value && !autovalue),
isAutovalue: !(value || !autovalue),
isAlreadyIncluded: !(!name || !paramAlreadyIncluded),
name: name,
value: value,
autovalue: autovalue
}
}, BannerWidget.prototype.onAddParameterNameChange = function() {
var _this$getAddParameter3 = this.getAddParametersInfo(),
validName = _this$getAddParameter3.validName,
validValue = _this$getAddParameter3.validValue,
isAutovalue = _this$getAddParameter3.isAutovalue,
isAlreadyIncluded = _this$getAddParameter3.isAlreadyIncluded,
name = _this$getAddParameter3.name,
autovalue = _this$getAddParameter3.autovalue;
this.addParameterValueInput.$input.attr("placeholder", autovalue || "");
var allowedValues = this.paramData && this.paramData.allowedValues && this.paramData.allowedValues.map(function(val) {
return {
data: val,
label: val
}
});
this.addParameterValueInput.setSuggestions(allowedValues || ), this.addParameterButton.setDisabled(!validName || !validValue), this.addParameterLayout.setNotices(validName && isAutovalue ? : ), this.addParameterLayout.setErrors(isAlreadyIncluded ? : )
}, BannerWidget.prototype.onAddParameterNameEnter = function() {
this.addParameterValueInput.focus()
}, BannerWidget.prototype.onAddParameterValueChange = function() {
var _this$getAddParameter4 = this.getAddParametersInfo(),
validName = _this$getAddParameter4.validName,
validValue = _this$getAddParameter4.validValue,
isAutovalue = _this$getAddParameter4.isAutovalue;
this.addParameterButton.setDisabled(!validName || !validValue), this.addParameterLayout.setNotices(validName && isAutovalue ? : )
}, BannerWidget.prototype.onAddParameterValueEnter = function() {
this.onAddParameterValueChange(), this.addParameterButton.isDisabled() || this.onParameterAdd()
}, BannerWidget.prototype.onParameterAdd = function() {
var _this$getAddParameter5 = this.getAddParametersInfo(),
validName = _this$getAddParameter5.validName,
validValue = _this$getAddParameter5.validValue,
name = _this$getAddParameter5.name,
value = _this$getAddParameter5.value,
autovalue = _this$getAddParameter5.autovalue;
if (validName && validValue) {
var newParameter = new _ParameterWidget.default({
name: name,
value: value || autovalue
}, this.paramData, {
$overlay: this.$overlay
});
this.parameterList.addItems(), this.addParameterNameInput.setValue(""), this.addParameterValueInput.setValue(""), this.addParameterNameInput.$input.focus()
}
}, BannerWidget.prototype.updateAddParameterNameSuggestions = function() {
var paramsInUse = {};
this.parameterList.getParameterItems().forEach(function(paramWidget) {
return paramsInUse = !0
}), this.addParameterNameInput.setSuggestions(this.parameterSuggestions.filter(function(suggestion) {
return !paramsInUse
}))
}, BannerWidget.prototype.onRemoveButtonClick = function() {
this.emit("remove")
}, BannerWidget.prototype.onClearButtonClick = function() {
this.parameterList.clearItems(this.parameterList.getParameterItems()), this.hasClassRatings && this.classDropdown.getMenu().selectItem(), this.hasImportanceRatings && this.importanceDropdown.getMenu().selectItem()
}, BannerWidget.prototype.bypassRedirect = function() {
this.redirectTargetMainText && (this.bypassedName = this.name, this.mainLabelPopupButton.setLabel("{{".concat(this.redirectTargetMainText, "}}").concat(this.inactiveProject ? " (inactive)" : "")), this.name = this.redirectTargetMainText, this.mainText = this.redirectTargetMainText, this.redirectTargetMainText = null, this.setChanged())
}, BannerWidget.prototype.makeWikitext = function() {
if (!this.changed && this.wikitext) return this.wikitext;
var pipe = this.pipeStyle,
equals = this.equalsStyle,
classItem = this.hasClassRatings && this.classDropdown.getMenu().findSelectedItem(),
classVal = classItem && classItem.getData(),
importanceItem = this.hasImportanceRatings && this.importanceDropdown.getMenu().findSelectedItem(),
importanceVal = importanceItem && importanceItem.getData();
return ("{{" + this.name + (this.hasClassRatings && null != classVal ? "".concat(pipe, "class").concat(equals).concat(classVal || "") : "") + (this.hasImportanceRatings && null != importanceVal ? "".concat(pipe, "importance").concat(equals).concat(importanceVal || "") : "") + this.parameterList.getParameterItems().map(function(parameter) {
return parameter.makeWikitext(pipe, equals)
}).join("") + this.endBracesStyle).replace(/\n+}}$/, "\n}}")
}, BannerWidget.prototype.setPreferences = function(prefs) {
this.preferences = prefs, this.preferences.bypassRedirects && this.bypassRedirect(), this.parameterList.setPreferences(prefs)
};
var _default = BannerWidget;
exports.default = _default
}, {
"../../Template": 3,
"../../util": 23,
"./DropdownParameterWidget": 6,
"./HorizontalLayoutWidget": 7,
"./ParameterListWidget": 8,
"./ParameterWidget": 9,
"./SuggestionLookupTextInputWidget": 11
}],
6: [function(require, module, exports) {
"use strict";
function DropdownParameterWidget(config) {
config = $.extend({
$element: $("<span style='display:inline-block;width:24%'>")
}, config || {}), DropdownParameterWidget.super.call(this, config), this.$overlay = config.$overlay, this.$element.addClass("rater-dropdownParameterWidget"), this.autofilled = !!config.autofilled, this.autofilledIcon = new OO.ui.IconWidget({
icon: "robot",
title: "Autofilled by Rater",
flags: "progressive",
$element: $("<span style='margin: 0 -5px 0 5px;min-width: 16px;width: 16px;left:unset;'>")
}).toggle(this.autofilled), this.$element.find(".oo-ui-indicatorElement-indicator").before(this.autofilledIcon.$element), this.menu.connect(this, {
choose: "onDropdownMenuChoose",
select: "onDropdownMenuSelect"
})
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0, OO.inheritClass(DropdownParameterWidget, OO.ui.DropdownWidget), DropdownParameterWidget.prototype.setAutofilled = function(setAutofill) {
this.autofilledIcon.toggle(!!setAutofill), this.$element.find(".oo-ui-dropdownWidget-handle").css({
border: setAutofill ? "1px dashed #36c" : ""
}), this.autofilled = !!setAutofill
}, DropdownParameterWidget.prototype.onDropdownMenuChoose = function() {
this.setAutofilled(!1), this.emit("change")
}, DropdownParameterWidget.prototype.onDropdownMenuSelect = function() {
this.emit("change")
}, DropdownParameterWidget.prototype.getValue = function() {
var selectedItem = this.menu.findSelectedItem();
return selectedItem && selectedItem.getData()
};
var _default = DropdownParameterWidget;
exports.default = _default
}, {}],
7: [function(require, module, exports) {
"use strict";
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable
})), keys.push.apply(keys, symbols)
}
return keys
}
function _defineProperty(obj, key, value) {
return key in obj ? Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}) : obj = value, obj
}
function HorizontalLayoutWidget(config) {
config = config || {}, HorizontalLayoutWidget.super.call(this, {}), this.layout = new OO.ui.HorizontalLayout(function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments ? arguments : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
_defineProperty(target, key, source)
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key))
})
}
return target
}({}, config, {
$element: this.$element
}))
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0, OO.inheritClass(HorizontalLayoutWidget, OO.ui.Widget);
var _default = HorizontalLayoutWidget;
exports.default = _default
}, {}],
8: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
function ParameterListWidget(config) {
config = config || {}, ParameterListWidget.parent.call(this, config), OO.ui.mixin.GroupElement.call(this, {
$group: this.$element
}), this.addItems(config.items), this.$element.addClass("rater-parameterListWidget"), this.preferences = config.preferences;
var displayLimit = this.preferences.collapseParamsLowerLimit + 1;
if (displayLimit && this.items.length > displayLimit) {
for (var hiddenCount = 0, i = displayLimit - 1 - 1; i < this.items.length; i++) this.items.autofilled || (this.items.toggle(!1), hiddenCount++);
0 < hiddenCount && (this.showMoreParametersButton = new OO.ui.ButtonWidget({
label: "Show " + hiddenCount + " more " + (1 === hiddenCount ? "parameter" : "parameters"),
framed: !1,
$element: $("<span style='margin-bottom:0'>")
}), this.addItems())
}
this.addParametersButton = new OO.ui.ButtonWidget({
label: "Add parameter",
icon: "add",
framed: !1,
$element: $("<span style='margin-bottom:0'>")
}), this.addItems(), this.aggregate({
delete: "parameterDelete"
}), this.connect(this, {
parameterDelete: "onParameterDelete"
}), this.aggregate({
change: "parameterChange"
}), this.connect(this, {
parameterChange: "onParameterChange"
}), this.aggregate({
updatedSize: "parameterUpdatedSize"
}), this.connect(this, {
parameterUpdatedSize: "onUpdatedSize"
}), this.showMoreParametersButton && this.showMoreParametersButton.connect(this, {
click: "onShowMoreParametersButtonClick"
}), this.addParametersButton.connect(this, {
click: "onAddParametersButtonClick"
})
}
OO.inheritClass(ParameterListWidget, OO.ui.Widget), OO.mixinClass(ParameterListWidget, OO.ui.mixin.GroupElement), ParameterListWidget.prototype.onUpdatedSize = function() {
this.emit("updatedSize")
}, ParameterListWidget.prototype.addItems = function(items, index) {
return 0 === items.length || (OO.ui.mixin.GroupElement.prototype.addItems.call(this, items, index), this.onUpdatedSize()), this
}, ParameterListWidget.prototype.onParameterDelete = function(parameter) {
this.removeItems(), this.emit("change")
}, ParameterListWidget.prototype.onParameterChange = function() {
this.emit("change")
}, ParameterListWidget.prototype.getParameterItems = function() {
return this.items.filter(function(item) {
return "ParameterWidget" === item.constructor.name
})
}, ParameterListWidget.prototype.onShowMoreParametersButtonClick = function() {
this.removeItems(), this.items.forEach(function(parameterWidget) {
return parameterWidget.toggle(!0)
}), this.onUpdatedSize()
}, ParameterListWidget.prototype.onAddParametersButtonClick = function() {
this.removeItems(), this.emit("addParametersButtonClick")
}, ParameterListWidget.prototype.makeWikitext = function(pipeStyle, equalsStyle) {
return this.getParameterItems().map(function(parameter) {
return parameter.makeWikitext(pipeStyle, equalsStyle)
}).join("")
}, ParameterListWidget.prototype.setPreferences = function(prefs) {
this.preferences = prefs;
var params = this.getParameterItems();
if (!(params.length <= this.preferences.collapseParamsLowerLimit)) {
var hiddenParams = params.filter(function(param) {
return !param.isVisible()
}),
visibleParamsCount = params.length - hiddenParams.length;
if (!(0 === hiddenParams || visibleParamsCount >= this.preferences.collapseParamsLowerLimit)) {
for (var numToUnhide = Math.min(this.preferences.collapseParamsLowerLimit - visibleParamsCount, hiddenParams.length), i = 0; i < numToUnhide; i++) hiddenParams.toggle(!0);
var stillHiddenCount = hiddenParams.length - numToUnhide;
0 == stillHiddenCount ? this.removeItems() : this.showMoreParametersButton.setLabel("Show " + stillHiddenCount + " more " + (1 == stillHiddenCount ? "paramter" : "paramters"))
}
}
};
var _default = ParameterListWidget;
exports.default = _default
}, {}],
9: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var obj, _util = require("../../util"),
_HorizontalLayoutWidget = (obj = require("./HorizontalLayoutWidget")) && obj.__esModule ? obj : {
default: obj
};
function ParameterWidget(parameter, paramData, config) {
switch (config = config || {}, ParameterWidget.super.call(this, config), this.$overlay = config.$overlay, this.name = parameter.name, this.value = parameter.value, this.autofilled = parameter.autofilled, this.isInvalid = null == parameter.value, this.paramData = paramData || {}, this.allowedValues = this.paramData.allowedValues || , this.isRequired = this.paramData.required, this.isSuggested = this.paramData.suggested, this.allowedValues.length) {
case 1:
this.allowedValues = null;
case 2:
var isFirstAllowedVal = 0 === this.allowedValues.indexOf(parameter.value) || 0 === this.allowedValues.map(_util.normaliseYesNo).indexOf((0, _util.normaliseYesNo)(parameter.value)),
isSecondAllowedVal = 1 === this.allowedValues.indexOf(parameter.value || null) || 1 === this.allowedValues.map(_util.normaliseYesNo).indexOf(parameter.value ? (0, _util.normaliseYesNo)(parameter.value) : null),
isIndeterminate = !isFirstAllowedVal && !isSecondAllowedVal;
this.checkbox = new OO.ui.CheckboxInputWidget({
selected: isIndeterminate ? void 0 : isFirstAllowedVal,
indeterminate: isIndeterminate || void 0,
$element: $("<label style='margin:0 0 0 5px'>")
})
}
this.input = new OO.ui.ComboBoxInputWidget({
value: this.value,
options: (0, _util.filterAndMap)(this.allowedValues, function(val) {
return null !== val
}, function(val) {
return {
data: val,
label: val
}
}),
$element: $("<div style='margin-bottom:0;'>"),
$overlay: this.$overlay
}), this.input.$element.find("input").css({
"padding-top": 0,
"padding-bottom": "2px",
height: "24px"
}), this.input.$element.find("span.oo-ui-labelElement-label").css({
"line-height": "normal"
}), this.input.$element.find("a.oo-ui-buttonElement-button").css({
"padding-top": 0,
height: "24px",
"min-height": "0"
}), this.confirmButton = new OO.ui.ButtonWidget({
icon: "check",
label: "Done",
framed: !1,
flags: "progressive",
$element: $("<span style='margin-right:0'>")
}), this.cancelButton = new OO.ui.ButtonWidget({
icon: "undo",
label: "Cancel",
framed: !1
}), this.deleteButton = new OO.ui.ButtonWidget({
icon: this.isRequired ? "restore" : "trash",
label: this.isRequired ? "Required parameter" : "Delete",
framed: !1,
flags: "destructive",
disabled: this.isRequired
}), this.editButtonControls = new OO.ui.ButtonGroupWidget({
items: ,
$element: $("<span style='font-size:92%'>")
}), this.editButtonControls.$element.find("a span:first-child").css({
"min-width": "unset",
width: "16px",
"margin-right": 0
}), this.editLayoutControls = new _HorizontalLayoutWidget.default({
items:
}), this.editLayout = new OO.ui.FieldLayout(this.editLayoutControls, {
label: this.name + " =",
align: "top",
help: this.paramData.description && this.paramData.description.en || !1,
helpInline: !0
}).toggle(), this.editLayout.$element.find("label.oo-ui-inline-help").css({
margin: "-10px 0 5px 10px"
}), this.invalidIcon = new OO.ui.IconWidget({
icon: "block",
title: "Invalid parameter: no value specified!",
flags: "destructive",
$element: $("<span style='margin: 0 5px 0 -5px; min-width: 16px; width: 16px;'>")
}).toggle(this.isInvalid), this.fullLabel = new OO.ui.LabelWidget({
label: this.name + (this.value ? " = " + this.value : " "),
$element: $("<label style='margin: 0;'>")
}), this.autofilledIcon = new OO.ui.IconWidget({
icon: "robot",
title: "Autofilled by Rater",
flags: "progressive",
$element: $("<span style='margin: 0 -5px 0 5px;min-width: 16px;width: 16px;'>")
}).toggle(this.autofilled), this.editButton = new OO.ui.ButtonWidget({
icon: "edit",
framed: !1,
$element: $("<span style='margin-bottom: 0;'>")
}), this.editButton.$element.find("a").css({
"border-radius": "0 10px 10px 0",
"margin-left": "5px"
}), this.editButton.$element.find("a span").first().css({
"min-width": "unset",
width: "16px"
}), this.readLayout = new OO.ui.HorizontalLayout({
items: ,
$element: $("<span style='margin:0;width:unset;'>")
}), this.checkbox && this.readLayout.addItems(, 2), this.$element = $("<div>").addClass("rater-parameterWidget").css({
width: "unset",
display: "inline-block",
border: this.autofilled ? "1px dashed #36c" : "1px solid #ddd",
"border-radius": "10px",
"padding-left": "10px",
margin: "0 8px 8px 0",
background: this.isInvalid ? "#fddd" : "#fffe"
}).append(this.readLayout.$element, this.editLayout.$element), this.editButton.connect(this, {
click: "onEditClick"
}), this.confirmButton.connect(this, {
click: "onConfirmClick"
}), this.cancelButton.connect(this, {
click: "onCancelClick"
}), this.deleteButton.connect(this, {
click: "onDeleteClick"
}), this.checkbox && this.checkbox.connect(this, {
change: "onCheckboxChange"
})
}
OO.inheritClass(ParameterWidget, OO.ui.Widget), ParameterWidget.prototype.onUpdatedSize = function() {
this.emit("updatedSize")
}, ParameterWidget.prototype.onEditClick = function() {
this.readLayout.toggle(!1), this.editLayout.toggle(!0), this.$element.css({
background: "#fffe"
}), this.input.focus(), this.onUpdatedSize()
}, ParameterWidget.prototype.onConfirmClick = function() {
this.setValue(this.input.getValue()), this.readLayout.toggle(!0), this.editLayout.toggle(!1), this.onUpdatedSize()
}, ParameterWidget.prototype.onCancelClick = function() {
this.input.setValue(this.value), this.readLayout.toggle(!0), this.editLayout.toggle(!1), this.onUpdatedSize()
}, ParameterWidget.prototype.onDeleteClick = function() {
this.emit("delete")
}, ParameterWidget.prototype.onCheckboxChange = function(isSelected, isIndeterminate) {
isIndeterminate || (isSelected ? this.setValue(this.allowedValues) : this.setValue(this.allowedValues))
}, ParameterWidget.prototype.setValue = function(val) {
if (this.autofilled = !1, this.autofilledIcon.toggle(!1), this.$element.css({
border: "1px solid #ddd"
}), this.value = val, this.input.setValue(this.value), this.isInvalid = null == this.value, this.invalidIcon.toggle(this.isInvalid), this.$element.css({
background: this.isInvalid ? "#fddd" : "#fffe"
}), this.fullLabel.setLabel(this.name + (this.value ? " = " + this.value : "")), this.checkbox) {
var isFirstAllowedVal = 0 === this.allowedValues.indexOf(val) || 0 === this.allowedValues.map(_util.normaliseYesNo).indexOf((0, _util.normaliseYesNo)(val)),
isSecondAllowedVal = 1 === this.allowedValues.indexOf(val || null) || 1 === this.allowedValues.map(_util.normaliseYesNo).indexOf(val ? (0, _util.normaliseYesNo)(val) : null),
isIndeterminate = !isFirstAllowedVal && !isSecondAllowedVal;
if (this.checkbox.setIndeterminate(isIndeterminate, !0), !isIndeterminate) {
var isSelected = isFirstAllowedVal;
this.checkbox.setSelected(isSelected, !0)
}
}
this.emit("change")
}, ParameterWidget.prototype.setAutofilled = function() {
this.autofilled = !0, this.autofilledIcon.toggle(!0), this.$element.css({
border: "1px dashed #36c"
})
}, ParameterWidget.prototype.makeWikitext = function(pipeStyle, equalsStyle) {
return this.isInvalid ? "" : pipeStyle + this.name + equalsStyle + (this.value || "")
}, ParameterWidget.prototype.focusInput = function() {
return this.input.focus()
};
var _default = ParameterWidget;
exports.default = _default
}, {
"../../util": 23,
"./HorizontalLayoutWidget": 7
}],
10: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var obj, _config = (obj = require("../../config")) && obj.__esModule ? obj : {
default: obj
};
function PrefsFormWidget(config) {
for (var prefName in config = config || {}, PrefsFormWidget.super.call(this, config), this.$element.addClass("rater-prefsFormWidget"), this.layout = new OO.ui.FieldsetLayout({
label: "Preferences",
$element: this.$element
}), this.preferences = {
autostart: {
input: new OO.ui.ToggleSwitchWidget,
label: "Autostart Rater"
},
autostartRedirects: {
input: new OO.ui.ToggleSwitchWidget,
label: "Autostart on redirects"
},
autostartNamespaces: {
input: new mw.widgets.NamespacesMultiselectWidget,
label: "Autostart in these namespaces"
},
minForShell: {
input: new OO.ui.NumberInputWidget({
min: 2
}),
label: "Minimum number of banners for WikiProject banner shell"
},
bypassRedirects: {
input: new OO.ui.ToggleSwitchWidget,
label: "Bypass redirects to banners"
},
autofillClassFromOthers: {
input: new OO.ui.ToggleSwitchWidget,
label: "Autofill class from other banners"
},
autofillClassFromOres: {
input: new OO.ui.ToggleSwitchWidget,
label: "Autofill class based on ORES prediction"
},
autofillImportance: {
input: new OO.ui.ToggleSwitchWidget,
label: "Autofill low importance"
},
collapseParamsLowerLimit: {
input: new OO.ui.NumberInputWidget({
min: 1
}),
label: "Minimum number of parameters to show uncollapsed"
},
watchlist: {
input: new OO.ui.ButtonSelectWidget({
items: [new OO.ui.ButtonOptionWidget({
data: "preferences",
label: "Default",
title: "Uses the same setting as if you manually edited the page, as per Special:Preferences"
}), new OO.ui.ButtonOptionWidget({
data: "watch",
label: "Always",
title: "Always add pages Rater edits to your watchlist"
}), new OO.ui.ButtonOptionWidget({
data: "nochange",
label: "Never",
title: "Never add pages Rater edit to your watchlist"
})]
}).selectItemByData("preferences"),
label: "Add edited pages to watchlist"
},
resetCache: {
input: new OO.ui.ButtonWidget({
label: "Reset cache",
title: "Remove cached data, including list of WikiProjects and template parameters",
flags:
})
}
}, this.preferences) this.layout.addItems(.input, {
label: this.preferences.label,
align: "right"
})]);
this.preferences.resetCache.input.connect(this, {
click: "onResetCacheClick"
})
}
OO.inheritClass(PrefsFormWidget, OO.ui.Widget), PrefsFormWidget.prototype.setPrefValues = function(prefs) {
var _this = this,
_loop = function(prefName) {
var value = prefs,
input = _this.preferences && _this.preferences.input;
switch (input && input.constructor.name) {
case "OoUiButtonSelectWidget":
input.selectItemByData(value);
break;
case "OoUiNumberInputWidget":
case "OoUiToggleSwitchWidget":
input.setValue(value);
break;
case "MwWidgetsNamespacesMultiselectWidget":
input.clearItems(), value.forEach(function(ns) {
return input.addTag(ns.toString(), 0 === ns ? "(Main)" : _config.default.mw.wgFormattedNamespaces)
})
}
};
for (var prefName in prefs) _loop(prefName)
}, PrefsFormWidget.prototype.getPrefs = function() {
var prefs = {};
for (var prefName in this.preferences) {
var input = this.preferences.input,
value = void 0;
switch (input.constructor.name) {
case "OoUiButtonSelectWidget":
value = input.findSelectedItem().getData();
break;
case "OoUiToggleSwitchWidget":
value = input.getValue();
break;
case "OoUiNumberInputWidget":
value = Number(input.getValue());
break;
case "MwWidgetsNamespacesMultiselectWidget":
value = input.getValue().map(Number)
}
prefs = value
}
return prefs
}, PrefsFormWidget.prototype.onResetCacheClick = function() {
var _this2 = this;
OO.ui.confirm("After reseting cache, Rater will close and restart. Any changes made will be discarded.").then(function(confirmed) {
confirmed && _this2.emit("resetCache")
})
};
var _default = PrefsFormWidget;
exports.default = _default
}, {
"../../config": 18
}],
11: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var SuggestionLookupTextInputWidget = function(config) {
OO.ui.TextInputWidget.call(this, config), OO.ui.mixin.LookupElement.call(this, config), this.suggestions = Array.isArray(config.suggestions) ? config.suggestions : , this.$element.addClass("rater-suggestionLookupTextInputWidget")
};
OO.inheritClass(SuggestionLookupTextInputWidget, OO.ui.TextInputWidget), OO.mixinClass(SuggestionLookupTextInputWidget, OO.ui.mixin.LookupElement), SuggestionLookupTextInputWidget.prototype.setSuggestions = function(suggestions) {
Array.isArray(suggestions) ? this.suggestions = suggestions : null != suggestions && console.warn(" SuggestionLookupTextInputWidget.prototype.setSuggestions called with a non-array value:", suggestions)
}, SuggestionLookupTextInputWidget.prototype.getLookupRequest = function() {
return $.Deferred().resolve(new RegExp("\\b" + mw.util.escapeRegExp(this.getValue()), "i")).promise({
abort: function() {}
})
}, SuggestionLookupTextInputWidget.prototype.getLookupCacheDataFromResponse = function(response) {
return response ||
}, SuggestionLookupTextInputWidget.prototype.getLookupMenuOptionsFromData = function(pattern) {
return this.suggestions.filter(function(suggestionItem) {
return pattern.test(suggestionItem.label) || !suggestionItem.label && pattern.test(suggestionItem.data)
}).map(function(optionItem) {
return new OO.ui.MenuOptionWidget({
data: optionItem.data,
label: optionItem.label || optionItem.data
})
})
}, SuggestionLookupTextInputWidget.prototype.onLookupMenuChoose = function(item) {
var itemData = item.getData();
itemData && itemData.name && item.setData(itemData.name), this.$input.blur(), OO.ui.mixin.LookupElement.prototype.onLookupMenuChoose.call(this, item), this.emit("choose", itemData)
};
var _default = SuggestionLookupTextInputWidget;
exports.default = _default
}, {}],
12: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var _config = _interopRequireDefault(require("../../config")),
_SuggestionLookupTextInputWidget = _interopRequireDefault(require("./SuggestionLookupTextInputWidget")),
_getBanners = require("../../getBanners");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
function _toConsumableArray(arr) {
return function(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr)
}(arr) || function(iter) {
if ("undefined" != typeof Symbol && Symbol.iterator in Object(iter)) return Array.from(iter)
}(arr) || function(o, minLen) {
if (!o) return;
if ("string" == typeof o) return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
"Object" === n && o.constructor && (n = o.constructor.name);
if ("Map" === n || "Set" === n) return Array.from(n);
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen)
}(arr) || function() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a () method.")
}()
}
function _arrayLikeToArray(arr, len) {
(null == len || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2 = arr;
return arr2
}
function TopBarWidget(config) {
var _this = this;
config = $.extend({
expanded: !1,
framed: !1,
padded: !1
}, config || {}), TopBarWidget.super.call(this, config), this.$overlay = config.$overlay, this.searchBox = new _SuggestionLookupTextInputWidget.default({
placeholder: "Add a WikiProject...",
$element: $("<div style='display:inline-block; margin:0 -1px; width:calc(100% - 55px);'>"),
$overlay: this.$overlay
}), (0, _getBanners.getBannerNames)().then(function(banners) {
return .concat(_toConsumableArray(banners.withRatings.map(function(bannerName) {
return {
label: bannerName.replace("WikiProject ", ""),
data: {
name: bannerName
}
}
})), _toConsumableArray(banners.withoutRatings.map(function(bannerName) {
return {
label: bannerName.replace("WikiProject ", ""),
data: {
name: bannerName,
withoutRatings: !0
}
}
})), _toConsumableArray(banners.wrappers.map(function(bannerName) {
return {
label: bannerName.replace("WikiProject ", "") + " ",
data: {
name: bannerName,
wrapper: !0
}
}
})), _toConsumableArray(banners.notWPBM.map(function(bannerName) {
return {
label: bannerName.replace("WikiProject ", ""),
data: {
name: bannerName
}
}
})), _toConsumableArray(banners.inactive.map(function(bannerName) {
return {
label: bannerName.replace("WikiProject ", "") + " ",
data: {
name: bannerName,
withoutRatings: !0
}
}
})), _toConsumableArray(banners.wir.map(function(bannerName) {
return {
label: bannerName + " ",
data: {
name: bannerName,
withoutRatings: !0
}
}
})))
}).then(function(bannerOptions) {
return _this.searchBox.setSuggestions(bannerOptions)
}), this.addBannerButton = new OO.ui.ButtonWidget({
icon: "add",
title: "Add",
flags: "progressive",
$element: $("<span style='float:right;margin: 0;transform: translateX(-12px);'>")
});
var $searchContainer = $("<div style='display:inline-block; flex-shrink:1; flex-grow:100; min-width:250px; width:50%;'>").append(this.searchBox.$element, this.addBannerButton.$element);
this.setAllDropDown = new OO.ui.DropdownWidget({
icon: "tag",
label: "Set all...",
invisibleLabel: !0,
menu: {
items: [new OO.ui.MenuSectionOptionWidget({
label: "Classes"
}), new OO.ui.MenuOptionWidget({
data: {
class: null
},
label: new OO.ui.HtmlSnippet('<span style="color:#777">(no class)</span>')
})].concat(_toConsumableArray(_config.default.bannerDefaults.classes.map(function(classname) {
return new OO.ui.MenuOptionWidget({
data: {
class: classname
},
label: classname
})
})), [new OO.ui.MenuSectionOptionWidget({
label: "Importances"
}), new OO.ui.MenuOptionWidget({
data: {
importance: null
},
label: new OO.ui.HtmlSnippet('<span style="color:#777">(no importance)</span>')
})], _toConsumableArray(_config.default.bannerDefaults.importances.map(function(importance) {
return new OO.ui.MenuOptionWidget({
data: {
importance: importance
},
label: importance
})
})))
},
$element: $("<span style=\"width:auto;display:inline-block;float:left;margin:0\" title='Set all...'>"),
$overlay: this.$overlay
}), this.removeAllButton = new OO.ui.ButtonWidget({
icon: "trash",
title: "Remove all",
flags: "destructive"
}), this.clearAllButton = new OO.ui.ButtonWidget({
icon: "cancel",
title: "Clear all",
flags: "destructive"
}), this.menuButtons = new OO.ui.ButtonGroupWidget({
items: ,
$element: $("<span style='flex:1 0 auto;'>")
}), this.menuButtons.$element.prepend(this.setAllDropDown.$element), this.$element.addClass("rater-topBarWidget").css({
position: "fixed",
width: "100%",
background: "#ccc",
display: "flex",
"flex-wrap": "wrap",
"justify-content": "space-around",
margin: "-2px 0 0 0"
}).append($searchContainer, this.menuButtons.$element), this.searchBox.connect(this, {
enter: "onSearchSelect",
choose: "onSearchSelect"
}), this.addBannerButton.connect(this, {
click: "onSearchSelect"
}), this.setAllDropDown.getMenu().connect(this, {
choose: "onRatingChoose"
}), this.removeAllButton.connect(this, {
click: "onRemoveAllClick"
}), this.clearAllButton.connect(this, {
click: "onClearAllClick"
})
}
OO.inheritClass(TopBarWidget, OO.ui.PanelLayout), TopBarWidget.prototype.onSearchSelect = function(data) {
this.emit("searchSelect", data)
}, TopBarWidget.prototype.onRatingChoose = function(item) {
var data = item.getData();
!data.class && null !== data.class || this.emit("setClasses", data.class), !data.importance && null !== data.importance || this.emit("setImportances", data.importance)
}, TopBarWidget.prototype.onRemoveAllClick = function() {
this.emit("removeAll")
}, TopBarWidget.prototype.onClearAllClick = function() {
this.emit("clearAll")
}, TopBarWidget.prototype.setDisabled = function(disable) {
.forEach(function(widget) {
return widget.setDisabled(disable)
})
};
var _default = TopBarWidget;
exports.default = _default
}, {
"../../config": 18,
"../../getBanners": 20,
"./SuggestionLookupTextInputWidget": 11
}],
13: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var _api = require("../api");
function _toConsumableArray(arr) {
return function(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr)
}(arr) || function(iter) {
if ("undefined" != typeof Symbol && Symbol.iterator in Object(iter)) return Array.from(iter)
}(arr) || function(o, minLen) {
if (!o) return;
if ("string" == typeof o) return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
"Object" === n && o.constructor && (n = o.constructor.name);
if ("Map" === n || "Set" === n) return Array.from(n);
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen)
}(arr) || function() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a () method.")
}()
}
function _arrayLikeToArray(arr, len) {
(null == len || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2 = arr;
return arr2
}
function LoadDialog(config) {
LoadDialog.super.call(this, config)
}
OO.inheritClass(LoadDialog, OO.ui.Dialog), LoadDialog.static.name = "loadDialog", LoadDialog.static.title = "Loading Rater...", LoadDialog.prototype.initialize = function() {
var _this$content$$elemen;
LoadDialog.super.prototype.initialize.call(this), this.content = new OO.ui.PanelLayout({
padded: !0,
expanded: !1
}), this.progressBar = new OO.ui.ProgressBarWidget({
progress: 1
}), this.setuptasks = [new OO.ui.LabelWidget({
label: "Loading your Rater preferences...",
$element: $('<p style="display:block">')
}), new OO.ui.LabelWidget({
label: "Loading list of project banners...",
$element: $('<p style="display:block">')
}), new OO.ui.LabelWidget({
label: "Loading talkpage wikitext...",
$element: $('<p style="display:block">')
}), new OO.ui.LabelWidget({
label: "Parsing talkpage templates...",
$element: $('<p style="display:block">')
}), new OO.ui.LabelWidget({
label: "Getting templates' parameter data...",
$element: $('<p style="display:block">')
}), new OO.ui.LabelWidget({
label: "Checking subject page...",
$element: $('<p style="display:block">')
}), new OO.ui.LabelWidget({
label: "Retrieving quality prediction...",
$element: $('<p style="display:block">')
}).toggle()], this.closeButton = new OO.ui.ButtonWidget({
label: "Close"
}).toggle(), this.setupPromises = , (_this$content$$elemen = this.content.$element).append.apply(_this$content$$elemen, [this.progressBar.$element, new OO.ui.LabelWidget({
label: "Initialising:",
$element: $('<strong style="display:block">')
}).$element].concat(_toConsumableArray(this.setuptasks.map(function(widget) {
return widget.$element
})), )), this.$body.append(this.content.$element), this.closeButton.connect(this, {
click: "onCloseButtonClick"
})
}, LoadDialog.prototype.onCloseButtonClick = function() {
this.close()
}, LoadDialog.prototype.getBodyHeight = function() {
return this.content.$element.outerHeight(!0)
}, LoadDialog.prototype.incrementProgress = function(amount, maximum) {
var priorProgress = this.progressBar.getProgress(),
incrementedProgress = Math.min(maximum || 100, priorProgress + amount);
this.progressBar.setProgress(incrementedProgress)
}, LoadDialog.prototype.addTaskPromiseHandlers = function(taskPromises) {
var _this = this;
taskPromises.forEach(function(promise, index) {
promise.then(function() {
return function(index) {
var widget = _this.setuptasks;
widget.setLabel(widget.getLabel() + " Done!");
for (var incrementPerStep = 100 / _this.setuptasks.length / 10, step = 0; step < 10; step++) window.setTimeout(_this.incrementProgress.bind(_this), 400 * step / 10, incrementPerStep)
}(index)
}, function(code, info) {
return function(index, code, info) {
var widget = _this.setuptasks;
widget.setLabel(widget.getLabel() + " Failed. " + (0, _api.makeErrorMsg)(code, info)), _this.closeButton.toggle(!0), _this.updateSize()
}(index, code, info)
})
})
}, LoadDialog.prototype.getSetupProcess = function(data) {
var _this2 = this;
return data = data || {}, LoadDialog.super.prototype.getSetupProcess.call(this, data).next(function() {
var showOresTask = !!data.ores;
_this2.setuptasks.toggle(showOresTask);
var taskPromises = data.ores ? data.promises : data.promises.slice(0, -1);
data.isOpened.then(function() {
return _this2.addTaskPromiseHandlers(taskPromises)
})
}, this)
}, LoadDialog.prototype.getHoldProcess = function(data) {
return (data = data || {}).success ? LoadDialog.super.prototype.getHoldProcess.call(this, data).next(800) : LoadDialog.super.prototype.getHoldProcess.call(this, data)
}, LoadDialog.prototype.getTeardownProcess = function(data) {
var _this3 = this;
return LoadDialog.super.prototype.getTeardownProcess.call(this, data).first(function() {
_this3.setuptasks.forEach(function(setuptask) {
var currentLabel = setuptask.getLabel();
setuptask.setLabel(currentLabel.slice(0, currentLabel.indexOf("...") + 3))
})
}, this)
};
var _default = LoadDialog;
exports.default = _default
}, {
"../api": 15
}],
14: [function(require, module, exports) {
"use strict";
function _typeof(obj) {
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
})(obj)
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var _BannerWidget = _interopRequireDefault(require("./Components/BannerWidget")),
_BannerListWidget = _interopRequireDefault(require("./Components/BannerListWidget")),
_config = _interopRequireDefault(require("../config")),
_api = _interopRequireWildcard(require("../api")),
_PrefsFormWidget = _interopRequireDefault(require("./Components/PrefsFormWidget")),
_prefs = require("../prefs"),
_Template = require("../Template"),
_TopBarWidget = _interopRequireDefault(require("./Components/TopBarWidget")),
_util = require("../util"),
cache = _interopRequireWildcard(require("../cache"));
function _getRequireWildcardCache() {
if ("function" != typeof WeakMap) return null;
var cache = new WeakMap;
return _getRequireWildcardCache = function() {
return cache
}, cache
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) return obj;
if (null === obj || "object" !== _typeof(obj) && "function" != typeof obj) return {
default: obj
};
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) return cache.get(obj);
var newObj = {},
hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj)
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj = obj
} return newObj.default = obj, cache && cache.set(obj, newObj), newObj
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
function MainWindow(config) {
MainWindow.super.call(this, config)
}
OO.inheritClass(MainWindow, OO.ui.ProcessDialog), MainWindow.static.name = "main", MainWindow.static.title = $("<span>").css({
"font-weight": "normal"
}).append($("<a>").css({
"font-weight": "bold"
}).attr({
href: mw.util.getUrl("WP:RATER"),
target: "_blank"
}).text("Rater"), " (", $("<a>").attr({
href: mw.util.getUrl("WT:RATER"),
target: "_blank"
}).text("talk"), ") ", $("<span>").css({
"font-size": "90%"
}).text("v" + _config.default.script.version)), MainWindow.static.size = "large", MainWindow.static.actions = [{
label: "X",
title: "Close (and discard any changes)",
flags: "primary",
modes:
}, {
action: "showPrefs",
flags: "safe",
icon: "settings",
title: "Preferences",
modes:
}, {
action: "save",
accessKey: "s",
label: new OO.ui.HtmlSnippet("<span style='padding:0 1em;'>Save</span>"),
flags: ,
modes:
}, {
action: "preview",
accessKey: "p",
label: "Show preview",
modes:
}, {
action: "changes",
accessKey: "v",
label: "Show changes",
modes:
}, {
action: "back",
label: "Back",
modes:
}, {
action: "savePrefs",
label: "Update",
flags: ,
modes: "prefs"
}, {
action: "closePrefs",
label: "Cancel",
flags: "safe",
modes: "prefs"
}], MainWindow.prototype.initialize = function() {
MainWindow.super.prototype.initialize.call(this), this.preferences = _config.default.defaultPrefs, this.topBar = new _TopBarWidget.default({
$overlay: this.$overlay
}), this.$head.css({
height: "73px"
}).append(this.topBar.$element), this.oresLabel = new OO.ui.LabelWidget({
$element: $("<span style='float:right; padding: 10px; max-width: 50%; text-align: center;'>"),
label: $("<span>").append($("<a>").attr({
href: mw.util.getUrl("mw:ORES"),
target: "_blank"
}).append($("<img>").css({
"vertical-align": "text-bottom;"
}).attr({
src: "//upload.wikimedia.org/wikipedia/commons/thumb/5/51/Objective_Revision_Evaluation_Service_logo.svg/40px-Objective_Revision_Evaluation_Service_logo.svg.png",
title: "Machine predicted quality from ORES",
alt: "ORES logo",
width: "20px",
height: "20px"
})), " ", $("<span class='oresPrediction'>"))
}).toggle(!1), this.pagetypeLabel = new OO.ui.LabelWidget({
$element: $("<span style='float:right; padding: 10px; max-width: 33.33%; text-align: center;'>")
}).toggle(!1), this.$foot.prepend(this.oresLabel.$element, this.pagetypeLabel.$element), this.bannerList = new _BannerListWidget.default({
preferences: this.preferences
}), this.editLayout = new OO.ui.PanelLayout({
padded: !1,
expanded: !1,
$content: this.bannerList.$element
}), this.prefsForm = new _PrefsFormWidget.default, this.prefsLayout = new OO.ui.PanelLayout({
padded: !0,
expanded: !1,
$content: this.prefsForm.$element
}), this.parsedContentContainer = new OO.ui.FieldsetLayout({
label: "Preview"
}), this.parsedContentWidget = new OO.ui.LabelWidget({
label: "",
$element: $("<div>")
}), this.parsedContentContainer.addItems([new OO.ui.FieldLayout(this.parsedContentWidget, {
align: "top"
})]), this.parsedContentLayout = new OO.ui.PanelLayout({
padded: !0,
expanded: !1,
$content: this.parsedContentContainer.$element
}), this.contentArea = new OO.ui.StackLayout({
items: ,
padded: !1,
expanded: !1
}), this.$body.css({
top: "73px"
}).append(this.contentArea.$element), this.topBar.connect(this, {
searchSelect: "onSearchSelect",
setClasses: "onSetClasses",
setImportances: "onSetImportances",
removeAll: "onRemoveAll",
clearAll: "onClearAll"
}), this.bannerList.connect(this, {
updatedSize: "onBannerListUpdateSize"
}), this.$body.attr("tabindex", "999").parent().attr("tabindex", "999").keydown(function(event) {
var scrollAmount;
switch (event.which) {
case 33:
scrollAmount = this.$body.scrollTop() - .9 * this.$body.height();
break;
case 34:
scrollAmount = this.$body.scrollTop() + .9 * this.$body.height();
break;
default:
return
}
this.$body.scrollTop(scrollAmount), event.preventDefault()
}.bind(this)), this.prefsForm.connect(this, {
resetCache: "onResetCache"
})
}, MainWindow.prototype.onBannerListUpdateSize = function() {
var scrollAmount = this.$body.scrollTop();
this.updateSize(), this.$body.scrollTop(scrollAmount)
}, MainWindow.prototype.makeDraggable = function() {
var $frameEl = this.$element.find(".oo-ui-window-frame"),
$handleEl = this.$element.find(".oo-ui-processDialog-location").css({
cursor: "move"
}),
position = {
x: 0,
y: 0
},
constrain = function(val, minVal, maxVal) {
return val < minVal ? minVal : maxVal < val ? maxVal : val
},
pointerdown = !1,
dragFrom = {},
pointer = "PointerEvent" in window ? "pointer" : "mouse";
$handleEl.on(pointer + "enter.raterMainWin", function() {
return $frameEl.css("will-change", "transform")
}), $handleEl.on(pointer + "leave.raterMainWin", function() {
pointerdown || $frameEl.css("will-change", "")
}), $handleEl.on(pointer + "down.raterMainWin", function(event) {
pointerdown = !0, dragFrom.x = event.clientX, dragFrom.y = event.clientY
}), $("body").on(pointer + "move.raterMainWin", function(event) {
if (pointerdown && null != dragFrom.x && null !== dragFrom.y) {
var val, limit, dx = event.clientX - dragFrom.x,
dy = event.clientY - dragFrom.y;
dragFrom.x = event.clientX, dragFrom.y = event.clientY, position.x = (val = position.x + dx, limit = window.innerWidth / 2 + $frameEl.outerWidth() / 2 - 100, constrain(val, -1 * limit, limit)), position.y = function(val) {
var minLimit = -1 * (window.innerHeight - $frameEl.outerHeight()) / 2,
maxLimit = (document.documentElement || document).scrollHeight - window.innerHeight / 2;
return constrain(val, minLimit, maxLimit)
}(position.y + dy), $frameEl.css("transform", "translate(".concat(position.x, "px, ").concat(position.y, "px)"))
}
}), $("body").on(pointer + "up.raterMainWin", function() {
pointerdown = !1, delete dragFrom.x, delete dragFrom.y, position.x = Math.round(position.x), position.y = Math.round(position.y), $frameEl.css("transform", "translate(".concat(position.x, "px, ").concat(position.y, "px)"))
})
}, MainWindow.prototype.getBodyHeight = function() {
var currentlayout = this.contentArea.getCurrentItem(),
layoutHeight = currentlayout && currentlayout.$element.outerHeight(!0),
contentHeight = currentlayout && currentlayout.$element.children(":first-child").outerHeight(!0);
return Math.max(200, layoutHeight, contentHeight)
}, MainWindow.prototype.getSetupProcess = function(data) {
var _this = this;
return data = data || {}, MainWindow.super.prototype.getSetupProcess.call(this, data).next(function() {
_this.makeDraggable(), _this.setPreferences(data.preferences), _this.prefsForm.setPrefValues(data.preferences), _this.subjectPage = data.subjectPage, _this.pageInfo = {
redirect: data.redirectTarget,
isDisambig: data.disambig,
hasStubtag: data.stubtag,
isArticle: data.isArticle
}, _this.actions.setMode("edit"), _this.bannerList.oresClass = data.isArticle && data.isList ? "List" : data.ores && data.ores.prediction, _this.bannerList.pageInfo = _this.pageInfo, _this.bannerList.addItems(data.banners.map(function(bannerTemplate) {
return new _BannerWidget.default(bannerTemplate, {
preferences: _this.preferences,
$overlay: _this.$overlay,
isArticle: _this.pageInfo.isArticle
})
}));
var shellTemplateBanner = _this.bannerList.items.find(function(banner) {
return banner.isShellTemplate
});
shellTemplateBanner && shellTemplateBanner.shellParam1Value && (shellTemplateBanner.nonStandardTemplates = _this.bannerList.items.reduce(function(bannersList, curBanner) {
return bannersList.replace(curBanner.wikitext, "")
}, shellTemplateBanner.shellParam1Value).trim().replace(/\n+/g, "\n")), _this.pageInfo.redirect ? _this.pagetypeLabel.setLabel("Redirect page").toggle(!0) : _this.pageInfo.isDisambig ? _this.pagetypeLabel.setLabel("Disambiguation page").toggle(!0) : _this.pageInfo.isArticle && data.isFL ? _this.pagetypeLabel.setLabel("Featured list").toggle(!0) : _this.pageInfo.isArticle && data.isList ? _this.pagetypeLabel.setLabel("List article").toggle(!0) : data.ores ? (_this.oresClass = data.ores.prediction, _this.oresLabel.toggle(!0).$element.find(".oresPrediction").append("Prediction: ", $("<strong>").text(data.ores.prediction), " (" + data.ores.probability + ")")) : _this.pageInfo.isArticle ? _this.pagetypeLabel.setLabel("Article page").toggle(!0) : _this.pagetypeLabel.setLabel(_this.subjectPage.getNamespacePrefix().slice(0, -1) + " page").toggle(!0), _this.talkWikitext = data.talkWikitext, _this.existingBannerNames = data.banners.map(function(bannerTemplate) {
return bannerTemplate.name
}), _this.talkpage = data.talkpage, _this.updateSize()
}, this)
}, MainWindow.prototype.getReadyProcess = function(data) {
var _this2 = this;
return data = data || {}, MainWindow.super.prototype.getReadyProcess.call(this, data).next(function() {
return _this2.topBar.searchBox.focus()
})
}, MainWindow.prototype.getActionProcess = function(action) {
var _this3 = this;
if ("showPrefs" === action) this.actions.setMode("prefs"), this.contentArea.setItem(this.prefsLayout), this.topBar.setDisabled(!0), this.updateSize();
else {
if ("savePrefs" === action) {
var updatedPrefs = this.prefsForm.getPrefs();
return (new OO.ui.Process).next((0, _prefs.setPrefs)(updatedPrefs).then(function() {
_this3.setPreferences(updatedPrefs), _this3.actions.setMode("edit"), _this3.contentArea.setItem(_this3.editLayout), _this3.topBar.setDisabled(!1), _this3.updateSize()
}, function(code, err) {
return $.Deferred().reject(new OO.ui.Error($("<div>").append($("<strong style='display:block;'>").text("Could not save preferences."), $("<span style='color:#777'>").text((0, _api.makeErrorMsg)(code, err)))))
}))
}
if ("clearCache" === action) return (new OO.ui.Process).next(function() {
cache.clearAllItems(), _this3.close({
restart: !0
})
});
if ("closePrefs" === action) this.actions.setMode("edit"), this.contentArea.setItem(this.editLayout), this.topBar.setDisabled(!1), this.prefsForm.setPrefValues(this.preferences), this.updateSize();
else {
if ("save" === action) return (new OO.ui.Process).next(_api.default.editWithRetry(this.talkpage.getPrefixedText(), {
rvsection: 0
}, function(revision) {
return {
section: 0,
text: _this3.transformTalkWikitext(revision.content),
summary: _this3.makeEditSummary(),
watchlist: _this3.preferences.watchlist
}
}).catch(function(code, err) {
return $.Deferred().reject(new OO.ui.Error($("<div>").append($("<strong style='display:block;'>").text("Could not save your changes."), $("<span style='color:#777'>").text((0, _api.makeErrorMsg)(code, err)))))
})).next(function() {
return _this3.close({
success: !0,
upgradedStub: _this3.pageInfo.hasStubtag && _this3.isRatedAndNotStub()
})
});
if ("preview" === action) return (new OO.ui.Process).next(_api.default.post({
action: "parse",
contentmodel: "wikitext",
text: this.transformTalkWikitext(this.talkWikitext) + "\n<hr>\n'''Edit summary:''' " + this.makeEditSummary(),
title: this.talkpage.getPrefixedText(),
pst: 1
}).then(function(result) {
if (!(result && result.parse && result.parse.text && result.parse.text)) return $.Deferred().reject("Empty result");
var previewHtmlSnippet = new OO.ui.HtmlSnippet(result.parse.text);
_this3.parsedContentWidget.setLabel(previewHtmlSnippet), _this3.parsedContentContainer.setLabel("Preview:"), _this3.actions.setMode("preview"), _this3.contentArea.setItem(_this3.parsedContentLayout), _this3.topBar.setDisabled(!0), _this3.updateSize()
}).catch(function(code, err) {
return $.Deferred().reject(new OO.ui.Error($("<div>").append($("<strong style='display:block;'>").text("Could not show changes."), $("<span style='color:#777'>").text((0, _api.makeErrorMsg)(code, err)))))
}));
if ("changes" === action) return (new OO.ui.Process).next(_api.default.post({
action: "compare",
format: "json",
fromtext: this.talkWikitext,
fromcontentmodel: "wikitext",
totext: this.transformTalkWikitext(this.talkWikitext),
tocontentmodel: "wikitext",
prop: "diff"
}).then(function(result) {
if (!result || !result.compare || !result.compare) return $.Deferred().reject("Empty result");
var $diff = $("<table>").addClass("diff").css("width", "100%").append($("<tr>").append($("<th>").attr({
colspan: "2",
scope: "col"
}).css("width", "50%").text("Latest revision"), $("<th>").attr({
colspan: "2",
scope: "col"
}).css("width", "50%").text("New text")), result.compare, $("<tfoot>").append($("<tr>").append($("<td colspan='4'>").append($("<strong>").text("Edit summary: "), _this3.makeEditSummary()))));
_this3.parsedContentWidget.setLabel($diff), _this3.parsedContentContainer.setLabel("Changes:"), _this3.actions.setMode("diff"), _this3.contentArea.setItem(_this3.parsedContentLayout), _this3.topBar.setDisabled(!0), _this3.updateSize()
}).catch(function(code, err) {
return $.Deferred().reject(new OO.ui.Error($("<div>").append($("<strong style='display:block;'>").text("Could not show changes."), $("<span style='color:#777'>").text((0, _api.makeErrorMsg)(code, err)))))
}));
if ("back" === action) this.actions.setMode("edit"), this.contentArea.setItem(this.editLayout), this.topBar.setDisabled(!1), this.updateSize();
else if (!action && this.bannerList.changed) return (new OO.ui.Process).next(OO.ui.confirm("Changes made will be discarded.", {
title: "Close Rater?"
}).then(function(confirmed) {
return confirmed ? _this3.close() : null
}))
}
}
return MainWindow.super.prototype.getActionProcess.call(this, action)
}, MainWindow.prototype.getTeardownProcess = function(data) {
var _this4 = this;
return MainWindow.super.prototype.getTeardownProcess.call(this, data).first(function() {
_this4.bannerList.clearItems(), _this4.topBar.searchBox.setValue(""), _this4.contentArea.setItem(_this4.editLayout), _this4.topBar.setDisabled(!1), _this4.oresLabel.toggle(!1).$element.find(".oresPrediction").empty(), _this4.pagetypeLabel.toggle(!1).setLabel(""), _this4.$element.find(".oo-ui-window-frame").css("transform", ""), _this4.$element.find(".oo-ui-processDialog-location").off(".raterMainWin"), $("body").off(".raterMainWin")
})
}, MainWindow.prototype.setPreferences = function(prefs) {
this.preferences = $.extend({}, _config.default.defaultPrefs, prefs), this.bannerList.setPreferences(this.preferences)
}, MainWindow.prototype.onResetCache = function() {
this.executeAction("clearCache")
}, MainWindow.prototype.onSearchSelect = function(data) {
var _this5 = this;
this.topBar.searchBox.pushPending();
var name = this.topBar.searchBox.getValue().trim();
if (name) {
var confirmText;
if (this.bannerList.items.find(function(banner) {
return banner.mainText === name || banner.redirectTargetMainText === name
})) return this.topBar.searchBox.popPending(), OO.ui.alert("There is already a {{" + name + "}} banner").then(this.searchBox.focus());
/^(?:P|ikiroject)/.test(name) ? "WikiProject Disambiguation" === name && 0 !== $("#ca-talk.new").length && 0 === this.bannerList.items.length && (confirmText = "New talk pages shouldn't be created if they will only contain the {{WikiProject Disambiguation}} banner. Continue?") : confirmText = new OO.ui.HtmlSnippet("{{" + mw.html.escape(name) + "}} is not a recognised WikiProject banner.<br/>Do you want to continue?"), $.when(!confirmText || OO.ui.confirm(confirmText)).then(function(confirmed) {
if (confirmed) return _BannerWidget.default.newFromTemplateName(name, data, {
preferences: _this5.preferences,
$overlay: _this5.$overlay,
isArticle: _this5.pageInfo.isArticle
}).then(function(banner) {
_this5.bannerList.addItems(), banner.setChanged(), _this5.updateSize()
})
}).then(function() {
return _this5.topBar.searchBox.setValue("").focus().popPending()
})
} else this.topBar.searchBox.popPending().focus()
}, MainWindow.prototype.onSetClasses = function(classVal) {
this.bannerList.items.forEach(function(banner) {
banner.hasClassRatings && (banner.classDropdown.getMenu().selectItemByData(classVal), banner.classDropdown.setAutofilled(!1))
})
}, MainWindow.prototype.onSetImportances = function(importanceVal) {
this.bannerList.items.forEach(function(banner) {
banner.hasImportanceRatings && (banner.importanceDropdown.getMenu().selectItemByData(importanceVal), banner.importanceDropdown.setAutofilled(!1))
})
}, MainWindow.prototype.onRemoveAll = function() {
this.bannerList.clearItems()
}, MainWindow.prototype.onClearAll = function() {
this.bannerList.items.forEach(function(banner) {
return banner.onClearButtonClick()
})
}, MainWindow.prototype.transformTalkWikitext = function(talkWikitext) {
var _this6 = this,
bannersWikitext = this.bannerList.makeWikitext();
if (!talkWikitext) return bannersWikitext.trim();
var talkTemplates = (0, _Template.parseTemplates)(talkWikitext, !0);
talkTemplates.forEach(function(template) {
_this6.existingBannerNames.includes(template.name) && (talkWikitext = talkWikitext.replace(template.wikitext, "\x01"))
});
var talkWikitextSections = (talkWikitext = (talkWikitext = talkWikitext.replace("\x01", "\x02")).replace(/(?:\s|\n)*\x01(?:\s|\n)*/g, "")).split("\x02").map(function(t) {
return t.trim()
});
if (2 === talkWikitextSections.length) return (talkWikitextSections + "\n" + bannersWikitext.trim() + "\n" + talkWikitextSections).trim();
var tempStr = talkWikitext;
return talkTemplates.forEach(function(template) {
tempStr = tempStr.replace(template.wikitext, "")
}), /^#REDIRECT/i.test(talkWikitext) || !tempStr.trim() ? talkWikitext.trim() + "\n" + bannersWikitext.trim() : bannersWikitext.trim() + "\n" + talkWikitext.trim()
}, MainWindow.prototype.isRatedAndNotStub = function() {
return 0 < this.bannerList.items.filter(function(banner) {
return banner.hasClassRatings && banner.classDropdown.getValue() && "Stub" !== banner.classDropdown.getValue()
}).length
}, MainWindow.prototype.makeEditSummary = function() {
var _this7 = this,
removedBanners = ,
editedBanners = ,
newBanners = ,
shortName = function(name) {
return name.replace("WikiProject ", "").replace("Subst:", "")
},
allClasses = (0, _util.uniqueArray)((0, _util.filterAndMap)(this.bannerList.items, function(banner) {
return banner.hasClassRatings
}, function(banner) {
return banner.classDropdown.getValue()
})),
overallClass = 1 === allClasses.length && allClasses,
allImportances = (0, _util.uniqueArray)((0, _util.filterAndMap)(this.bannerList.items, function(banner) {
return banner.hasImportanceRatings
}, function(banner) {
return banner.importanceDropdown.getValue()
})),
overallImportance = 1 === allImportances.length && allImportances,
someClassesChanged = !1,
someImportancesChanged = !1;
this.existingBannerNames.forEach(function(name) {
_this7.bannerList.items.find(function(banner) {
return banner.name === name || banner.bypassedName === name
}) || removedBanners.push("\u2212" + shortName(name))
}), this.bannerList.items.forEach(function(banner) {
var isNew = !banner.wikitext;
if (isNew || banner.changed) {
var newClass = banner.hasClassRatings && (isNew || banner.classChanged) && banner.classDropdown.getValue();
newClass && (someClassesChanged = !0), overallClass && (newClass = null);
var newImportance = banner.hasImportanceRatings && (isNew || banner.importanceChanged) && banner.importanceDropdown.getValue();
newImportance && (someImportancesChanged = !0), overallImportance && (newImportance = null);
var rating = newClass && newImportance ? newClass + "/" + newImportance : newClass || newImportance || "";
rating = rating && " (" + rating + ")", isNew ? newBanners.push("+" + shortName(banner.name) + rating) : editedBanners.push(shortName(banner.name) + rating)
}
});
var overallRating = someClassesChanged && overallClass && someImportancesChanged && overallImportance ? overallClass + "/" + overallImportance : someClassesChanged && overallClass || someImportancesChanged && overallImportance || "";
return "Assessment".concat(overallRating = overallRating && " (" + overallRating + ")", ": ").concat(.concat(editedBanners, newBanners, removedBanners).join(", ")).concat(_config.default.script.advert)
};
var _default = MainWindow;
exports.default = _default
}, {
"../Template": 3,
"../api": 15,
"../cache": 17,
"../config": 18,
"../prefs": 21,
"../util": 23,
"./Components/BannerListWidget": 4,
"./Components/BannerWidget": 5,
"./Components/PrefsFormWidget": 10,
"./Components/TopBarWidget": 12
}],
15: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.makeErrorMsg = exports.default = void 0;
var obj, _config = (obj = require("./config")) && obj.__esModule ? obj : {
default: obj
};
function _typeof(obj) {
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
})(obj)
}
var API = new mw.Api({
ajax: {
headers: {
"Api-User-Agent": "Rater/" + _config.default.script.version + " ( https://en.wikipedia.orghttps://wiki95.com/en/User:Evad37/Rater )"
}
}
});
API.getORES = function(revisionID) {
return $.get("https://ores.wikimedia.org/v3/scores/enwiki?models=articlequality&revids=" + revisionID)
}, API.getRaw = function(page) {
return $.get("https:" + _config.default.mw.wgServer + mw.util.getUrl(page, {
action: "raw"
})).then(function(data) {
return data || $.Deferred().reject("ok-but-empty")
})
};
var getPage = function(title, params) {
return API.get($.extend({
action: "query",
format: "json",
curtimestamp: 1,
titles: title,
prop: "revisions|info",
rvprop: "content|timestamp",
rvslots: "main"
}, params)).then(function(response) {
var page = Object.values(response.query.pages),
starttime = response.curtimestamp;
return $.Deferred().resolve(page, starttime)
})
},
processPage = function(page, starttime, transform) {
var basetimestamp = page.revisions && page.revisions.timestamp,
simplifiedPage = {
pageid: page.pageid,
missing: "" === page.missing,
redirect: "" === page.redirect,
categories: page.categories,
ns: page.ns,
title: page.title,
content: page.revisions && page.revisions.slots.main
};
return $.when(transform(simplifiedPage)).then(function(editParams) {
return $.extend({
action: "edit",
title: page.title,
assert: "user",
basetimestamp: basetimestamp,
starttimestamp: starttime
}, editParams)
})
};
API.editWithRetry = function(title, getParams, transform) {
return getPage(title, getParams).then(function(page, starttime) {
return processPage(page, starttime, transform)
}, function() {
return getPage(title, getParams).then(processPage, transform)
}).then(function(editParams) {
return API.postWithToken("csrf", editParams).catch(function(errorCode) {
return "editconflict" === errorCode ? API.editWithRetry(title, getParams, transform) : API.postWithToken("csrf", editParams)
})
})
};
exports.makeErrorMsg = function(first, second) {
var code, xhr, message;
if ("object" === _typeof(first) && "string" == typeof second) {
var errorObj = first.responseJSON && first.responseJSON.error;
errorObj ? (code = errorObj.code, message = errorObj.message) : xhr = first
} else if ("string" == typeof first && "object" === _typeof(second)) {
second.error ? (code = errorObj.code, message = errorObj.info) : "ok-but-empty" === first ? (code = null, message = "Got an empty response from the server") : xhr = second && second.xhr
}
return code && message ? "API error ".concat(code, ": ").concat(message) : message ? "API error: ".concat(message) : xhr ? "HTTP error ".concat(xhr.status) : "string" == typeof first && "error" !== first && "string" == typeof second && "error" !== second ? "Error ".concat(first, ": ").concat(second) : "string" == typeof first && "error" !== first ? "Error: ".concat(first) : "Unknown API error"
};
var _default = API;
exports.default = _default
}, {
"./config": 18
}],
16: [function(require, module, exports) {
"use strict";
function _typeof(obj) {
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
})(obj)
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var _config = _interopRequireDefault(require("./config")),
_prefs = require("./prefs"),
_api = function(obj) {
if (obj && obj.__esModule) return obj;
if (null === obj || "object" !== _typeof(obj) && "function" != typeof obj) return {
default: obj
};
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) return cache.get(obj);
var newObj = {},
hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj)
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj = obj
} newObj.default = obj, cache && cache.set(obj, newObj);
return newObj
}(require("./api")),
_setup = _interopRequireDefault(require("./setup"));
function _getRequireWildcardCache() {
if ("function" != typeof WeakMap) return null;
var cache = new WeakMap;
return _getRequireWildcardCache = function() {
return cache
}, cache
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
function _default() {
return (0, _prefs.getPrefs)().then(function(prefs) {
if (prefs.autostart && ((prefs.autostartRedirects || !window.location.search.includes("redirect=no")) && !/(action|diff|oldid)/.test(window.location.search) && "Main Page" !== mw.Title.newFromText(_config.default.mw.wgPageName).getSubjectPage().getPrefixedText() && (!prefs.autostartNamespaces || !prefs.autostartNamespaces.length || prefs.autostartNamespaces.includes(_config.default.mw.wgNamespaceNumber)))) {
if ($("#ca-talk.new").length) return (0, _setup.default)();
var talkTitle = mw.Title.newFromText(_config.default.mw.wgPageName).getTalkPage();
return _api.default.get({
action: "query",
format: "json",
prop: "templates",
titles: talkTitle.getPrefixedText(),
tlnamespace: "10",
tllimit: "500",
indexpageids: 1
}).then(function(result) {
var id = result.query.pageids,
templates = result.query.pages.templates;
return templates && templates.some(function(template) {
return /(WikiProject|WPBanner)/.test(template.title)
}) ? void 0 : (0, _setup.default)()
}, function(code, jqxhr) {
return console.warn(""), $.Deferred().reject()
})
}
})
}
exports.default = _default
}, {
"./api": 15,
"./config": 18,
"./prefs": 21,
"./setup": 22
}],
17: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.clearAllItems = exports.clearInvalidItems = exports.clearItemIfInvalid = exports.read = exports.write = void 0;
var _util = require("./util");
exports.write = function(key, val, staleDays, expiryDays) {
try {
var staleDuration = 864e5 * (staleDays || 1),
expiryDuration = 864e5 * (expiryDays || 30),
stringVal = JSON.stringify({
value: val,
staleDate: new Date(Date.now() + staleDuration).toISOString(),
expiryDate: new Date(Date.now() + expiryDuration).toISOString()
});
localStorage.setItem("Rater-" + key, stringVal)
} catch (e) {}
};
var read = function(key) {
var val;
try {
var stringVal = localStorage.getItem("Rater-" + key);
"" !== stringVal && (val = JSON.parse(stringVal))
} catch (e) {
console.log(" error reading " + key + " from localStorage cache:"), console.log("\t" + e.name + " message: " + e.message + (e.at ? " at: " + e.at : "") + (e.text ? " text: " + e.text : ""))
}
return val || null
};
exports.read = read;
var isRaterKey = function(key) {
return key && 0 === key.indexOf("Rater-")
},
clearItemIfInvalid = function(key) {
if (isRaterKey(key)) {
var item = read(key.replace("Rater-", ""));
(!item || !item.expiryDate || (0, _util.isAfterDate)(item.expiryDate)) && localStorage.removeItem(key)
}
};
exports.clearItemIfInvalid = clearItemIfInvalid;
exports.clearInvalidItems = function() {
for (var i = localStorage.length; 0 <= i; i--) setTimeout(clearItemIfInvalid, 100, localStorage.key(i))
};
exports.clearAllItems = function() {
for (var i = localStorage.length; 0 <= i; i--) {
var key = localStorage.key(i);
isRaterKey(key) && localStorage.removeItem(key)
}
}
}, {
"./util": 23
}],
18: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var version = require("../package.json").version,
_default = {
script: {
advert: " (])"),
version: version
},
defaultPrefs: {
autostart: !1,
autostartRedirects: !1,
autostartNamespaces: ,
minForShell: 3,
bypassRedirects: !0,
autofillClassFromOthers: !0,
autofillClassFromOres: !0,
autofillImportance: !0,
collapseParamsLowerLimit: 6,
watchlist: "preferences"
},
mw: mw.config.get(),
bannerDefaults: {
classes: ,
importances: ,
extendedClasses: ,
extendedImportances:
},
customBanners: {
"WikiProject Military history": {
classes: ,
importances:
},
"WikiProject Portals": {
classes: ,
importances:
},
"WikiProject Video games": {
classes: ,
importances:
}
},
shellTemplates: ,
defaultParameterData: {
auto: {
label: {
en: "Auto-rated"
},
description: {
en: "Automatically rated by a bot. Allowed values: ."
},
autovalue: "yes"
},
listas: {
label: {
en: "List as"
},
description: {
en: "Sortkey for talk page"
}
},
small: {
label: {
en: "Small?"
},
description: {
en: "Display a small version. Allowed values: ."
},
autovalue: "yes"
},
attention: {
label: {
en: "Attention required?"
},
description: {
en: "Immediate attention required. Allowed values: ."
},
autovalue: "yes"
},
"needs-image": {
label: {
en: "Needs image?"
},
description: {
en: "Request that an image or photograph of the subject be added to the article. Allowed values: ."
},
aliases: ,
autovalue: "yes",
suggested: !0
},
"needs-infobox": {
label: {
en: "Needs infobox?"
},
description: {
en: "Request that an infobox be added to the article. Allowed values: ."
},
aliases: ,
autovalue: "yes",
suggested: !0
}
}
};
exports.default = _default
}, {
"../package.json": 1
}],
19: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
exports.default = "table.diff, td.diff-otitle, td.diff-ntitle { table-layout: auto !important;; }\ntd.diff-otitle, td.diff-ntitle { text-align: center; }\ntd.diff-marker { text-align: right; font-weight: bold; font-size: 1.25em; }\ntd.diff-lineno { font-weight: bold; }\ntd.diff-addedline, td.diff-deletedline, td.diff-context { font-size: 88%; vertical-align: top; white-space: -moz-pre-wrap; white-space: pre-wrap; }\ntd.diff-addedline, td.diff-deletedline { border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; }\ntd.diff-addedline { border-color: #a3d3ff; }\ntd.diff-deletedline { border-color: #ffe49c; }\ntd.diff-context { background: #f3f3f3; color: #333333; border-style: solid; border-width: 1px 1px 1px 4px; border-color: #e6e6e6; border-radius: 0.33em; }\n.diffchange { font-weight: bold; text-decoration: none; }\ntable.diff {\n border: none;\n width: 98%; border-spacing: 4px;\n table-layout: fixed; /* Ensures that colums are of equal width */\n}\ntd.diff-addedline .diffchange, td.diff-deletedline .diffchange { border-radius: 0.33em; padding: 0.25em 0; }\ntd.diff-addedline .diffchange {\tbackground: #d8ecff; }\ntd.diff-deletedline .diffchange { background: #feeec8; }\ntable.diff td {\tpadding: 0.33em 0.66em; }\ntable.diff col.diff-marker { width: 2%; }\ntable.diff col.diff-content { width: 48%; }\ntable.diff td div {\n /* Force-wrap very long lines such as URLs or page-widening char strings. */\n word-wrap: break-word;\n /* As fallback (FF<3.5, Opera <10.5), scrollbars will be added for very wide cells\n instead of text overflowing or widening */\n overflow: auto;\n}html body.rater-mainWindow-open {\n\tposition: unset;\n\toverflow: unset;\n}\nhtml body.rater-mainWindow-open .oo-ui-windowManager-modal > .oo-ui-dialog.oo-ui-window-active {\n position: static;\n padding: 0;\n}html body.rater-mainWindow-open .oo-ui-dialog.oo-ui-window-active > div {\n z-index: 110;\n transition: all 0.25s ease-out 0s, transform 0s !important\n}\n"
}, {}],
20: [function(require, module, exports) {
"use strict";
function _typeof(obj) {
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
})(obj)
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.getBannerNames = void 0;
var _api = _interopRequireWildcard(require("./api")),
_util = require("./util"),
cache = _interopRequireWildcard(require("./cache"));
function _getRequireWildcardCache() {
if ("function" != typeof WeakMap) return null;
var cache = new WeakMap;
return _getRequireWildcardCache = function() {
return cache
}, cache
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) return obj;
if (null === obj || "object" !== _typeof(obj) && "function" != typeof obj) return {
default: obj
};
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) return cache.get(obj);
var newObj = {},
hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj)
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj = obj
} return newObj.default = obj, cache && cache.set(obj, newObj), newObj
}
var cacheBanners = function(banners) {
cache.write("banners", banners, 2, 60)
},
getListOfBannersFromApi = function() {
var finishedPromise = $.Deferred(),
querySkeleton = {
action: "query",
format: "json",
list: "categorymembers",
cmprop: "title",
cmnamespace: "10",
cmlimit: "500"
},
categories = [{
title: "Category:WikiProject banners with quality assessment",
abbreviation: "withRatings",
banners: ,
processed: $.Deferred()
}, {
title: "Category:WikiProject banners without quality assessment",
abbreviation: "withoutRatings",
banners: ,
processed: $.Deferred()
}, {
title: "Category:WikiProject banner wrapper templates",
abbreviation: "wrappers",
banners: ,
processed: $.Deferred()
}, {
title: "Category:WikiProject banner templates not based on WPBannerMeta",
abbreviation: "notWPBM",
banners: ,
processed: $.Deferred()
}, {
title: "Category:Inactive WikiProject banners",
abbreviation: "inactive",
banners: ,
processed: $.Deferred()
}, {
title: "Category:Wrapper templates for WikiProject Women in Red",
abbreviation: "wir",
banners: ,
processed: $.Deferred()
}],
processQuery = function(result, catIndex) {
if (result.query && result.query.categorymembers) {
var resultTitles = result.query.categorymembers.map(function(info) {
return info.title.slice(9)
});
Array.prototype.push.apply(categories.banners, resultTitles), result.continue ? doApiQuery($.extend(categories.query, result.continue), catIndex) : categories.processed.resolve()
} else finishedPromise.reject()
},
doApiQuery = function(q, catIndex) {
_api.default.get(q).done(function(result) {
processQuery(result, catIndex)
}).fail(function(code, jqxhr) {
console.warn(" " + (0, _api.makeErrorMsg)(code, jqxhr, "Could not retrieve pages from ]")), finishedPromise.reject()
})
};
return categories.forEach(function(cat, index, arr) {
cat.query = $.extend({
cmtitle: cat.title
}, querySkeleton), $.when(arr && arr.processed || !0).then(function() {
doApiQuery(cat.query, index)
})
}), categories.processed.then(function() {
var banners = {};
categories.forEach(function(catObject) {
banners = catObject.banners
}), finishedPromise.resolve(banners)
}), finishedPromise
};
exports.getBannerNames = function() {
return ((cachedBanners = cache.read("banners")) && cachedBanners.value && cachedBanners.staleDate ? ((0, _util.isAfterDate)(cachedBanners.staleDate) && getListOfBannersFromApi().then(cacheBanners), $.Deferred().resolve(cachedBanners.value)) : $.Deferred().reject()).then(function(banners) {
return banners.withRatings && banners.withoutRatings && banners.wrappers && banners.notWPBM && banners.inactive && banners.wir ? banners : (getListOfBannersFromApi().then(cacheBanners), $.extend({
withRatings: ,
withoutRatings: ,
wrappers: ,
notWPBM: ,
inactive: ,
wir:
}, banners))
}).catch(function() {
var bannersPromise = getListOfBannersFromApi();
return bannersPromise.then(cacheBanners), bannersPromise
});
var cachedBanners
}
}, {
"./api": 15,
"./cache": 17,
"./util": 23
}],
21: [function(require, module, exports) {
"use strict";
function _typeof(obj) {
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
})(obj)
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.setPrefs = exports.getPrefs = exports.default = void 0;
var _api = _interopRequireDefault(require("./api")),
_util = require("./util"),
_config = _interopRequireDefault(require("./config")),
cache = function(obj) {
if (obj && obj.__esModule) return obj;
if (null === obj || "object" !== _typeof(obj) && "function" != typeof obj) return {
default: obj
};
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) return cache.get(obj);
var newObj = {},
hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj)
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj = obj
} newObj.default = obj, cache && cache.set(obj, newObj);
return newObj
}(require("./cache"));
function _getRequireWildcardCache() {
if ("function" != typeof WeakMap) return null;
var cache = new WeakMap;
return _getRequireWildcardCache = function() {
return cache
}, cache
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
var prefsPage = "User:".concat(mw.config.get("wgUserName"), "/raterPrefs.json"),
writePrefsToCache = function(prefs) {
return cache.write("prefs", prefs, 1 / 24 / 60 * 1, 1 / 24 / 60 * 1)
},
getPrefs = function() {
return ((cachedPrefs = cache.read("prefs")) && cachedPrefs.value && cachedPrefs.staleDate && !(0, _util.isAfterDate)(cachedPrefs.staleDate) ? $.Deferred().resolve(cachedPrefs.value) : $.Deferred().reject()).then(function(prefs) {
return $.Deferred().resolve(prefs)
}, function() {
return _api.default.get({
action: "query",
format: "json",
prop: "revisions",
titles: prefsPage,
rvprop: "content",
rvslots: "main"
}).then(function(response) {
var prefs, page = response.query.pages];
if (!page.pageid || "" === page.missing) return _config.default.defaultPrefs;
try {
prefs = JSON.parse(page.revisions.slots.main)
} catch (e) {
return $.Deferred().reject("JSON-parsing-error", e)
}
return writePrefsToCache(prefs), prefs
})
});
var cachedPrefs
},
setPrefs = function(updatedPrefs) {
return _api.default.editWithRetry(prefsPage, null, function() {
return {
text: JSON.stringify(updatedPrefs),
summary: "Saving Rater preferences " + _config.default.script.advert
}
}).then(function() {
return writePrefsToCache(updatedPrefs)
})
},
_default = {
get: exports.getPrefs = getPrefs,
set: exports.setPrefs = setPrefs
};
exports.default = _default
}, {
"./api": 15,
"./cache": 17,
"./config": 18,
"./util": 23
}],
22: [function(require, module, exports) {
"use strict";
function _typeof(obj) {
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
})(obj)
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var _config = _interopRequireDefault(require("./config")),
_api = _interopRequireDefault(require("./api")),
_Template = require("./Template"),
_getBanners = require("./getBanners"),
cache = function(obj) {
if (obj && obj.__esModule) return obj;
if (null === obj || "object" !== _typeof(obj) && "function" != typeof obj) return {
default: obj
};
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) return cache.get(obj);
var newObj = {},
hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj)
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
desc && (desc.get || desc.set) ? Object.defineProperty(newObj, key, desc) : newObj = obj
} newObj.default = obj, cache && cache.set(obj, newObj);
return newObj
}(require("./cache")),
_windowManager = _interopRequireDefault(require("./windowManager")),
_prefs = require("./prefs"),
_util = require("./util");
function _getRequireWildcardCache() {
if ("function" != typeof WeakMap) return null;
var cache = new WeakMap;
return _getRequireWildcardCache = function() {
return cache
}, cache
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable
})), keys.push.apply(keys, symbols)
}
return keys
}
function _defineProperty(obj, key, value) {
return key in obj ? Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}) : obj = value, obj
}
function _toConsumableArray(arr) {
return function(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr)
}(arr) || function(iter) {
if ("undefined" != typeof Symbol && Symbol.iterator in Object(iter)) return Array.from(iter)
}(arr) || function(o, minLen) {
if (!o) return;
if ("string" == typeof o) return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
"Object" === n && o.constructor && (n = o.constructor.name);
if ("Map" === n || "Set" === n) return Array.from(n);
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen)
}(arr) || function() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a () method.")
}()
}
function _arrayLikeToArray(arr, len) {
(null == len || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2 = arr;
return arr2
}
function _default(clickEvent) {
clickEvent && clickEvent.preventDefault();
var setupCompletedPromise = $.Deferred(),
currentPage = mw.Title.newFromText(_config.default.mw.wgPageName),
talkPage = currentPage && currentPage.getTalkPage(),
subjectPage = currentPage && currentPage.getSubjectPage(),
subjectIsArticle = _config.default.mw.wgNamespaceNumber <= 1,
prefsPromise = (0, _prefs.getPrefs)(),
bannersPromise = (0, _getBanners.getBannerNames)(),
loadTalkPromise = _api.default.get({
action: "query",
prop: "revisions",
rvprop: "content",
rvsection: "0",
titles: talkPage.getPrefixedText(),
indexpageids: 1
}).then(function(result) {
var id = result.query.pageids;
return id < 0 ? "" : result.query.pages.revisions
}),
parseTalkPromise = loadTalkPromise.then(function(wikitext) {
return (0, _Template.parseTemplates)(wikitext, !0)
}).then(function(templates) {
return templates.filter(function(template) {
return null !== template.getTitle()
})
}).then(function(templates) {
return (0, _Template.getWithRedirectTo)(templates)
}).then(function(templates) {
return bannersPromise.then(function(allBanners) {
return (0, _util.filterAndMap)(templates, function(template) {
if (template.isShellTemplate()) return !0;
var mainText = template.redirectTarget ? template.redirectTarget.getMainText() : template.getTitle().getMainText();
return allBanners.withRatings.includes(mainText) || allBanners.withoutRatings.includes(mainText) || allBanners.wrappers.includes(mainText) || allBanners.notWPBM.includes(mainText) || allBanners.inactive.includes(mainText) || allBanners.wir.includes(mainText)
}, function(template) {
var mainText = template.redirectTarget ? template.redirectTarget.getMainText() : template.getTitle().getMainText();
return allBanners.wrappers.includes(mainText) && (template.redirectTarget = mw.Title.newFromText("Template:Subst:" + mainText)), (allBanners.withoutRatings.includes(mainText) || allBanners.wir.includes(mainText)) && (template.withoutRatings = !0), allBanners.inactive.includes(mainText) && (template.inactiveProject = !0), template
})
})
}),
templateDetailsPromise = parseTalkPromise.then(function(templates) {
return $.when.apply(null, .concat(_toConsumableArray(templates.map(function(template) {
return template.isShellTemplate() ? null : template.setClassesAndImportances()
})), _toConsumableArray(templates.map(function(template) {
return template.setParamDataAndSuggestions()
})))).then(function() {
return templates.forEach(function(template) {
return template.addMissingParams()
}), templates
})
}),
subjectPageCheckPromise = _api.default.get({
action: "query",
format: "json",
formatversion: "2",
prop: "categories",
titles: subjectPage.getPrefixedText(),
redirects: 1,
clcategories:
}).then(function(response) {
if (!response || !response.query || !response.query.pages) return null;
var redirectTarget = response.query.redirects && response.query.redirects.to || !1;
if (redirectTarget || !subjectIsArticle) return {
redirectTarget: redirectTarget
};
var page = response.query.pages,
hasCategory = function(category) {
return page.categories && page.categories.find(function(cat) {
return cat.title === "Category:" + category
})
};
return {
redirectTarget: redirectTarget,
disambig: hasCategory("All disambiguation pages"),
stubtag: hasCategory("All stub articles"),
isGA: hasCategory("Good articles"),
isFA: hasCategory("Featured articles"),
isFL: hasCategory("Featured lists"),
isList: !hasCategory("Featured lists") && /^Lists? of/.test(subjectPage.getPrefixedText())
}
}).catch(function() {
return null
}),
shouldGetOres = subjectIsArticle;
if (shouldGetOres) var oresPromise = (currentPage.isTalkPage() ? _api.default.get({
action: "query",
format: "json",
prop: "revisions",
titles: subjectPage.getPrefixedText(),
rvprop: "ids",
indexpageids: 1
}).then(function(result) {
if (result.query.redirects) return !1;
var id = result.query.pageids,
page = result.query.pages;
return "" !== page.missing && (id < 0 ? $.Deferred().reject() : page.revisions.revid)
}) : $.Deferred().resolve(_config.default.mw.wgRevisionId)).then(function(latestRevId) {
return !!latestRevId && _api.default.getORES(latestRevId).then(function(result) {
var data = result.enwiki.scores.articlequality;
if (data.error) return $.Deferred().reject(data.error.type, data.error.message);
var prediction = data.score.prediction,
probabilities = data.score.probability;
return "FA" === prediction || "GA" === prediction ? {
prediction: prediction,
probability: (100 * probabilities).toFixed(1) + "%"
} : {
prediction: prediction,
probability: (100 * probabilities).toFixed(1) + "%"
}
}).catch(function() {
return null
})
});
var isOpenedPromise = $.Deferred(),
loadDialogWin = _windowManager.default.openWindow("loadDialog", {
promises: ,
ores: shouldGetOres,
isOpened: isOpenedPromise
});
return loadDialogWin.opened.then(isOpenedPromise.resolve), $.when(prefsPromise, loadTalkPromise, templateDetailsPromise, subjectPageCheckPromise, shouldGetOres && oresPromise).then(function(preferences, talkWikitext, banners, subjectPageCheck, oresPredicition) {
var result = {
success: !0,
talkpage: talkPage,
subjectPage: subjectPage,
talkWikitext: talkWikitext,
banners: banners,
preferences: preferences,
isArticle: subjectIsArticle
};
subjectPageCheck && (result = function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments ? arguments : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
_defineProperty(target, key, source)
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key))
})
}
return target
}({}, result, {}, subjectPageCheck)), !oresPredicition || !subjectPageCheck || subjectPageCheck.isFL || (result.ores = oresPredicition), _windowManager.default.closeWindow("loadDialog", result)
}), loadDialogWin.closed.then(function(data) {
data && data.success ? setupCompletedPromise.resolve(data) : data && data.error ? setupCompletedPromise.reject(data.error.code, data.error.info) : setupCompletedPromise.resolve(null), cache.clearInvalidItems()
}), setupCompletedPromise
}
exports.default = _default
}, {
"./Template": 3,
"./api": 15,
"./cache": 17,
"./config": 18,
"./getBanners": 20,
"./prefs": 21,
"./util": 23,
"./windowManager": 24
}],
23: [function(require, module, exports) {
"use strict";
function _toConsumableArray(arr) {
return function(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr)
}(arr) || function(iter) {
if ("undefined" != typeof Symbol && Symbol.iterator in Object(iter)) return Array.from(iter)
}(arr) || function(o, minLen) {
if (!o) return;
if ("string" == typeof o) return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
"Object" === n && o.constructor && (n = o.constructor.name);
if ("Map" === n || "Set" === n) return Array.from(n);
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen)
}(arr) || function() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a () method.")
}()
}
function _arrayLikeToArray(arr, len) {
(null == len || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2 = arr;
return arr2
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.mostFrequent = function(array) {
if (!array || !Array.isArray(array) || 0 === array.length) return null;
var map = {},
mostFreq = null;
return array.forEach(function(item) {
map = (map || 0) + 1, (null === mostFreq || map > map) && (mostFreq = item)
}), mostFreq
}, exports.uniqueArray = function(array) {
if (!array || !Array.isArray(array) || 0 === array.length) return ;
var seen = {},
unique = ;
return array.forEach(function(item) {
seen || (unique.push(item), seen = !0)
}), unique
}, exports.classMask = function(classVal) {
if (!classVal) return classVal;
switch (classVal.toLowerCase()) {
case "fa":
case "fl":
case "a":
case "ga":
case "b":
case "c":
case "na":
case "fm":
case "al":
case "bl":
case "cl":
return classVal.toUpperCase();
case "start":
case "stub":
case "list":
case "portal":
case "project":
case "draft":
case "book":
case "future":
case "current":
case "complete":
case "substantial":
case "basic":
case "incomplete":
case "meta":
return classVal.slice(0, 1).toUpperCase() + classVal.slice(1).toLowerCase();
case "image":
case "img":
case "file":
return "File";
case "category":
case "cat":
case "categ":
return "Category";
case "disambiguation":
case "disambig":
case "disamb":
case "dab":
return "Disambig";
case "redirect":
case "redir":
case "red":
return "Redirect";
case "template":
case "temp":
case "tpl":
return "Template";
case "bplus":
case "b+":
return "Bplus";
case "fpo":
return "FPo";
default:
return classVal
}
}, exports.importanceMask = function(importance) {
return importance ? "na" !== importance.toLowerCase() ? importance.slice(0, 1).toUpperCase() + importance.slice(1).toLowerCase() : "NA" : importance
}, exports.normaliseYesNo = exports.filterAndMap = exports.isAfterDate = void 0;
exports.isAfterDate = function(dateString) {
return new Date(dateString) < new Date
};
var yesWords = ,
noWords = ;
exports.normaliseYesNo = function(val) {
if (null == val) return val;
var trimmedLcVal = val.trim().toLowerCase();
return yesWords.includes(trimmedLcVal) ? "yes" : noWords.includes(trimmedLcVal) ? "no" : trimmedLcVal
};
exports.filterAndMap = function(array, filterPredicate, mapTransform) {
return array.reduce(function(accumulated, currentVal, currentIndex) {
return filterPredicate(currentVal, currentIndex, array) ? .concat(_toConsumableArray(accumulated), ) : accumulated
}, )
}
}, {}],
24: [function(require, module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var _LoadDialog = _interopRequireDefault(require("./Windows/LoadDialog")),
_MainWindow = _interopRequireDefault(require("./Windows/MainWindow"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
var factory = new OO.Factory;
factory.register(_LoadDialog.default), factory.register(_MainWindow.default);
var manager = new OO.ui.WindowManager({
factory: factory
});
$(document.body).append(manager.$element);
var _default = manager;
exports.default = _default
}, {
"./Windows/LoadDialog": 13,
"./Windows/MainWindow": 14
}]
}, {}, );
/* </nowiki> */