cluster_search_ui/commit

Better handling of paths shorter than 3.

authorChris Dijkshoorn
Tue Mar 31 17:00:15 2015 +0100
committerChris Dijkshoorn
Tue Mar 31 17:00:15 2015 +0100
commit3d7c1f4f8fff9fc51c71cdc98e276055cb53c920
treeb98ee14e5ef1c8a1658120766d18c0b30810a688
parentdbafded7663e5c565af74833f898c5d07cbacffd
Diff style: patch stat
diff --git a/web/js/search.js b/web/js/search.js
index c8c3274..f0a5157 100644
--- a/web/js/search.js
+++ b/web/js/search.js
@@ -170,26 +170,33 @@ function pathHtmlElements(path) {
 
 function unfoldPathEvent(id, path) {
 	var pathElements = $.el.h4();
-	
-	for(var i=0; i<path.length; i++) {
-		// Label colouring
-		if(i==0){
-			pathElements.appendChild(
-				$.el.span({'class':'path-label path-literal'},
-						  query));
-		} else if(i%2==0){
-			pathElements.appendChild(
-				$.el.span({'class':'path-label path-resource'},
-					   path[i].label));
-		} else {
-			pathElements.appendChild(
-				$.el.span({'class':'path-label path-property'},
-					   path[i].label));
-		}
-		// Add arrow if not end of path
-		if(!(path.length==i+1)){
-			pathElements.appendChild(
-				$.el.span({'class':'glyphicon glyphicon-arrow-right'}));
+
+	if(path.length==0){
+		// Only show query in case there is no path
+		pathElements.appendChild(
+			$.el.span({'class':'path-label path-literal'},
+					  query));
+	} else {
+		for(var i=0; i<path.length; i++) {
+			// Label colouring
+			if(i==0){
+				pathElements.appendChild(
+					$.el.span({'class':'path-label path-literal'},
+							query));
+			} else if(i%2==0){
+				pathElements.appendChild(
+					$.el.span({'class':'path-label path-resource'},
+						path[i].label));
+			} else {
+				pathElements.appendChild(
+					$.el.span({'class':'path-label path-property'},
+						path[i].label));
+			}
+			// Add arrow if not end of path
+			if(!(path.length==i+1)){
+				pathElements.appendChild(
+					$.el.span({'class':'glyphicon glyphicon-arrow-right'}));
+			}
 		}
 	};