diff --git a/chrome/content/zotero/locateMenu.js b/chrome/content/zotero/locateMenu.js index a46fa5afd1..13df37cd27 100644 --- a/chrome/content/zotero/locateMenu.js +++ b/chrome/content/zotero/locateMenu.js @@ -544,7 +544,7 @@ var Zotero_LocateMenu = new function() { this.useExternalViewer = true; this.canHandleItem = function (item) { - return _getBestFile(item).then(function (item) !!item); + return _getBestFile(item).then(item => !!item); } this.handleItems = Zotero.Promise.coroutine(function* (items, event) { @@ -573,7 +573,7 @@ var Zotero_LocateMenu = new function() { */ ViewOptions._libraryLookup = new function() { this.icon = "chrome://zotero/skin/locate-library-lookup.png"; - this.canHandleItem = function (item) Zotero.Promise.resolve(item.isRegularItem()); + this.canHandleItem = function (item) { return Zotero.Promise.resolve(item.isRegularItem()); }; this.handleItems = Zotero.Promise.method(function (items, event) { var urls = []; for (let item of items) { diff --git a/chrome/content/zotero/xpcom/data/cachedTypes.js b/chrome/content/zotero/xpcom/data/cachedTypes.js index 620a2b0b02..e34b6089f6 100644 --- a/chrome/content/zotero/xpcom/data/cachedTypes.js +++ b/chrome/content/zotero/xpcom/data/cachedTypes.js @@ -371,9 +371,9 @@ Zotero.ItemTypes = new function() { } if (params.length) { sql += 'OR id IN ' - + '(' + params.map(function () '?').join() + ') ' + + '(' + params.map(() => '?').join() + ') ' + 'ORDER BY id NOT IN ' - + '(' + params.map(function () '?').join() + ') '; + + '(' + params.map(() => '?').join() + ') '; params = params.concat(params); } else { diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js index b7e998fdb5..c210e4aed6 100644 --- a/chrome/content/zotero/xpcom/data/collection.js +++ b/chrome/content/zotero/xpcom/data/collection.js @@ -45,32 +45,32 @@ Zotero.Collection.prototype._dataTypes = Zotero.Collection._super.prototype._dat ]); Zotero.defineProperty(Zotero.Collection.prototype, 'ChildObjects', { - get: function() Zotero.Items + get: function() { return Zotero.Items; } }); Zotero.defineProperty(Zotero.Collection.prototype, 'id', { - get: function() this._get('id'), - set: function(val) this._set('id', val) + get: function() { return this._get('id'); }, + set: function(val) { return this._set('id', val); } }); Zotero.defineProperty(Zotero.Collection.prototype, 'libraryID', { - get: function() this._get('libraryID'), - set: function(val) this._set('libraryID', val) + get: function() { return this._get('libraryID'); }, + set: function(val) { return this._set('libraryID', val); } }); Zotero.defineProperty(Zotero.Collection.prototype, 'key', { - get: function() this._get('key'), - set: function(val) this._set('key', val) + get: function() { return this._get('key'); }, + set: function(val) { return this._set('key', val); } }); Zotero.defineProperty(Zotero.Collection.prototype, 'name', { - get: function() this._get('name'), - set: function(val) this._set('name', val) + get: function() { return this._get('name'); }, + set: function(val) { return this._set('name', val); } }); Zotero.defineProperty(Zotero.Collection.prototype, 'version', { - get: function() this._get('version'), - set: function(val) this._set('version', val) + get: function() { return this._get('version'); }, + set: function(val) { return this._set('version', val); } }); Zotero.defineProperty(Zotero.Collection.prototype, 'synced', { - get: function() this._get('synced'), - set: function(val) this._set('synced', val) + get: function() { return this._get('synced'); }, + set: function(val) { return this._set('synced', val); } }); Zotero.defineProperty(Zotero.Collection.prototype, 'parent', { get: function() { @@ -290,14 +290,14 @@ Zotero.Collection.prototype._saveData = Zotero.Promise.coroutine(function* (env) env.sqlColumns.unshift('collectionID'); env.sqlValues.unshift(collectionID ? { int: collectionID } : null); - let placeholders = env.sqlColumns.map(function () '?').join(); + let placeholders = env.sqlColumns.map(() => '?').join(); let sql = "INSERT INTO collections (" + env.sqlColumns.join(', ') + ") " + "VALUES (" + placeholders + ")"; yield Zotero.DB.queryAsync(sql, env.sqlValues); } else { let sql = 'UPDATE collections SET ' - + env.sqlColumns.map(function (x) x + '=?').join(', ') + ' WHERE collectionID=?'; + + env.sqlColumns.map(x => x + '=?').join(', ') + ' WHERE collectionID=?'; env.sqlValues.push(collectionID ? { int: collectionID } : null); yield Zotero.DB.queryAsync(sql, env.sqlValues); } @@ -604,7 +604,7 @@ Zotero.Collection.prototype._eraseData = Zotero.Promise.coroutine(function* (env } } - var placeholders = collections.map(function () '?').join(); + var placeholders = collections.map(() => '?').join(); // Remove item associations for all descendent collections yield Zotero.DB.queryAsync('DELETE FROM collectionItems WHERE collectionID IN ' diff --git a/chrome/content/zotero/xpcom/data/collections.js b/chrome/content/zotero/xpcom/data/collections.js index ff6566fb13..b43a3ae87e 100644 --- a/chrome/content/zotero/xpcom/data/collections.js +++ b/chrome/content/zotero/xpcom/data/collections.js @@ -104,7 +104,7 @@ Zotero.Collections = function() { } // Do proper collation sort - children.sort(function (a, b) Zotero.localeCompare(a.name, b.name)); + children.sort((a, b) => Zotero.localeCompare(a.name, b.name)); if (!recursive) return children; diff --git a/chrome/content/zotero/xpcom/data/dataObject.js b/chrome/content/zotero/xpcom/data/dataObject.js index 9c99eef61a..35aedb5a36 100644 --- a/chrome/content/zotero/xpcom/data/dataObject.js +++ b/chrome/content/zotero/xpcom/data/dataObject.js @@ -66,13 +66,13 @@ Zotero.DataObject.prototype._objectType = 'dataObject'; Zotero.DataObject.prototype._dataTypes = ['primaryData']; Zotero.defineProperty(Zotero.DataObject.prototype, 'objectType', { - get: function() this._objectType + get: function() { return this._objectType; } }); Zotero.defineProperty(Zotero.DataObject.prototype, 'id', { - get: function() this._id + get: function() { return this._id; } }); Zotero.defineProperty(Zotero.DataObject.prototype, 'libraryID', { - get: function() this._libraryID + get: function() { return this._libraryID; } }); Zotero.defineProperty(Zotero.DataObject.prototype, 'library', { get: function () { @@ -80,18 +80,18 @@ Zotero.defineProperty(Zotero.DataObject.prototype, 'library', { } }); Zotero.defineProperty(Zotero.DataObject.prototype, 'key', { - get: function() this._key + get: function() { return this._key; } }); Zotero.defineProperty(Zotero.DataObject.prototype, 'libraryKey', { - get: function() this._libraryID + "/" + this._key + get: function() { return this._libraryID + "/" + this._key; } }); Zotero.defineProperty(Zotero.DataObject.prototype, 'parentKey', { - get: function () this._getParentKey(), - set: function(v) this._setParentKey(v) + get: function () { return this._getParentKey(); }, + set: function(v) { return this._setParentKey(v); } }); Zotero.defineProperty(Zotero.DataObject.prototype, 'parentID', { - get: function() this._getParentID(), - set: function(v) this._setParentID(v) + get: function() { return this._getParentID(); }, + set: function(v) { return this._setParentID(v); } }); Zotero.defineProperty(Zotero.DataObject.prototype, '_canHaveParent', { @@ -99,7 +99,7 @@ Zotero.defineProperty(Zotero.DataObject.prototype, '_canHaveParent', { }); Zotero.defineProperty(Zotero.DataObject.prototype, 'ObjectsClass', { - get: function() this._ObjectsClass + get: function() { return this._ObjectsClass; } }); diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index 7426e453bf..1b399ca9de 100644 --- a/chrome/content/zotero/xpcom/data/dataObjects.js +++ b/chrome/content/zotero/xpcom/data/dataObjects.js @@ -62,18 +62,18 @@ Zotero.DataObjects.prototype._ZDO_idOnly = false; // Public properties Zotero.defineProperty(Zotero.DataObjects.prototype, 'idColumn', { - get: function() this._ZDO_id + get: function() { return this._ZDO_id; } }); Zotero.defineProperty(Zotero.DataObjects.prototype, 'table', { - get: function() this._ZDO_table + get: function() { return this._ZDO_table; } }); Zotero.defineProperty(Zotero.DataObjects.prototype, 'relationsTable', { - get: function() this._ZDO_object + 'Relations' + get: function() { return this._ZDO_object + 'Relations'; } }); Zotero.defineProperty(Zotero.DataObjects.prototype, 'primaryFields', { - get: function () Object.keys(this._primaryDataSQLParts) + get: function () { return Object.keys(this._primaryDataSQLParts); } }, {lazy: true}); Zotero.defineProperty(Zotero.DataObjects.prototype, "_primaryDataSQLWhere", { @@ -81,7 +81,7 @@ Zotero.defineProperty(Zotero.DataObjects.prototype, "_primaryDataSQLWhere", { }); Zotero.defineProperty(Zotero.DataObjects.prototype, 'primaryDataSQLFrom', { - get: function() " " + this._primaryDataSQLFrom + " " + this._primaryDataSQLWhere + get: function() { return " " + this._primaryDataSQLFrom + " " + this._primaryDataSQLWhere; } }, {lateInit: true}); Zotero.DataObjects.prototype.init = function() { diff --git a/chrome/content/zotero/xpcom/data/feed.js b/chrome/content/zotero/xpcom/data/feed.js index 77b6bbf1cd..21ff215716 100644 --- a/chrome/content/zotero/xpcom/data/feed.js +++ b/chrome/content/zotero/xpcom/data/feed.js @@ -51,13 +51,13 @@ Zotero.Feed = function(params = {}) { // Feeds are not editable by the user. Remove the setter this.editable = false; Zotero.defineProperty(this, 'editable', { - get: function() this._get('_libraryEditable') + get: function() { return this._get('_libraryEditable'); } }); // Feeds are not filesEditable by the user. Remove the setter this.filesEditable = false; Zotero.defineProperty(this, 'filesEditable', { - get: function() this._get('_libraryFilesEditable') + get: function() { return this._get('_libraryFilesEditable'); } }); Zotero.Utilities.assignProps(this, params, @@ -115,10 +115,10 @@ Zotero.defineProperty(Zotero.Feed.prototype, 'libraryTypes', { value: Object.freeze(Zotero.Feed._super.prototype.libraryTypes.concat(['feed'])) }); Zotero.defineProperty(Zotero.Feed.prototype, 'unreadCount', { - get: function() this._feedUnreadCount + get: function() { return this._feedUnreadCount; } }); Zotero.defineProperty(Zotero.Feed.prototype, 'updating', { - get: function() !!this._updating, + get: function() { return !!this._updating; } }); (function() { @@ -128,8 +128,8 @@ for (let i=0; i "G." + c + " AS " + Zotero.Group._colToProp(c)).join(", ") }); Zotero.defineProperty(Zotero.Group, '_rowSQL', { @@ -77,13 +77,13 @@ Zotero.defineProperty(Zotero.Group.prototype, 'libraryTypes', { }); Zotero.defineProperty(Zotero.Group.prototype, 'groupID', { - get: function() this._groupID, - set: function(v) this._groupID = v + get: function() { return this._groupID; }, + set: function(v) { return this._groupID = v; } }); Zotero.defineProperty(Zotero.Group.prototype, 'id', { - get: function() this.groupID, - set: function(v) this.groupID = v + get: function() { return this.groupID; }, + set: function(v) { return this.groupID = v; } }); // Create accessors @@ -93,8 +93,8 @@ for (let i=0; i v + '=?').join(', ') + " WHERE groupID=?"; params.push(this.groupID); yield Zotero.DB.queryAsync(sql, params); diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 56fe5dbea4..cc9e1d802c 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -89,7 +89,7 @@ Zotero.extendClass(Zotero.DataObject, Zotero.Item); Zotero.Item.prototype._objectType = 'item'; Zotero.defineProperty(Zotero.Item.prototype, 'ContainerObjectsClass', { - get: function() Zotero.Collections + get: function() { return Zotero.Collections; } }); Zotero.Item.prototype._dataTypes = Zotero.Item._super.prototype._dataTypes.concat([ @@ -104,8 +104,8 @@ Zotero.Item.prototype._dataTypes = Zotero.Item._super.prototype._dataTypes.conca ]); Zotero.defineProperty(Zotero.Item.prototype, 'id', { - get: function() this._id, - set: function(val) this.setField('id', val) + get: function() { return this._id; }, + set: function(val) { return this.setField('id', val); } }); Zotero.defineProperty(Zotero.Item.prototype, 'itemID', { get: function() { @@ -114,52 +114,52 @@ Zotero.defineProperty(Zotero.Item.prototype, 'itemID', { } }); Zotero.defineProperty(Zotero.Item.prototype, 'libraryID', { - get: function() this._libraryID, - set: function(val) this.setField('libraryID', val) + get: function() { return this._libraryID; }, + set: function(val) { return this.setField('libraryID', val); } }); Zotero.defineProperty(Zotero.Item.prototype, 'key', { - get: function() this._key, - set: function(val) this.setField('key', val) + get: function() { return this._key; }, + set: function(val) { return this.setField('key', val); } }); Zotero.defineProperty(Zotero.Item.prototype, 'itemTypeID', { - get: function() this._itemTypeID + get: function() { return this._itemTypeID; } }); Zotero.defineProperty(Zotero.Item.prototype, 'dateAdded', { - get: function() this._dateAdded, - set: function(val) this.setField('dateAdded', val) + get: function() { return this._dateAdded; }, + set: function(val) { return this.setField('dateAdded', val); } }); Zotero.defineProperty(Zotero.Item.prototype, 'dateModified', { - get: function() this._dateModified, - set: function(val) this.setField('dateModified', val) + get: function() { return this._dateModified; }, + set: function(val) { return this.setField('dateModified', val); } }); Zotero.defineProperty(Zotero.Item.prototype, 'version', { - get: function() this._version, - set: function(val) this.setField('version', val) + get: function() { return this._version; }, + set: function(val) { return this.setField('version', val); } }); Zotero.defineProperty(Zotero.Item.prototype, 'synced', { - get: function() this._synced, - set: function(val) this.setField('synced', val) + get: function() { return this._synced; }, + set: function(val) { return this.setField('synced', val); } }); // .parentKey and .parentID defined in dataObject.js, but create aliases Zotero.defineProperty(Zotero.Item.prototype, 'parentItemID', { - get: function() this.parentID, - set: function(val) this.parentID = val + get: function() { return this.parentID; }, + set: function(val) { return this.parentID = val; } }); Zotero.defineProperty(Zotero.Item.prototype, 'parentItemKey', { - get: function() this.parentKey, - set: function(val) this.parentKey = val + get: function() { return this.parentKey; }, + set: function(val) { return this.parentKey = val; } }); Zotero.defineProperty(Zotero.Item.prototype, 'firstCreator', { - get: function() this._firstCreator + get: function() { return this._firstCreator; } }); Zotero.defineProperty(Zotero.Item.prototype, 'sortCreator', { - get: function() this._sortCreator + get: function() { return this._sortCreator; } }); Zotero.defineProperty(Zotero.Item.prototype, 'relatedItems', { - get: function() this._getRelatedItems() + get: function() { return this._getRelatedItems(); } }); Zotero.defineProperty(Zotero.Item.prototype, 'treeViewID', { @@ -1023,7 +1023,7 @@ Zotero.Item.prototype.getCreators = function () { */ Zotero.Item.prototype.getCreatorsJSON = function () { this._requireData('creators'); - return this._creators.map(function (data) Zotero.Creators.internalToJSON(data)); + return this._creators.map(data => Zotero.Creators.internalToJSON(data)); } @@ -1274,7 +1274,7 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) { env.sqlValues.unshift(parseInt(itemID)); let sql = "INSERT INTO items (" + env.sqlColumns.join(", ") + ") " - + "VALUES (" + env.sqlValues.map(function () "?").join() + ")"; + + "VALUES (" + env.sqlValues.map(() => "?").join() + ")"; yield Zotero.DB.queryAsync(sql, env.sqlValues); if (!env.options.skipNotifier) { @@ -1328,7 +1328,7 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) { // Delete blank fields if (del.length) { sql = 'DELETE from itemData WHERE itemID=? AND ' - + 'fieldID IN (' + del.map(function () '?').join() + ')'; + + 'fieldID IN (' + del.map(() => '?').join() + ')'; yield Zotero.DB.queryAsync(sql, [itemID].concat(del)); } } @@ -2040,7 +2040,7 @@ Zotero.Item.prototype.getNotes = function(includeTrashed) { var rows = this._notes.rows.concat(); // Remove trashed items if necessary if (!includeTrashed) { - rows = rows.filter(function (row) !row.trashed); + rows = rows.filter(row => !row.trashed); } // Sort by title if necessary if (!sortChronologically) { @@ -3205,12 +3205,12 @@ Zotero.Item.prototype.getAttachments = function(includeTrashed) { var rows = this._attachments.rows.concat(); // Remove trashed items if necessary if (!includeTrashed) { - rows = rows.filter(function (row) !row.trashed); + rows = rows.filter(row => !row.trashed); } // Sort by title if necessary if (!Zotero.Prefs.get('sortAttachmentsChronologically')) { var collation = Zotero.getLocaleCollation(); - rows.sort(function (a, b) collation.compareString(1, a.title, b.title)); + rows.sort((a, b) => collation.compareString(1, a.title, b.title)); } var ids = rows.map(row => row.itemID); this._attachments[cacheKey] = ids; @@ -3317,7 +3317,7 @@ Zotero.Item.prototype.getTags = function () { */ Zotero.Item.prototype.hasTag = function (tagName) { this._requireData('tags'); - return this._tags.some(function (tagData) tagData.tag == tagName); + return this._tags.some(tagData => tagData.tag == tagName); } @@ -3454,7 +3454,7 @@ Zotero.Item.prototype.replaceTag = function (oldTag, newTag) { */ Zotero.Item.prototype.removeTag = function(tagName) { this._requireData('tags'); - var newTags = this._tags.filter(function (tagData) tagData.tag !== tagName); + var newTags = this._tags.filter(tagData => tagData.tag !== tagName); if (newTags.length == this._tags.length) { Zotero.debug('Cannot remove missing tag ' + tagName + ' from item ' + this.libraryKey); return; @@ -3658,7 +3658,7 @@ Zotero.Item.prototype.getImageSrcWithTags = Zotero.Promise.coroutine(function* ( colorData.sort(function (a, b) { return a.position - b.position; }); - var colors = colorData.map(function (val) val.color); + var colors = colorData.map(val => val.color); return Zotero.Tags.generateItemsListImage(colors, uri); }); diff --git a/chrome/content/zotero/xpcom/data/library.js b/chrome/content/zotero/xpcom/data/library.js index d401168bc2..1e576c9787 100644 --- a/chrome/content/zotero/xpcom/data/library.js +++ b/chrome/content/zotero/xpcom/data/library.js @@ -79,7 +79,7 @@ Zotero.Library._colToProp = function(c) { // Select all columns in a unique manner, so we can JOIN tables with same column names (e.g. version) Zotero.defineProperty(Zotero.Library, '_rowSQLSelect', { - value: "L.libraryID, " + Zotero.Library._dbColumns.map(function(c) "L." + c + " AS " + Zotero.Library._colToProp(c)).join(", ") + value: "L.libraryID, " + Zotero.Library._dbColumns.map(c => "L." + c + " AS " + Zotero.Library._colToProp(c)).join(", ") + ", (SELECT COUNT(*)>0 FROM collections C WHERE C.libraryID=L.libraryID) AS hasCollections" + ", (SELECT COUNT(*)>0 FROM savedSearches S WHERE S.libraryID=L.libraryID) AS hasSearches" }); @@ -111,18 +111,18 @@ Zotero.defineProperty(Zotero.Library.prototype, 'fixedLibraries', { }); Zotero.defineProperty(Zotero.Library.prototype, 'libraryID', { - get: function() this._libraryID, - set: function(id) { throw new Error("Cannot change library ID") } + get: function() { return this._libraryID; }, + set: function(id) { throw new Error("Cannot change library ID"); } }); Zotero.defineProperty(Zotero.Library.prototype, 'id', { - get: function() this.libraryID, - set: function(val) this.libraryID = val + get: function() { return this.libraryID; }, + set: function(val) { return this.libraryID = val; } }); Zotero.defineProperty(Zotero.Library.prototype, 'libraryType', { - get: function() this._get('_libraryType'), - set: function(v) this._set('_libraryType', v) + get: function() { return this._get('_libraryType'); }, + set: function(v) { return this._set('_libraryType', v); } }); /** @@ -148,8 +148,8 @@ Zotero.defineProperty(Zotero.Library.prototype, 'libraryTypeID', { }); Zotero.defineProperty(Zotero.Library.prototype, 'libraryVersion', { - get: function() this._get('_libraryVersion'), - set: function(v) this._set('_libraryVersion', v) + get: function() { return this._get('_libraryVersion'); }, + set: function(v) { return this._set('_libraryVersion', v); } }); @@ -159,7 +159,7 @@ Zotero.defineProperty(Zotero.Library.prototype, 'syncable', { Zotero.defineProperty(Zotero.Library.prototype, 'lastSync', { - get: function() this._get('_libraryLastSync') + get: function() { return this._get('_libraryLastSync'); } }); @@ -199,8 +199,8 @@ Zotero.defineProperty(Zotero.Library.prototype, 'hasTrash', { for (let i=0; i v + "=?").join(", ") + " WHERE libraryID=?"; yield Zotero.DB.queryAsync(sql, params); diff --git a/chrome/content/zotero/xpcom/data/notes.js b/chrome/content/zotero/xpcom/data/notes.js index bc48ec6194..f2cda0d58e 100644 --- a/chrome/content/zotero/xpcom/data/notes.js +++ b/chrome/content/zotero/xpcom/data/notes.js @@ -28,9 +28,9 @@ Zotero.Notes = new function() { this.noteToTitle = noteToTitle; this.__defineGetter__("MAX_TITLE_LENGTH", function() { return 120; }); - this.__defineGetter__("defaultNote", function () '
'); - this.__defineGetter__("notePrefix", function () '
'); - this.__defineGetter__("noteSuffix", function () '
'); + this.__defineGetter__("defaultNote", function () { return '
'; }); + this.__defineGetter__("notePrefix", function () { return '
'; }); + this.__defineGetter__("noteSuffix", function () { return '
'; }); /** * Return first line (or first MAX_LENGTH characters) of note content diff --git a/chrome/content/zotero/xpcom/data/search.js b/chrome/content/zotero/xpcom/data/search.js index 8da92927ac..91a28cb48a 100644 --- a/chrome/content/zotero/xpcom/data/search.js +++ b/chrome/content/zotero/xpcom/data/search.js @@ -62,31 +62,31 @@ Zotero.Search.prototype.setName = function(val) { } Zotero.defineProperty(Zotero.Search.prototype, 'id', { - get: function() this._get('id'), - set: function(val) this._set('id', val) + get: function() { return this._get('id'); }, + set: function(val) { return this._set('id', val); } }); Zotero.defineProperty(Zotero.Search.prototype, 'libraryID', { - get: function() this._get('libraryID'), - set: function(val) this._set('libraryID', val) + get: function() { return this._get('libraryID'); }, + set: function(val) { return this._set('libraryID', val); } }); Zotero.defineProperty(Zotero.Search.prototype, 'key', { - get: function() this._get('key'), - set: function(val) this._set('key', val) + get: function() { return this._get('key'); }, + set: function(val) { return this._set('key', val); } }); Zotero.defineProperty(Zotero.Search.prototype, 'name', { - get: function() this._get('name'), - set: function(val) this._set('name', val) + get: function() { return this._get('name'); }, + set: function(val) { return this._set('name', val); } }); Zotero.defineProperty(Zotero.Search.prototype, 'version', { - get: function() this._get('version'), - set: function(val) this._set('version', val) + get: function() { return this._get('version'); }, + set: function(val) { return this._set('version', val); } }); Zotero.defineProperty(Zotero.Search.prototype, 'synced', { - get: function() this._get('synced'), - set: function(val) this._set('synced', val) + get: function() { return this._get('synced'); }, + set: function(val) { return this._set('synced', val); } }); Zotero.defineProperty(Zotero.Search.prototype, 'conditions', { - get: function() this.getConditions() + get: function() { return this.getConditions(); } }); Zotero.defineProperty(Zotero.Search.prototype, '_canHaveParent', { value: false @@ -175,14 +175,14 @@ Zotero.Search.prototype._saveData = Zotero.Promise.coroutine(function* (env) { env.sqlColumns.unshift('savedSearchID'); env.sqlValues.unshift(searchID ? { int: searchID } : null); - let placeholders = env.sqlColumns.map(function () '?').join(); + let placeholders = env.sqlColumns.map(() => '?').join(); let sql = "INSERT INTO savedSearches (" + env.sqlColumns.join(', ') + ") " + "VALUES (" + placeholders + ")"; yield Zotero.DB.queryAsync(sql, env.sqlValues); } else { let sql = 'UPDATE savedSearches SET ' - + env.sqlColumns.map(function (x) x + '=?').join(', ') + ' WHERE savedSearchID=?'; + + env.sqlColumns.map(x => x + '=?').join(', ') + ' WHERE savedSearchID=?'; env.sqlValues.push(searchID ? { int: searchID } : null); yield Zotero.DB.queryAsync(sql, env.sqlValues); } @@ -634,7 +634,7 @@ Zotero.Search.prototype.search = Zotero.Promise.coroutine(function* (asTempTable // (a separate fulltext word search filtered by fulltext content) for (let condition of Object.values(this._conditions)){ if (condition['condition']=='fulltextContent'){ - var fulltextWordIntersectionFilter = function (val, index, array) !!hash[val]; + var fulltextWordIntersectionFilter = (val, index, array) => !!hash[val]; var fulltextWordIntersectionConditionFilter = function(val, index, array) { return hash[val] ? (condition.operator == 'contains') : diff --git a/chrome/content/zotero/xpcom/data/tags.js b/chrome/content/zotero/xpcom/data/tags.js index e0f04edbe7..e5b689bbfa 100644 --- a/chrome/content/zotero/xpcom/data/tags.js +++ b/chrome/content/zotero/xpcom/data/tags.js @@ -248,7 +248,7 @@ Zotero.Tags = new function() { oldItemIDs, Zotero.DB.MAX_BOUND_PARAMETERS - 2, Zotero.Promise.coroutine(function* (chunk) { - let placeholders = chunk.map(function () '?').join(','); + let placeholders = chunk.map(() => '?').join(','); // This is ugly, but it's much faster than doing replaceTag() for each item let sql = 'UPDATE OR REPLACE itemTags SET tagID=?, type=0 ' @@ -349,7 +349,7 @@ Zotero.Tags = new function() { Zotero.Utilities.arrayUnique(oldItemIDs), Zotero.DB.MAX_BOUND_PARAMETERS - 1, Zotero.Promise.coroutine(function* (chunk) { - let placeholders = chunk.map(function () '?').join(','); + let placeholders = chunk.map(() => '?').join(','); sql = 'UPDATE items SET synced=0, clientDateModified=? ' + 'WHERE itemID IN (' + placeholders + ')' @@ -539,7 +539,7 @@ Zotero.Tags = new function() { return; } - tagColors = tagColors.filter(function (val) val.name != name); + tagColors = tagColors.filter(val => val.name != name); } else { // Get current position if present @@ -620,7 +620,7 @@ Zotero.Tags = new function() { var affectedItems = []; // Get all items linked to previous or current tag colors - var tagNames = tagColors.concat(previousTagColors).map(function (val) val.name); + var tagNames = tagColors.concat(previousTagColors).map(val => val.name); tagNames = Zotero.Utilities.arrayUnique(tagNames); if (tagNames.length) { for (let i=0; i x.match(/^( [0-9]+)?$/)); // If none found or first one has a suffix, use default name if (!suffixes.length || suffixes[0]) { @@ -841,15 +841,15 @@ Zotero.DBConnection.prototype.executeSQLFile = Zotero.Promise.coroutine(function // Ugly hack to parse triggers with embedded semicolons .replace(/;---/g, "TEMPSEMI") .split("\n") - .filter(function (x) nonCommentRE.test(x)) - .map(function (x) x.match(trailingCommentRE)[1]) + .filter(x => nonCommentRE.test(x)) + .map(x => x.match(trailingCommentRE)[1]) .join(""); if (sql.substr(-1) == ";") { sql = sql.substr(0, sql.length - 1); } var statements = sql.split(";") - .map(function (x) x.replace(/TEMPSEMI/g, ";")); + .map(x => x.replace(/TEMPSEMI/g, ";")); this.requireTransaction(); diff --git a/chrome/content/zotero/xpcom/duplicates.js b/chrome/content/zotero/xpcom/duplicates.js index e6e6786302..7784836980 100644 --- a/chrome/content/zotero/xpcom/duplicates.js +++ b/chrome/content/zotero/xpcom/duplicates.js @@ -36,8 +36,8 @@ Zotero.Duplicates = function (libraryID) { } -Zotero.Duplicates.prototype.__defineGetter__('name', function () Zotero.getString('pane.collections.duplicate')); -Zotero.Duplicates.prototype.__defineGetter__('libraryID', function () this._libraryID); +Zotero.Duplicates.prototype.__defineGetter__('name', function () { return Zotero.getString('pane.collections.duplicate'); }); +Zotero.Duplicates.prototype.__defineGetter__('libraryID', function () { return this._libraryID; }); /** * Get duplicates, populate a temporary table, and return a search based @@ -251,7 +251,7 @@ Zotero.Duplicates.prototype._findDuplicates = Zotero.Promise.coroutine(function* + "JOIN itemData USING (itemID) " + "JOIN itemDataValues USING (valueID) " + "WHERE libraryID=? AND fieldID IN (" - + dateFields.map(function () '?').join() + ") " + + dateFields.map(() => '?').join() + ") " + "AND SUBSTR(value, 1, 4) != '0000' " + "AND itemID NOT IN (SELECT itemID FROM deletedItems) " + "ORDER BY value"; diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index bc46e62785..f0bf022601 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -637,7 +637,7 @@ Zotero.HTTP = new function() { * through the error log and doing a fragile string comparison. */ _pacInstalled = function () { - return Zotero.getErrors(true).some(function (val) val.indexOf("PAC file installed") == 0) + return Zotero.getErrors(true).some(val => val.indexOf("PAC file installed") == 0) } diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 10cf893f64..9fbaa5fb20 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -480,7 +480,7 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio // Clear item type icon and tag colors when a tag is added to or removed from an item if (type == 'item-tag') { // TODO: Only update if colored tag changed? - ids.map(function (val) val.split("-")[0]).forEach(function (val) { + ids.map(val => val.split("-")[0]).forEach(function (val) { delete this._itemImages[val]; }.bind(this)); return; @@ -1432,7 +1432,7 @@ Zotero.ItemTreeView.prototype.sort = function (itemID) { // Cache primary values while sorting, since base-field-mapped getField() // calls are relatively expensive var cache = {}; - sortFields.forEach(function (x) cache[x] = {}) + sortFields.forEach(x => cache[x] = {}) // Get the display field for a row (which might be a placeholder title) function getField(field, row) { diff --git a/chrome/content/zotero/xpcom/locateManager.js b/chrome/content/zotero/xpcom/locateManager.js index 253a3c3e77..87222c3188 100644 --- a/chrome/content/zotero/xpcom/locateManager.js +++ b/chrome/content/zotero/xpcom/locateManager.js @@ -75,7 +75,7 @@ Zotero.LocateManager = new function() { /** * Returns an array of all search engines */ - this.getEngines = function() _locateEngines.slice(0); + this.getEngines = function() { return _locateEngines.slice(0); } /** * Returns an array of all search engines visible that should be visible in the dropdown diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index c838cf56f2..aa0d01e618 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -27,8 +27,8 @@ Zotero.Sync.Storage = new function () { // TEMP - this.__defineGetter__("defaultError", function () Zotero.getString('sync.storage.error.default', Zotero.appName)); - this.__defineGetter__("defaultErrorRestart", function () Zotero.getString('sync.storage.error.defaultRestart', Zotero.appName)); + this.__defineGetter__("defaultError", function () { return Zotero.getString('sync.storage.error.default', Zotero.appName); }); + this.__defineGetter__("defaultErrorRestart", function () { return Zotero.getString('sync.storage.error.defaultRestart', Zotero.appName); }); var _itemDownloadPercentages = {}; diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index f1a5cfe7a7..6ff63dfd00 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -72,7 +72,7 @@ Components.utils.import("resource://gre/modules/PluralForm.jsm"); * @property {Boolean} locked Whether all Zotero panes are locked * with an overlay */ - this.__defineGetter__('locked', function () _locked); + this.__defineGetter__('locked', function () { return _locked; }); this.__defineSetter__('locked', function (lock) { var wasLocked = _locked; _locked = lock; @@ -788,7 +788,7 @@ Components.utils.import("resource://gre/modules/PluralForm.jsm"); var e = { name: 'NS_ERROR_FILE_ACCESS_DENIED', message: msg, - toString: function () this.message + toString: function () { return this.message; } }; throw (e); } diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index d57a1d8d20..1ada0bf5cc 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -33,7 +33,7 @@ var ZoteroPane = new function() this.itemsView = false; this.progressWindow = false; this._listeners = {}; - this.__defineGetter__('loaded', function () _loaded); + this.__defineGetter__('loaded', function () { return _loaded; }); var _lastSelectedItems = []; //Privileged methods diff --git a/components/zotero-service.js b/components/zotero-service.js index a11b4aeb97..2be849a88a 100644 --- a/components/zotero-service.js +++ b/components/zotero-service.js @@ -327,7 +327,7 @@ function makeZoteroContext(isConnector) { // add connector-related properties zContext.Zotero.isConnector = isConnector; zContext.Zotero.instanceID = instanceID; - zContext.Zotero.__defineGetter__("isFirstLoadThisSession", function() isFirstLoadThisSession); + zContext.Zotero.__defineGetter__("isFirstLoadThisSession", function() { return isFirstLoadThisSession; }); }; /**