History

Update editEntitiesWithTag to use static lookup table

Ryan Huffman committed 10 years ago

Commit 02347471 parent 1f25ba81 file · +12 −6Browse files

Showing the changes to tutorial/tutorial.js (1 of 1 file). Show all

Unified · Split

tutorial/tutorial.js+12−6
@@ -201,12 +201,18 @@ function deleteEntitiesWithTag(tag) { · 200 unmodified lines
201 }201 }
202}202}
203function editEntitiesWithTag(tag, propertiesOrFn) {203function editEntitiesWithTag(tag, propertiesOrFn) {
204 var entityIDs = findEntitiesWithTag(tag);204 //var entityIDs = findEntitiesWithTag(tag);
205 for (var i = 0; i < entityIDs.length; ++i) {205 var entities = TUTORIAL_TAG_TO_ENTITY_IDS_MAP[tag];
206 if (isFunction(propertiesOrFn)) {206
207 Entities.editEntity(entityIDs[i], propertiesOrFn(entityIDs[i]));207 debug("Editing tag: ", tag);
208 } else {208 if (entities) {
209 Entities.editEntity(entityIDs[i], propertiesOrFn);209 for (entityID in entities) {
210 debug("Editing: ", entityID, ", ", propertiesOrFn, ", Is in local tree: ", isEntityInLocalTree(entityID));
211 if (isFunction(propertiesOrFn)) {
212 Entities.editEntity(entityID, propertiesOrFn(entityIDs[i]));
213 } else {
214 Entities.editEntity(entityID, propertiesOrFn);
215 }
210 }216 }
211 }217 }
212}218}