diff --git a/public/javascripts/outfits/edit.js b/public/javascripts/outfits/edit.js index f64ea206..c6daef0f 100644 --- a/public/javascripts/outfits/edit.js +++ b/public/javascripts/outfits/edit.js @@ -92,7 +92,7 @@ Partial.ItemSet = function ItemSet(wardrobe, selector) { info_link = $('', { 'class': 'object-info', html: 'i', - href: '/items/' + item.id, + href: item.getURL(), target: '_blank' }); if( diff --git a/public/javascripts/wardrobe.js b/public/javascripts/wardrobe.js index 46891d37..8b163917 100644 --- a/public/javascripts/wardrobe.js +++ b/public/javascripts/wardrobe.js @@ -125,6 +125,22 @@ function Wardrobe() { this.loaded = true; } + function getNameForSlug() { + return item.name.toLowerCase().replace(/ /g, '-'); + } + + function getSlug() { + var slug = item.id.toString(); + if(this.hasOwnProperty('name')) { + slug += '-' + getNameForSlug(); + } + return slug; + } + + this.getURL = function() { + return "/items/" + getSlug(); + } + Item.cache[id] = this; }