User:Chlod/Scripts/Deputy.js: Difference between revisions

Content deleted Content added
(bot/CD)
(bot/CD)
Line 4,066:
 
var version = "0.8.0";
var gitAbbrevHash = "9aedaec3537070";
var gitBranch = "main";
var gitDate = "ThuSun, 515 Sep 2024 0022:2900:5031 +0800";
var gitVersion = "0.8.0+g9aedaecg3537070";
 
/**
Line 5,886:
}
 
/**
* Generates serializer and deserializer for serialized <b>string</b> enums.
*
* Trying to use anything that isn't a string enum here (union enum, numeral enum)
* will likely cause serialization/deserialization failures.
*
* @param _enum
* @param defaultValue
* @return An object containing a `serializer` and `deserializer`.
*/
function generateEnumSerializers(_enum, defaultValue) {
return {
serialize: (value) => value === defaultValue ? undefined : value,
deserialize: (value) => value
};
}
/**
* Generates configuration properties for serialized <b>string</b> enums.
Line 5,897 ⟶ 5,913:
*/
function generateEnumConfigurationProperties(_enum, defaultValue) {
return Object.assign(Object.assign({}, generateEnumSerializers(_enum, defaultValue)), { displayOptions: {
return {
serialize: (value) => value === defaultValue ? undefined : value,
deserialize: (value) => value,
displayOptions: {
type: 'radio'
}, allowedValues: fromObjectEntries(Array.from(new Set(Object.keys(_enum)).values())
},
.map((v) => [_enum[v], _enum[v]])), defaultValue: defaultValue });
allowedValues: fromObjectEntries(Array.from(new Set(Object.keys(_enum)).values())
.map((v) => [_enum[v], _enum[v]])),
defaultValue: defaultValue
};
}
var PortletNameView;
Line 5,935 ⟶ 5,945:
ContributionSurveyRowSigningBehavior["Never"] = "never";
})(ContributionSurveyRowSigningBehavior || (ContributionSurveyRowSigningBehavior = {}));
 
var DeputyPageToolbarState;
(function (DeputyPageToolbarState) {
DeputyPageToolbarState[DeputyPageToolbarState["Open"] = 0] = "Open";
DeputyPageToolbarState[DeputyPageToolbarState["Collapsed"] = 1] = "Collapsed";
DeputyPageToolbarState[DeputyPageToolbarState["Hidden"] = 2] = "Hidden";
})(DeputyPageToolbarState || (DeputyPageToolbarState = {}));
 
