Index: main/trunk/model-sites-dev/von-sparql/js/von-sparql-comparison-script.js
===================================================================
--- main/trunk/model-sites-dev/von-sparql/js/von-sparql-comparison-script.js	(revision 28914)
+++ main/trunk/model-sites-dev/von-sparql/js/von-sparql-comparison-script.js	(revision 29445)
@@ -1,2 +1,9 @@
+// Von-Sparql Collection Comparison Script
+//
+// Contains script to build queries to compare contents of
+// one collection with another.
+
+
+//Builds a single-collection query from inputs
 function generateQuery(side,dataset){
 	var predicate = $('#sel_' + side + 'Predicate').val(); 	
@@ -31,4 +38,5 @@
 }
 
+//Builds a query comparing data selected from two collections
 function generateComparisonQuery(){
 
@@ -38,7 +46,8 @@
 
 	//Start generating query
-    	var sparqlQuery = "";
+	var sparqlQuery = "";
 	var sparqlQueryHeader = "";
-	///////INTERSECTION///////
+
+	//If query type is an intersection of the collection data
 	if(query.type=="intersection"){
 		sparqlQueryHeader 	+= 	"SELECT DISTINCT ?common ";
@@ -51,5 +60,5 @@
 			sparqlQuery 	+=	"	?s <" + query.pred_L + "> "// ?common;"; 
 			
-		sparqlQuery += generateFilter("left", comparisonMethod);
+		sparqlQuery += setComparisonMethod("left", comparisonMethod);
 
 		if(!$('#cb_showOnlyCommonObjects').is(':checked')){
@@ -79,5 +88,5 @@
 			sparqlQuery 	+=	"	?s1 <" + query.pred_R + "> "// ?common;" ; 
 
-		sparqlQuery += generateFilter("right", comparisonMethod);
+		sparqlQuery += setComparisonMethod("right", comparisonMethod);
 
 		if(!$('#cb_showOnlyCommonObjects').is(':checked')){
@@ -106,5 +115,5 @@
 	
 
-    //////MINUS/////
+	//If query is for data that is in one collection, but not the other (MINUS)
 	if(query.type=="minus"){
 		sparqlQueryHeader 	+= 	"SELECT DISTINCT ?minus " ;
@@ -140,5 +149,6 @@
 		sparqlQuery			+=	"} ";
 		sparqlQuery 		+= 	"MINUS{" 
-					 		+ 	"GRAPH gsdl:" + leftCollection + "{" ;
+						+  	"GRAPH gsdl:" + leftCollection + "{" ;
+	
 		if(query.refine_L!="")
 			sparqlQuery 	+= 	"	?s <" + query.pred_L + "> \"" + query.predval_L + "\";"  
@@ -147,5 +157,5 @@
 			sparqlQuery 	+=	"	?s <" + query.pred_L + "> "; 
 
-		sparqlQuery += generateFilter("left", comparisonMethod)
+		sparqlQuery += setComparisonMethod("left", comparisonMethod)
 		sparqlQuery 		+=	"}"  
 							+	"GRAPH gsdl:" + rightCollection +"{";
@@ -156,5 +166,5 @@
 			sparqlQuery 	+=	"	?s1 <" + query.pred_R + "> " ; 
 
-		sparqlQuery += generateFilter("right", comparisonMethod)
+		sparqlQuery += setComparisonMethod("right", comparisonMethod)
 		sparqlQuery 		+=	"}"  
 							+	"}}";
@@ -163,9 +173,10 @@
 	sparqlQuery += "LIMIT " + $('#sel_comparisonLimit').val() + " ";
 	sparqlQuery += "OFFSET " + ((query.page-1) * $('#sel_comparisonLimit').val()); 
-	console.log(sparqlQuery);
 	return sparqlQuery;
 } 
 
-function generateFilter(side, comparisonMethod){
+//Used when substrings of returned values are used for comparison 
+//i.e. when numbers are extracted from DATE triples for plotting in a line graph, etc"
+function setComparisonMethod(side, comparisonMethod){
 	var query = "";
 	var tempVar;
@@ -209,5 +220,5 @@
 
 
-
+//Updates the "value" selector with possible values
 function updateValueSelector(predicate, selector, collectionName){
     var refineDataset = "GRAPH gsdl:" + collectionName + " {\n";
@@ -255,4 +266,6 @@
 }
 
+//Updates the selector which contains available predicates after 
+//previously restricting a predicate to a certain value
 function updateVisualizePredicateSelector(predicate,value,selector,collection){
 	var sparqlQuery;
@@ -295,5 +308,5 @@
 }
 
-function drawFilteredDataset(side, collection){
+function drawCollectionChart(side, collection){
 	var Q = new sgvizler.Query();
 	Q.query(generateQuery(side, collection))
@@ -316,25 +329,4 @@
 	sgvizler.defaultChartWidth(defaultChartWidth);
 	sgvizler.defaultChartHeight(defaultChartHeight);
-
-/*	var ajaxSparqlQuery = sparqlEndpoint + "?query=" + encodeURIComponent(generateComparisonQuery());
-
-	$('#table_combinedResults').jqGrid({
-		url: ajaxSparqlQuery,
-		datatype: "spreadsheet",
-		colNames: ['Common'],
-		colModel: [{name: 'common',
-					index: 'results.bindings.common',
-					width: '300'}],
-		rowNum: 10,
-		rowList: [10,20,30],
-		pager: '#table_combinedResultsPager',
-//		sortname: 'common',
-		viewrecords: true,
-		sortorder: 'desc',
-		caption: 'Results table'
-	});
-	$('#table_combinedResults').jqGrid('navGrid','#div_combinedResultsPager',{edit:false, add:false, del:false});
-
-*/	
 }
 
@@ -346,4 +338,5 @@
 	return name;
 }
+
 //Fills the predicate selector with values
 function populatePredicateSelector(collection, selector){
@@ -398,5 +391,4 @@
 
 function setCursor(style){
-	console.log("Cursor: " + style);
 	document.body.style.cursor = style;
 }
