diff --git a/chrome/content/zotero/elements/attachmentPreview.js b/chrome/content/zotero/elements/attachmentPreview.js index e98e90ceaa..dac28ad9f0 100644 --- a/chrome/content/zotero/elements/attachmentPreview.js +++ b/chrome/content/zotero/elements/attachmentPreview.js @@ -447,7 +447,7 @@ try { _reader.uninit(); } - catch (e) {} + catch {} } this._id("preview")?.remove(); // Make previously loaded next-preview be current preview browser diff --git a/chrome/content/zotero/elements/base.js b/chrome/content/zotero/elements/base.js index 78ae15ca9c..fc965e2e35 100644 --- a/chrome/content/zotero/elements/base.js +++ b/chrome/content/zotero/elements/base.js @@ -82,4 +82,5 @@ function XULElementMixin(Class) { }; } +// eslint-disable-next-line no-unused-vars var XULElementBase = XULElementMixin(XULElement); diff --git a/chrome/content/zotero/elements/collapsibleSection.js b/chrome/content/zotero/elements/collapsibleSection.js index d6f6b15bbf..598461587f 100644 --- a/chrome/content/zotero/elements/collapsibleSection.js +++ b/chrome/content/zotero/elements/collapsibleSection.js @@ -301,7 +301,7 @@ moveSectionDown.hidden = !canMoveDown; resetSectionOrder.hidden = !canReset; - reorderSeparator.hidden = !canMoveUp && !canMoveDown && !canReset; + reorderSeparator.hidden = !canMoveUp && !canMoveDown && !canReset; }); return contextMenu; diff --git a/chrome/content/zotero/elements/colorPicker.js b/chrome/content/zotero/elements/colorPicker.js index c9c8189690..b04f743fc9 100644 --- a/chrome/content/zotero/elements/colorPicker.js +++ b/chrome/content/zotero/elements/colorPicker.js @@ -77,7 +77,7 @@ try { localized = Zotero.getString(label); } - catch (e) {} + catch {} if (!localized || localized == label) { return label; } diff --git a/chrome/content/zotero/elements/editableText.js b/chrome/content/zotero/elements/editableText.js index dbe5558ef0..22bf14ade1 100644 --- a/chrome/content/zotero/elements/editableText.js +++ b/chrome/content/zotero/elements/editableText.js @@ -153,7 +153,7 @@ return props; } } - catch (e) { + catch { // Ignore } return null; diff --git a/chrome/content/zotero/elements/guidancePanel.js b/chrome/content/zotero/elements/guidancePanel.js index d7f0510293..a721a82dd3 100644 --- a/chrome/content/zotero/elements/guidancePanel.js +++ b/chrome/content/zotero/elements/guidancePanel.js @@ -99,7 +99,7 @@ try { shown = Zotero.Prefs.get(pref); } - catch (e) {} + catch {} if (shown && !force) { return; } diff --git a/chrome/content/zotero/elements/itemBox.js b/chrome/content/zotero/elements/itemBox.js index 40dbafcfb0..c3b926bda0 100644 --- a/chrome/content/zotero/elements/itemBox.js +++ b/chrome/content/zotero/elements/itemBox.js @@ -2887,7 +2887,7 @@ _handleCreatorTransformCapitalize = (event) => { this.capitalizeCreatorName(event); - } + }; _handleLinkMenuShowing = () => { let menu = this._linkMenu; diff --git a/chrome/content/zotero/elements/itemPaneSection.js b/chrome/content/zotero/elements/itemPaneSection.js index dcca5e8572..51e8d8cb90 100644 --- a/chrome/content/zotero/elements/itemPaneSection.js +++ b/chrome/content/zotero/elements/itemPaneSection.js @@ -106,7 +106,7 @@ class ItemPaneSectionElementBase extends XULElementBase { this._section.removeEventListener("toggle", this._handleSectionToggle); this._section = null; } - this._resetRenderedFlags() + this._resetRenderedFlags(); } initCollapsibleSection() { diff --git a/chrome/content/zotero/elements/menulistItemTypes.js b/chrome/content/zotero/elements/menulistItemTypes.js index 2508a6a834..42eac37304 100644 --- a/chrome/content/zotero/elements/menulistItemTypes.js +++ b/chrome/content/zotero/elements/menulistItemTypes.js @@ -33,10 +33,6 @@ } class ItemTypeMenuList extends customElements.get("menulist") { - constructor() { - super(); - } - connectedCallback() { super.connectedCallback(); diff --git a/chrome/content/zotero/elements/publicationsLicenseInfo.js b/chrome/content/zotero/elements/publicationsLicenseInfo.js index 5b90a72357..11beaee82e 100644 --- a/chrome/content/zotero/elements/publicationsLicenseInfo.js +++ b/chrome/content/zotero/elements/publicationsLicenseInfo.js @@ -23,7 +23,6 @@ ***** END LICENSE BLOCK ***** */ -/* global XULElementBase: false */ { const links = { diff --git a/chrome/content/zotero/elements/richlistCheckbox.js b/chrome/content/zotero/elements/richlistCheckbox.js index 4641fe9762..b3bada01ff 100644 --- a/chrome/content/zotero/elements/richlistCheckbox.js +++ b/chrome/content/zotero/elements/richlistCheckbox.js @@ -29,6 +29,7 @@ if (!customElements.get("richlistitem")) { delete document.createXULElement("richlistitem"); } + /** * Extend richlistbox for checkbox inputs since we use them in multiple places */ @@ -37,7 +38,7 @@ this._checkbox = document.createXULElement('checkbox'); this._checkbox.setAttribute('native', 'true'); this._checkbox.setAttribute('checked', this.checked); - this._checkbox.addEventListener('focus', () => this.control.focus()) + this._checkbox.addEventListener('focus', () => this.control.focus()); this._label = document.createElement('label'); this._label.textContent = this.label; this.append(this._checkbox); @@ -46,11 +47,11 @@ // this.control (parent richlistbox) only available after connecting this.control.addEventListener('keypress', (event) => { if ( - event.key == " " && - !event.ctrlKey && - !event.shiftKey && - !event.altKey && - !event.metaKey + event.key == " " + && !event.ctrlKey + && !event.shiftKey + && !event.altKey + && !event.metaKey ) { if (!this.selected) return; this.checked = !this.checked; @@ -67,17 +68,19 @@ get label() { return this.getAttribute('label'); } + set label(val) { this._label.innerText = val; - return this.setAttribute('label', 'val'); + this.setAttribute('label', 'val'); } get checked() { return JSON.parse(this.getAttribute('checked')); } + set checked(val) { - this._checkbox.setAttribute('checked', !!val); - return this.setAttribute('checked', !!val); + this._checkbox.setAttribute('checked', !!val); + this.setAttribute('checked', !!val); } } diff --git a/chrome/content/zotero/elements/textLink.js b/chrome/content/zotero/elements/textLink.js index 90df930011..7f2762ca9a 100644 --- a/chrome/content/zotero/elements/textLink.js +++ b/chrome/content/zotero/elements/textLink.js @@ -48,12 +48,12 @@ var uri = null; try { const nsISSM = Components.interfaces.nsIScriptSecurityManager; - const secMan = - Components.classes["@mozilla.org/scriptsecuritymanager;1"] + const secMan + = Components.classes["@mozilla.org/scriptsecuritymanager;1"] .getService(nsISSM); - const ioService = - Components.classes["@mozilla.org/network/io-service;1"] + const ioService + = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); uri = ioService.newURI(href, null, null); @@ -63,7 +63,7 @@ secMan.checkLoadURIWithPrincipal(nullPrincipal, uri, nsISSM.DISALLOW_INHERIT_PRINCIPAL); } - catch (ex) { + catch { var msg = "Error: Cannot open a " + uri.scheme + ": link using the zotero-text-link CE."; Components.utils.reportError(msg); return; @@ -83,14 +83,11 @@ // otherwise, fall back to opening the anchor directly var win = window; if (win.isChromeWindow) { - while (win.opener && !win.opener.closed) - win = win.opener; + while (win.opener && !win.opener.closed) win = win.opener; } - if (uri) - win.open(uri.spec); - else - win.open(href); + if (uri) win.open(uri.spec); + else win.open(href); event.preventDefault(); } diff --git a/chrome/content/zotero/elements/zoteroSearch.js b/chrome/content/zotero/elements/zoteroSearch.js index fc3d06e461..4945654df9 100644 --- a/chrome/content/zotero/elements/zoteroSearch.js +++ b/chrome/content/zotero/elements/zoteroSearch.js @@ -89,8 +89,9 @@ this.querySelector('#joinModeMenu').value = 'all'; var conditionsBox = this.querySelector('#conditions'); - while (conditionsBox.hasChildNodes()) + while (conditionsBox.hasChildNodes()) { conditionsBox.removeChild(conditionsBox.firstChild); + } var conditions = this.search.getConditions(); for (let id in conditions) { @@ -100,10 +101,12 @@ case 'recursive': case 'noChildren': case 'includeParentsAndChildren': + { let checkbox = condition.condition + 'Checkbox'; this.querySelector(`#${checkbox}`).setAttribute('condition', id); this.querySelector(`#${checkbox}`).checked = condition.operator == 'true'; continue; + } } if (condition.condition == 'joinMode') { @@ -125,15 +128,15 @@ // Default to an empty 'title' condition if (!ref) { - ref = this.search.getCondition(this.search.addCondition("title","contains","")) + ref = this.search.getCondition(this.search.addCondition("title", "contains", "")); } condition.initWithParentAndCondition(this, ref); - if (conditionsBox.childNodes.length == 2){ + if (conditionsBox.childNodes.length == 2) { conditionsBox.childNodes[0].enableRemoveButton(); } - else if (conditionsBox.childNodes.length == 1){ + else if (conditionsBox.childNodes.length == 1) { conditionsBox.childNodes[0].disableRemoveButton(); } } @@ -143,14 +146,14 @@ this.search.removeCondition(id); - for (var i = 0, len=conditionsBox.childNodes.length; i < len; i++){ - if (conditionsBox.childNodes[i].conditionID == id){ + for (var i = 0, len = conditionsBox.childNodes.length; i < len; i++) { + if (conditionsBox.childNodes[i].conditionID == id) { conditionsBox.removeChild(conditionsBox.childNodes[i]); break; } } - if (conditionsBox.childNodes.length == 1){ + if (conditionsBox.childNodes.length == 1) { conditionsBox.childNodes[0].disableRemoveButton(); } } @@ -171,22 +174,18 @@ updateJoinMode() { var menu = this.querySelector('#joinModeMenu'); - if(menu.hasAttribute('condition')) - this.search.updateCondition(menu.getAttribute('condition'),'joinMode',menu.value,null); - else - menu.setAttribute('condition', this.search.addCondition('joinMode',menu.value,null)); + if (menu.hasAttribute('condition')) this.search.updateCondition(menu.getAttribute('condition'), 'joinMode', menu.value, null); + else menu.setAttribute('condition', this.search.addCondition('joinMode', menu.value, null)); } updateCheckbox(condition) { var checkbox = this.querySelector('#' + condition + 'Checkbox'); var value = checkbox.checked ? 'true' : 'false'; - if(checkbox.hasAttribute('condition')) - { + if (checkbox.hasAttribute('condition')) { this.search.updateCondition(checkbox.getAttribute('condition'), condition, value, null); } - else - { + else { checkbox.setAttribute('condition', this.search.addCondition(condition, value, null)); } @@ -196,7 +195,7 @@ updateSearch() { var conditionsBox = this.querySelector('#conditions'); if (conditionsBox.hasChildNodes()) { - for(var i = 0, len=conditionsBox.childNodes.length; i < len; i++) { + for (var i = 0, len = conditionsBox.childNodes.length; i < len; i++) { conditionsBox.childNodes[i].updateSearch(); } } @@ -295,7 +294,7 @@ try { baseFields = Zotero.ItemFields.getTypeFieldsFromBase(condition.name); } - catch (e) {} + catch {} // Add tooltip, building it if it doesn't exist if (baseFields) { @@ -304,13 +303,14 @@ try { fieldName = Zotero.ItemFields.getLocalizedString(condition.name); } - catch (e) {} + catch {} + let localized; if (fieldName) { - var localized = [fieldName]; + localized = [fieldName]; } else { - var localized = []; + localized = []; } for (let baseField of baseFields) { @@ -407,13 +407,11 @@ // Display appropriate operators for condition var selectThis; - for(var i = 0, len = operatorsList.firstChild.childNodes.length; i < len; i++) - { + for (var i = 0, len = operatorsList.firstChild.childNodes.length; i < len; i++) { var val = operatorsList.firstChild.childNodes[i].getAttribute('value'); var hidden = !operators[val]; operatorsList.firstChild.childNodes[i].setAttribute('hidden', hidden); - if (!hidden && (selectThis == null || this.selectedOperator == val)) - { + if (!hidden && (selectThis === null || this.selectedOperator == val)) { selectThis = i; } } @@ -425,7 +423,8 @@ // Generate drop-down menu instead of textbox for certain conditions switch (conditionName) { case 'collection': - var rows = []; + { + let rows = []; var libraryID = this.parent.search.libraryID; @@ -460,43 +459,45 @@ } this.createValueMenu(rows); break; - + } case 'itemType': - var rows = Zotero.ItemTypes.getTypes().map(type => ({ + { + let rows = Zotero.ItemTypes.getTypes().map(type => ({ name: Zotero.ItemTypes.getLocalizedString(type.id), value: type.name })); // Sort by localized name - var collation = Zotero.getLocaleCollation(); + let collation = Zotero.getLocaleCollation(); rows.sort((a, b) => collation.compareString(1, a.name, b.name)); this.createValueMenu(rows); break; - + } case 'fileTypeID': - var rows = Zotero.FileTypes.getTypes().map(type => ({ + { + let rows = Zotero.FileTypes.getTypes().map(type => ({ name: Zotero.getString('file-type-' + type.name), value: type.id })); // Sort by localized name - var collation = Zotero.getLocaleCollation(); + let collation = Zotero.getLocaleCollation(); rows.sort((a, b) => collation.compareString(1, a.name, b.name)); this.createValueMenu(rows); break; - + } default: - if (operatorsList.value=='isInTheLast') - { + { + if (operatorsList.value == 'isInTheLast') { this.querySelector('#value-date-age').value = this.value; } // Textbox else { // If switching from menu to textbox, clear value - if (this.querySelector('#valuefield').hidden){ + if (this.querySelector('#valuefield').hidden) { this.querySelector('#valuefield').value = ''; } // If switching between textbox conditions, get loaded value for new one @@ -507,6 +508,7 @@ // Update field drop-down if applicable this.querySelector('#valuefield').update(conditionName, this.mode); } + } } this.onOperatorSelected(); @@ -525,10 +527,9 @@ } // Textbox + units dropdown for isInTheLast operator - else if (operatorsList.value=='isInTheLast') - { + else if (operatorsList.value == 'isInTheLast') { // If switching from text field, clear value - if (this.querySelector('#value-date-age').hidden){ + if (this.querySelector('#value-date-age').hidden) { this.value = ''; } this.querySelector('#valuefield').hidden = true; @@ -537,10 +538,9 @@ } // Textbox - else - { + else { // If switching from date age, clear value - if (this.querySelector('#valuefield').hidden){ + if (this.querySelector('#valuefield').hidden) { this.value = ''; } this.querySelector('#valuefield').hidden = false; @@ -580,11 +580,10 @@ initWithParentAndCondition(parent, condition) { this.parent = parent; - this.conditionID = condition['id']; + this.conditionID = condition.id; var menu = this.querySelector('#conditionsmenu'); - if(this.parent.search) - { + if (this.parent.search) { this.dontupdate = true; //so that the search doesn't get updated while we are creating controls. var prefix = ''; @@ -610,19 +609,18 @@ menu.setAttribute('value', uiCondition); // Convert datetimes from UTC to localtime - if ((condition['condition']=='accessDate' || - condition['condition']=='dateAdded' || - condition['condition']=='dateModified') && - Zotero.Date.isSQLDateTime(condition['value'])){ - - condition['value'] = - Zotero.Date.dateToSQL(Zotero.Date.sqlToDate(condition['value'], true)); + if ((condition.condition == 'accessDate' + || condition.condition == 'dateAdded' + || condition.condition == 'dateModified') + && Zotero.Date.isSQLDateTime(condition.value)) { + condition.value + = Zotero.Date.dateToSQL(Zotero.Date.sqlToDate(condition.value, true)); } - this.mode = condition['mode']; - this.querySelector('#operatorsmenu').value = condition['operator']; - this.value = prefix + - (condition.value ? condition.value : ''); + this.mode = condition.mode; + this.querySelector('#operatorsmenu').value = condition.operator; + this.value = prefix + + (condition.value ? condition.value : ''); this.dontupdate = false; } @@ -631,15 +629,14 @@ } updateSearch() { - if(this.parent && this.parent.search && !this.dontupdate) - { + if (this.parent && this.parent.search && !this.dontupdate) { var condition = this.selectedCondition; var operator = this.querySelector('#operatorsmenu').value; + let value; // Regular text field - if (!this.querySelector('#valuefield').hidden) - { - var value = this.querySelector('#valuefield').value; + if (!this.querySelector('#valuefield').hidden) { + value = this.querySelector('#valuefield').value; // Convert datetimes to UTC before saving switch (condition) { @@ -647,41 +644,37 @@ case 'dateAdded': case 'dateModified': if (Zotero.Date.isSQLDateTime(value)) { - var value = Zotero.Date.dateToSQL(Zotero.Date.sqlToDate(value), true); + value = Zotero.Date.dateToSQL(Zotero.Date.sqlToDate(value), true); } } // Append mode to condition - if (this.querySelector('#valuefield').mode){ + if (this.querySelector('#valuefield').mode) { condition += '/' + this.querySelector('#valuefield').mode; } } // isInTheLast operator - else if (!this.querySelector('#value-date-age').hidden) - { - var value = this.querySelector('#value-date-age').value; + else if (!this.querySelector('#value-date-age').hidden) { + value = this.querySelector('#value-date-age').value; } // Handle special C1234 and S5678 form for // collections and searches else if (condition == 'collection') { - var letter = this.querySelector('#valuemenu').value.substr(0,1); - if (letter=='C') - { + var letter = this.querySelector('#valuemenu').value.substr(0, 1); + if (letter == 'C') { condition = 'collection'; } - else if (letter=='S') - { + else if (letter == 'S') { condition = 'savedSearch'; } - var value = this.querySelector('#valuemenu').value.substr(1); + value = this.querySelector('#valuemenu').value.substr(1); } // Regular drop-down menu - else - { - var value = this.querySelector('#valuemenu').value; + else { + value = this.querySelector('#valuemenu').value; } this.parent.search.updateCondition(this.conditionID, condition, operator, value); } @@ -706,7 +699,7 @@ revealSelectedCondition(menu) { if (!this.selectedCondition || this.isPrimaryCondition(this.selectedCondition)) { - return; + return false; } if (!menu) { @@ -733,14 +726,14 @@ onLibraryChange() { switch (this.selectedCondition) { - case 'collection': - this.onConditionSelected(this.selectedCondition, true); - break; + case 'collection': + this.onConditionSelected(this.selectedCondition, true); + break; } } onRemoveClicked() { - if (this.parent){ + if (this.parent) { window.resizeBy(0, -1 * this.getBoundingClientRect().height); window.dispatchEvent(new CustomEvent('resize')); this.parent.removeCondition(this.conditionID); @@ -749,14 +742,14 @@ onAddClicked(event) { event.preventDefault(); - if (this.parent){ + if (this.parent) { let ref = this.parent.search.getCondition( this.parent.search.addCondition( this.querySelector('#conditionsmenu').getAttribute('data-value'), this.querySelector('#operatorsmenu').value, "" ) - ) + ); this.parent.addCondition(ref); window.resizeBy(0, this.getBoundingClientRect().height); } @@ -814,20 +807,20 @@ } get mode() { - if (this.getAttribute('hasOptions')!='true'){ + if (this.getAttribute('hasOptions') != 'true') { return false; } var menu = this.querySelector('#textbox-fulltext-menu'); var selectedIndex = -1; - for (var i=0; i