Replace legacy syntax for each...in with for...of

This commit is contained in:
Tom Najdek 2016-10-18 13:20:01 +01:00 committed by Dan Stillman
parent b445283f4e
commit 269e2f8bff
28 changed files with 87 additions and 87 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;
} }

View file

@ -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;
} }

View file

@ -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);

View file

@ -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();

View file

@ -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;

View file

@ -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();
} }
} }

View file

@ -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;

View file

@ -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)
@ -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) {

View file

@ -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] = [];
} }

View file

@ -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?

View file

@ -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,7 +632,7 @@ 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 = function (val, index, array) !!hash[val];
var fulltextWordIntersectionConditionFilter = function(val, index, array) { var fulltextWordIntersectionConditionFilter = function(val, index, array) {
@ -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 + '%');

View file

@ -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=? "

View file

@ -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]) {

View file

@ -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) {
@ -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);
} }
@ -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;

View file

@ -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;
} }

View file

@ -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);
} }

View file

@ -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;

View file

@ -464,7 +464,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;
} }

View file

@ -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;

View file

@ -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);
} }
} }

View file

@ -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;

View file

@ -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;

View file

@ -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 {
@ -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') {

View file

@ -596,7 +596,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;