/**
Line 6,050 ⟶ 6,067:
type: 'checkbox'
}
}),
toolbarInitialState: new Setting(Object.assign(Object.assign({}, generateEnumSerializers(DeputyPageToolbarState, DeputyPageToolbarState.Open)), { defaultValue: DeputyPageToolbarState.Open, displayOptions: { hidden: true } }))
};
this.ante = {
Line 11,894 ⟶ 11,912:
constructor(options) {
var _a;
this.state = DeputyPageToolbarState.Open;
this.instanceId = generateId();
this.revisionStatusUpdateListener = this.onRevisionStatusUpdate.bind(this);
Line 11,900 ⟶ 11,919:
this.revision = (_a = options.revision) !== null && _a !== void 0 ? _a : mw.config.get('wgRevisionId');
}
this.state = window.deputy.config.cci.toolbarInitialState.get();
this.runAsyncJobs();
}
Line 12,145 ⟶ 12,165:
this.renderMenu(mw.msg('deputy.session.page.analysis'), deputyPageAnalysisOptions()),
this.renderMenu(mw.msg('deputy.session.page.tools'), deputyPageTools())));
}
/**
* Rends the page toolbar actions and main section, if the dropdown is open.
*/
renderOpen() {
return [
h_1("div", { class: "dp-pageToolbar-actions" },
h_1("div", { class: "dp-pageToolbar-close", role: "button", title: mw.msg('deputy.session.page.close'), onClick: () => this.setState(DeputyPageToolbarState.Hidden) }),
h_1("div", { class: "dp-pageToolbar-collapse", role: "button", title: mw.msg('deputy.session.page.collapse'), onClick: () => this.setState(DeputyPageToolbarState.Collapsed) })),
h_1("div", { class: "dp-pageToolbar-main" },
this.renderStatusDropdown(),
this.renderCaseInfo(),
this.renderRevisionInfo(),
this.revisionNavigationSection =
this.renderRevisionNavigationButtons(),
this.renderMenus())
];
}
/**
* Renders the collapsed toolbar button.
*
* @return The render button, to be included in the main toolbar.
*/
renderCollapsed() {
return h_1("div", { class: "dp-pageToolbar-collapsed", role: "button", title: mw.msg('deputy.session.page.expand'), onClick: () => this.setState(DeputyPageToolbarState.Open) });
}
/**
Line 12,150 ⟶ 12,195:
*/
render() {
console.log(this.state);
if (this.state === DeputyPageToolbarState.Hidden) {
const portletLink = mw.util.addPortletLink('p-tb', '#', mw.msg('deputy.session.page.open'), 'pt-dp-pt', mw.msg('deputy.session.page.open.tooltip'));
portletLink.querySelector('a').addEventListener('click', (event) => {
event.preventDefault();
this.setState(DeputyPageToolbarState.Open);
return false;
});
// Placeholder element
return this.element = h_1("div", { class: "deputy" });
}
else {
const toolbar = document.getElementById('pt-dp-pt');
if (toolbar) {
removeElement(toolbar);
}
}
return this.element = h_1("div", { class: "deputy dp-pageToolbar" },
this.renderStatusDropdownstate === DeputyPageToolbarState.Open && this.renderOpen(),
this.renderCaseInfostate === DeputyPageToolbarState.Collapsed && this.renderCollapsed(),);
this.renderRevisionInfo(),
this.revisionNavigationSection =
this.renderRevisionNavigationButtons(),
this.renderMenus());
}
/**
Line 12,169 ⟶ 12,227:
(_c = this.previousRevisionButton) === null || _c === void 0 ? void 0 : _c.setDisabled(disabled);
(_d = this.nextRevisionButton) === null || _d === void 0 ? void 0 : _d.setDisabled(disabled);
}
/**
* Sets the display state of the toolbar. This will also set the
* initial state configuration option for the user.
*
* @param state
*/
setState(state) {
this.state = state;
window.deputy.config.cci.toolbarInitialState.set(state);
window.deputy.config.save();
swapElements(this.element, this.render());
}
/**
Line 12,228 ⟶ 12,298:
}
/**
*
* @param data
*/
Line 18,531 ⟶ 18,600:
];
 
var deputyStyles = "/*=============================================================================== GLOBAL DEPUTY CLASSES===============================================================================*/* > .deputy.dp-heading {position: absolute;opacity: 0;pointer-events: none;}*:hover > .deputy.dp-heading:not(.dp-heading--active) {opacity: 1;pointer-events: all;}.dp-loadingDots-1, .dp-loadingDots-2, .dp-loadingDots-3 {display: inline-block;margin: 0.1em 0.6em 0.1em 0.1em;width: 0.8em;height: 0.8em;background-color: rgba(0, 0, 0, 50%);animation: dp-loadingDots linear 3s infinite;border-radius: 50%;}@keyframes dp-loadingDots {0% {background-color: rgba(0, 0, 0, 10%);}16% {background-color: rgba(0, 0, 0, 40%);}32% {background-color: rgba(0, 0, 0, 10%);}100% {background-color: rgba(0, 0, 0, 10%);}}.dp-loadingDots-1 {animation-delay: -1s;}.dp-loadingDots-2 {animation-delay: -0.5s;}#mw-content-text.dp-reloading {opacity: 0.2;pointer-events: none;}p.dp-messageWidget-message {margin: 0 0 0.5em 0;}.dp-messageWidget-actions .oo-ui-buttonElement {margin-top: 0;}.oo-ui-image-destructive.oo-ui-icon-checkAll, .oo-ui-image-destructive.mw-ui-icon-checkAll::before {background-image: url(\"data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2220%22 height=%2220%22 viewBox=%220 0 20 20%22%3E%3Ctitle%3E check all %3C/title%3E%3Cpath fill=%22%23d73333%22 d=%22m.29 12.71 1.42-1.42 2.22 2.22 8.3-10.14 1.54 1.26-9.7 11.86zM12 10h5v2h-5zm-3 4h5v2H9zm6-8h5v2h-5z%22/%3E%3C/svg%3E\");}/*=============================================================================== DEPUTY REVIEW DIALOG (DeputyReviewDialog)===============================================================================*/.dp-review-progress {flex: 1;width: 60%;min-width: 300px;}/*=============================================================================== DEPUTY ENTRY POINTS (DeputyCCISessionStartLink, etc.)===============================================================================*/.deputy.dp-sessionStarter {font-size: small;font-weight: normal;margin-left: 0.25em;vertical-align: baseline;line-height: 1em;font-family: sans-serif;}.deputy.dp-sessionStarter::before {content: '\\200B';}.mw-content-ltr .deputy.dp-sessionStarter .dp-sessionStarter-bracket:first-of-type,.mw-content-rtl .deputy.dp-sessionStarter .dp-sessionStarter-bracket:not(:first-of-type) {margin-right: 0.25em;color: #54595d;}.client-js .deputy.dp-sessionStarter .dp-sessionStarter-bracket:first-of-type,.client-js .deputy.dp-sessionStarter .dp-sessionStarter-bracket:not(:first-of-type) {margin-left: 0.25em;color: #54595d}.dp-cs-section-add {position: absolute;top: 0;/* -1.6em derived from MediaWiki list margins. */left: -1.6em;width: calc(100% + 1.6em);background-color: rgba(255, 255, 255, 75%);display: flex;justify-content: center;align-items: center;}.dp-cs-section-add .dp-cs-section-addButton {opacity: 0;transition: opacity 0.2s ease-in-out;}.dp-cs-section-add:hover .dp-cs-section-addButton {opacity: 1;}/*=============================================================================== DEPUTY CONTRIBUTION SURVEY SECTION===============================================================================*/.dp-cs-section-archived .dp-cs-row-content {background-color: rgba(255, 0, 0, 6%);}.dp-cs-session-notice {margin-top: 8px;position: sticky;top: 8px;z-index: 50;}.skin-vector-2022.vector-sticky-header-visible .dp-cs-session-notice {top: calc(3.125rem + 8px);}.dp-cs-section-footer {position: relative;padding: 8px;}.dp-cs-section-danger--separator {flex-basis: 100%;margin: 8px 0;border-bottom: 1px solid #d73333;color: #d73333;font-weight: bold;font-size: 0.7em;text-align: right;text-transform: uppercase;line-height: 0.7em;padding-bottom: 0.2em;}.dp-cs-section-closing {margin: 1em 1.75em;}.dp-cs-section-progress {margin-top: 8px;max-height: 0;transition: max-height 0.2s ease-in-out;display: flex;justify-content: center;align-items: center;overflow: hidden;}.dp-cs-section-progress.active {max-height: 50px;}.dp-cs-section-progress .oo-ui-progressBarWidget {flex: 1}.dp-cs-section-closingCommentsField {margin-top: 8px;}.dp-cs-extraneous {border: 1px solid rgba(0, 159, 255, 40%);background-color: rgba(0, 159, 255, 10%);margin-bottom: 8px;padding: 16px;}.dp-cs-extraneous > dl {margin-left: -1.6em;}.dp-cs-extraneous > :first-child {margin-top: 0 !important;}.dp-cs-extraneous > :last-child {margin-bottom: 0 !important;}.dp-cs-section-archived-warn, .dp-cs-row, .dp-cs-extraneous {margin-bottom: 8px;}.dp-cs-row .dp--loadingDots {display: flex;align-items: center;justify-content: center;padding: 0.4em;}.dp-cs-row-status {max-width: 5.4em;}.dp-cs-row-status .oo-ui-dropdownWidget-handle .oo-ui-labelElement-label {width: 0;opacity: 0;}.dp-cs-row-status .dp-cs-row-status--unknown:not(.oo-ui-optionWidget-selected) {display: none;}.dp-cs-row-head > * {vertical-align: middle;}.dp-cs-row-comments {padding: 16px;background-color: rgba(0, 159, 255, 10%);margin: 4px 0;}.dp-cs-row-comments > b {letter-spacing: 0.1em;font-weight: bold;text-transform: uppercase;color: rgba(0, 0, 0, 0.5);}.dp-cs-row-comments hr {border-color: rgb(0, 31, 51);}body.mediawiki.ltr .dp-cs-row-head > :not(:first-child):not(:last-child),body.mediawiki.ltr .dp-cs-row-head > :not(:first-child):not(:last-child) {margin-right: 16px;}body.mediawiki.rtl .dp-cs-row-head > :not(:first-child):not(:last-child),body.mediawiki.rtl .dp-cs-row-head > :not(:first-child):not(:last-child) {margin-left: 16px;}.dp-cs-row-links {margin-right: 0 !important;}.dp-cs-row-links > :not(:last-child) {margin-right: 8px !important;}.dp-cs-row-title {font-weight: bold;font-size: 1.2em;vertical-align: middle;}.dp-cs-row-details {color: #4a5054;font-weight: bold;}.dp-cs-row-toggle .oo-ui-iconElement-icon {background-size: 1em;}.dp-cs-row-toggle .oo-ui-buttonElement-button {border-radius: 50%;}.dp-cs-row .history-user,.dp-cs-row :not(.newpage) + .mw-changeslist-date {margin-left: 0.4em;margin-right: 0.2em;}.dp-cs-row .newpage {margin-left: 0.4em;}.dp-cs-row-content {padding: 16px;background-color: rgba(0, 0, 0, 6%);margin: 4px 0;}.dp-cs-row-content.dp-cs-row-content-empty {display: none !important;}.dp-cs-row-unfinishedWarning {margin-bottom: 8px;}.dp-cs-section-unfinishedWarning {margin-top: 8px;}.dp-cs-row-closeComments {font-family: monospace, monospace;font-size: small;}.dp-cs-row-closeComments:not(:last-child) {margin-bottom: 8px;}.dp-cs-row-finished .oo-ui-fieldLayout:first-child {margin-top: 0;}.dp-cs-row-finished .oo-ui-fieldLayout {margin-top: 8px;}.dp-cs-row-revisions .mw-tag-markers .mw-tag-marker:not(:first-child),.dp-cs-row-detail:not(:first-child) {margin-left: 0.2em;}.dp-cs-rev-checkbox {margin-right: 4px;}.dp-cs-rev-toggleDiff {vertical-align: baseline;margin-right: 4px;}.dp-cs-rev-diff {background-color: white;position: relative;}.dp-cs-rev-diff--loaded {margin: 4px 0;padding: 8px 14px;}.dp-cs-rev-diff--hidden {display: none;}.dp-cs-rev-toggleDiff > .oo-ui-buttonElement-button {padding: 0;min-height: 1em;background-color: unset !important;}.dp-cs-rev-toggleDiff .oo-ui-indicatorElement-indicator {top: -1px;}/*=============================================================================== DEPUTY PAGE TOOLBAR===============================================================================*/.dp-pageToolbar {position: fixed;bottom: 8px;left: 8px;z-index: 100;padding: 8px;background-color: #fff;border: 1px solid gray;font-size: 0.9rem;display: flex;}.dp-pageToolbar .dp-pageToolbar-main {padding: 8px;display: flex;align-items: center;}.dp-pageToolbar-actions {width: 12px;display: flex;flex-direction: column;font-size: 12px;line-height: 1em;}.dp-pageToolbar-close {cursor: pointer;height: 12px;text-align: center;background-color: rgba(0, 0, 0, 0.25);}.dp-pageToolbar-close:hover {transition: background-color 0.1s ease-in-out;background-color: rgba(0, 0, 0, 0.4);}.dp-pageToolbar-close::before {content: '×';vertical-align: middle;position: relative;right: 1px;}.dp-pageToolbar-collapse {cursor: pointer;flex: 1;background-color: rgba(0, 0, 0, 0.125);text-align: center;writing-mode: vertical-rl;position: relative;}.dp-pageToolbar-collapse:hover {transition: background-color 0.1s ease-in-out;background-color: rgba(0, 0, 0, 0.25);}.dp-pageToolbar-collapse::before {content: '»';position: absolute;vertical-align: middle;width: 12px;left: 0;bottom: 2px;}.dp-pageToolbar-collapsed {cursor: pointer;width: 32px;height: 32px;/* logo-white.svg */background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDgwIDEwODAiIHdpZHRoPSIxMDgwIiBoZWlnaHQ9IjEwODAiPjxkZWZzPjxzdHlsZT4uY2xzLTF7ZmlsbDojMDI5N2IxO308L3N0eWxlPjwvZGVmcz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik04NzcuNTQsNDM4LjY5YTQzNy41NCw0MzcuNTQsMCwwLDEtODQuMzgsMjU4Ljc4bDI2Ny4wNiwyNjcuMjJhNjcuNTYsNjcuNTYsMCwxLDEtOTUuNTYsOTUuNTRMNjk3LjYsNzkzYTQzNi4yNyw0MzYuMjcsMCwwLDEtMjU4LjgzLDg0LjM2QzE5Ni4zOSw4NzcuMzcsMCw2ODEsMCw0MzguNjlTMTk2LjM5LDAsNDM4Ljc3LDAsODc3LjU0LDE5Ni4zNSw4NzcuNTQsNDM4LjY5Wk00MzguNzcsNzQyLjM5YzE2Ny43LDAsMzAzLjc3LTEzNiwzMDMuNzctMzAzLjdTNjA2LjQ3LDEzNSw0MzguNzcsMTM1LDEzNSwyNzEsMTM1LDQzOC42OSwyNzEuMDcsNzQyLjM5LDQzOC43Nyw3NDIuMzlaIi8+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNTI0LjgzLDUxNS4yOGExMDQuODUsMTA0Ljg1LDAsMCwxLTE0OS40MSwwYy00MS41LTQxLjg3LTQxLjUtMTEwLDAtMTUxLjk1YTEwNC45MiwxMDQuOTIsMCwwLDEsMTQ5LjUxLjA4QTUwLjc2LDUwLjc2LDAsMCwwLDU5NywyOTEuOWEyMDYuNDQsMjA2LjQ0LDAsMCwwLTI5My41NSwwYy04MC41Nyw4MS4yNy04MC41NywyMTMuNTMsMCwyOTQuODNBMjA1LjI1LDIwNS4yNSwwLDAsMCw0NTAuMTgsNjQ4aDBBMjA1LjMsMjA1LjMsMCwwLDAsNTk3LDU4Ni43MWE1MC43Nyw1MC43NywwLDAsMC03Mi4xNi03MS40M1oiLz48L3N2Zz4=') no-repeat center;background-size: 24px;}@media only screen and (max-width: 768px) {.dp-pageToolbar {flex-wrap: wrap;bottom: 0;left: 0;border-left: 0;border-bottom: 0;border-right: 0;width: 100%;}}.dp-pt-section {display: inline-block;white-space: nowrap;}.dp-pt-section .oo-ui-popupWidget-popup {/** Avoid preventing line breaks in popups */white-space: initial;}.dp-pt-section + .dp-pt-section {/* TODO: Recheck RTL compatibility */margin-left: 16px;padding-left: 16px;border-left: 1px solid gray;}.dp-pt-section:last-child {/* TODO: Recheck RTL compatibility */margin-right: 8px;}.dp-pt-section-label {font-weight: bold;font-size: 0.6rem;color: #4a5054;text-transform: uppercase;}.dp-pt-section-content .oo-ui-buttonElement:last-child {margin-right: 0;}.dp-pt-caseInfo {font-weight: bold;font-size: 1.3rem;pointer-events: none;}.dp-pt-missingRevision {white-space: normal;}.dp-pageToolbar .dp-cs-row-status {width: 5.4em;}.dp-pt-menu .oo-ui-menuSelectWidget {min-width: 300px;}.dp-pt-menu .oo-ui-menuOptionWidget {padding-top: 8px;padding-bottom: 8px;}";
 
var deputyCoreEnglish = {
Line 18,618 ⟶ 18,687:
"deputy.session.revision.new.tooltip": "This edit created a new page.",
"deputy.session.revision.missing": "The revision [[Special:Diff/$1|$1]] could not be found. It may have been deleted or suppressed.",
"deputy.session.page.close": "Minimize the toolbar to the sidebar",
"deputy.session.page.collapse": "Collapse the toolbar",
"deputy.session.page.expand": "Expand the toolbar",
"deputy.session.page.open": "Open Deputy toolbar",
"deputy.session.page.open.tooltip": "Open the Deputy page toolbar",
"deputy.session.page.diff.previous": "Navigate to the previous unassessed revision",
"deputy.session.page.diff.next": "Navigate to the next unassessed revision",