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"));
for each(var v in this._fieldAlternatives[fieldName]) {
for (let v of this._fieldAlternatives[fieldName]) {
var menuitem = document.createElement("menuitem");
var sv = Zotero.Utilities.ellipsize(v, 60);
menuitem.setAttribute('label', sv);

View file

@ -528,7 +528,7 @@
this._tags = yield Zotero.Tags.getAll(this.libraryID, this._types);
for (let tag of this.selection) {
for each(var tag2 in this._tags) {
for (let tag2 of this._tags) {
if (tag == tag2) {
var found = true;
break;

View file

@ -474,7 +474,7 @@ var Zotero_File_Interface = new function() {
function _doBibliographyOptions(name, items) {
// make sure at least one item is not a standalone note or attachment
var haveRegularItem = false;
for each(var item in items) {
for (let item of items) {
if (item.isRegularItem()) {
haveRegularItem = true;
break;

View file

@ -460,7 +460,7 @@ var Zotero_RTFScan = new function() {
*/
function _refreshCanAdvance() {
var canAdvance = true;
for each(var itemList in citationItemIDs) {
for (let itemList of citationItemIDs) {
if(itemList.length != 1) {
canAdvance = false;
break;

View file

@ -37,7 +37,7 @@ var Zotero_CSL_Editor = new function() {
var styles = Zotero.Styles.getAll();
var currentStyle = null;
for each(var style in styles) {
for (let style of styles) {
if (style.source) {
continue;
}

View file

@ -56,7 +56,7 @@ var Zotero_CSL_Preview = new function() {
var styles = Zotero.Styles.getAll();
// XXX needs its own string really for the title!
var str = '<html><head><title></title></head><body>';
for each(var style in styles) {
for (let style of styles) {
if (style.source) {
continue;
}

View file

@ -141,7 +141,7 @@ Zotero.Annotate = new function() {
} else {
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.spec == annotationURL) {
if(haveBrowser) {
@ -364,7 +364,7 @@ Zotero.Annotate.Path.prototype.fromNode = function(node, offset) {
// is still part of the first text node
if(sibling.getAttribute) {
// 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) {
this.offset += child.nodeValue.length;
}
@ -754,14 +754,14 @@ Zotero.Annotations.prototype.save = function() {
Zotero.Annotations.prototype.load = Zotero.Promise.coroutine(function* () {
// load annotations
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();
annotation.initWithDBRow(row);
}
// load highlights
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 {
var highlight = new Zotero.Highlight(this);
highlight.initWithDBRow(row);

View file

@ -76,7 +76,7 @@ Zotero.API = {
var s2 = new Zotero.Search();
s2.setScope(s);
var groups = Zotero.Groups.getAll();
for each(var group in groups) {
for (let group of groups) {
s2.addCondition('libraryID', 'isNot', group.libraryID);
}
var ids = yield s2.search();

View file

@ -143,7 +143,7 @@ Zotero.Cite = {
output.push(bib[1][i]);
// add COinS
for each(var itemID in bib[0].entry_ids[i]) {
for (let itemID of bib[0].entry_ids[i]) {
try {
var co = Zotero.OpenURL.createContextObject(Zotero.Items.get(itemID), "1.0");
if(!co) continue;

View file

@ -1533,7 +1533,7 @@ Zotero.CollectionTreeView.prototype.canDropCheck = function (row, orient, dataTr
var ids = data;
var items = Zotero.Items.get(ids);
var skip = true;
for each(var item in items) {
for (let item of items) {
// Can only drag top-level items
if (!item.isTopLevelItem()) {
Zotero.debug("Can't drag child item");
@ -1738,7 +1738,7 @@ Zotero.CollectionTreeView.prototype.canDropCheckAsync = Zotero.Promise.coroutine
}
var descendents = col.getDescendents(false, 'collection');
for each(var descendent in descendents) {
for (let descendent of descendents) {
descendent = Zotero.Collections.get(descendent.id);
// 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) {
var noteIDs = item.getNotes();
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 });
newNote.parentID = newItemID;
yield newNote.save({
@ -1898,7 +1898,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
if (options.childLinks || options.childFileAttachments) {
var attachmentIDs = item.getAttachments();
var attachments = Zotero.Items.get(attachmentIDs);
for each(var attachment in attachments) {
for (let attachment of attachments) {
var linkMode = attachment.attachmentLinkMode;
// Skip linked files
@ -2069,7 +2069,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
var sameLibrary = false;
}
for each(var item in items) {
for (let item of items) {
if (!item.isTopLevelItem()) {
continue;
}
@ -2126,7 +2126,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
var lastWin = wm.getMostRecentWindow("navigator:browser");
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();
}
}

View file

@ -283,7 +283,7 @@ Zotero.CreatorTypes = new function() {
var valid = false;
var types = this.getTypesForItemType(itemTypeID);
for each(var type in types) {
for (let type of types) {
if (type.id == creatorTypeID) {
valid = true;
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
var baseFieldID =
Zotero.ItemFields.getBaseIDFromTypeAndField(oldItemTypeID, oldFieldID);
@ -532,14 +532,14 @@ Zotero.Item.prototype.setType = function(itemTypeID, loadIn) {
// Initialize this._itemData with type-specific fields
this._itemData = {};
var fields = Zotero.ItemFields.getItemTypeFields(itemTypeID);
for each(var fieldID in fields) {
for (let fieldID of fields) {
this._itemData[fieldID] = null;
}
// DEBUG: clear change item data?
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
// (e.g., book -> bookTitle), mark the old value as explicitly
// 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");
}
var realDiffs = numDiffs;
for each(var field in ignoreFields) {
for (let field of ignoreFields) {
if (diff[0].primary[field] != undefined) {
realDiffs--;
if (realDiffs == 0) {

View file

@ -75,7 +75,7 @@ Zotero.ItemFields = new function() {
var sql = "SELECT DISTINCT baseFieldID FROM baseFieldMappingsCombined";
var baseFields = yield Zotero.DB.columnQueryAsync(sql);
for each(var field in fields) {
for (let field of fields) {
_fields[field['fieldID']] = {
id: field['fieldID'],
name: field.fieldName,
@ -440,7 +440,7 @@ Zotero.ItemFields = new function() {
var baseFields = yield Zotero.DB.columnQueryAsync(sql);
var fields = [];
for each(var row in rows) {
for (let row of rows) {
if (!fields[row.itemTypeID]) {
fields[row.itemTypeID] = [];
}

View file

@ -743,12 +743,12 @@ Zotero.Items = function() {
var toSave = {};
toSave[item.id] = item;
for each(var otherItem in otherItems) {
for (let otherItem of otherItems) {
let otherItemURI = Zotero.URI.getItemURI(otherItem);
// Move child items to master
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);
// TODO: Skip identical children?

View file

@ -255,7 +255,7 @@ Zotero.Search.prototype.clone = function (libraryID) {
var conditions = this.getConditions();
for each(var condition in conditions) {
for (let condition of Object.values(conditions)) {
var name = condition.mode ?
condition.condition + '/' + condition.mode :
condition.condition
@ -299,7 +299,7 @@ Zotero.Search.prototype.addCondition = function (condition, operator, value, req
if (condition.match(/^quicksearch/)) {
var parts = Zotero.SearchConditions.parseSearchString(value);
for each(var part in parts) {
for (let part of parts) {
this.addCondition('blockStart');
// 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 {
var splits = Zotero.Fulltext.semanticSplitter(part.text);
for each(var split in splits) {
for (let split of splits) {
this.addCondition('fulltextWord', operator, split, false);
}
}
@ -498,7 +498,7 @@ Zotero.Search.prototype.getConditions = function(){
Zotero.Search.prototype.hasPostSearchFilter = function() {
this._requireData('conditions');
for each(var i in this._conditions){
for (let i of Object.values(this._conditions)) {
if (i.condition == 'fulltextContent'){
return true;
}
@ -530,7 +530,7 @@ Zotero.Search.prototype.search = Zotero.Promise.coroutine(function* (asTempTable
var joinMode = 'all';
// 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) {
case 'joinMode':
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
// fulltextContent is part of), return the union of the main search and
// (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'){
var fulltextWordIntersectionFilter = function (val, index, array) !!hash[val];
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 --
// those that are required in an ANY search and any outside the
// quicksearch in an ALL search
for each(var c in this._conditions) {
for (let c of Object.values(this._conditions)) {
if (c.condition == 'blockStart') {
var inQS = true;
continue;
@ -688,7 +688,7 @@ Zotero.Search.prototype.search = Zotero.Promise.coroutine(function* (asTempTable
}
var splits = Zotero.Fulltext.semanticSplitter(condition.value);
for each(var split in splits){
for (let split of splits){
s.addCondition('fulltextWord', condition.operator, split);
}
var fulltextWordIDs = yield s.search();
@ -1043,7 +1043,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
if (this._hasPrimaryConditions) {
sql += " AND ";
for each(var condition in conditions){
for (let condition of Object.values(conditions)){
var skipOperators = false;
var openParens = 0;
var condSQL = '';
@ -1088,7 +1088,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
if (typeFields) {
condSQL += 'fieldID IN (?,';
// Add type-specific fields
for each(var fieldID in typeFields) {
for (let fieldID of typeFields) {
condSQL += '?,';
condSQLParams.push(fieldID);
}
@ -1113,7 +1113,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
if (dateFields) {
condSQL += 'fieldID IN (?,';
// Add type-specific date fields (dateEnacted, dateDecided, issueDate)
for each(var fieldID in dateFields) {
for (let fieldID of dateFields) {
condSQL += '?,';
condSQLParams.push(fieldID);
}
@ -1148,7 +1148,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
// for the collection/search
if (objLibraryID === undefined) {
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') {
foundLibraryID = true;
obj = yield objectTypeClass.getByLibraryAndKeyAsync(
@ -1246,7 +1246,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
+ 'fileTypeID=?)';
var patterns = yield Zotero.DB.columnQueryAsync(ftSQL, { int: condition.value });
if (patterns) {
for each(str in patterns) {
for (let str of patterns) {
condSQL += 'contentType LIKE ? OR ';
condSQLParams.push(str + '%');
}
@ -1402,7 +1402,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
if (useFreeform && dateparts['part']){
go = true;
var parts = dateparts['part'].split(' ');
for each (var part in parts){
for (let part of parts) {
condSQL += " AND SUBSTR(" + condition['field'] + ", 12, 100)";
condSQL += " LIKE ?";
condSQLParams.push('%' + part + '%');

View file

@ -392,7 +392,7 @@ Zotero.Duplicates.prototype._findDuplicates = Zotero.Promise.coroutine(function*
// Match on exact 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) "
+ "JOIN itemDataValues USING (valueID) "
+ "WHERE libraryID=? AND fieldID=? "

View file

@ -1500,7 +1500,7 @@ Zotero.Integration.Fields.prototype._processFields = function(i) {
e.setContext(this, i)
} else if(e instanceof Zotero.Integration.MissingItemException) {
// 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]) {
this._removeCodeFields[i] = true;
removeCode = true;
@ -2173,7 +2173,7 @@ Zotero.Integration.Session.prototype.reselectItem = function(doc, exception) {
var itemID = io.dataOut[0];
// 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;
}
// 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
for each(var reselectKey in reselectKeys) {
for (let reselectKey of reselectKeys) {
if(this.reselectedItems[reselectKey]) {
zoteroItem = Zotero.Items.get(this.reselectedItems[reselectKey]);
citationItem.id = zoteroItem.id;
@ -2479,7 +2479,7 @@ Zotero.Integration.Session.prototype.unserializeCitation = function(arg, index)
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
if(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());
}
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.updateIndices[citationIndices[newCitation[0]]] = true;
}
@ -2651,7 +2651,7 @@ Zotero.Integration.Session.prototype._updateCitations = function* () {
if(force) {
allUpdatesForced = true;
// 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) {
if(!this.citationsByIndex[i].properties.delete) {
allUpdatesForced = false;
@ -2736,7 +2736,7 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
if(documentData.uncited[0]) {
// new style array of arrays with URIs
let zoteroItem, needUpdate;
for each(var uris in documentData.uncited) {
for (let uris of documentData.uncited) {
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(uris);
var id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id;
if(zoteroItem && !this.citationsByItemID[id]) {
@ -2765,7 +2765,7 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
if(documentData.custom[0]) {
// new style array of arrays with URIs
var zoteroItem, needUpdate;
for each(var custom in documentData.custom) {
for (let custom of documentData.custom) {
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(custom[0]);
if(!zoteroItem) continue;
if(needUpdate) this.bibliographyDataHasChanged = true;
@ -2794,7 +2794,7 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
// set entries to be omitted from bibliography
if(documentData.omitted) {
let zoteroItem, needUpdate;
for each(var uris in documentData.omitted) {
for (let uris of documentData.omitted) {
[zoteroItem, update] = this.uriMap.getZoteroItemForURIs(uris);
var id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.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(
'zotero-items-column-' + extraData.column
);
for each(var id in ids) {
for (let id of ids) {
if (extraData.column == 'title') {
delete this._itemImages[id];
}
@ -524,7 +524,7 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
}
}
else {
for each(var id in ids) {
for (let id of ids) {
delete this._itemImages[id];
this._treebox.invalidateRow(this._rowMap[id]);
}
@ -589,7 +589,7 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
}
var splitIDs = [];
for each(var id in ids) {
for (let id of ids) {
var split = id.split('-');
// Skip if not an item in this collection
if (split[0] != collectionTreeRow.ref.id) {
@ -764,7 +764,7 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
var allDeleted = true;
var isTrash = collectionTreeRow.isTrash();
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 (allDeleted && !isTrash && !item.deleted) {
allDeleted = false;
@ -857,7 +857,7 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
var items = Zotero.Items.get(ids);
if (items) {
var found = false;
for each(var item in items) {
for (let item of items) {
// Check for note and attachment type, since it's quicker
// than checking for parent item
if (item.itemTypeID == 1 || item.itemTypeID == 14) {
@ -1778,7 +1778,7 @@ Zotero.ItemTreeView.prototype.selectItems = function(ids) {
}
var rows = [];
for each(var id in ids) {
for (let id of ids) {
if(this._rowMap[id] !== undefined) rows.push(this._rowMap[id]);
}
rows.sort(function (a, b) {
@ -2045,7 +2045,7 @@ Zotero.ItemTreeView.prototype._saveOpenState = function (close) {
Zotero.ItemTreeView.prototype.rememberOpenState = function (itemIDs) {
var rowsToOpen = [];
for each(var id in itemIDs) {
for (let id of itemIDs) {
var row = this._rowMap[id];
// Item may not still exist
if (row == undefined) {
@ -2190,7 +2190,7 @@ Zotero.ItemTreeView.prototype.getVisibleFields = function() {
*/
Zotero.ItemTreeView.prototype.getSortedItems = function(asIDs) {
var items = [];
for each(var item in this._rows) {
for (let item of this._rows) {
if (asIDs) {
items.push(item.ref.id);
}
@ -2863,7 +2863,7 @@ Zotero.ItemTreeView.prototype.canDropCheck = function (row, orient, dataTransfer
if (rowItem) {
var canDrop = false;
for each(var item in items) {
for (let item of items) {
// If any regular items, disallow drop
if (item.isRegularItem()) {
return false;
@ -2885,7 +2885,7 @@ Zotero.ItemTreeView.prototype.canDropCheck = function (row, orient, dataTransfer
// In library, allow children to be dragged out of parent
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
if (item.isTopLevelItem()) {
return false;

View file

@ -89,7 +89,7 @@ Zotero.LocateManager = new function() {
*/
this.getEngineByName = function(engineName) {
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;
}
@ -98,7 +98,7 @@ Zotero.LocateManager = new function() {
*/
this.getEngineByAlias = function(engineAlias) {
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;
}

View file

@ -219,7 +219,7 @@ Zotero.ProgressWindow = function(_window = null) {
var newDescription = _progressWindow.document.createElement("description");
var parts = Zotero.Utilities.parseMarkup(text);
for each(var part in parts) {
for (let part of parts) {
if (part.type == 'text') {
var elem = _progressWindow.document.createTextNode(part.text);
}

View file

@ -49,8 +49,8 @@ Zotero.Proxies = new function() {
rows.map(row => this.newProxyFromRow(row))
);
for each(var proxy in Zotero.Proxies.proxies) {
for each(var host in proxy.hosts) {
for (let proxy of Zotero.Proxies.proxies) {
for (let host of proxy.hosts) {
Zotero.Proxies.hosts[host] = proxy;
}
}
@ -104,7 +104,7 @@ Zotero.Proxies = new function() {
// see if there is a proxy we already know
var m = false;
var proxy;
for each(proxy in Zotero.Proxies.proxies) {
for (proxy of Zotero.Proxies.proxies) {
if(proxy.proxyID && proxy.regexp && proxy.multiHost) {
m = proxy.regexp.exec(url);
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
// list to do reverse mapping
if(proxy.proxyID) {
for each(var host in proxy.hosts) {
for (let host of proxy.hosts) {
Zotero.Proxies.hosts[host] = proxy;
}
}
@ -336,7 +336,7 @@ Zotero.Proxies = new function() {
* @type String
*/
this.proxyToProper = function(url, onlyReturnIfProxied) {
for each(var proxy in Zotero.Proxies.proxies) {
for (let proxy of Zotero.Proxies.proxies) {
if(proxy.regexp) {
var m = proxy.regexp.exec(url);
if(m) {
@ -456,9 +456,9 @@ Zotero.Proxies = new function() {
/^muse\.jhu\.edu$/
]
for each(var blackPattern in hostBlacklist) {
for (let blackPattern of hostBlacklist) {
if(blackPattern.test(host)) {
for each(var whitePattern in hostWhitelist) {
for (let whitePattern of hostWhitelist) {
if(whitePattern.test(host)) {
return false;
}
@ -702,7 +702,7 @@ Zotero.Proxy.prototype.validate = function() {
return ["scheme.invalid"];
}
for each(var host in this.hosts) {
for (let host of this.hosts) {
var oldHost = Zotero.Proxies.hosts[host];
if(oldHost && oldHost.proxyID && oldHost != this) {
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
&& [80, 443, -1].indexOf(toProxy.port) == -1) {
var proxy;
for each(proxy in Zotero.Proxies.proxies) {
for (proxy of Zotero.Proxies.proxies) {
if(proxy.regexp) {
var m = proxy.regexp.exec(fromProxy.spec);
if(m) break;

View file

@ -464,7 +464,7 @@ Zotero.QuickCopy = new function() {
// add styles to list
_formattedNames = {};
var styles = Zotero.Styles.getVisible();
for each(var style in styles) {
for (let style of styles) {
_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<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';
// If not valid XML, display notes with entities encoded
@ -180,7 +180,7 @@ Zotero.Report.HTML = new function () {
table = true;
var displayText;
for each(var creator in obj['creators']) {
for (let creator of obj['creators']) {
// One field
if (creator.name !== undefined) {
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
var add = true;
for each(var newFunc in request[name]) {
for each(var currentFunc in this[name]) {
for (let newFunc of request[name]) {
for (let currentFunc of this[name]) {
if (newFunc.toString() === currentFunc.toString()) {
Zotero.debug("Callback already exists in request -- not importing");
add = false;
@ -266,8 +266,8 @@ Zotero.Sync.Storage.Request.prototype.onProgress = function (progress, progressM
Zotero.Sync.Storage.setItemDownloadPercentage(this.name, this.percentage);
}
if (this.onProgress) {
for each(var f in this._onProgress) {
if (this.onProgress && this._onProgress) {
for (let f of this._onProgress) {
f(progress, progressMax);
}
}

View file

@ -347,7 +347,7 @@ Zotero.Styles = new function() {
if(existingFile) {
// find associated style
for each(var existingStyle in _styles) {
for (let existingStyle of _styles) {
if(destFile.equals(existingStyle.file)) {
existingTitle = existingStyle.title;
break;

View file

@ -181,7 +181,7 @@ Zotero.Sync.Server = new function () {
if (ids) {
var items = Zotero.Items.get(ids);
var rolledBack = false;
for each(var item in items) {
for (let item of items) {
var file = item.getFile();
if (!file) {
continue;
@ -563,7 +563,7 @@ Zotero.Sync.Server.Data = new function() {
introMsg += Zotero.getString('sync.conflict.tag.addedToLocal');
}
var itemText = [];
for each(var id in addedItemIDs) {
for (let id of addedItemIDs) {
var item = Zotero.Items.get(id);
var title = item.getField('title');
var text = " - " + title;

View file

@ -1075,7 +1075,7 @@ Components.utils.import("resource://gre/modules/PluralForm.jsm");
function getErrors(asStrings) {
var errors = [];
for each(var msg in _startupErrors.concat(_recentErrors)) {
for (let msg of _startupErrors.concat(_recentErrors)) {
// Remove password in malformed XML messages
if (msg.category == 'malformed-xml') {
try {
@ -1676,7 +1676,7 @@ Components.utils.import("resource://gre/modules/PluralForm.jsm");
if (button.length) {
button = button[0];
var menupopup = button.firstChild;
for each(var menuitem in menupopup.childNodes) {
for (let menuitem of menupopup.childNodes) {
if (menuitem.id.substr(prefixLen) == mode) {
menuitem.setAttribute('checked', true);
searchBox.placeholder = modes[mode].label;
@ -2166,7 +2166,7 @@ Zotero.Keys = new function() {
var cmds = Zotero.Prefs.prefBranch.getChildList('keys', {}, {});
// 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.'
// Remove old pref
if (cmd == 'overrideGlobal') {

View file

@ -596,7 +596,7 @@ function ZoteroProtocolHandler() {
var search = new Zotero.Search();
search.setScope(s);
var groups = Zotero.Groups.getAll();
for each(var group in groups) {
for (let group of groups) {
search.addCondition('libraryID', 'isNot', group.libraryID);
}
break;