View Single Post
Old 11-06-2012, 05:40 PM   PM User | #3
WhatABoringName
New to the CF scene

 
Join Date: Nov 2012
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
WhatABoringName is an unknown quantity at this point
Thanks, that already helped a lot. However, if I may be so bold to ask for one small way of making the code a lot easier as the dictionary will grow bigger. Now my code is this:

Code:
var albumCover = document.getElementsByClassName('album-cover')[0] // Get the album cover
var currentLink = location.pathname
var dictionary = 
{ // location.pathname : image source for albumCover
'/music/King+Crimson/Red' : 'http://i1325.photobucket.com/albums/u622/last_fm_projeKct/Last%20FM%20covers/Red.jpg',
'/music/King+Crimson/Discipline' : 'http://i1325.photobucket.com/albums/u622/last_fm_projeKct/Last%20FM%20covers/Discipline.jpg'
}

if (currentLink === '/music/King+Crimson/Red')
	{
		albumCover.src = 'http://i1325.photobucket.com/albums/u622/last_fm_projeKct/Last%20FM%20covers/Red.jpg'
	};
Is there a way of adressing the dictionary instead of having an if-statement for each 'location.pathname'?

If not, no worries. This already got me what I needed.

Cheers!
WhatABoringName is offline   Reply With Quote