wardrobe js now serves pretty item urls

This commit is contained in:
Emi Matchu 2011-05-20 19:38:08 -04:00
parent c18a333bd2
commit fa46a03c91
2 changed files with 17 additions and 1 deletions

View file

@ -92,7 +92,7 @@ Partial.ItemSet = function ItemSet(wardrobe, selector) {
info_link = $('<a/>', {
'class': 'object-info',
html: '<span>i</span>',
href: '/items/' + item.id,
href: item.getURL(),
target: '_blank'
});
if(

View file

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