Remove use of syntax where curly brackets are omitted in function defs

This commit is contained in:
Tom Najdek 2016-10-15 20:20:09 +01:00 committed by Dan Stillman
parent 54a2126b7d
commit d4dc86c975
23 changed files with 137 additions and 137 deletions

View File

@ -544,7 +544,7 @@ var Zotero_LocateMenu = new function() {
this.useExternalViewer = true; this.useExternalViewer = true;
this.canHandleItem = function (item) { 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) { this.handleItems = Zotero.Promise.coroutine(function* (items, event) {
@ -573,7 +573,7 @@ var Zotero_LocateMenu = new function() {
*/ */
ViewOptions._libraryLookup = new function() { ViewOptions._libraryLookup = new function() {
this.icon = "chrome://zotero/skin/locate-library-lookup.png"; 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) { this.handleItems = Zotero.Promise.method(function (items, event) {
var urls = []; var urls = [];
for (let item of items) { for (let item of items) {

View File

@ -371,9 +371,9 @@ Zotero.ItemTypes = new function() {
} }
if (params.length) { if (params.length) {
sql += 'OR id IN ' sql += 'OR id IN '
+ '(' + params.map(function () '?').join() + ') ' + '(' + params.map(() => '?').join() + ') '
+ 'ORDER BY id NOT IN ' + 'ORDER BY id NOT IN '
+ '(' + params.map(function () '?').join() + ') '; + '(' + params.map(() => '?').join() + ') ';
params = params.concat(params); params = params.concat(params);
} }
else { else {

View File

@ -45,32 +45,32 @@ Zotero.Collection.prototype._dataTypes = Zotero.Collection._super.prototype._dat
]); ]);
Zotero.defineProperty(Zotero.Collection.prototype, 'ChildObjects', { Zotero.defineProperty(Zotero.Collection.prototype, 'ChildObjects', {
get: function() Zotero.Items get: function() { return Zotero.Items; }
}); });
Zotero.defineProperty(Zotero.Collection.prototype, 'id', { Zotero.defineProperty(Zotero.Collection.prototype, 'id', {
get: function() this._get('id'), get: function() { return this._get('id'); },
set: function(val) this._set('id', val) set: function(val) { return this._set('id', val); }
}); });
Zotero.defineProperty(Zotero.Collection.prototype, 'libraryID', { Zotero.defineProperty(Zotero.Collection.prototype, 'libraryID', {
get: function() this._get('libraryID'), get: function() { return this._get('libraryID'); },
set: function(val) this._set('libraryID', val) set: function(val) { return this._set('libraryID', val); }
}); });
Zotero.defineProperty(Zotero.Collection.prototype, 'key', { Zotero.defineProperty(Zotero.Collection.prototype, 'key', {
get: function() this._get('key'), get: function() { return this._get('key'); },
set: function(val) this._set('key', val) set: function(val) { return this._set('key', val); }
}); });
Zotero.defineProperty(Zotero.Collection.prototype, 'name', { Zotero.defineProperty(Zotero.Collection.prototype, 'name', {
get: function() this._get('name'), get: function() { return this._get('name'); },
set: function(val) this._set('name', val) set: function(val) { return this._set('name', val); }
}); });
Zotero.defineProperty(Zotero.Collection.prototype, 'version', { Zotero.defineProperty(Zotero.Collection.prototype, 'version', {
get: function() this._get('version'), get: function() { return this._get('version'); },
set: function(val) this._set('version', val) set: function(val) { return this._set('version', val); }
}); });
Zotero.defineProperty(Zotero.Collection.prototype, 'synced', { Zotero.defineProperty(Zotero.Collection.prototype, 'synced', {
get: function() this._get('synced'), get: function() { return this._get('synced'); },
set: function(val) this._set('synced', val) set: function(val) { return this._set('synced', val); }
}); });
Zotero.defineProperty(Zotero.Collection.prototype, 'parent', { Zotero.defineProperty(Zotero.Collection.prototype, 'parent', {
get: function() { get: function() {
@ -290,14 +290,14 @@ Zotero.Collection.prototype._saveData = Zotero.Promise.coroutine(function* (env)
env.sqlColumns.unshift('collectionID'); env.sqlColumns.unshift('collectionID');
env.sqlValues.unshift(collectionID ? { int: collectionID } : null); 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(', ') + ") " let sql = "INSERT INTO collections (" + env.sqlColumns.join(', ') + ") "
+ "VALUES (" + placeholders + ")"; + "VALUES (" + placeholders + ")";
yield Zotero.DB.queryAsync(sql, env.sqlValues); yield Zotero.DB.queryAsync(sql, env.sqlValues);
} }
else { else {
let sql = 'UPDATE collections SET ' 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); env.sqlValues.push(collectionID ? { int: collectionID } : null);
yield Zotero.DB.queryAsync(sql, env.sqlValues); 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 // Remove item associations for all descendent collections
yield Zotero.DB.queryAsync('DELETE FROM collectionItems WHERE collectionID IN ' yield Zotero.DB.queryAsync('DELETE FROM collectionItems WHERE collectionID IN '

View File

@ -104,7 +104,7 @@ Zotero.Collections = function() {
} }
// Do proper collation sort // 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; if (!recursive) return children;

View File

@ -66,13 +66,13 @@ Zotero.DataObject.prototype._objectType = 'dataObject';
Zotero.DataObject.prototype._dataTypes = ['primaryData']; Zotero.DataObject.prototype._dataTypes = ['primaryData'];
Zotero.defineProperty(Zotero.DataObject.prototype, 'objectType', { Zotero.defineProperty(Zotero.DataObject.prototype, 'objectType', {
get: function() this._objectType get: function() { return this._objectType; }
}); });
Zotero.defineProperty(Zotero.DataObject.prototype, 'id', { Zotero.defineProperty(Zotero.DataObject.prototype, 'id', {
get: function() this._id get: function() { return this._id; }
}); });
Zotero.defineProperty(Zotero.DataObject.prototype, 'libraryID', { Zotero.defineProperty(Zotero.DataObject.prototype, 'libraryID', {
get: function() this._libraryID get: function() { return this._libraryID; }
}); });
Zotero.defineProperty(Zotero.DataObject.prototype, 'library', { Zotero.defineProperty(Zotero.DataObject.prototype, 'library', {
get: function () { get: function () {
@ -80,18 +80,18 @@ Zotero.defineProperty(Zotero.DataObject.prototype, 'library', {
} }
}); });
Zotero.defineProperty(Zotero.DataObject.prototype, 'key', { Zotero.defineProperty(Zotero.DataObject.prototype, 'key', {
get: function() this._key get: function() { return this._key; }
}); });
Zotero.defineProperty(Zotero.DataObject.prototype, 'libraryKey', { 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', { Zotero.defineProperty(Zotero.DataObject.prototype, 'parentKey', {
get: function () this._getParentKey(), get: function () { return this._getParentKey(); },
set: function(v) this._setParentKey(v) set: function(v) { return this._setParentKey(v); }
}); });
Zotero.defineProperty(Zotero.DataObject.prototype, 'parentID', { Zotero.defineProperty(Zotero.DataObject.prototype, 'parentID', {
get: function() this._getParentID(), get: function() { return this._getParentID(); },
set: function(v) this._setParentID(v) set: function(v) { return this._setParentID(v); }
}); });
Zotero.defineProperty(Zotero.DataObject.prototype, '_canHaveParent', { Zotero.defineProperty(Zotero.DataObject.prototype, '_canHaveParent', {
@ -99,7 +99,7 @@ Zotero.defineProperty(Zotero.DataObject.prototype, '_canHaveParent', {
}); });
Zotero.defineProperty(Zotero.DataObject.prototype, 'ObjectsClass', { Zotero.defineProperty(Zotero.DataObject.prototype, 'ObjectsClass', {
get: function() this._ObjectsClass get: function() { return this._ObjectsClass; }
}); });

View File

@ -62,18 +62,18 @@ Zotero.DataObjects.prototype._ZDO_idOnly = false;
// Public properties // Public properties
Zotero.defineProperty(Zotero.DataObjects.prototype, 'idColumn', { Zotero.defineProperty(Zotero.DataObjects.prototype, 'idColumn', {
get: function() this._ZDO_id get: function() { return this._ZDO_id; }
}); });
Zotero.defineProperty(Zotero.DataObjects.prototype, 'table', { Zotero.defineProperty(Zotero.DataObjects.prototype, 'table', {
get: function() this._ZDO_table get: function() { return this._ZDO_table; }
}); });
Zotero.defineProperty(Zotero.DataObjects.prototype, 'relationsTable', { 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', { Zotero.defineProperty(Zotero.DataObjects.prototype, 'primaryFields', {
get: function () Object.keys(this._primaryDataSQLParts) get: function () { return Object.keys(this._primaryDataSQLParts); }
}, {lazy: true}); }, {lazy: true});
Zotero.defineProperty(Zotero.DataObjects.prototype, "_primaryDataSQLWhere", { Zotero.defineProperty(Zotero.DataObjects.prototype, "_primaryDataSQLWhere", {
@ -81,7 +81,7 @@ Zotero.defineProperty(Zotero.DataObjects.prototype, "_primaryDataSQLWhere", {
}); });
Zotero.defineProperty(Zotero.DataObjects.prototype, 'primaryDataSQLFrom', { Zotero.defineProperty(Zotero.DataObjects.prototype, 'primaryDataSQLFrom', {
get: function() " " + this._primaryDataSQLFrom + " " + this._primaryDataSQLWhere get: function() { return " " + this._primaryDataSQLFrom + " " + this._primaryDataSQLWhere; }
}, {lateInit: true}); }, {lateInit: true});
Zotero.DataObjects.prototype.init = function() { Zotero.DataObjects.prototype.init = function() {

View File

@ -51,13 +51,13 @@ Zotero.Feed = function(params = {}) {
// Feeds are not editable by the user. Remove the setter // Feeds are not editable by the user. Remove the setter
this.editable = false; this.editable = false;
Zotero.defineProperty(this, 'editable', { 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 // Feeds are not filesEditable by the user. Remove the setter
this.filesEditable = false; this.filesEditable = false;
Zotero.defineProperty(this, 'filesEditable', { Zotero.defineProperty(this, 'filesEditable', {
get: function() this._get('_libraryFilesEditable') get: function() { return this._get('_libraryFilesEditable'); }
}); });
Zotero.Utilities.assignProps(this, params, 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'])) value: Object.freeze(Zotero.Feed._super.prototype.libraryTypes.concat(['feed']))
}); });
Zotero.defineProperty(Zotero.Feed.prototype, 'unreadCount', { Zotero.defineProperty(Zotero.Feed.prototype, 'unreadCount', {
get: function() this._feedUnreadCount get: function() { return this._feedUnreadCount; }
}); });
Zotero.defineProperty(Zotero.Feed.prototype, 'updating', { Zotero.defineProperty(Zotero.Feed.prototype, 'updating', {
get: function() !!this._updating, get: function() { return !!this._updating; }
}); });
(function() { (function() {
@ -128,8 +128,8 @@ for (let i=0; i<accessors.length; i++) {
let name = accessors[i]; let name = accessors[i];
let prop = Zotero.Feed._colToProp(name); let prop = Zotero.Feed._colToProp(name);
Zotero.defineProperty(Zotero.Feed.prototype, name, { Zotero.defineProperty(Zotero.Feed.prototype, name, {
get: function() this._get(prop), get: function() { return this._get(prop); },
set: function(v) this._set(prop, v) set: function(v) { return this._set(prop, v); }
}) })
} }
let getters = ['lastCheck', 'lastUpdate', 'lastCheckError']; let getters = ['lastCheck', 'lastUpdate', 'lastCheckError'];
@ -137,7 +137,7 @@ for (let i=0; i<getters.length; i++) {
let name = getters[i]; let name = getters[i];
let prop = Zotero.Feed._colToProp(name); let prop = Zotero.Feed._colToProp(name);
Zotero.defineProperty(Zotero.Feed.prototype, name, { Zotero.defineProperty(Zotero.Feed.prototype, name, {
get: function() this._get(prop), get: function() { return this._get(prop); }
}) })
} }
})() })()

View File

@ -46,7 +46,7 @@ Zotero.defineProperty(Zotero.FeedItem.prototype, 'isFeedItem', {
}); });
Zotero.defineProperty(Zotero.FeedItem.prototype, 'guid', { Zotero.defineProperty(Zotero.FeedItem.prototype, 'guid', {
get: function() this._feedItemGUID, get: function() { return this._feedItemGUID; },
set: function(val) { set: function(val) {
if (this.id) throw new Error('Cannot set GUID after item ID is already set'); if (this.id) throw new Error('Cannot set GUID after item ID is already set');
if (typeof val != 'string') throw new Error('GUID must be a non-empty string'); if (typeof val != 'string') throw new Error('GUID must be a non-empty string');

View File

@ -58,7 +58,7 @@ Zotero.Group._colToProp = function(c) {
Zotero.defineProperty(Zotero.Group, '_rowSQLSelect', { Zotero.defineProperty(Zotero.Group, '_rowSQLSelect', {
value: Zotero.Library._rowSQLSelect + ", G.groupID, " value: Zotero.Library._rowSQLSelect + ", G.groupID, "
+ Zotero.Group._dbColumns.map(function(c) "G." + c + " AS " + Zotero.Group._colToProp(c)).join(", ") + Zotero.Group._dbColumns.map(c => "G." + c + " AS " + Zotero.Group._colToProp(c)).join(", ")
}); });
Zotero.defineProperty(Zotero.Group, '_rowSQL', { Zotero.defineProperty(Zotero.Group, '_rowSQL', {
@ -77,13 +77,13 @@ Zotero.defineProperty(Zotero.Group.prototype, 'libraryTypes', {
}); });
Zotero.defineProperty(Zotero.Group.prototype, 'groupID', { Zotero.defineProperty(Zotero.Group.prototype, 'groupID', {
get: function() this._groupID, get: function() { return this._groupID; },
set: function(v) this._groupID = v set: function(v) { return this._groupID = v; }
}); });
Zotero.defineProperty(Zotero.Group.prototype, 'id', { Zotero.defineProperty(Zotero.Group.prototype, 'id', {
get: function() this.groupID, get: function() { return this.groupID; },
set: function(v) this.groupID = v set: function(v) { return this.groupID = v; }
}); });
// Create accessors // Create accessors
@ -93,8 +93,8 @@ for (let i=0; i<accessors.length; i++) {
let name = accessors[i]; let name = accessors[i];
let prop = Zotero.Group._colToProp(name); let prop = Zotero.Group._colToProp(name);
Zotero.defineProperty(Zotero.Group.prototype, name, { Zotero.defineProperty(Zotero.Group.prototype, name, {
get: function() this._get(prop), get: function() { return this._get(prop); },
set: function(v) this._set(prop, v) set: function(v) { return this._set(prop, v); }
}) })
} }
})(); })();
@ -201,7 +201,7 @@ Zotero.Group.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
Zotero.Notifier.queue('add', 'group', this.groupID); Zotero.Notifier.queue('add', 'group', this.groupID);
} }
else if (changedCols.length) { else if (changedCols.length) {
let sql = "UPDATE groups SET " + changedCols.map(function (v) v + '=?').join(', ') let sql = "UPDATE groups SET " + changedCols.map(v => v + '=?').join(', ')
+ " WHERE groupID=?"; + " WHERE groupID=?";
params.push(this.groupID); params.push(this.groupID);
yield Zotero.DB.queryAsync(sql, params); yield Zotero.DB.queryAsync(sql, params);

View File

@ -89,7 +89,7 @@ Zotero.extendClass(Zotero.DataObject, Zotero.Item);
Zotero.Item.prototype._objectType = 'item'; Zotero.Item.prototype._objectType = 'item';
Zotero.defineProperty(Zotero.Item.prototype, 'ContainerObjectsClass', { 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([ 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', { Zotero.defineProperty(Zotero.Item.prototype, 'id', {
get: function() this._id, get: function() { return this._id; },
set: function(val) this.setField('id', val) set: function(val) { return this.setField('id', val); }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'itemID', { Zotero.defineProperty(Zotero.Item.prototype, 'itemID', {
get: function() { get: function() {
@ -114,52 +114,52 @@ Zotero.defineProperty(Zotero.Item.prototype, 'itemID', {
} }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'libraryID', { Zotero.defineProperty(Zotero.Item.prototype, 'libraryID', {
get: function() this._libraryID, get: function() { return this._libraryID; },
set: function(val) this.setField('libraryID', val) set: function(val) { return this.setField('libraryID', val); }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'key', { Zotero.defineProperty(Zotero.Item.prototype, 'key', {
get: function() this._key, get: function() { return this._key; },
set: function(val) this.setField('key', val) set: function(val) { return this.setField('key', val); }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'itemTypeID', { Zotero.defineProperty(Zotero.Item.prototype, 'itemTypeID', {
get: function() this._itemTypeID get: function() { return this._itemTypeID; }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'dateAdded', { Zotero.defineProperty(Zotero.Item.prototype, 'dateAdded', {
get: function() this._dateAdded, get: function() { return this._dateAdded; },
set: function(val) this.setField('dateAdded', val) set: function(val) { return this.setField('dateAdded', val); }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'dateModified', { Zotero.defineProperty(Zotero.Item.prototype, 'dateModified', {
get: function() this._dateModified, get: function() { return this._dateModified; },
set: function(val) this.setField('dateModified', val) set: function(val) { return this.setField('dateModified', val); }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'version', { Zotero.defineProperty(Zotero.Item.prototype, 'version', {
get: function() this._version, get: function() { return this._version; },
set: function(val) this.setField('version', val) set: function(val) { return this.setField('version', val); }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'synced', { Zotero.defineProperty(Zotero.Item.prototype, 'synced', {
get: function() this._synced, get: function() { return this._synced; },
set: function(val) this.setField('synced', val) set: function(val) { return this.setField('synced', val); }
}); });
// .parentKey and .parentID defined in dataObject.js, but create aliases // .parentKey and .parentID defined in dataObject.js, but create aliases
Zotero.defineProperty(Zotero.Item.prototype, 'parentItemID', { Zotero.defineProperty(Zotero.Item.prototype, 'parentItemID', {
get: function() this.parentID, get: function() { return this.parentID; },
set: function(val) this.parentID = val set: function(val) { return this.parentID = val; }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'parentItemKey', { Zotero.defineProperty(Zotero.Item.prototype, 'parentItemKey', {
get: function() this.parentKey, get: function() { return this.parentKey; },
set: function(val) this.parentKey = val set: function(val) { return this.parentKey = val; }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'firstCreator', { Zotero.defineProperty(Zotero.Item.prototype, 'firstCreator', {
get: function() this._firstCreator get: function() { return this._firstCreator; }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'sortCreator', { Zotero.defineProperty(Zotero.Item.prototype, 'sortCreator', {
get: function() this._sortCreator get: function() { return this._sortCreator; }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'relatedItems', { Zotero.defineProperty(Zotero.Item.prototype, 'relatedItems', {
get: function() this._getRelatedItems() get: function() { return this._getRelatedItems(); }
}); });
Zotero.defineProperty(Zotero.Item.prototype, 'treeViewID', { Zotero.defineProperty(Zotero.Item.prototype, 'treeViewID', {
@ -1023,7 +1023,7 @@ Zotero.Item.prototype.getCreators = function () {
*/ */
Zotero.Item.prototype.getCreatorsJSON = function () { Zotero.Item.prototype.getCreatorsJSON = function () {
this._requireData('creators'); 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)); env.sqlValues.unshift(parseInt(itemID));
let sql = "INSERT INTO items (" + env.sqlColumns.join(", ") + ") " 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); yield Zotero.DB.queryAsync(sql, env.sqlValues);
if (!env.options.skipNotifier) { if (!env.options.skipNotifier) {
@ -1328,7 +1328,7 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
// Delete blank fields // Delete blank fields
if (del.length) { if (del.length) {
sql = 'DELETE from itemData WHERE itemID=? AND ' 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)); yield Zotero.DB.queryAsync(sql, [itemID].concat(del));
} }
} }
@ -2040,7 +2040,7 @@ Zotero.Item.prototype.getNotes = function(includeTrashed) {
var rows = this._notes.rows.concat(); var rows = this._notes.rows.concat();
// Remove trashed items if necessary // Remove trashed items if necessary
if (!includeTrashed) { if (!includeTrashed) {
rows = rows.filter(function (row) !row.trashed); rows = rows.filter(row => !row.trashed);
} }
// Sort by title if necessary // Sort by title if necessary
if (!sortChronologically) { if (!sortChronologically) {
@ -3205,12 +3205,12 @@ Zotero.Item.prototype.getAttachments = function(includeTrashed) {
var rows = this._attachments.rows.concat(); var rows = this._attachments.rows.concat();
// Remove trashed items if necessary // Remove trashed items if necessary
if (!includeTrashed) { if (!includeTrashed) {
rows = rows.filter(function (row) !row.trashed); rows = rows.filter(row => !row.trashed);
} }
// Sort by title if necessary // Sort by title if necessary
if (!Zotero.Prefs.get('sortAttachmentsChronologically')) { if (!Zotero.Prefs.get('sortAttachmentsChronologically')) {
var collation = Zotero.getLocaleCollation(); 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); var ids = rows.map(row => row.itemID);
this._attachments[cacheKey] = ids; this._attachments[cacheKey] = ids;
@ -3317,7 +3317,7 @@ Zotero.Item.prototype.getTags = function () {
*/ */
Zotero.Item.prototype.hasTag = function (tagName) { Zotero.Item.prototype.hasTag = function (tagName) {
this._requireData('tags'); 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) { Zotero.Item.prototype.removeTag = function(tagName) {
this._requireData('tags'); 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) { if (newTags.length == this._tags.length) {
Zotero.debug('Cannot remove missing tag ' + tagName + ' from item ' + this.libraryKey); Zotero.debug('Cannot remove missing tag ' + tagName + ' from item ' + this.libraryKey);
return; return;
@ -3658,7 +3658,7 @@ Zotero.Item.prototype.getImageSrcWithTags = Zotero.Promise.coroutine(function* (
colorData.sort(function (a, b) { colorData.sort(function (a, b) {
return a.position - b.position; 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); return Zotero.Tags.generateItemsListImage(colors, uri);
}); });

View File

@ -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) // Select all columns in a unique manner, so we can JOIN tables with same column names (e.g. version)
Zotero.defineProperty(Zotero.Library, '_rowSQLSelect', { 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 collections C WHERE C.libraryID=L.libraryID) AS hasCollections"
+ ", (SELECT COUNT(*)>0 FROM savedSearches S WHERE S.libraryID=L.libraryID) AS hasSearches" + ", (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', { Zotero.defineProperty(Zotero.Library.prototype, 'libraryID', {
get: function() this._libraryID, get: function() { return this._libraryID; },
set: function(id) { throw new Error("Cannot change library ID") } set: function(id) { throw new Error("Cannot change library ID"); }
}); });
Zotero.defineProperty(Zotero.Library.prototype, 'id', { Zotero.defineProperty(Zotero.Library.prototype, 'id', {
get: function() this.libraryID, get: function() { return this.libraryID; },
set: function(val) this.libraryID = val set: function(val) { return this.libraryID = val; }
}); });
Zotero.defineProperty(Zotero.Library.prototype, 'libraryType', { Zotero.defineProperty(Zotero.Library.prototype, 'libraryType', {
get: function() this._get('_libraryType'), get: function() { return this._get('_libraryType'); },
set: function(v) this._set('_libraryType', v) set: function(v) { return this._set('_libraryType', v); }
}); });
/** /**
@ -148,8 +148,8 @@ Zotero.defineProperty(Zotero.Library.prototype, 'libraryTypeID', {
}); });
Zotero.defineProperty(Zotero.Library.prototype, 'libraryVersion', { Zotero.defineProperty(Zotero.Library.prototype, 'libraryVersion', {
get: function() this._get('_libraryVersion'), get: function() { return this._get('_libraryVersion'); },
set: function(v) this._set('_libraryVersion', v) set: function(v) { return this._set('_libraryVersion', v); }
}); });
@ -159,7 +159,7 @@ Zotero.defineProperty(Zotero.Library.prototype, 'syncable', {
Zotero.defineProperty(Zotero.Library.prototype, 'lastSync', { 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<accessors.length; i++) { for (let i=0; i<accessors.length; i++) {
let prop = Zotero.Library._colToProp(accessors[i]); let prop = Zotero.Library._colToProp(accessors[i]);
Zotero.defineProperty(Zotero.Library.prototype, accessors[i], { Zotero.defineProperty(Zotero.Library.prototype, accessors[i], {
get: function() this._get(prop), get: function() { return this._get(prop); },
set: function(v) this._set(prop, v) set: function(v) { return this._set(prop, v); }
}) })
} }
})() })()
@ -514,7 +514,7 @@ Zotero.Library.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
this._libraryID = id; this._libraryID = id;
} else if (changedCols.length) { } else if (changedCols.length) {
params.push(this.libraryID); params.push(this.libraryID);
let sql = "UPDATE libraries SET " + changedCols.map(function(v) v + "=?").join(", ") let sql = "UPDATE libraries SET " + changedCols.map(v => v + "=?").join(", ")
+ " WHERE libraryID=?"; + " WHERE libraryID=?";
yield Zotero.DB.queryAsync(sql, params); yield Zotero.DB.queryAsync(sql, params);

View File

@ -28,9 +28,9 @@ Zotero.Notes = new function() {
this.noteToTitle = noteToTitle; this.noteToTitle = noteToTitle;
this.__defineGetter__("MAX_TITLE_LENGTH", function() { return 120; }); this.__defineGetter__("MAX_TITLE_LENGTH", function() { return 120; });
this.__defineGetter__("defaultNote", function () '<div class="zotero-note znv1"></div>'); this.__defineGetter__("defaultNote", function () { return '<div class="zotero-note znv1"></div>'; });
this.__defineGetter__("notePrefix", function () '<div class="zotero-note znv1">'); this.__defineGetter__("notePrefix", function () { return '<div class="zotero-note znv1">'; });
this.__defineGetter__("noteSuffix", function () '</div>'); this.__defineGetter__("noteSuffix", function () { return '</div>'; });
/** /**
* Return first line (or first MAX_LENGTH characters) of note content * Return first line (or first MAX_LENGTH characters) of note content

View File

@ -62,31 +62,31 @@ Zotero.Search.prototype.setName = function(val) {
} }
Zotero.defineProperty(Zotero.Search.prototype, 'id', { Zotero.defineProperty(Zotero.Search.prototype, 'id', {
get: function() this._get('id'), get: function() { return this._get('id'); },
set: function(val) this._set('id', val) set: function(val) { return this._set('id', val); }
}); });
Zotero.defineProperty(Zotero.Search.prototype, 'libraryID', { Zotero.defineProperty(Zotero.Search.prototype, 'libraryID', {
get: function() this._get('libraryID'), get: function() { return this._get('libraryID'); },
set: function(val) this._set('libraryID', val) set: function(val) { return this._set('libraryID', val); }
}); });
Zotero.defineProperty(Zotero.Search.prototype, 'key', { Zotero.defineProperty(Zotero.Search.prototype, 'key', {
get: function() this._get('key'), get: function() { return this._get('key'); },
set: function(val) this._set('key', val) set: function(val) { return this._set('key', val); }
}); });
Zotero.defineProperty(Zotero.Search.prototype, 'name', { Zotero.defineProperty(Zotero.Search.prototype, 'name', {
get: function() this._get('name'), get: function() { return this._get('name'); },
set: function(val) this._set('name', val) set: function(val) { return this._set('name', val); }
}); });
Zotero.defineProperty(Zotero.Search.prototype, 'version', { Zotero.defineProperty(Zotero.Search.prototype, 'version', {
get: function() this._get('version'), get: function() { return this._get('version'); },
set: function(val) this._set('version', val) set: function(val) { return this._set('version', val); }
}); });
Zotero.defineProperty(Zotero.Search.prototype, 'synced', { Zotero.defineProperty(Zotero.Search.prototype, 'synced', {
get: function() this._get('synced'), get: function() { return this._get('synced'); },
set: function(val) this._set('synced', val) set: function(val) { return this._set('synced', val); }
}); });
Zotero.defineProperty(Zotero.Search.prototype, 'conditions', { Zotero.defineProperty(Zotero.Search.prototype, 'conditions', {
get: function() this.getConditions() get: function() { return this.getConditions(); }
}); });
Zotero.defineProperty(Zotero.Search.prototype, '_canHaveParent', { Zotero.defineProperty(Zotero.Search.prototype, '_canHaveParent', {
value: false value: false
@ -175,14 +175,14 @@ Zotero.Search.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
env.sqlColumns.unshift('savedSearchID'); env.sqlColumns.unshift('savedSearchID');
env.sqlValues.unshift(searchID ? { int: searchID } : null); 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(', ') + ") " let sql = "INSERT INTO savedSearches (" + env.sqlColumns.join(', ') + ") "
+ "VALUES (" + placeholders + ")"; + "VALUES (" + placeholders + ")";
yield Zotero.DB.queryAsync(sql, env.sqlValues); yield Zotero.DB.queryAsync(sql, env.sqlValues);
} }
else { else {
let sql = 'UPDATE savedSearches SET ' 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); env.sqlValues.push(searchID ? { int: searchID } : null);
yield Zotero.DB.queryAsync(sql, env.sqlValues); 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) // (a separate fulltext word search filtered by fulltext content)
for (let condition of Object.values(this._conditions)){ for (let condition of Object.values(this._conditions)){
if (condition['condition']=='fulltextContent'){ 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) { var fulltextWordIntersectionConditionFilter = function(val, index, array) {
return hash[val] ? return hash[val] ?
(condition.operator == 'contains') : (condition.operator == 'contains') :

View File

@ -248,7 +248,7 @@ Zotero.Tags = new function() {
oldItemIDs, oldItemIDs,
Zotero.DB.MAX_BOUND_PARAMETERS - 2, Zotero.DB.MAX_BOUND_PARAMETERS - 2,
Zotero.Promise.coroutine(function* (chunk) { 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 // This is ugly, but it's much faster than doing replaceTag() for each item
let sql = 'UPDATE OR REPLACE itemTags SET tagID=?, type=0 ' let sql = 'UPDATE OR REPLACE itemTags SET tagID=?, type=0 '
@ -349,7 +349,7 @@ Zotero.Tags = new function() {
Zotero.Utilities.arrayUnique(oldItemIDs), Zotero.Utilities.arrayUnique(oldItemIDs),
Zotero.DB.MAX_BOUND_PARAMETERS - 1, Zotero.DB.MAX_BOUND_PARAMETERS - 1,
Zotero.Promise.coroutine(function* (chunk) { Zotero.Promise.coroutine(function* (chunk) {
let placeholders = chunk.map(function () '?').join(','); let placeholders = chunk.map(() => '?').join(',');
sql = 'UPDATE items SET synced=0, clientDateModified=? ' sql = 'UPDATE items SET synced=0, clientDateModified=? '
+ 'WHERE itemID IN (' + placeholders + ')' + 'WHERE itemID IN (' + placeholders + ')'
@ -539,7 +539,7 @@ Zotero.Tags = new function() {
return; return;
} }
tagColors = tagColors.filter(function (val) val.name != name); tagColors = tagColors.filter(val => val.name != name);
} }
else { else {
// Get current position if present // Get current position if present
@ -620,7 +620,7 @@ Zotero.Tags = new function() {
var affectedItems = []; var affectedItems = [];
// Get all items linked to previous or current tag colors // 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); tagNames = Zotero.Utilities.arrayUnique(tagNames);
if (tagNames.length) { if (tagNames.length) {
for (let i=0; i<tagNames.length; i++) { for (let i=0; i<tagNames.length; i++) {

View File

@ -375,7 +375,7 @@ Zotero.DBConnection.prototype.getNextName = Zotero.Promise.coroutine(function* (
+ " WHERE libraryID=? AND " + field + " LIKE ? ORDER BY " + field; + " WHERE libraryID=? AND " + field + " LIKE ? ORDER BY " + field;
var params = [libraryID, name + "%"]; var params = [libraryID, name + "%"];
var suffixes = yield this.columnQueryAsync(sql, params); var suffixes = yield this.columnQueryAsync(sql, params);
suffixes.filter(function (x) x.match(/^( [0-9]+)?$/)); suffixes.filter(x => x.match(/^( [0-9]+)?$/));
// If none found or first one has a suffix, use default name // If none found or first one has a suffix, use default name
if (!suffixes.length || suffixes[0]) { 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 // Ugly hack to parse triggers with embedded semicolons
.replace(/;---/g, "TEMPSEMI") .replace(/;---/g, "TEMPSEMI")
.split("\n") .split("\n")
.filter(function (x) nonCommentRE.test(x)) .filter(x => nonCommentRE.test(x))
.map(function (x) x.match(trailingCommentRE)[1]) .map(x => x.match(trailingCommentRE)[1])
.join(""); .join("");
if (sql.substr(-1) == ";") { if (sql.substr(-1) == ";") {
sql = sql.substr(0, sql.length - 1); sql = sql.substr(0, sql.length - 1);
} }
var statements = sql.split(";") var statements = sql.split(";")
.map(function (x) x.replace(/TEMPSEMI/g, ";")); .map(x => x.replace(/TEMPSEMI/g, ";"));
this.requireTransaction(); this.requireTransaction();

View File

@ -36,8 +36,8 @@ Zotero.Duplicates = function (libraryID) {
} }
Zotero.Duplicates.prototype.__defineGetter__('name', function () Zotero.getString('pane.collections.duplicate')); Zotero.Duplicates.prototype.__defineGetter__('name', function () { return Zotero.getString('pane.collections.duplicate'); });
Zotero.Duplicates.prototype.__defineGetter__('libraryID', function () this._libraryID); Zotero.Duplicates.prototype.__defineGetter__('libraryID', function () { return this._libraryID; });
/** /**
* Get duplicates, populate a temporary table, and return a search based * 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 itemData USING (itemID) "
+ "JOIN itemDataValues USING (valueID) " + "JOIN itemDataValues USING (valueID) "
+ "WHERE libraryID=? AND fieldID IN (" + "WHERE libraryID=? AND fieldID IN ("
+ dateFields.map(function () '?').join() + ") " + dateFields.map(() => '?').join() + ") "
+ "AND SUBSTR(value, 1, 4) != '0000' " + "AND SUBSTR(value, 1, 4) != '0000' "
+ "AND itemID NOT IN (SELECT itemID FROM deletedItems) " + "AND itemID NOT IN (SELECT itemID FROM deletedItems) "
+ "ORDER BY value"; + "ORDER BY value";

View File

@ -637,7 +637,7 @@ Zotero.HTTP = new function() {
* through the error log and doing a fragile string comparison. * through the error log and doing a fragile string comparison.
*/ */
_pacInstalled = function () { _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)
} }

View File

@ -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 // Clear item type icon and tag colors when a tag is added to or removed from an item
if (type == 'item-tag') { if (type == 'item-tag') {
// TODO: Only update if colored tag changed? // 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]; delete this._itemImages[val];
}.bind(this)); }.bind(this));
return; return;
@ -1432,7 +1432,7 @@ Zotero.ItemTreeView.prototype.sort = function (itemID) {
// Cache primary values while sorting, since base-field-mapped getField() // Cache primary values while sorting, since base-field-mapped getField()
// calls are relatively expensive // calls are relatively expensive
var cache = {}; 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) // Get the display field for a row (which might be a placeholder title)
function getField(field, row) { function getField(field, row) {

View File

@ -75,7 +75,7 @@ Zotero.LocateManager = new function() {
/** /**
* Returns an array of all search engines * 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 * Returns an array of all search engines visible that should be visible in the dropdown

View File

@ -27,8 +27,8 @@
Zotero.Sync.Storage = new function () { Zotero.Sync.Storage = new function () {
// TEMP // TEMP
this.__defineGetter__("defaultError", function () Zotero.getString('sync.storage.error.default', Zotero.appName)); this.__defineGetter__("defaultError", function () { return Zotero.getString('sync.storage.error.default', Zotero.appName); });
this.__defineGetter__("defaultErrorRestart", function () Zotero.getString('sync.storage.error.defaultRestart', Zotero.appName)); this.__defineGetter__("defaultErrorRestart", function () { return Zotero.getString('sync.storage.error.defaultRestart', Zotero.appName); });
var _itemDownloadPercentages = {}; var _itemDownloadPercentages = {};

View File

@ -72,7 +72,7 @@ Components.utils.import("resource://gre/modules/PluralForm.jsm");
* @property {Boolean} locked Whether all Zotero panes are locked * @property {Boolean} locked Whether all Zotero panes are locked
* with an overlay * with an overlay
*/ */
this.__defineGetter__('locked', function () _locked); this.__defineGetter__('locked', function () { return _locked; });
this.__defineSetter__('locked', function (lock) { this.__defineSetter__('locked', function (lock) {
var wasLocked = _locked; var wasLocked = _locked;
_locked = lock; _locked = lock;
@ -788,7 +788,7 @@ Components.utils.import("resource://gre/modules/PluralForm.jsm");
var e = { var e = {
name: 'NS_ERROR_FILE_ACCESS_DENIED', name: 'NS_ERROR_FILE_ACCESS_DENIED',
message: msg, message: msg,
toString: function () this.message toString: function () { return this.message; }
}; };
throw (e); throw (e);
} }

View File

@ -33,7 +33,7 @@ var ZoteroPane = new function()
this.itemsView = false; this.itemsView = false;
this.progressWindow = false; this.progressWindow = false;
this._listeners = {}; this._listeners = {};
this.__defineGetter__('loaded', function () _loaded); this.__defineGetter__('loaded', function () { return _loaded; });
var _lastSelectedItems = []; var _lastSelectedItems = [];
//Privileged methods //Privileged methods

View File

@ -327,7 +327,7 @@ function makeZoteroContext(isConnector) {
// add connector-related properties // add connector-related properties
zContext.Zotero.isConnector = isConnector; zContext.Zotero.isConnector = isConnector;
zContext.Zotero.instanceID = instanceID; zContext.Zotero.instanceID = instanceID;
zContext.Zotero.__defineGetter__("isFirstLoadThisSession", function() isFirstLoadThisSession); zContext.Zotero.__defineGetter__("isFirstLoadThisSession", function() { return isFirstLoadThisSession; });
}; };
/** /**