Merge pull request #1111
Remove occurrences of legacy/non-standard/non-strict js syntax Closes #1111
This commit is contained in:
commit
36b6722c5c
55 changed files with 270 additions and 260 deletions
|
@ -475,7 +475,7 @@
|
||||||
|
|
||||||
var popup = button.appendChild(document.createElement("menupopup"));
|
var popup = button.appendChild(document.createElement("menupopup"));
|
||||||
|
|
||||||
for each(var v in this._fieldAlternatives[fieldName]) {
|
for (let v of this._fieldAlternatives[fieldName]) {
|
||||||
var menuitem = document.createElement("menuitem");
|
var menuitem = document.createElement("menuitem");
|
||||||
var sv = Zotero.Utilities.ellipsize(v, 60);
|
var sv = Zotero.Utilities.ellipsize(v, 60);
|
||||||
menuitem.setAttribute('label', sv);
|
menuitem.setAttribute('label', sv);
|
||||||
|
|
|
@ -528,7 +528,7 @@
|
||||||
this._tags = yield Zotero.Tags.getAll(this.libraryID, this._types);
|
this._tags = yield Zotero.Tags.getAll(this.libraryID, this._types);
|
||||||
|
|
||||||
for (let tag of this.selection) {
|
for (let tag of this.selection) {
|
||||||
for each(var tag2 in this._tags) {
|
for (let tag2 of this._tags) {
|
||||||
if (tag == tag2) {
|
if (tag == tag2) {
|
||||||
var found = true;
|
var found = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -474,7 +474,7 @@ var Zotero_File_Interface = new function() {
|
||||||
function _doBibliographyOptions(name, items) {
|
function _doBibliographyOptions(name, items) {
|
||||||
// make sure at least one item is not a standalone note or attachment
|
// make sure at least one item is not a standalone note or attachment
|
||||||
var haveRegularItem = false;
|
var haveRegularItem = false;
|
||||||
for each(var item in items) {
|
for (let item of items) {
|
||||||
if (item.isRegularItem()) {
|
if (item.isRegularItem()) {
|
||||||
haveRegularItem = true;
|
haveRegularItem = true;
|
||||||
break;
|
break;
|
||||||
|
@ -611,7 +611,7 @@ var Zotero_File_Interface = new function() {
|
||||||
// open file
|
// open file
|
||||||
var fStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
|
var fStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
|
||||||
createInstance(Components.interfaces.nsIFileOutputStream);
|
createInstance(Components.interfaces.nsIFileOutputStream);
|
||||||
fStream.init(fp.file, 0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate
|
fStream.init(fp.file, 0x02 | 0x08 | 0x20, 0o664, 0); // write, create, truncate
|
||||||
return fStream;
|
return fStream;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -384,8 +384,8 @@ var Zotero_LocateMenu = new function() {
|
||||||
return _getURL(item).then((val) => val !== false);
|
return _getURL(item).then((val) => val !== false);
|
||||||
}
|
}
|
||||||
this.handleItems = Zotero.Promise.coroutine(function* (items, event) {
|
this.handleItems = Zotero.Promise.coroutine(function* (items, event) {
|
||||||
var urls = yield Zotero.Promise.all([for (item of items) _getURL(item)]);
|
var urls = yield Zotero.Promise.all(items.map(item => _getURL(item)));
|
||||||
ZoteroPane_Local.loadURI([for (url of urls) if (url) url], event);
|
ZoteroPane_Local.loadURI(urls.filter(url => !!url), event);
|
||||||
});
|
});
|
||||||
|
|
||||||
var _getURL = Zotero.Promise.coroutine(function* (item) {
|
var _getURL = Zotero.Promise.coroutine(function* (item) {
|
||||||
|
@ -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) {
|
||||||
|
|
|
@ -160,7 +160,7 @@ var Zotero_RecognizePDF = new function() {
|
||||||
try {
|
try {
|
||||||
var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
||||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||||
inputStream.init(cacheFile, 0x01, 0664, 0);
|
inputStream.init(cacheFile, 0x01, 0o664, 0);
|
||||||
try {
|
try {
|
||||||
var intlStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
var intlStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||||
.createInstance(Components.interfaces.nsIConverterInputStream);
|
.createInstance(Components.interfaces.nsIConverterInputStream);
|
||||||
|
|
|
@ -460,7 +460,7 @@ var Zotero_RTFScan = new function() {
|
||||||
*/
|
*/
|
||||||
function _refreshCanAdvance() {
|
function _refreshCanAdvance() {
|
||||||
var canAdvance = true;
|
var canAdvance = true;
|
||||||
for each(var itemList in citationItemIDs) {
|
for (let itemList of citationItemIDs) {
|
||||||
if(itemList.length != 1) {
|
if(itemList.length != 1) {
|
||||||
canAdvance = false;
|
canAdvance = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -70,7 +70,10 @@ var Zotero_Tag_Color_Chooser = new function() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Get unused color at random
|
// Get unused color at random
|
||||||
var usedColors = [for (x of tagColors.values()) x.color];
|
var usedColors = [];
|
||||||
|
for (let x of tagColors.values()) {
|
||||||
|
usedColors.push(x.color);
|
||||||
|
}
|
||||||
var unusedColors = Zotero.Utilities.arrayDiff(
|
var unusedColors = Zotero.Utilities.arrayDiff(
|
||||||
colorPicker.colors, usedColors
|
colorPicker.colors, usedColors
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var tmp = Zotero.getTempDirectory();
|
var tmp = Zotero.getTempDirectory();
|
||||||
tmp.append(Zotero.randomString());
|
tmp.append(Zotero.randomString());
|
||||||
tmp.create(Components.interfaces.nsIFile.FILE_TYPE, 0644);
|
tmp.create(Components.interfaces.nsIFile.FILE_TYPE, 0o644);
|
||||||
|
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
var nowTS = Zotero.Date.toUnixTimestamp(date) * 1000;
|
var nowTS = Zotero.Date.toUnixTimestamp(date) * 1000;
|
||||||
|
|
|
@ -37,7 +37,7 @@ var Zotero_CSL_Editor = new function() {
|
||||||
|
|
||||||
var styles = Zotero.Styles.getAll();
|
var styles = Zotero.Styles.getAll();
|
||||||
var currentStyle = null;
|
var currentStyle = null;
|
||||||
for each(var style in styles) {
|
for (let style of styles) {
|
||||||
if (style.source) {
|
if (style.source) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ var Zotero_CSL_Preview = new function() {
|
||||||
var styles = Zotero.Styles.getAll();
|
var styles = Zotero.Styles.getAll();
|
||||||
// XXX needs its own string really for the title!
|
// XXX needs its own string really for the title!
|
||||||
var str = '<html><head><title></title></head><body>';
|
var str = '<html><head><title></title></head><body>';
|
||||||
for each(var style in styles) {
|
for (let style of styles) {
|
||||||
if (style.source) {
|
if (style.source) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ Zotero.Annotate = new function() {
|
||||||
} else {
|
} else {
|
||||||
var browsers = win.document.getElementsByTagNameNS(XUL_NAMESPACE, "browser");
|
var browsers = win.document.getElementsByTagNameNS(XUL_NAMESPACE, "browser");
|
||||||
}
|
}
|
||||||
for each(var browser in browsers) {
|
for (let browser of browsers) {
|
||||||
if(browser.currentURI) {
|
if(browser.currentURI) {
|
||||||
if(browser.currentURI.spec == annotationURL) {
|
if(browser.currentURI.spec == annotationURL) {
|
||||||
if(haveBrowser) {
|
if(haveBrowser) {
|
||||||
|
@ -364,7 +364,7 @@ Zotero.Annotate.Path.prototype.fromNode = function(node, offset) {
|
||||||
// is still part of the first text node
|
// is still part of the first text node
|
||||||
if(sibling.getAttribute) {
|
if(sibling.getAttribute) {
|
||||||
// get offset of all child nodes
|
// get offset of all child nodes
|
||||||
for each(var child in sibling.childNodes) {
|
for (let child of sibling.childNodes) {
|
||||||
if(child && child.nodeType == TEXT_TYPE) {
|
if(child && child.nodeType == TEXT_TYPE) {
|
||||||
this.offset += child.nodeValue.length;
|
this.offset += child.nodeValue.length;
|
||||||
}
|
}
|
||||||
|
@ -754,14 +754,14 @@ Zotero.Annotations.prototype.save = function() {
|
||||||
Zotero.Annotations.prototype.load = Zotero.Promise.coroutine(function* () {
|
Zotero.Annotations.prototype.load = Zotero.Promise.coroutine(function* () {
|
||||||
// load annotations
|
// load annotations
|
||||||
var rows = yield Zotero.DB.queryAsync("SELECT * FROM annotations WHERE itemID = ?", [this.itemID]);
|
var rows = yield Zotero.DB.queryAsync("SELECT * FROM annotations WHERE itemID = ?", [this.itemID]);
|
||||||
for each(var row in rows) {
|
for (let row of rows) {
|
||||||
var annotation = this.createAnnotation();
|
var annotation = this.createAnnotation();
|
||||||
annotation.initWithDBRow(row);
|
annotation.initWithDBRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load highlights
|
// load highlights
|
||||||
var rows = yield Zotero.DB.queryAsync("SELECT * FROM highlights WHERE itemID = ?", [this.itemID]);
|
var rows = yield Zotero.DB.queryAsync("SELECT * FROM highlights WHERE itemID = ?", [this.itemID]);
|
||||||
for each(var row in rows) {
|
for (let row of rows) {
|
||||||
try {
|
try {
|
||||||
var highlight = new Zotero.Highlight(this);
|
var highlight = new Zotero.Highlight(this);
|
||||||
highlight.initWithDBRow(row);
|
highlight.initWithDBRow(row);
|
||||||
|
|
|
@ -76,7 +76,7 @@ Zotero.API = {
|
||||||
var s2 = new Zotero.Search();
|
var s2 = new Zotero.Search();
|
||||||
s2.setScope(s);
|
s2.setScope(s);
|
||||||
var groups = Zotero.Groups.getAll();
|
var groups = Zotero.Groups.getAll();
|
||||||
for each(var group in groups) {
|
for (let group of groups) {
|
||||||
s2.addCondition('libraryID', 'isNot', group.libraryID);
|
s2.addCondition('libraryID', 'isNot', group.libraryID);
|
||||||
}
|
}
|
||||||
var ids = yield s2.search();
|
var ids = yield s2.search();
|
||||||
|
|
|
@ -848,7 +848,7 @@ Zotero.Attachments = new function(){
|
||||||
var tmpDir = Zotero.getStorageDirectory();
|
var tmpDir = Zotero.getStorageDirectory();
|
||||||
tmpDir.append("tmp-" + Zotero.Utilities.randomString(6));
|
tmpDir.append("tmp-" + Zotero.Utilities.randomString(6));
|
||||||
yield OS.File.makeDir(tmpDir.path, {
|
yield OS.File.makeDir(tmpDir.path, {
|
||||||
unixMode: 0755
|
unixMode: 0o755
|
||||||
});
|
});
|
||||||
return tmpDir;
|
return tmpDir;
|
||||||
});
|
});
|
||||||
|
|
|
@ -143,7 +143,7 @@ Zotero.Cite = {
|
||||||
output.push(bib[1][i]);
|
output.push(bib[1][i]);
|
||||||
|
|
||||||
// add COinS
|
// add COinS
|
||||||
for each(var itemID in bib[0].entry_ids[i]) {
|
for (let itemID of bib[0].entry_ids[i]) {
|
||||||
try {
|
try {
|
||||||
var co = Zotero.OpenURL.createContextObject(Zotero.Items.get(itemID), "1.0");
|
var co = Zotero.OpenURL.createContextObject(Zotero.Items.get(itemID), "1.0");
|
||||||
if(!co) continue;
|
if(!co) continue;
|
||||||
|
|
|
@ -1533,7 +1533,7 @@ Zotero.CollectionTreeView.prototype.canDropCheck = function (row, orient, dataTr
|
||||||
var ids = data;
|
var ids = data;
|
||||||
var items = Zotero.Items.get(ids);
|
var items = Zotero.Items.get(ids);
|
||||||
var skip = true;
|
var skip = true;
|
||||||
for each(var item in items) {
|
for (let item of items) {
|
||||||
// Can only drag top-level items
|
// Can only drag top-level items
|
||||||
if (!item.isTopLevelItem()) {
|
if (!item.isTopLevelItem()) {
|
||||||
Zotero.debug("Can't drag child item");
|
Zotero.debug("Can't drag child item");
|
||||||
|
@ -1738,7 +1738,7 @@ Zotero.CollectionTreeView.prototype.canDropCheckAsync = Zotero.Promise.coroutine
|
||||||
}
|
}
|
||||||
|
|
||||||
var descendents = col.getDescendents(false, 'collection');
|
var descendents = col.getDescendents(false, 'collection');
|
||||||
for each(var descendent in descendents) {
|
for (let descendent of descendents) {
|
||||||
descendent = Zotero.Collections.get(descendent.id);
|
descendent = Zotero.Collections.get(descendent.id);
|
||||||
// Disallow if linked collection already exists for any subcollections
|
// Disallow if linked collection already exists for any subcollections
|
||||||
//
|
//
|
||||||
|
@ -1883,7 +1883,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
|
||||||
if (options.childNotes) {
|
if (options.childNotes) {
|
||||||
var noteIDs = item.getNotes();
|
var noteIDs = item.getNotes();
|
||||||
var notes = Zotero.Items.get(noteIDs);
|
var notes = Zotero.Items.get(noteIDs);
|
||||||
for each(var note in notes) {
|
for (let note of notes) {
|
||||||
let newNote = note.clone(targetLibraryID, { skipTags: !options.tags });
|
let newNote = note.clone(targetLibraryID, { skipTags: !options.tags });
|
||||||
newNote.parentID = newItemID;
|
newNote.parentID = newItemID;
|
||||||
yield newNote.save({
|
yield newNote.save({
|
||||||
|
@ -1898,7 +1898,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
|
||||||
if (options.childLinks || options.childFileAttachments) {
|
if (options.childLinks || options.childFileAttachments) {
|
||||||
var attachmentIDs = item.getAttachments();
|
var attachmentIDs = item.getAttachments();
|
||||||
var attachments = Zotero.Items.get(attachmentIDs);
|
var attachments = Zotero.Items.get(attachmentIDs);
|
||||||
for each(var attachment in attachments) {
|
for (let attachment of attachments) {
|
||||||
var linkMode = attachment.attachmentLinkMode;
|
var linkMode = attachment.attachmentLinkMode;
|
||||||
|
|
||||||
// Skip linked files
|
// Skip linked files
|
||||||
|
@ -2069,7 +2069,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
|
||||||
var sameLibrary = false;
|
var sameLibrary = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for each(var item in items) {
|
for (let item of items) {
|
||||||
if (!item.isTopLevelItem()) {
|
if (!item.isTopLevelItem()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2126,7 +2126,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
|
||||||
var lastWin = wm.getMostRecentWindow("navigator:browser");
|
var lastWin = wm.getMostRecentWindow("navigator:browser");
|
||||||
lastWin.openDialog('chrome://zotero/content/merge.xul', '', 'chrome,modal,centerscreen', io);
|
lastWin.openDialog('chrome://zotero/content/merge.xul', '', 'chrome,modal,centerscreen', io);
|
||||||
|
|
||||||
for each(var obj in io.dataOut) {
|
for (let obj of io.dataOut) {
|
||||||
yield obj.ref.save();
|
yield obj.ref.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,7 @@ Zotero.CreatorTypes = new function() {
|
||||||
|
|
||||||
var valid = false;
|
var valid = false;
|
||||||
var types = this.getTypesForItemType(itemTypeID);
|
var types = this.getTypesForItemType(itemTypeID);
|
||||||
for each(var type in types) {
|
for (let type of types) {
|
||||||
if (type.id == creatorTypeID) {
|
if (type.id == creatorTypeID) {
|
||||||
valid = true;
|
valid = true;
|
||||||
break;
|
break;
|
||||||
|
@ -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 {
|
||||||
|
|
|
@ -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 '
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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; }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
|
@ -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); }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
|
@ -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');
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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', {
|
||||||
|
@ -447,7 +447,7 @@ Zotero.Item.prototype.setType = function(itemTypeID, loadIn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for each(var oldFieldID in obsoleteFields) {
|
for (let oldFieldID of obsoleteFields) {
|
||||||
// Try to get a base type for this field
|
// Try to get a base type for this field
|
||||||
var baseFieldID =
|
var baseFieldID =
|
||||||
Zotero.ItemFields.getBaseIDFromTypeAndField(oldItemTypeID, oldFieldID);
|
Zotero.ItemFields.getBaseIDFromTypeAndField(oldItemTypeID, oldFieldID);
|
||||||
|
@ -532,14 +532,14 @@ Zotero.Item.prototype.setType = function(itemTypeID, loadIn) {
|
||||||
// Initialize this._itemData with type-specific fields
|
// Initialize this._itemData with type-specific fields
|
||||||
this._itemData = {};
|
this._itemData = {};
|
||||||
var fields = Zotero.ItemFields.getItemTypeFields(itemTypeID);
|
var fields = Zotero.ItemFields.getItemTypeFields(itemTypeID);
|
||||||
for each(var fieldID in fields) {
|
for (let fieldID of fields) {
|
||||||
this._itemData[fieldID] = null;
|
this._itemData[fieldID] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG: clear change item data?
|
// DEBUG: clear change item data?
|
||||||
|
|
||||||
if (copiedFields) {
|
if (copiedFields) {
|
||||||
for each(var f in copiedFields) {
|
for (let f of copiedFields) {
|
||||||
// For fields that we moved to different fields in the new type
|
// For fields that we moved to different fields in the new type
|
||||||
// (e.g., book -> bookTitle), mark the old value as explicitly
|
// (e.g., book -> bookTitle), mark the old value as explicitly
|
||||||
// false in previousData (since otherwise it would be null)
|
// false in previousData (since otherwise it would be null)
|
||||||
|
@ -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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3793,7 +3793,7 @@ Zotero.Item.prototype.diff = function (item, includeMatches, ignoreFields) {
|
||||||
throw ("ignoreFields cannot be used if includeMatches is set");
|
throw ("ignoreFields cannot be used if includeMatches is set");
|
||||||
}
|
}
|
||||||
var realDiffs = numDiffs;
|
var realDiffs = numDiffs;
|
||||||
for each(var field in ignoreFields) {
|
for (let field of ignoreFields) {
|
||||||
if (diff[0].primary[field] != undefined) {
|
if (diff[0].primary[field] != undefined) {
|
||||||
realDiffs--;
|
realDiffs--;
|
||||||
if (realDiffs == 0) {
|
if (realDiffs == 0) {
|
||||||
|
|
|
@ -75,7 +75,7 @@ Zotero.ItemFields = new function() {
|
||||||
var sql = "SELECT DISTINCT baseFieldID FROM baseFieldMappingsCombined";
|
var sql = "SELECT DISTINCT baseFieldID FROM baseFieldMappingsCombined";
|
||||||
var baseFields = yield Zotero.DB.columnQueryAsync(sql);
|
var baseFields = yield Zotero.DB.columnQueryAsync(sql);
|
||||||
|
|
||||||
for each(var field in fields) {
|
for (let field of fields) {
|
||||||
_fields[field['fieldID']] = {
|
_fields[field['fieldID']] = {
|
||||||
id: field['fieldID'],
|
id: field['fieldID'],
|
||||||
name: field.fieldName,
|
name: field.fieldName,
|
||||||
|
@ -440,7 +440,7 @@ Zotero.ItemFields = new function() {
|
||||||
var baseFields = yield Zotero.DB.columnQueryAsync(sql);
|
var baseFields = yield Zotero.DB.columnQueryAsync(sql);
|
||||||
|
|
||||||
var fields = [];
|
var fields = [];
|
||||||
for each(var row in rows) {
|
for (let row of rows) {
|
||||||
if (!fields[row.itemTypeID]) {
|
if (!fields[row.itemTypeID]) {
|
||||||
fields[row.itemTypeID] = [];
|
fields[row.itemTypeID] = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -743,12 +743,12 @@ Zotero.Items = function() {
|
||||||
var toSave = {};
|
var toSave = {};
|
||||||
toSave[item.id] = item;
|
toSave[item.id] = item;
|
||||||
|
|
||||||
for each(var otherItem in otherItems) {
|
for (let otherItem of otherItems) {
|
||||||
let otherItemURI = Zotero.URI.getItemURI(otherItem);
|
let otherItemURI = Zotero.URI.getItemURI(otherItem);
|
||||||
|
|
||||||
// Move child items to master
|
// Move child items to master
|
||||||
var ids = otherItem.getAttachments(true).concat(otherItem.getNotes(true));
|
var ids = otherItem.getAttachments(true).concat(otherItem.getNotes(true));
|
||||||
for each(var id in ids) {
|
for (let id of ids) {
|
||||||
var attachment = yield this.getAsync(id);
|
var attachment = yield this.getAsync(id);
|
||||||
|
|
||||||
// TODO: Skip identical children?
|
// TODO: Skip identical children?
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ Zotero.Search.prototype.clone = function (libraryID) {
|
||||||
|
|
||||||
var conditions = this.getConditions();
|
var conditions = this.getConditions();
|
||||||
|
|
||||||
for each(var condition in conditions) {
|
for (let condition of Object.values(conditions)) {
|
||||||
var name = condition.mode ?
|
var name = condition.mode ?
|
||||||
condition.condition + '/' + condition.mode :
|
condition.condition + '/' + condition.mode :
|
||||||
condition.condition
|
condition.condition
|
||||||
|
@ -299,7 +299,7 @@ Zotero.Search.prototype.addCondition = function (condition, operator, value, req
|
||||||
if (condition.match(/^quicksearch/)) {
|
if (condition.match(/^quicksearch/)) {
|
||||||
var parts = Zotero.SearchConditions.parseSearchString(value);
|
var parts = Zotero.SearchConditions.parseSearchString(value);
|
||||||
|
|
||||||
for each(var part in parts) {
|
for (let part of parts) {
|
||||||
this.addCondition('blockStart');
|
this.addCondition('blockStart');
|
||||||
|
|
||||||
// If search string is 8 characters, see if this is a item key
|
// If search string is 8 characters, see if this is a item key
|
||||||
|
@ -329,7 +329,7 @@ Zotero.Search.prototype.addCondition = function (condition, operator, value, req
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var splits = Zotero.Fulltext.semanticSplitter(part.text);
|
var splits = Zotero.Fulltext.semanticSplitter(part.text);
|
||||||
for each(var split in splits) {
|
for (let split of splits) {
|
||||||
this.addCondition('fulltextWord', operator, split, false);
|
this.addCondition('fulltextWord', operator, split, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ Zotero.Search.prototype.getConditions = function(){
|
||||||
|
|
||||||
Zotero.Search.prototype.hasPostSearchFilter = function() {
|
Zotero.Search.prototype.hasPostSearchFilter = function() {
|
||||||
this._requireData('conditions');
|
this._requireData('conditions');
|
||||||
for each(var i in this._conditions){
|
for (let i of Object.values(this._conditions)) {
|
||||||
if (i.condition == 'fulltextContent'){
|
if (i.condition == 'fulltextContent'){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ Zotero.Search.prototype.search = Zotero.Promise.coroutine(function* (asTempTable
|
||||||
var joinMode = 'all';
|
var joinMode = 'all';
|
||||||
|
|
||||||
// Set some variables for conditions to avoid further lookups
|
// Set some variables for conditions to avoid further lookups
|
||||||
for each(var condition in this._conditions) {
|
for (let condition of Object.values(this._conditions)) {
|
||||||
switch (condition.condition) {
|
switch (condition.condition) {
|
||||||
case 'joinMode':
|
case 'joinMode':
|
||||||
if (condition.operator == 'any') {
|
if (condition.operator == 'any') {
|
||||||
|
@ -632,9 +632,9 @@ Zotero.Search.prototype.search = Zotero.Promise.coroutine(function* (asTempTable
|
||||||
// If join mode ANY or there's a quicksearch (which we assume
|
// If join mode ANY or there's a quicksearch (which we assume
|
||||||
// fulltextContent is part of), return the union of the main search and
|
// fulltextContent is part of), return the union of the main search and
|
||||||
// (a separate fulltext word search filtered by fulltext content)
|
// (a separate fulltext word search filtered by fulltext content)
|
||||||
for each(var condition in 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') :
|
||||||
|
@ -669,7 +669,7 @@ Zotero.Search.prototype.search = Zotero.Promise.coroutine(function* (asTempTable
|
||||||
// Add any necessary conditions to the fulltext word search --
|
// Add any necessary conditions to the fulltext word search --
|
||||||
// those that are required in an ANY search and any outside the
|
// those that are required in an ANY search and any outside the
|
||||||
// quicksearch in an ALL search
|
// quicksearch in an ALL search
|
||||||
for each(var c in this._conditions) {
|
for (let c of Object.values(this._conditions)) {
|
||||||
if (c.condition == 'blockStart') {
|
if (c.condition == 'blockStart') {
|
||||||
var inQS = true;
|
var inQS = true;
|
||||||
continue;
|
continue;
|
||||||
|
@ -688,7 +688,7 @@ Zotero.Search.prototype.search = Zotero.Promise.coroutine(function* (asTempTable
|
||||||
}
|
}
|
||||||
|
|
||||||
var splits = Zotero.Fulltext.semanticSplitter(condition.value);
|
var splits = Zotero.Fulltext.semanticSplitter(condition.value);
|
||||||
for each(var split in splits){
|
for (let split of splits){
|
||||||
s.addCondition('fulltextWord', condition.operator, split);
|
s.addCondition('fulltextWord', condition.operator, split);
|
||||||
}
|
}
|
||||||
var fulltextWordIDs = yield s.search();
|
var fulltextWordIDs = yield s.search();
|
||||||
|
@ -1043,7 +1043,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
|
||||||
if (this._hasPrimaryConditions) {
|
if (this._hasPrimaryConditions) {
|
||||||
sql += " AND ";
|
sql += " AND ";
|
||||||
|
|
||||||
for each(var condition in conditions){
|
for (let condition of Object.values(conditions)){
|
||||||
var skipOperators = false;
|
var skipOperators = false;
|
||||||
var openParens = 0;
|
var openParens = 0;
|
||||||
var condSQL = '';
|
var condSQL = '';
|
||||||
|
@ -1088,7 +1088,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
|
||||||
if (typeFields) {
|
if (typeFields) {
|
||||||
condSQL += 'fieldID IN (?,';
|
condSQL += 'fieldID IN (?,';
|
||||||
// Add type-specific fields
|
// Add type-specific fields
|
||||||
for each(var fieldID in typeFields) {
|
for (let fieldID of typeFields) {
|
||||||
condSQL += '?,';
|
condSQL += '?,';
|
||||||
condSQLParams.push(fieldID);
|
condSQLParams.push(fieldID);
|
||||||
}
|
}
|
||||||
|
@ -1113,7 +1113,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
|
||||||
if (dateFields) {
|
if (dateFields) {
|
||||||
condSQL += 'fieldID IN (?,';
|
condSQL += 'fieldID IN (?,';
|
||||||
// Add type-specific date fields (dateEnacted, dateDecided, issueDate)
|
// Add type-specific date fields (dateEnacted, dateDecided, issueDate)
|
||||||
for each(var fieldID in dateFields) {
|
for (let fieldID of dateFields) {
|
||||||
condSQL += '?,';
|
condSQL += '?,';
|
||||||
condSQLParams.push(fieldID);
|
condSQLParams.push(fieldID);
|
||||||
}
|
}
|
||||||
|
@ -1148,7 +1148,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
|
||||||
// for the collection/search
|
// for the collection/search
|
||||||
if (objLibraryID === undefined) {
|
if (objLibraryID === undefined) {
|
||||||
let foundLibraryID = false;
|
let foundLibraryID = false;
|
||||||
for each (let c in this._conditions) {
|
for (let c of Object.values(this._conditions)) {
|
||||||
if (c.condition == 'libraryID' && c.operator == 'is') {
|
if (c.condition == 'libraryID' && c.operator == 'is') {
|
||||||
foundLibraryID = true;
|
foundLibraryID = true;
|
||||||
obj = yield objectTypeClass.getByLibraryAndKeyAsync(
|
obj = yield objectTypeClass.getByLibraryAndKeyAsync(
|
||||||
|
@ -1246,7 +1246,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
|
||||||
+ 'fileTypeID=?)';
|
+ 'fileTypeID=?)';
|
||||||
var patterns = yield Zotero.DB.columnQueryAsync(ftSQL, { int: condition.value });
|
var patterns = yield Zotero.DB.columnQueryAsync(ftSQL, { int: condition.value });
|
||||||
if (patterns) {
|
if (patterns) {
|
||||||
for each(str in patterns) {
|
for (let str of patterns) {
|
||||||
condSQL += 'contentType LIKE ? OR ';
|
condSQL += 'contentType LIKE ? OR ';
|
||||||
condSQLParams.push(str + '%');
|
condSQLParams.push(str + '%');
|
||||||
}
|
}
|
||||||
|
@ -1402,7 +1402,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
|
||||||
if (useFreeform && dateparts['part']){
|
if (useFreeform && dateparts['part']){
|
||||||
go = true;
|
go = true;
|
||||||
var parts = dateparts['part'].split(' ');
|
var parts = dateparts['part'].split(' ');
|
||||||
for each (var part in parts){
|
for (let part of parts) {
|
||||||
condSQL += " AND SUBSTR(" + condition['field'] + ", 12, 100)";
|
condSQL += " AND SUBSTR(" + condition['field'] + ", 12, 100)";
|
||||||
condSQL += " LIKE ?";
|
condSQL += " LIKE ?";
|
||||||
condSQLParams.push('%' + part + '%');
|
condSQLParams.push('%' + part + '%');
|
||||||
|
|
|
@ -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++) {
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -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";
|
||||||
|
@ -392,7 +392,7 @@ Zotero.Duplicates.prototype._findDuplicates = Zotero.Promise.coroutine(function*
|
||||||
|
|
||||||
// Match on exact fields
|
// Match on exact fields
|
||||||
/*var fields = [''];
|
/*var fields = [''];
|
||||||
for each(var field in fields) {
|
for (let field of fields) {
|
||||||
var sql = "SELECT itemID, value FROM items JOIN itemData USING (itemID) "
|
var sql = "SELECT itemID, value FROM items JOIN itemData USING (itemID) "
|
||||||
+ "JOIN itemDataValues USING (valueID) "
|
+ "JOIN itemDataValues USING (valueID) "
|
||||||
+ "WHERE libraryID=? AND fieldID=? "
|
+ "WHERE libraryID=? AND fieldID=? "
|
||||||
|
|
|
@ -124,7 +124,7 @@ Zotero.File = new function(){
|
||||||
this.getBinaryContents = function(file) {
|
this.getBinaryContents = function(file) {
|
||||||
var iStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
var iStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
||||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||||
iStream.init(file, 0x01, 0664, 0);
|
iStream.init(file, 0x01, 0o664, 0);
|
||||||
var bStream = Components.classes["@mozilla.org/binaryinputstream;1"]
|
var bStream = Components.classes["@mozilla.org/binaryinputstream;1"]
|
||||||
.createInstance(Components.interfaces.nsIBinaryInputStream);
|
.createInstance(Components.interfaces.nsIBinaryInputStream);
|
||||||
bStream.setInputStream(iStream);
|
bStream.setInputStream(iStream);
|
||||||
|
@ -154,7 +154,7 @@ Zotero.File = new function(){
|
||||||
} else if(file instanceof Components.interfaces.nsIFile) {
|
} else if(file instanceof Components.interfaces.nsIFile) {
|
||||||
fis = Components.classes["@mozilla.org/network/file-input-stream;1"].
|
fis = Components.classes["@mozilla.org/network/file-input-stream;1"].
|
||||||
createInstance(Components.interfaces.nsIFileInputStream);
|
createInstance(Components.interfaces.nsIFileInputStream);
|
||||||
fis.init(file, 0x01, 0664, 0);
|
fis.init(file, 0x01, 0o664, 0);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("File is not an nsIInputStream or nsIFile");
|
throw new Error("File is not an nsIInputStream or nsIFile");
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ Zotero.File = new function(){
|
||||||
}
|
}
|
||||||
var fos = Components.classes["@mozilla.org/network/file-output-stream;1"].
|
var fos = Components.classes["@mozilla.org/network/file-output-stream;1"].
|
||||||
createInstance(Components.interfaces.nsIFileOutputStream);
|
createInstance(Components.interfaces.nsIFileOutputStream);
|
||||||
fos.init(file, 0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate
|
fos.init(file, 0x02 | 0x08 | 0x20, 0o664, 0); // write, create, truncate
|
||||||
|
|
||||||
var os = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
|
var os = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
|
||||||
.createInstance(Components.interfaces.nsIConverterOutputStream);
|
.createInstance(Components.interfaces.nsIConverterOutputStream);
|
||||||
|
@ -642,7 +642,7 @@ Zotero.File = new function(){
|
||||||
.getTypeFromFile(file);
|
.getTypeFromFile(file);
|
||||||
var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
||||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||||
inputStream.init(file, 0x01, 0600, 0);
|
inputStream.init(file, 0x01, 0o600, 0);
|
||||||
var stream = Components.classes["@mozilla.org/binaryinputstream;1"]
|
var stream = Components.classes["@mozilla.org/binaryinputstream;1"]
|
||||||
.createInstance(Components.interfaces.nsIBinaryInputStream);
|
.createInstance(Components.interfaces.nsIBinaryInputStream);
|
||||||
stream.setInputStream(inputStream);
|
stream.setInputStream(inputStream);
|
||||||
|
@ -768,7 +768,7 @@ Zotero.File = new function(){
|
||||||
file = this.pathToFile(file);
|
file = this.pathToFile(file);
|
||||||
newFile = this.pathToFile(newFile);
|
newFile = this.pathToFile(newFile);
|
||||||
|
|
||||||
newFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
|
newFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
||||||
var newName = newFile.leafName;
|
var newName = newFile.leafName;
|
||||||
newFile.remove(null);
|
newFile.remove(null);
|
||||||
|
|
||||||
|
@ -807,7 +807,7 @@ Zotero.File = new function(){
|
||||||
if (dir.exists() && !dir.isDirectory()) {
|
if (dir.exists() && !dir.isDirectory()) {
|
||||||
dir.remove(null);
|
dir.remove(null);
|
||||||
}
|
}
|
||||||
dir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
dir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -818,7 +818,7 @@ Zotero.File = new function(){
|
||||||
path,
|
path,
|
||||||
{
|
{
|
||||||
ignoreExisting: true,
|
ignoreExisting: true,
|
||||||
unixMode: 0755
|
unixMode: 0o755
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1500,7 +1500,7 @@ Zotero.Integration.Fields.prototype._processFields = function(i) {
|
||||||
e.setContext(this, i)
|
e.setContext(this, i)
|
||||||
} else if(e instanceof Zotero.Integration.MissingItemException) {
|
} else if(e instanceof Zotero.Integration.MissingItemException) {
|
||||||
// Check if we've already decided to remove this field code
|
// Check if we've already decided to remove this field code
|
||||||
for each(var reselectKey in e.reselectKeys) {
|
for (let reselectKey of e.reselectKeys) {
|
||||||
if(this._removeCodeKeys[reselectKey]) {
|
if(this._removeCodeKeys[reselectKey]) {
|
||||||
this._removeCodeFields[i] = true;
|
this._removeCodeFields[i] = true;
|
||||||
removeCode = true;
|
removeCode = true;
|
||||||
|
@ -2173,7 +2173,7 @@ Zotero.Integration.Session.prototype.reselectItem = function(doc, exception) {
|
||||||
var itemID = io.dataOut[0];
|
var itemID = io.dataOut[0];
|
||||||
|
|
||||||
// add reselected item IDs to hash, so they can be used
|
// add reselected item IDs to hash, so they can be used
|
||||||
for each(var reselectKey in exception.reselectKeys) {
|
for (let reselectKey of exception.reselectKeys) {
|
||||||
me.reselectedItems[reselectKey] = itemID;
|
me.reselectedItems[reselectKey] = itemID;
|
||||||
}
|
}
|
||||||
// add old URIs to map, so that they will be included
|
// add old URIs to map, so that they will be included
|
||||||
|
@ -2379,7 +2379,7 @@ Zotero.Integration.Session.prototype.lookupItems = function(citation, index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// look to see if item has already been reselected
|
// look to see if item has already been reselected
|
||||||
for each(var reselectKey in reselectKeys) {
|
for (let reselectKey of reselectKeys) {
|
||||||
if(this.reselectedItems[reselectKey]) {
|
if(this.reselectedItems[reselectKey]) {
|
||||||
zoteroItem = Zotero.Items.get(this.reselectedItems[reselectKey]);
|
zoteroItem = Zotero.Items.get(this.reselectedItems[reselectKey]);
|
||||||
citationItem.id = zoteroItem.id;
|
citationItem.id = zoteroItem.id;
|
||||||
|
@ -2479,7 +2479,7 @@ Zotero.Integration.Session.prototype.unserializeCitation = function(arg, index)
|
||||||
|
|
||||||
if(!citation.properties) citation.properties = {};
|
if(!citation.properties) citation.properties = {};
|
||||||
|
|
||||||
for each(var citationItem in citation.citationItems) {
|
for (let citationItem of citation.citationItems) {
|
||||||
// for upgrade from Zotero 2.0 or earlier
|
// for upgrade from Zotero 2.0 or earlier
|
||||||
if(citationItem.locatorType) {
|
if(citationItem.locatorType) {
|
||||||
citationItem.label = citationItem.locatorType;
|
citationItem.label = citationItem.locatorType;
|
||||||
|
@ -2634,7 +2634,7 @@ Zotero.Integration.Session.prototype.formatCitation = function(index, citation)
|
||||||
Zotero.debug("Integration: style.processCitationCluster("+citation.toSource()+", "+citationsPre.toSource()+", "+citationsPost.toSource());
|
Zotero.debug("Integration: style.processCitationCluster("+citation.toSource()+", "+citationsPre.toSource()+", "+citationsPost.toSource());
|
||||||
}
|
}
|
||||||
var newCitations = this.style.processCitationCluster(citation, citationsPre, citationsPost);
|
var newCitations = this.style.processCitationCluster(citation, citationsPre, citationsPost);
|
||||||
for each(var newCitation in newCitations[1]) {
|
for (let newCitation of newCitations[1]) {
|
||||||
this.citationText[citationIndices[newCitation[0]]] = newCitation[1];
|
this.citationText[citationIndices[newCitation[0]]] = newCitation[1];
|
||||||
this.updateIndices[citationIndices[newCitation[0]]] = true;
|
this.updateIndices[citationIndices[newCitation[0]]] = true;
|
||||||
}
|
}
|
||||||
|
@ -2651,7 +2651,7 @@ Zotero.Integration.Session.prototype._updateCitations = function* () {
|
||||||
if(force) {
|
if(force) {
|
||||||
allUpdatesForced = true;
|
allUpdatesForced = true;
|
||||||
// make sure at least one citation gets updated
|
// make sure at least one citation gets updated
|
||||||
updateLoop: for each(var indexList in [this.newIndices, this.updateIndices]) {
|
updateLoop: for (let indexList of [this.newIndices, this.updateIndices]) {
|
||||||
for(var i in indexList) {
|
for(var i in indexList) {
|
||||||
if(!this.citationsByIndex[i].properties.delete) {
|
if(!this.citationsByIndex[i].properties.delete) {
|
||||||
allUpdatesForced = false;
|
allUpdatesForced = false;
|
||||||
|
@ -2736,7 +2736,7 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
|
||||||
if(documentData.uncited[0]) {
|
if(documentData.uncited[0]) {
|
||||||
// new style array of arrays with URIs
|
// new style array of arrays with URIs
|
||||||
let zoteroItem, needUpdate;
|
let zoteroItem, needUpdate;
|
||||||
for each(var uris in documentData.uncited) {
|
for (let uris of documentData.uncited) {
|
||||||
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(uris);
|
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(uris);
|
||||||
var id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id;
|
var id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id;
|
||||||
if(zoteroItem && !this.citationsByItemID[id]) {
|
if(zoteroItem && !this.citationsByItemID[id]) {
|
||||||
|
@ -2765,7 +2765,7 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
|
||||||
if(documentData.custom[0]) {
|
if(documentData.custom[0]) {
|
||||||
// new style array of arrays with URIs
|
// new style array of arrays with URIs
|
||||||
var zoteroItem, needUpdate;
|
var zoteroItem, needUpdate;
|
||||||
for each(var custom in documentData.custom) {
|
for (let custom of documentData.custom) {
|
||||||
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(custom[0]);
|
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(custom[0]);
|
||||||
if(!zoteroItem) continue;
|
if(!zoteroItem) continue;
|
||||||
if(needUpdate) this.bibliographyDataHasChanged = true;
|
if(needUpdate) this.bibliographyDataHasChanged = true;
|
||||||
|
@ -2794,7 +2794,7 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
|
||||||
// set entries to be omitted from bibliography
|
// set entries to be omitted from bibliography
|
||||||
if(documentData.omitted) {
|
if(documentData.omitted) {
|
||||||
let zoteroItem, needUpdate;
|
let zoteroItem, needUpdate;
|
||||||
for each(var uris in documentData.omitted) {
|
for (let uris of documentData.omitted) {
|
||||||
[zoteroItem, update] = this.uriMap.getZoteroItemForURIs(uris);
|
[zoteroItem, update] = this.uriMap.getZoteroItemForURIs(uris);
|
||||||
var id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id;
|
var id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id;
|
||||||
if(zoteroItem && this.citationsByItemID[id]) {
|
if(zoteroItem && this.citationsByItemID[id]) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ Zotero.IPC = new function() {
|
||||||
if(!Zotero.isWin) { // no pipe support on Fx 3.6
|
if(!Zotero.isWin) { // no pipe support on Fx 3.6
|
||||||
_instancePipe = _getPipeDirectory();
|
_instancePipe = _getPipeDirectory();
|
||||||
if(!_instancePipe.exists()) {
|
if(!_instancePipe.exists()) {
|
||||||
_instancePipe.create(Ci.nsIFile.DIRECTORY_TYPE, 0700);
|
_instancePipe.create(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
|
||||||
}
|
}
|
||||||
_instancePipe.append(Zotero.instanceID);
|
_instancePipe.append(Zotero.instanceID);
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ Zotero.IPC = new function() {
|
||||||
// On Linux, O_NONBLOCK = 00004000
|
// On Linux, O_NONBLOCK = 00004000
|
||||||
// On both, O_WRONLY = 0x0001
|
// On both, O_WRONLY = 0x0001
|
||||||
var mode = 0x0001;
|
var mode = 0x0001;
|
||||||
if(!block) mode = mode | (Zotero.isLinux ? 00004000 : 0x0004);
|
if(!block) mode = mode | (Zotero.isLinux ? 0o0004000 : 0x0004);
|
||||||
|
|
||||||
var fd = open(pipe.path, mode);
|
var fd = open(pipe.path, mode);
|
||||||
if(fd === -1) return false;
|
if(fd === -1) return false;
|
||||||
|
@ -387,7 +387,7 @@ Zotero.IPC.Pipe = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// make pipe
|
// make pipe
|
||||||
var ret = _mkfifo(file.path, 0600);
|
var ret = _mkfifo(file.path, 0o600);
|
||||||
return file.exists();
|
return file.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -516,7 +516,7 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
|
||||||
var col = this._treebox.columns.getNamedColumn(
|
var col = this._treebox.columns.getNamedColumn(
|
||||||
'zotero-items-column-' + extraData.column
|
'zotero-items-column-' + extraData.column
|
||||||
);
|
);
|
||||||
for each(var id in ids) {
|
for (let id of ids) {
|
||||||
if (extraData.column == 'title') {
|
if (extraData.column == 'title') {
|
||||||
delete this._itemImages[id];
|
delete this._itemImages[id];
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for each(var id in ids) {
|
for (let id of ids) {
|
||||||
delete this._itemImages[id];
|
delete this._itemImages[id];
|
||||||
this._treebox.invalidateRow(this._rowMap[id]);
|
this._treebox.invalidateRow(this._rowMap[id]);
|
||||||
}
|
}
|
||||||
|
@ -589,7 +589,7 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
|
||||||
}
|
}
|
||||||
|
|
||||||
var splitIDs = [];
|
var splitIDs = [];
|
||||||
for each(var id in ids) {
|
for (let id of ids) {
|
||||||
var split = id.split('-');
|
var split = id.split('-');
|
||||||
// Skip if not an item in this collection
|
// Skip if not an item in this collection
|
||||||
if (split[0] != collectionTreeRow.ref.id) {
|
if (split[0] != collectionTreeRow.ref.id) {
|
||||||
|
@ -764,7 +764,7 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
|
||||||
var allDeleted = true;
|
var allDeleted = true;
|
||||||
var isTrash = collectionTreeRow.isTrash();
|
var isTrash = collectionTreeRow.isTrash();
|
||||||
var items = Zotero.Items.get(ids);
|
var items = Zotero.Items.get(ids);
|
||||||
for each(var item in items) {
|
for (let item of items) {
|
||||||
// If not viewing trash and all items were deleted, ignore modify
|
// If not viewing trash and all items were deleted, ignore modify
|
||||||
if (allDeleted && !isTrash && !item.deleted) {
|
if (allDeleted && !isTrash && !item.deleted) {
|
||||||
allDeleted = false;
|
allDeleted = false;
|
||||||
|
@ -857,7 +857,7 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
|
||||||
var items = Zotero.Items.get(ids);
|
var items = Zotero.Items.get(ids);
|
||||||
if (items) {
|
if (items) {
|
||||||
var found = false;
|
var found = false;
|
||||||
for each(var item in items) {
|
for (let item of items) {
|
||||||
// Check for note and attachment type, since it's quicker
|
// Check for note and attachment type, since it's quicker
|
||||||
// than checking for parent item
|
// than checking for parent item
|
||||||
if (item.itemTypeID == 1 || item.itemTypeID == 14) {
|
if (item.itemTypeID == 1 || item.itemTypeID == 14) {
|
||||||
|
@ -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) {
|
||||||
|
@ -1778,7 +1778,7 @@ Zotero.ItemTreeView.prototype.selectItems = function(ids) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var rows = [];
|
var rows = [];
|
||||||
for each(var id in ids) {
|
for (let id of ids) {
|
||||||
if(this._rowMap[id] !== undefined) rows.push(this._rowMap[id]);
|
if(this._rowMap[id] !== undefined) rows.push(this._rowMap[id]);
|
||||||
}
|
}
|
||||||
rows.sort(function (a, b) {
|
rows.sort(function (a, b) {
|
||||||
|
@ -2045,7 +2045,7 @@ Zotero.ItemTreeView.prototype._saveOpenState = function (close) {
|
||||||
|
|
||||||
Zotero.ItemTreeView.prototype.rememberOpenState = function (itemIDs) {
|
Zotero.ItemTreeView.prototype.rememberOpenState = function (itemIDs) {
|
||||||
var rowsToOpen = [];
|
var rowsToOpen = [];
|
||||||
for each(var id in itemIDs) {
|
for (let id of itemIDs) {
|
||||||
var row = this._rowMap[id];
|
var row = this._rowMap[id];
|
||||||
// Item may not still exist
|
// Item may not still exist
|
||||||
if (row == undefined) {
|
if (row == undefined) {
|
||||||
|
@ -2190,7 +2190,7 @@ Zotero.ItemTreeView.prototype.getVisibleFields = function() {
|
||||||
*/
|
*/
|
||||||
Zotero.ItemTreeView.prototype.getSortedItems = function(asIDs) {
|
Zotero.ItemTreeView.prototype.getSortedItems = function(asIDs) {
|
||||||
var items = [];
|
var items = [];
|
||||||
for each(var item in this._rows) {
|
for (let item of this._rows) {
|
||||||
if (asIDs) {
|
if (asIDs) {
|
||||||
items.push(item.ref.id);
|
items.push(item.ref.id);
|
||||||
}
|
}
|
||||||
|
@ -2673,7 +2673,7 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
if (destDir.exists()) {
|
if (destDir.exists()) {
|
||||||
destDir.remove(true);
|
destDir.remove(true);
|
||||||
}
|
}
|
||||||
destDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
destDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
|
||||||
}
|
}
|
||||||
|
|
||||||
var copiedFiles = [];
|
var copiedFiles = [];
|
||||||
|
@ -2721,7 +2721,7 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
// directory, it's a duplicate, so give this one
|
// directory, it's a duplicate, so give this one
|
||||||
// a different name
|
// a different name
|
||||||
else {
|
else {
|
||||||
copiedFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
|
copiedFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
||||||
var newName = copiedFile.leafName;
|
var newName = copiedFile.leafName;
|
||||||
copiedFile.remove(null);
|
copiedFile.remove(null);
|
||||||
}
|
}
|
||||||
|
@ -2762,7 +2762,7 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
// it's a duplicate, so give this one a different
|
// it's a duplicate, so give this one a different
|
||||||
// name
|
// name
|
||||||
else {
|
else {
|
||||||
copiedFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
|
copiedFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
||||||
var newName = copiedFile.leafName;
|
var newName = copiedFile.leafName;
|
||||||
copiedFile.remove(null);
|
copiedFile.remove(null);
|
||||||
}
|
}
|
||||||
|
@ -2863,7 +2863,7 @@ Zotero.ItemTreeView.prototype.canDropCheck = function (row, orient, dataTransfer
|
||||||
if (rowItem) {
|
if (rowItem) {
|
||||||
var canDrop = false;
|
var canDrop = false;
|
||||||
|
|
||||||
for each(var item in items) {
|
for (let item of items) {
|
||||||
// If any regular items, disallow drop
|
// If any regular items, disallow drop
|
||||||
if (item.isRegularItem()) {
|
if (item.isRegularItem()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2885,7 +2885,7 @@ Zotero.ItemTreeView.prototype.canDropCheck = function (row, orient, dataTransfer
|
||||||
|
|
||||||
// In library, allow children to be dragged out of parent
|
// In library, allow children to be dragged out of parent
|
||||||
else if (collectionTreeRow.isLibrary(true) || collectionTreeRow.isCollection()) {
|
else if (collectionTreeRow.isLibrary(true) || collectionTreeRow.isCollection()) {
|
||||||
for each(var item in items) {
|
for (let item of items) {
|
||||||
// Don't allow drag if any top-level items
|
// Don't allow drag if any top-level items
|
||||||
if (item.isTopLevelItem()) {
|
if (item.isTopLevelItem()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -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
|
||||||
|
@ -89,7 +89,7 @@ Zotero.LocateManager = new function() {
|
||||||
*/
|
*/
|
||||||
this.getEngineByName = function(engineName) {
|
this.getEngineByName = function(engineName) {
|
||||||
engineName = engineName.toLowerCase();
|
engineName = engineName.toLowerCase();
|
||||||
for each(var engine in _locateEngines) if(engine.name.toLowerCase() == engineName) return engine;
|
for (let engine of _locateEngines) if(engine.name.toLowerCase() == engineName) return engine;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ Zotero.LocateManager = new function() {
|
||||||
*/
|
*/
|
||||||
this.getEngineByAlias = function(engineAlias) {
|
this.getEngineByAlias = function(engineAlias) {
|
||||||
engineAlias = engineAlias.toLowerCase();
|
engineAlias = engineAlias.toLowerCase();
|
||||||
for each(var engine in _locateEngines) if(engine.alias.toLowerCase() == engineAlias) return engine;
|
for (let engine of _locateEngines) if(engine.alias.toLowerCase() == engineAlias) return engine;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ Zotero.LocateManager = new function() {
|
||||||
if(locateDir.exists()) locateDir.remove(true);
|
if(locateDir.exists()) locateDir.remove(true);
|
||||||
|
|
||||||
// create new locate dir
|
// create new locate dir
|
||||||
locateDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0700);
|
locateDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o700);
|
||||||
|
|
||||||
// copy default file to new locate dir
|
// copy default file to new locate dir
|
||||||
Zotero.File.putContents(_jsonFile,
|
Zotero.File.putContents(_jsonFile,
|
||||||
|
@ -233,7 +233,7 @@ Zotero.LocateManager = new function() {
|
||||||
// write the icon to the file
|
// write the icon to the file
|
||||||
var fos = Components.classes["@mozilla.org/network/file-output-stream;1"].
|
var fos = Components.classes["@mozilla.org/network/file-output-stream;1"].
|
||||||
createInstance(Components.interfaces.nsIFileOutputStream);
|
createInstance(Components.interfaces.nsIFileOutputStream);
|
||||||
fos.init(iconFile, 0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate
|
fos.init(iconFile, 0x02 | 0x08 | 0x20, 0o664, 0); // write, create, truncate
|
||||||
var bos = Components.classes["@mozilla.org/binaryoutputstream;1"].
|
var bos = Components.classes["@mozilla.org/binaryoutputstream;1"].
|
||||||
createInstance(Components.interfaces.nsIBinaryOutputStream);
|
createInstance(Components.interfaces.nsIBinaryOutputStream);
|
||||||
bos.setOutputStream(fos);
|
bos.setOutputStream(fos);
|
||||||
|
|
|
@ -219,7 +219,7 @@ Zotero.ProgressWindow = function(_window = null) {
|
||||||
var newDescription = _progressWindow.document.createElement("description");
|
var newDescription = _progressWindow.document.createElement("description");
|
||||||
|
|
||||||
var parts = Zotero.Utilities.parseMarkup(text);
|
var parts = Zotero.Utilities.parseMarkup(text);
|
||||||
for each(var part in parts) {
|
for (let part of parts) {
|
||||||
if (part.type == 'text') {
|
if (part.type == 'text') {
|
||||||
var elem = _progressWindow.document.createTextNode(part.text);
|
var elem = _progressWindow.document.createTextNode(part.text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,8 @@ Zotero.Proxies = new function() {
|
||||||
rows.map(row => this.newProxyFromRow(row))
|
rows.map(row => this.newProxyFromRow(row))
|
||||||
);
|
);
|
||||||
|
|
||||||
for each(var proxy in Zotero.Proxies.proxies) {
|
for (let proxy of Zotero.Proxies.proxies) {
|
||||||
for each(var host in proxy.hosts) {
|
for (let host of proxy.hosts) {
|
||||||
Zotero.Proxies.hosts[host] = proxy;
|
Zotero.Proxies.hosts[host] = proxy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ Zotero.Proxies = new function() {
|
||||||
// see if there is a proxy we already know
|
// see if there is a proxy we already know
|
||||||
var m = false;
|
var m = false;
|
||||||
var proxy;
|
var proxy;
|
||||||
for each(proxy in Zotero.Proxies.proxies) {
|
for (proxy of Zotero.Proxies.proxies) {
|
||||||
if(proxy.proxyID && proxy.regexp && proxy.multiHost) {
|
if(proxy.proxyID && proxy.regexp && proxy.multiHost) {
|
||||||
m = proxy.regexp.exec(url);
|
m = proxy.regexp.exec(url);
|
||||||
if(m) break;
|
if(m) break;
|
||||||
|
@ -304,7 +304,7 @@ Zotero.Proxies = new function() {
|
||||||
// if there is a proxy ID (i.e., if this is a persisting, transparent proxy), add to host
|
// if there is a proxy ID (i.e., if this is a persisting, transparent proxy), add to host
|
||||||
// list to do reverse mapping
|
// list to do reverse mapping
|
||||||
if(proxy.proxyID) {
|
if(proxy.proxyID) {
|
||||||
for each(var host in proxy.hosts) {
|
for (let host of proxy.hosts) {
|
||||||
Zotero.Proxies.hosts[host] = proxy;
|
Zotero.Proxies.hosts[host] = proxy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ Zotero.Proxies = new function() {
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.proxyToProper = function(url, onlyReturnIfProxied) {
|
this.proxyToProper = function(url, onlyReturnIfProxied) {
|
||||||
for each(var proxy in Zotero.Proxies.proxies) {
|
for (let proxy of Zotero.Proxies.proxies) {
|
||||||
if(proxy.regexp) {
|
if(proxy.regexp) {
|
||||||
var m = proxy.regexp.exec(url);
|
var m = proxy.regexp.exec(url);
|
||||||
if(m) {
|
if(m) {
|
||||||
|
@ -456,9 +456,9 @@ Zotero.Proxies = new function() {
|
||||||
/^muse\.jhu\.edu$/
|
/^muse\.jhu\.edu$/
|
||||||
]
|
]
|
||||||
|
|
||||||
for each(var blackPattern in hostBlacklist) {
|
for (let blackPattern of hostBlacklist) {
|
||||||
if(blackPattern.test(host)) {
|
if(blackPattern.test(host)) {
|
||||||
for each(var whitePattern in hostWhitelist) {
|
for (let whitePattern of hostWhitelist) {
|
||||||
if(whitePattern.test(host)) {
|
if(whitePattern.test(host)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -702,7 +702,7 @@ Zotero.Proxy.prototype.validate = function() {
|
||||||
return ["scheme.invalid"];
|
return ["scheme.invalid"];
|
||||||
}
|
}
|
||||||
|
|
||||||
for each(var host in this.hosts) {
|
for (let host of this.hosts) {
|
||||||
var oldHost = Zotero.Proxies.hosts[host];
|
var oldHost = Zotero.Proxies.hosts[host];
|
||||||
if(oldHost && oldHost.proxyID && oldHost != this) {
|
if(oldHost && oldHost.proxyID && oldHost != this) {
|
||||||
return ["host.proxyExists", host];
|
return ["host.proxyExists", host];
|
||||||
|
@ -903,7 +903,7 @@ Zotero.Proxies.Detectors.EZProxy = function(channel) {
|
||||||
if(fromProxy && toProxy && fromProxy.host == toProxy.host && fromProxy.port != toProxy.port
|
if(fromProxy && toProxy && fromProxy.host == toProxy.host && fromProxy.port != toProxy.port
|
||||||
&& [80, 443, -1].indexOf(toProxy.port) == -1) {
|
&& [80, 443, -1].indexOf(toProxy.port) == -1) {
|
||||||
var proxy;
|
var proxy;
|
||||||
for each(proxy in Zotero.Proxies.proxies) {
|
for (proxy of Zotero.Proxies.proxies) {
|
||||||
if(proxy.regexp) {
|
if(proxy.regexp) {
|
||||||
var m = proxy.regexp.exec(fromProxy.spec);
|
var m = proxy.regexp.exec(fromProxy.spec);
|
||||||
if(m) break;
|
if(m) break;
|
||||||
|
|
|
@ -71,7 +71,12 @@ Zotero.QuickCopy = new function() {
|
||||||
+ "WHERE setting='quickCopySite'";
|
+ "WHERE setting='quickCopySite'";
|
||||||
var rows = yield Zotero.DB.queryAsync(sql);
|
var rows = yield Zotero.DB.queryAsync(sql);
|
||||||
// Unproxify storage row
|
// Unproxify storage row
|
||||||
_siteSettings = [for (row of rows) { domainPath: row.domainPath, format: row.format }];
|
_siteSettings = rows.map(row => {
|
||||||
|
return {
|
||||||
|
domainPath: row.domainPath,
|
||||||
|
format: row.format
|
||||||
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -464,7 +469,7 @@ Zotero.QuickCopy = new function() {
|
||||||
// add styles to list
|
// add styles to list
|
||||||
_formattedNames = {};
|
_formattedNames = {};
|
||||||
var styles = Zotero.Styles.getVisible();
|
var styles = Zotero.Styles.getVisible();
|
||||||
for each(var style in styles) {
|
for (let style of styles) {
|
||||||
_formattedNames['bibliography=' + style.styleID] = style.title;
|
_formattedNames['bibliography=' + style.styleID] = style.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ Zotero.Report.HTML = new function () {
|
||||||
content += '\t\t\t\t<h3 class="notes">' + escapeXML(Zotero.getString('report.notes')) + '</h3>\n';
|
content += '\t\t\t\t<h3 class="notes">' + escapeXML(Zotero.getString('report.notes')) + '</h3>\n';
|
||||||
}
|
}
|
||||||
content += '\t\t\t\t<ul class="notes">\n';
|
content += '\t\t\t\t<ul class="notes">\n';
|
||||||
for each(var note in obj.reportChildren.notes) {
|
for (let note of obj.reportChildren.notes) {
|
||||||
content += '\t\t\t\t\t<li id="item_' + note.itemKey + '">\n';
|
content += '\t\t\t\t\t<li id="item_' + note.itemKey + '">\n';
|
||||||
|
|
||||||
// If not valid XML, display notes with entities encoded
|
// If not valid XML, display notes with entities encoded
|
||||||
|
@ -180,7 +180,7 @@ Zotero.Report.HTML = new function () {
|
||||||
table = true;
|
table = true;
|
||||||
var displayText;
|
var displayText;
|
||||||
|
|
||||||
for each(var creator in obj['creators']) {
|
for (let creator of obj['creators']) {
|
||||||
// One field
|
// One field
|
||||||
if (creator.name !== undefined) {
|
if (creator.name !== undefined) {
|
||||||
displayText = creator.name;
|
displayText = creator.name;
|
||||||
|
|
|
@ -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 = {};
|
||||||
|
|
||||||
|
|
|
@ -655,7 +655,7 @@ Zotero.Sync.Storage.Local = {
|
||||||
+ " into attachment directory as '" + fileName + "'");
|
+ " into attachment directory as '" + fileName + "'");
|
||||||
try {
|
try {
|
||||||
var finalFileName = Zotero.File.createShortened(
|
var finalFileName = Zotero.File.createShortened(
|
||||||
path, Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644
|
path, Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0o644
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -822,7 +822,7 @@ Zotero.Sync.Storage.Local = {
|
||||||
let shortened;
|
let shortened;
|
||||||
try {
|
try {
|
||||||
shortened = Zotero.File.createShortened(
|
shortened = Zotero.File.createShortened(
|
||||||
destPath, Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644
|
destPath, Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0o644
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|
|
@ -85,8 +85,8 @@ Zotero.Sync.Storage.Request.prototype.importCallbacks = function (request) {
|
||||||
}
|
}
|
||||||
// Otherwise add functions that don't already exist
|
// Otherwise add functions that don't already exist
|
||||||
var add = true;
|
var add = true;
|
||||||
for each(var newFunc in request[name]) {
|
for (let newFunc of request[name]) {
|
||||||
for each(var currentFunc in this[name]) {
|
for (let currentFunc of this[name]) {
|
||||||
if (newFunc.toString() === currentFunc.toString()) {
|
if (newFunc.toString() === currentFunc.toString()) {
|
||||||
Zotero.debug("Callback already exists in request -- not importing");
|
Zotero.debug("Callback already exists in request -- not importing");
|
||||||
add = false;
|
add = false;
|
||||||
|
@ -266,8 +266,8 @@ Zotero.Sync.Storage.Request.prototype.onProgress = function (progress, progressM
|
||||||
Zotero.Sync.Storage.setItemDownloadPercentage(this.name, this.percentage);
|
Zotero.Sync.Storage.setItemDownloadPercentage(this.name, this.percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.onProgress) {
|
if (this.onProgress && this._onProgress) {
|
||||||
for each(var f in this._onProgress) {
|
for (let f of this._onProgress) {
|
||||||
f(progress, progressMax);
|
f(progress, progressMax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,7 +347,7 @@ Zotero.Styles = new function() {
|
||||||
|
|
||||||
if(existingFile) {
|
if(existingFile) {
|
||||||
// find associated style
|
// find associated style
|
||||||
for each(var existingStyle in _styles) {
|
for (let existingStyle of _styles) {
|
||||||
if(destFile.equals(existingStyle.file)) {
|
if(destFile.equals(existingStyle.file)) {
|
||||||
existingTitle = existingStyle.title;
|
existingTitle = existingStyle.title;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -181,7 +181,7 @@ Zotero.Sync.Server = new function () {
|
||||||
if (ids) {
|
if (ids) {
|
||||||
var items = Zotero.Items.get(ids);
|
var items = Zotero.Items.get(ids);
|
||||||
var rolledBack = false;
|
var rolledBack = false;
|
||||||
for each(var item in items) {
|
for (let item of items) {
|
||||||
var file = item.getFile();
|
var file = item.getFile();
|
||||||
if (!file) {
|
if (!file) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -563,7 +563,7 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
introMsg += Zotero.getString('sync.conflict.tag.addedToLocal');
|
introMsg += Zotero.getString('sync.conflict.tag.addedToLocal');
|
||||||
}
|
}
|
||||||
var itemText = [];
|
var itemText = [];
|
||||||
for each(var id in addedItemIDs) {
|
for (let id of addedItemIDs) {
|
||||||
var item = Zotero.Items.get(id);
|
var item = Zotero.Items.get(id);
|
||||||
var title = item.getField('title');
|
var title = item.getField('title');
|
||||||
var text = " - " + title;
|
var text = " - " + title;
|
||||||
|
|
|
@ -786,7 +786,7 @@ Zotero.Translate.IO.Read.prototype = {
|
||||||
if(this._rawStream) this._rawStream.close();
|
if(this._rawStream) this._rawStream.close();
|
||||||
this._rawStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
this._rawStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
||||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||||
this._rawStream.init(this.file, 0x01, 0664, 0);
|
this._rawStream.init(this.file, 0x01, 0o664, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"_rewind":function() {
|
"_rewind":function() {
|
||||||
|
@ -921,7 +921,7 @@ Zotero.Translate.IO.Write = function(file) {
|
||||||
Zotero.Translate.IO.maintainedInstances.push(this);
|
Zotero.Translate.IO.maintainedInstances.push(this);
|
||||||
this._rawStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
|
this._rawStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
|
||||||
.createInstance(Components.interfaces.nsIFileOutputStream);
|
.createInstance(Components.interfaces.nsIFileOutputStream);
|
||||||
this._rawStream.init(file, 0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate
|
this._rawStream.init(file, 0x02 | 0x08 | 0x20, 0o664, 0); // write, create, truncate
|
||||||
this._writtenToStream = false;
|
this._writtenToStream = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -754,7 +754,7 @@ Zotero.Translate.ItemGetter.prototype = {
|
||||||
this._exportFileDirectory.append(name);
|
this._exportFileDirectory.append(name);
|
||||||
|
|
||||||
// create directory
|
// create directory
|
||||||
this._exportFileDirectory.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0700);
|
this._exportFileDirectory.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o700);
|
||||||
|
|
||||||
// generate a new location for the exported file, with the appropriate
|
// generate a new location for the exported file, with the appropriate
|
||||||
// extension
|
// extension
|
||||||
|
@ -831,7 +831,7 @@ Zotero.Translate.ItemGetter.prototype = {
|
||||||
// Create intermediate directories if they don't exist
|
// Create intermediate directories if they don't exist
|
||||||
parent = targetFile;
|
parent = targetFile;
|
||||||
while((parent = parent.parent) && !parent.exists()) {
|
while((parent = parent.parent) && !parent.exists()) {
|
||||||
parent.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0700);
|
parent.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o700);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete any existing file if overwriteExisting is set, or throw an exception
|
// Delete any existing file if overwriteExisting is set, or throw an exception
|
||||||
|
|
|
@ -98,7 +98,7 @@ Zotero.Utilities.Internal = {
|
||||||
var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
||||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||||
// open for reading
|
// open for reading
|
||||||
istream.init(strOrFile, 0x01, 0444, 0);
|
istream.init(strOrFile, 0x01, 0o444, 0);
|
||||||
var ch = Components.classes["@mozilla.org/security/hash;1"]
|
var ch = Components.classes["@mozilla.org/security/hash;1"]
|
||||||
.createInstance(Components.interfaces.nsICryptoHash);
|
.createInstance(Components.interfaces.nsICryptoHash);
|
||||||
// we want to use the MD5 algorithm
|
// we want to use the MD5 algorithm
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -1075,7 +1075,7 @@ Components.utils.import("resource://gre/modules/PluralForm.jsm");
|
||||||
function getErrors(asStrings) {
|
function getErrors(asStrings) {
|
||||||
var errors = [];
|
var errors = [];
|
||||||
|
|
||||||
for each(var msg in _startupErrors.concat(_recentErrors)) {
|
for (let msg of _startupErrors.concat(_recentErrors)) {
|
||||||
// Remove password in malformed XML messages
|
// Remove password in malformed XML messages
|
||||||
if (msg.category == 'malformed-xml') {
|
if (msg.category == 'malformed-xml') {
|
||||||
try {
|
try {
|
||||||
|
@ -1413,7 +1413,7 @@ Components.utils.import("resource://gre/modules/PluralForm.jsm");
|
||||||
|
|
||||||
|
|
||||||
function moveToUnique(file, newFile){
|
function moveToUnique(file, newFile){
|
||||||
newFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
|
newFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
||||||
var newName = newFile.leafName;
|
var newName = newFile.leafName;
|
||||||
newFile.remove(null);
|
newFile.remove(null);
|
||||||
|
|
||||||
|
@ -1676,7 +1676,7 @@ Components.utils.import("resource://gre/modules/PluralForm.jsm");
|
||||||
if (button.length) {
|
if (button.length) {
|
||||||
button = button[0];
|
button = button[0];
|
||||||
var menupopup = button.firstChild;
|
var menupopup = button.firstChild;
|
||||||
for each(var menuitem in menupopup.childNodes) {
|
for (let menuitem of menupopup.childNodes) {
|
||||||
if (menuitem.id.substr(prefixLen) == mode) {
|
if (menuitem.id.substr(prefixLen) == mode) {
|
||||||
menuitem.setAttribute('checked', true);
|
menuitem.setAttribute('checked', true);
|
||||||
searchBox.placeholder = modes[mode].label;
|
searchBox.placeholder = modes[mode].label;
|
||||||
|
@ -2166,7 +2166,7 @@ Zotero.Keys = new function() {
|
||||||
var cmds = Zotero.Prefs.prefBranch.getChildList('keys', {}, {});
|
var cmds = Zotero.Prefs.prefBranch.getChildList('keys', {}, {});
|
||||||
|
|
||||||
// Get the key=>command mappings from the prefs
|
// Get the key=>command mappings from the prefs
|
||||||
for each(var cmd in cmds) {
|
for (let cmd of cmds) {
|
||||||
cmd = cmd.substr(5); // strips 'keys.'
|
cmd = cmd.substr(5); // strips 'keys.'
|
||||||
// Remove old pref
|
// Remove old pref
|
||||||
if (cmd == 'overrideGlobal') {
|
if (cmd == 'overrideGlobal') {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -231,10 +231,10 @@ ZoteroAutoComplete.prototype.startSearch = Zotero.Promise.coroutine(function* (s
|
||||||
if (resultsCallback) {
|
if (resultsCallback) {
|
||||||
resultsCallback(results);
|
resultsCallback(results);
|
||||||
this.updateResults(
|
this.updateResults(
|
||||||
[for (x of results) x.val],
|
Object.values(results).map(x => x.val),
|
||||||
[for (x of results) x.comment],
|
Object.values(results).map(x => x.comment),
|
||||||
false
|
false
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
resultCode = null;
|
resultCode = null;
|
||||||
Zotero.debug("Autocomplete query completed");
|
Zotero.debug("Autocomplete query completed");
|
||||||
|
|
|
@ -74,8 +74,10 @@ function ZoteroProtocolHandler() {
|
||||||
Zotero.API.Data.getGenerator(path)
|
Zotero.API.Data.getGenerator(path)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (e if e instanceof Zotero.Router.InvalidPathException) {
|
catch (e) {
|
||||||
return "URL could not be parsed";
|
if (e instanceof Zotero.Router.InvalidPathException) {
|
||||||
|
return "URL could not be parsed";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -596,7 +598,7 @@ function ZoteroProtocolHandler() {
|
||||||
var search = new Zotero.Search();
|
var search = new Zotero.Search();
|
||||||
search.setScope(s);
|
search.setScope(s);
|
||||||
var groups = Zotero.Groups.getAll();
|
var groups = Zotero.Groups.getAll();
|
||||||
for each(var group in groups) {
|
for (let group of groups) {
|
||||||
search.addCondition('libraryID', 'isNot', group.libraryID);
|
search.addCondition('libraryID', 'isNot', group.libraryID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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; });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue