cluster_search_ui/commit

Made the generation of thumbnail ids more restrictive so it doesnt intervere with jQuery.

authorChris Dijkshoorn
Wed Jun 17 14:33:08 2015 +0200
committerChris Dijkshoorn
Wed Jun 17 14:33:08 2015 +0200
commit57a953cae93df47b080f19dc4356e9387508ad1f
tree824adc2b4af2680aa1d808dd14e08757756027ca
parentd41b18ca9d1d6a6546f11eab924d804a34c39a7f
Diff style: patch stat
diff --git a/web/js/thumbnail.js b/web/js/thumbnail.js
index c5faf01..a6b24aa 100644
--- a/web/js/thumbnail.js
+++ b/web/js/thumbnail.js
@@ -96,18 +96,23 @@ function changeThumbnails(pageNumber, activePage, numberOfPages, clusterId) {
 }
 
 function getId(uri) {
-	id = uri.substr(uri.lastIndexOf('/') + 1);
+	var dirtyId = uri.substr(uri.lastIndexOf('/') + 1);
+	// Only allow characters that won't trip up jQuery
+	var id = dirtyId.replace(/[^\w\-]/gi, '');
 	return id;
 }
 
 function addClickEvent(id, link, clusterId, index) {
 	//Add thumbnail click event
+	console.log("Adding click event for ", clusterId, id);
 	$("#cluster" + clusterId  + " #" + id).click(function() {
+		//Add info to local storage to be able to save context
 		localStorage.setItem("itemIndex", index);
 		localStorage.setItem("clusterId", clusterId);
 		localStorage.setItem("currentCluster", JSON.stringify(enrichedClusters[clusterId]));
 		if((clusterId+1) == clusters.length)
 			localStorage.setItem("query", "random");
 		document.location.href=link;
+		console.log("Added click event for id", id ,link, clusterId, index);
 	});
 }