From 7ec75bb139d6dc1839fe4992272a383d8d543b20 Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 6 Mar 2012 22:18:36 -0500 Subject: [PATCH] avoid overwriting javascript Array.prototype.map, oops --- public/javascripts/outfits/edit.js | 6 +++--- public/javascripts/wardrobe.js | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/public/javascripts/outfits/edit.js b/public/javascripts/outfits/edit.js index b6d8009c..a10ebe82 100644 --- a/public/javascripts/outfits/edit.js +++ b/public/javascripts/outfits/edit.js @@ -356,21 +356,21 @@ View.Hash = function (wardrobe) { } singleOutfitResponse('updateClosetItems', function (items) { - var item_ids = items.map('id'); + var item_ids = items.mapProperty('id'); if(!arraysMatch(item_ids, data.closet)) { changeQuery({closet: item_ids}); } }); singleOutfitResponse('updateWornItems', function (items) { - var item_ids = items.map('id'), changes = {}; + var item_ids = items.mapProperty('id'), changes = {}; if(!arraysMatch(item_ids, data.objects)) { changes.objects = item_ids; } if(arraysMatch(item_ids, data.closet) || arraysMatch(item_ids, data.objects)) { changes.closet = undefined; } else { - changes.closet = wardrobe.outfit.getClosetItems().map('id'); + changes.closet = wardrobe.outfit.getClosetItems().mapProperty('id'); } if(changes.objects || changes.closet) changeQuery(changes); }); diff --git a/public/javascripts/wardrobe.js b/public/javascripts/wardrobe.js index 9013170b..14ac8fe6 100644 --- a/public/javascripts/wardrobe.js +++ b/public/javascripts/wardrobe.js @@ -28,7 +28,7 @@ function arraysMatch(array1, array2) { return true; } -Array.prototype.map = function (property) { +Array.prototype.mapProperty = function (property) { return $.map(this, function (element) { return element[property]; }); @@ -327,11 +327,11 @@ function Wardrobe() { new_items = [], new_worn_item_ids = []; if(added_item) { // now that we've loaded, check for conflicts on the added item - item_zones = added_item.getAssetsFitting(outfit.pet_type).map('zone_id'); + item_zones = added_item.getAssetsFitting(outfit.pet_type).mapProperty('zone_id'); item_zones_length = item_zones.length; for(var i = 0; i < outfit.worn_items.length; i++) { existing_item = outfit.worn_items[i]; - existing_item_zones = existing_item.getAssetsFitting(outfit.pet_type).map('zone_id'); + existing_item_zones = existing_item.getAssetsFitting(outfit.pet_type).mapProperty('zone_id'); passed = true; if(existing_item != added_item) { for(var j = 0; j < item_zones_length; j++) { @@ -1307,6 +1307,7 @@ Wardrobe.getStandardView = function (options) { assets.sort(function (a, b) { return a.depth - b.depth; }); + console.log(assets.mapProperty('id'));return; for(var i = 0; i < assets.length; i++) { url += "," + encodeURIComponent(assets[i].imageURL(size));