Added missing comments

git-svn-id: https://svn.apache.org/repos/asf/incubator/photark/mobile/trunk@1375669 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/assets/www/scripts/MapView.js b/assets/www/scripts/MapView.js
index 5c29f38..7c97644 100644
--- a/assets/www/scripts/MapView.js
+++ b/assets/www/scripts/MapView.js
@@ -17,16 +17,17 @@
  * under the License.
  */
 
-
+//Maps has to be initialized to the location of the current image when loaded
 $('#mapView').live("pageshow", function() {
 	if (getLocation() != "" && getLocation() != "undefined" && !(typeof(getLocation()) === 'undefined')) {
+		//Has to convert to coordinates first
 		var geocoder2 = new google.maps.Geocoder();
 		geocoder2.geocode({'address': getLocation()}, function(results, status) {
 		    if (status == google.maps.GeocoderStatus.OK) {		        
 		        $('#map_canvas').gmap({'center': new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng()), 'zoom': 10, 'disableDefaultUI':false, 'callback': function() {
 					var self = this;
 					self.addMarker({'position': this.get('map').getCenter() }).click(function() {
-						self.openInfoWindow({ 'content': 'Hello World!' }, this);
+						self.openInfoWindow({ 'content': getLocation() }, this);
 					});	
 				}});
 		    } else {
diff --git a/assets/www/scripts/contacts.js b/assets/www/scripts/contacts.js
index c738740..2843f6b 100644
--- a/assets/www/scripts/contacts.js
+++ b/assets/www/scripts/contacts.js
@@ -16,8 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
+//This class is used to deal with phonebook contacts
+
 var contactsLoaded=false;
 
+//load contacts and populate the contacts page
 function getContacts() {
 	if(!contactsLoaded){
 		contactsLoaded=true;
@@ -82,6 +86,7 @@
 		$('#allContacts').html('No contacts');
 }
 
+//On click name has to be added to the add tag text box
 function onContactsClick(name){
 	$('#editPeople').val(name);
 	$.mobile.changePage( $("#NewTag") );
diff --git a/assets/www/scripts/dataAccess.js b/assets/www/scripts/dataAccess.js
index 555b6b6..a621406 100644
--- a/assets/www/scripts/dataAccess.js
+++ b/assets/www/scripts/dataAccess.js
@@ -17,7 +17,11 @@
  * under the License.
  */
 
+//This class is used to interact with the SQLite database
 
+
+//Global variables
+//When a photo is loaded these will be initialized
 var uri=0;
 var nickname="Not defined.";
 var date;
@@ -29,6 +33,7 @@
 var clause;
 var result=new Array();
 
+//getter methods
 
 function getNickname(){
 	return nickname;
@@ -58,16 +63,17 @@
 	return uri;
 }
 
+function getResult() {
+	return result;
+}
 
+//This has to be called once at the start of the application
+//Initialize the database connection
 function openDB() {
 	db = window.openDatabase("photark", "1.0", "DB", 1000000);
 	db.transaction(populateDB, errorCB, successCB);
 }
 
-function getResult() {
-	return result;
-}
-
 function populateDB(tx) {
 	tx.executeSql('CREATE TABLE IF NOT EXISTS MAIN (uri unique,nickname, date,time,location,description)');
 	tx.executeSql('CREATE TABLE IF NOT EXISTS PEOPLE (uri,name,x,y,PRIMARY KEY (uri, name))');
@@ -81,6 +87,8 @@
 	//Do nothing
 }
 
+
+//gets data of a image and initialize variables
 function viewData(img){
 	uri=img;
 	clearData();
@@ -123,8 +131,8 @@
 	updateHome();
 }
 
+//save variable values to the database
 function updateDB(){
-	//var db = window.openDatabase("photark", "1.0", "DB", 1000000);
 	db.transaction(insertToDB, errorCB, successCB);
 	updateHome();
 }
@@ -136,6 +144,7 @@
 	}
 }
 
+//update page with loaded data
 function updateHome(){
 	temp4="";
 	for (i = 0; i < tagObjectsSaved.length; i++) {
@@ -150,6 +159,7 @@
 	$("#metadata").append("<p> Time: "+time+"</p>");
 }
 
+//save a tag to the database
 function addTag(name,x,y){
 	db.transaction(function(tx){
 		  saveTag(tx,uri,name,x,y);
@@ -194,6 +204,7 @@
 	tx.executeSql('DELETE FROM PEOPLE WHERE URI="'+uri+'"');
 }
 
+//remove all records with current uri
 function removeFromDB(){
 	db.transaction(deleteRecords, errorCB, successCB);
 }
diff --git a/assets/www/scripts/geoLocation.js b/assets/www/scripts/geoLocation.js
index 7e722e8..9f013a4 100644
--- a/assets/www/scripts/geoLocation.js
+++ b/assets/www/scripts/geoLocation.js
@@ -20,6 +20,8 @@
 //<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
 var pos;
 
+//This is used to call location based services
+
 function onGeoSuccess(position) {
 	pos=position;
     alert( 'Location success: '+pos.coords.latitude+","+ pos.coords.longitude);
@@ -32,7 +34,7 @@
           'message: ' + error.message + '\n');
 }
 
-
+//Get device location (using GPS,Wi-Fi,etc.)
 function getGeoLocation(){
 	try{
 	navigator.geolocation.getCurrentPosition(onGeoSuccess,onGeoError,{ enableHighAccuracy: false });
@@ -47,7 +49,7 @@
 	getGeoLocation();
 }
 
-
+//add location of the current photo to the database
 function updateLocation(){
 	var latlng = new google.maps.LatLng(pos.coords.latitude,pos.coords.longitude);
 	//var latlng = new google.maps.LatLng(6.9167,79.8333);
@@ -66,6 +68,7 @@
 	$.mobile.changePage("#main");
 }
 
+//reverse geocoding using google maps API
 function adressToCoordinate(address) {
 	var loc;
 	var geocoder = new google.maps.Geocoder();
diff --git a/assets/www/scripts/photark_events.js b/assets/www/scripts/photark_events.js
index a40ebd5..a104a04 100644
--- a/assets/www/scripts/photark_events.js
+++ b/assets/www/scripts/photark_events.js
@@ -17,15 +17,17 @@
  * under the License.
  */
 
+//Contains event based actions of the UI
 function initilizeClickEvents() {
-	
+
+	// Clicked location of the photo has to identified to add a new tag
 	$("#tagPicture").click(function(e) {
-	 	 e.preventDefault();
-	 	 var x = e.pageX - this.offsetLeft;
-	     var y = e.pageY - this.offsetTop;				     
-	 	 showDialog(e,x,y) ;
-    });
-	
+		e.preventDefault();
+		var x = e.pageX - this.offsetLeft;
+		var y = e.pageY - this.offsetTop;
+		showDialog(e, x, y);
+	});
+
 	$('#ContactsPage li a').live('click', function() {
 		var name = $(this).text();
 		onContactsClick(name);
@@ -34,8 +36,8 @@
 }
 
 function initializePageShowFunctions() {
-	//This method load existing metadata to edit metadata page on page load
-	$('#EditMetadata').live('pageshow', function () {
+	// This method load existing metadata to edit metadata page on page load
+	$('#EditMetadata').live('pageshow', function() {
 		$("#nickName").val(getNickname());
 		$("#editDate").val(getDate());
 		$("#editTime").val(getTime());
@@ -44,23 +46,22 @@
 		// var people=getPeople();
 		// var s="";
 		// for (var i=0; i < people.length; i++) {
-		  // s=s+people[i]+',';
+		// s=s+people[i]+',';
 		// };
 		// $("#editPeople").val(s);
 	});
-	
-	$('#photoTag').live('pageshow', function () {
+
+	// Tags are marked when tag page is loaded
+	$('#photoTag').live('pageshow', function() {
 		$('#tagPicture').html('<img id="tagImage"/>');
-		displayTagImage(uri) ;
+		displayTagImage(uri);
 		markTags(tagObjectsSaved);
 		markTags(tagObjects);
 	});
-	
-	$('#ContactsPage').live('pageshow', function () {
+
+	// User may click the browse button to add tags using contacts. So it has to
+	// be initialized
+	$('#ContactsPage').live('pageshow', function() {
 		getContacts();
 	});
 }
-
-
-
-
diff --git a/assets/www/scripts/search.js b/assets/www/scripts/search.js
index e5ccdb6..f993ea5 100644
--- a/assets/www/scripts/search.js
+++ b/assets/www/scripts/search.js
@@ -18,6 +18,8 @@
  */
 
 function doSearch(){
+	
+	//initialize search parameters
 	var name=$("#searchName").val();
 	var startDate=$("#searchStartDate").val();
 	var endDate=$("#searchEndDate").val();
@@ -88,6 +90,8 @@
 
 
 function showResults(results) {
+	//clear and populate search results page
+	
 	$("#resultGallery").html("");
 	$("#Gallery").html("");
 
@@ -110,32 +114,34 @@
 }
 
 function selectResult(uri){
-	$("#metadata").html("");
-	var largeImage = document.getElementById('largeImage');
-	largeImage.style.display = 'block';
-	largeImage.src = uri;
-	onImageUpdated();
-	$('#toolbar').listview("create");
-	window.resolveLocalFileSystemURI(uri, onFileEntryComplete, isFail);
-	viewData(uri);
-	$('#largeImage').click(function() { fullScreen(largeImage.src); });
+//	$("#metadata").html("");
+//	var largeImage = document.getElementById('largeImage');
+//	largeImage.style.display = 'block';
+//	largeImage.src = uri;
+//	onImageUpdated();
+//	$('#toolbar').listview("create");
+//	window.resolveLocalFileSystemURI(uri, onFileEntryComplete, isFail);
+//	viewData(uri);
+//	$('#largeImage').click(function() { fullScreen(largeImage.src); });
+//	
+//	displayTagImage(uri) ;
+//	
+//	tagObjects=new Array();
+//	
+//    $('#largeImage').css({
+//          // Using jQuery CSS we write the $width variable we previously specified as a pixel value. We use max-width incase the image is smaller than our viewport it won't scale it larger. Don't forget to set height to auto or else it will squish your photos.
+//          'max-width' : windowWidth , 'height' : 'auto'
+//    });   
+//    
+//    tagObjectsSaved=new Array();
+//	$('#largeImage').click(function() { fullScreen(largeImage.src); });
+	onPhotoURISuccess(uri);
 	
-	displayTagImage(uri) ;
-	
-	tagObjects=new Array();
-	
-    $('#largeImage').css({
-          // Using jQuery CSS we write the $width variable we previously specified as a pixel value. We use max-width incase the image is smaller than our viewport it won't scale it larger. Don't forget to set height to auto or else it will squish your photos.
-          'max-width' : windowWidth , 'height' : 'auto'
-    });   
-    
-    tagObjectsSaved=new Array();
-	$('#largeImage').click(function() { fullScreen(largeImage.src); });
-
 	$.mobile.changePage( $("#main") );
 }
 
 function viewAllImages(){
+	//do a search which matches any image
 	searchDB('SELECT * FROM MAIN WHERE nickname LIKE "%";');
 }
 
diff --git a/assets/www/scripts/tagging.js b/assets/www/scripts/tagging.js
index 9f655a3..30dfc81 100644
--- a/assets/www/scripts/tagging.js
+++ b/assets/www/scripts/tagging.js
@@ -17,32 +17,14 @@
  * under the License.
  */
 
-var tagEnabled=false;
+var tagEnabled=false;	//Whether add tag has clicked or not
 var eValue;
 var xValue;
 var yValue;
 
-
+//Called when user click on the photo to add a tag
 function showDialog(e, x, y) {
-	if(tagEnabled){
-//		$('<div>').simpledialog2({
-//			mode : 'button',
-//			headerText : 'Tag',
-//			headerClose : true,
-//			buttonPrompt : 'Type Name',
-//			buttonInput : true,
-//			buttons : {
-//				'OK' : {
-//					click : function() {
-//							var name = $.mobile.sdLastInput;
-//							showTag(name, x, y);
-//							var tgx = new TagObject(name, x, y);
-//							tagObjects.push(tgx);
-//					}
-//				},
-//			}
-//		})
-		
+	if(tagEnabled){		
 		eValue=e;
 		xValue=x;
 		yValue=y;
@@ -55,8 +37,8 @@
 
 function TagObject(name, x, y) {
 	this.name = name;
-	this.x = x;
-	this.y = y;
+	this.x = x;		//x coordinate of clicked point
+	this.y = y;		//y coordinate of clicked point
 }
 
 function saveTags() {
@@ -72,6 +54,7 @@
 	enableTagging();
 }
 
+//Marks associated tags when a new image is loaded
 function markTags(tagObjectsSaved) {
 	for (i = 0; i < tagObjectsSaved.length; i++) {
 		showTag(tagObjectsSaved[i].name, parseInt(tagObjectsSaved[i].x),
@@ -87,6 +70,7 @@
 	img.appendTo('#tagPicture');
 }
 
+//Delete all tags associated with current photo from the database
 function clearTags() {
 	$('<div>').simpledialog2({
 	    mode: 'button',
@@ -127,6 +111,7 @@
 
 }
 
+//toggle UI controls
 function enableTagging() {
 	if(!tagEnabled){
 		tagEnabled=true;
@@ -153,6 +138,7 @@
 	$.mobile.changePage("#photoTag");
 }
 
+//Disable tag editing mode
 function cancelTagging() {
 	tagObjects=new Array();
 	enableTagging();
diff --git a/assets/www/scripts/utils.js b/assets/www/scripts/utils.js
index 10c5a5f..e273f36 100644
--- a/assets/www/scripts/utils.js
+++ b/assets/www/scripts/utils.js
@@ -19,6 +19,7 @@
 
 var fileURI;
 
+//Delete a photo from the phone
 function deleteFile() {
 	window.resolveLocalFileSystemURI(uri, deleteEntry, function() {
 		alert('error: unable to resovle local fs uri')
@@ -42,6 +43,7 @@
 	$('#largeImage').attr("src", "images/logo.png");
 }
 
+//This uses photo swipe library to view a image in fullscreen
 function fullScreen(uri) {
 	$("#Gallery").html(
 			'<li><a href="' + uri + '" ><img src="' + uri
@@ -72,6 +74,7 @@
 	}
 }
 
+//Adjust UI elements according to the screen size
 function adjustScreenLayout() {
 	windowWidth = $(window).width();
 	windowHeight = $(window).height();
@@ -94,6 +97,7 @@
 	$('#map_canvas').css('margin-right', 'auto');
 }
 
+//TODO not working
 function loadjscssfile(scriptUrl) {
 	var head = document.getElementsByTagName("head")[0];
 	script = document.createElement('script');
@@ -110,6 +114,7 @@
 	}
 }
 
+//returns system date
 function getCurrentDate() {
 	var currentTime = new Date()
 	var month = currentTime.getMonth() + 1
@@ -118,6 +123,7 @@
 	return (month + "/" + day + "/" + year);
 }
 
+//returns system time
 function getCurrentTime() {
 	var time = "";
 	var currentTime = new Date();
@@ -142,6 +148,7 @@
 	return time;
 }
 
+//Check whether a data network is available
 function checkNetwork() {
 	var networkState = navigator.network.connection.type;
 	if (networkState == Connection.NONE) {