From 11240c5b0e14317f9bcee06e1471d949790b5da7 Mon Sep 17 00:00:00 2001 From: Git Date: Mon, 28 Jan 2013 08:00:16 +0000 Subject: [PATCH] Empty commit --- static/functions/lastfm.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/static/functions/lastfm.js b/static/functions/lastfm.js index 59272dbf..1903ecf0 100644 --- a/static/functions/lastfm.js +++ b/static/functions/lastfm.js @@ -111,10 +111,15 @@ } } - // Escape ampersands with html code to avoid breaking the search links - function escapeAmp(input){ + // Escape ampersands with url code to avoid breaking the search links + function escapeAmpUrl(input){ return input.replace(/&/g,"%26"); } + + // Escape ampersands with html code to avoid breaking the search links + function escapeAmpHtml(input){ + return input.replace(/&/g,"&"); + } // Functions for fetching the required data are as follows. @@ -166,11 +171,11 @@ var k = initialCount; if (a.length < 3) k = a.length; for (var i = 0; i < k; i++) { - sharedArtistsHtml += '
  • ' + a[i]['name'] + '
  • ' + sharedArtistsHtml += '
  • ' + escapeAmpHtml(a[i]['name']) + '
  • ' } if ( a.length > 3 ){ for (i = 3; i < a.length; i++) { - sharedArtistsHtml += '' + sharedArtistsHtml += '' } sharedArtistsHtml += '
  • [Expand]
  • ' } @@ -210,7 +215,7 @@ // Fix Last.fm API returning more than one entry despite limit on certain conditions. if ( typeof(json[0]) === "object" ) json = json[0]; html += '
  • Last played: '; - html += '' + json['artist']['#text'] + ' - ' + json['name'] + ''; + html += '' + escapeAmpHtml(json['artist']['#text']) + ' - ' + escapeAmpHtml(json['name']) + ''; html += "
  • "; lastPlayedTrack = html; } @@ -245,11 +250,11 @@ var k = initialCount; if (j.length < 3) k = j.length; for (var i = 0; i < k; i++) { - html += '
  • ' + j[i]['name'] + '
  • ' + html += '
  • ' + escapeAmpHtml(j[i]['name']) + '
  • ' } if ( j.length>3 ){ for (i = 3; i < j.length; i++) { - html += '' + html += '' } html+= '
  • [Expand]
  • ' } @@ -288,11 +293,11 @@ var k = initialCount; if (j.length < 3) k = j.length; for (var i = 0; i < k; i++) { - html += '
  • ' + j[i]['artist']['name'] + ' - ' + j[i]['name'] + '
  • ' + html += '
  • ' + escapeAmpHtml(j[i]['artist']['name']) + ' - ' + escapeAmpHtml(j[i]['name']) + '
  • ' } if ( j.length>3 ){ for (i = 3; i < j.length; i++) { - html += '' + html += '' } html+= '
  • [Expand]
  • ' } @@ -331,11 +336,11 @@ var k = initialCount; if (j.length < 3) k = j.length; for (var i = 0; i < k; i++) { - html += '
  • ' + j[i]['artist']['name'] + ' - ' + j[i]['name'] + '
  • ' + html += '
  • ' + escapeAmpHtml(j[i]['artist']['name']) + ' - ' + escapeAmpHtml(j[i]['name']) + '
  • ' } if ( j.length>3 ){ for (i = 3; i < j.length; i++) { - html += '' + html += '' } html+= '
  • [Expand]
  • ' }