accurator/commit

Added superdomain to domain info for allowing retrieval of sibling domains, resolves #260

authorChris Dijkshoorn
Tue Apr 19 19:49:19 2016 +0200
committerChris Dijkshoorn
Tue Apr 19 19:49:19 2016 +0200
commit0f7a7274729e661bfe0f4f1ab07a3dbe0282677f
treebb5a6241e66bdf7819c19e1da138c47446994790
parent0c895ff06c23ccb9a121f4a78fcd688be63c4040
Diff style: patch stat
diff --git a/lib/accurator/domain.pl b/lib/accurator/domain.pl
index ebe9d4e..403b7f3 100644
--- a/lib/accurator/domain.pl
+++ b/lib/accurator/domain.pl
@@ -40,8 +40,9 @@ get_root_domains([Domain | DomainUris],  [DomainLabel | Filtered]) :-
 %	Create a dictionary filled with information about the domain.
 get_domain_dic(DomainUri, Domain, Dic) :-
 	setof(Property, Value^rdf(DomainUri, Property, Value), Properties),
-	get_values(DomainUri, Properties, PropertyPairs),
+	get_values(DomainUri, Properties, PropertyPairs0),
 	domain_image(DomainUri, ImagePairs),
+	super_domain(DomainUri, PropertyPairs0, PropertyPairs),
 	append([[domain-Domain], PropertyPairs, ImagePairs], Pairs),
 	dict_pairs(Dic, elements, Pairs).
 
@@ -83,3 +84,13 @@ domain_image(DomainUri, [image-ImagePath, imageBrightness-Brightness]) :-
 	rdf(Image, accu:hasFilePath, literal(ImagePath)),
 	rdf(Image, accu:brightness, literal(Brightness)).
 domain_image(_DomainUri, []).
+
+%%	super_domain(+Domain, +Pairs0, -Pairs1)
+%
+%	Retrieve the super domain of a domain and when possible add to list
+%	of pairs.
+super_domain(Domain, Pairs, [superDomain-SuperDomain | Pairs]) :-
+	rdf(SuperDomain, accu:subDomains, Domain), !.
+super_domain(_Domain, Pairs, Pairs).
+
+
diff --git a/web/js/results.js b/web/js/results.js
index 80b8469..259f5f4 100644
--- a/web/js/results.js
+++ b/web/js/results.js
@@ -433,7 +433,9 @@ function domainButton(domainData, labels) {
 		// show option to select other subdomain
 		addDomainButton(labels.resultsBtnChangeSubDomain);
 		$("#resultsBtnSubDomains").click(function() {
-			document.location.href = "domain.html?domain=" + domainData.superDomain;
+			document.location.href =
+				"domain.html?domain=" +
+				generateDomainFromUri(domainData.superDomain);
 		});
 	}
 }
@@ -441,7 +443,7 @@ function domainButton(domainData, labels) {
 function addDomainButton(label) {
 	$(".resultsDivControls").append(
 		$.el.button({
-			'class':'btn btn-default',
+			'class':'btn btn-primary',
 			'id':'resultsBtnSubDomains'},
 			label
 		)