You are viewing a plain text version of this content. The canonical link for it is here.
Posted to photark-commits@incubator.apache.org by pr...@apache.org on 2012/08/23 04:27:53 UTC

svn commit: r1376362 - in /incubator/photark/mobile/trunk/assets/www: ./ scripts/

Author: prabhathp
Date: Thu Aug 23 04:27:53 2012
New Revision: 1376362

URL: http://svn.apache.org/viewvc?rev=1376362&view=rev
Log:
renaming photark specific files as photark-*.*

Added:
    incubator/photark/mobile/trunk/assets/www/scripts/photark_MapView.js
    incubator/photark/mobile/trunk/assets/www/scripts/photark_contacts.js
    incubator/photark/mobile/trunk/assets/www/scripts/photark_dataAccess.js
    incubator/photark/mobile/trunk/assets/www/scripts/photark_geoLocation.js
    incubator/photark/mobile/trunk/assets/www/scripts/photark_search.js
    incubator/photark/mobile/trunk/assets/www/scripts/photark_tagging.js
    incubator/photark/mobile/trunk/assets/www/scripts/photark_utils.js
Removed:
    incubator/photark/mobile/trunk/assets/www/scripts/MapView.js
    incubator/photark/mobile/trunk/assets/www/scripts/contacts.js
    incubator/photark/mobile/trunk/assets/www/scripts/dataAccess.js
    incubator/photark/mobile/trunk/assets/www/scripts/geoLocation.js
    incubator/photark/mobile/trunk/assets/www/scripts/search.js
    incubator/photark/mobile/trunk/assets/www/scripts/tagging.js
    incubator/photark/mobile/trunk/assets/www/scripts/utils.js
Modified:
    incubator/photark/mobile/trunk/assets/www/index.html

Modified: incubator/photark/mobile/trunk/assets/www/index.html
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/index.html?rev=1376362&r1=1376361&r2=1376362&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/index.html (original)
+++ incubator/photark/mobile/trunk/assets/www/index.html Thu Aug 23 04:27:53 2012
@@ -41,11 +41,11 @@
 		<!-- Photark core Java Script files --> 
 		<script type="text/javascript" charset="utf-8" src="scripts/photark_UI.js"></script>
 		<script type="text/javascript" charset="utf-8" src="scripts/photark_events.js"></script>
-		<script type="text/javascript" charset="utf-8" src="scripts/contacts.js" ></script>
-		<script type="text/javascript" charset="utf-8" src="scripts/utils.js" ></script>
-		<script type="text/javascript" charset="utf-8" src="scripts/tagging.js" ></script>
-		<script type="text/javascript" charset="utf-8" src="scripts/dataAccess.js"></script>
-		<script type="text/javascript" charset="utf-8" src="scripts/search.js"></script>	
+		<script type="text/javascript" charset="utf-8" src="scripts/photark_contacts.js" ></script>
+		<script type="text/javascript" charset="utf-8" src="scripts/photark_utils.js" ></script>
+		<script type="text/javascript" charset="utf-8" src="scripts/photark_tagging.js" ></script>
+		<script type="text/javascript" charset="utf-8" src="scripts/photark_dataAccess.js"></script>
+		<script type="text/javascript" charset="utf-8" src="scripts/photark_search.js"></script>	
 		
 		<!--For Flickr Implementation Start-->
 		<script type="text/javascript" charset="utf-8" src="scripts/childbrowser.js"></script>
@@ -61,14 +61,14 @@
 		<script type="text/javascript" charset="utf-8" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true"></script>
 		
 		<!-- Photark core Java Script files --> 
-		<script type="text/javascript" charset="utf-8" src="scripts/geoLocation.js" ></script>
+		<script type="text/javascript" charset="utf-8" src="scripts/photark_geoLocation.js" ></script>
 		
 		<!-- map UI library for JQuery -->
 		<script type="text/javascript" charset="utf-8" src="scripts/jquery.ui.map.js"></script>
 		<!-- <script type="text/javascript" charset="utf-8" src="scripts/jquery.ui.map.services.js"></script> -->
 		
 		<!-- Photark core Java Script files -->
-		<script type="text/javascript" charset="utf-8" src="scripts/MapView.js"></script>
+		<script type="text/javascript" charset="utf-8" src="scripts/photark_MapView.js"></script>
 		
 		<script type="text/javascript">
 			var pictureSource;

Added: incubator/photark/mobile/trunk/assets/www/scripts/photark_MapView.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/photark_MapView.js?rev=1376362&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/photark_MapView.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/photark_MapView.js Thu Aug 23 04:27:53 2012
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * 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': getLocation() }, this);
+					});	
+				}});
+		    } else {
+		        alert(address + " cannot be found on Google Maps. Map view will be not available for this photo.");
+		    }
+		});
+		
+	}else {
+		alert('Location not defined!');
+		$.mobile.changePage("#main");
+	}
+	
+});
\ No newline at end of file

Added: incubator/photark/mobile/trunk/assets/www/scripts/photark_contacts.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/photark_contacts.js?rev=1376362&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/photark_contacts.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/photark_contacts.js Thu Aug 23 04:27:53 2012
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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;
+		var optFilter = new ContactFindOptions();
+		optFilter.filter = "";
+		// to return all contacts
+		optFilter.multiple = true;
+		// return multiple results
+		fields = [ "name" ];
+
+		// get all contacts
+		navigator.contacts.find(fields, gcsSuccess, gcsError, optFilter);
+	}
+	
+}
+
+/* get all contacts error */
+function gcsError(contactError) {
+	alert('Contacts Error');
+}
+
+function gcsSuccess(contacts) {
+	if (contacts.length != 0) {
+		// get formatted names and sort
+		var names = new Array();
+		for ( var i = 0; i < contacts.length; ++i) {
+			if (contacts[i].name) {
+				if (contacts[i].name.formatted)
+					names.push(contacts[i].name.formatted);
+			}
+		}
+		names.sort();
+
+		var list = $('#allContacts');
+		// list to put contacts
+		list.html('');
+		// remove all the list items
+		var divider = names[0][0];
+		// first divider letter
+		for ( var i = 0; i < names.length; ++i) {
+			if (divider != names[i][0]) {// add a new divider
+				divider = names[i][0];
+				list
+						.append('<li data-role="list-divider">' + divider
+								+ '</li>');
+				list
+						.append('<li><a href="#"><img src="images/contactIcon.png" class="ui-li-icon" alt="Contact" onclick=\'onContactsClick("'+names[i]+'")\'/>'
+								+ names[i] + '</a></li>');
+			} else {
+				if (i == 0)
+					list.append('<li data-role="list-divider">' + divider
+							+ '</li>');
+				list
+						.append('<li><a href="#"><img src="images/contactIcon.png" class="ui-li-icon" alt="Contact" onclick=\'onContactsClick("'+names[i]+'")\'/>'
+								+ names[i] + '</a></li>');
+			}
+		}
+
+		list.listview('refresh');
+		// refresh the list view
+	} else
+		$('#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") );
+}
+
+

Added: incubator/photark/mobile/trunk/assets/www/scripts/photark_dataAccess.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/photark_dataAccess.js?rev=1376362&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/photark_dataAccess.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/photark_dataAccess.js Thu Aug 23 04:27:53 2012
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * 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;
+var time;
+var loc;
+var description;
+var people=new Array();
+var db;
+var clause;
+var result=new Array();
+
+//getter methods
+
+function getNickname(){
+	return nickname;
+}
+
+function getDate(){
+	return date;
+}
+
+function getTime(){
+	return time;
+}
+
+function getLocation(){
+	return loc;
+}
+
+function getDescription(){
+	return description;
+}
+
+function getPeople(){
+	return people;
+}
+
+function getURI() {
+	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 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))');
+}
+
+function errorCB(err) {
+	alert("Error processing SQL: " + err.code);
+}
+
+function successCB() {
+	//Do nothing
+}
+
+
+//gets data of a image and initialize variables
+function viewData(img){
+	uri=img;
+	clearData();
+	db.transaction(retriviewDB, errorCB, successCB);
+}
+
+function retriviewDB(tx){
+	tx.executeSql('SELECT * FROM MAIN WHERE URI="'+uri+'"', [], querySuccess, errorCB);
+	tx.executeSql('SELECT * FROM PEOPLE WHERE URI="'+uri+'"', [], queryPeopleSuccess, errorCB);
+}
+
+function querySuccess(tx, results){
+	var len = results.rows.length;
+	for (var i=0; i<len; i++){
+		nickname=results.rows.item(i).nickname;
+		date=results.rows.item(i).date;
+		time=results.rows.item(i).time;
+		loc=results.rows.item(i).location;
+		description=results.rows.item(i).description;
+	}
+}
+
+function clearData(){
+	nickname="Not defined.";
+	date="";
+	time="";
+	loc="";
+	description="";
+	people=new Array();
+	tagObjectsSaved=new Array();
+}
+
+function queryPeopleSuccess(tx, results) {
+	var len = results.rows.length;
+	for (var i=0; i<len; i++){
+		people.push(results.rows.item(i).name);
+		var tg1=new TagObject(results.rows.item(i).name,results.rows.item(i).x,results.rows.item(i).y);
+		tagObjectsSaved.push(tg1);
+	}
+	updateHome();
+}
+
+//save variable values to the database
+function updateDB(){
+	db.transaction(insertToDB, errorCB, successCB);
+	updateHome();
+}
+
+function insertToDB(tx) {	
+	tx.executeSql('REPLACE INTO MAIN (uri,nickname, date,time,location,description) VALUES ("'+uri+'","'+nickname+'","'+date+'","'+time+'","'+loc+'","'+description+'")');
+	for (var i = 0; i < people.length; i++) {
+		tx.executeSql('REPLACE INTO PEOPLE (uri,name) VALUES ("'+uri+'","'+people[i]+'")');
+	}
+}
+
+//update page with loaded data
+function updateHome(){
+	temp4="";
+	for (i = 0; i < tagObjectsSaved.length; i++) {
+		temp4+=tagObjectsSaved[i].name+", ";
+	}
+	$("#metadata").html("");
+	$("#metadata").append("<p> Name: "+nickname+"</p>");
+	$("#metadata").append("<p> Location: "+loc+"</p>");
+	$("#metadata").append("<p> Description: "+description+"</p>");
+	$("#metadata").append("<p> Tags: "+temp4+"</p>");
+	$("#metadata").append("<p> Date: "+date+"</p>");
+	$("#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);
+	}, errorCB, successCB);
+}
+
+function saveTag(tx,uri,name,x,y) {
+	tx.executeSql('REPLACE INTO PEOPLE (uri,name,x,y) VALUES ("'+uri+'","'+name+'","'+x+'","'+y+'")');
+}
+
+
+function searchDB(s){
+	clause=s;
+	db.transaction(queryDB, errorCB, successCB);
+}
+
+//To search photos using people names
+function searchPeople(s) {
+	clause=s;
+	db.transaction(queryDB, errorCB, successCB);
+}
+
+function queryDB(tx){
+	tx.executeSql(clause,[], searchSuccess, errorCB);
+}
+
+function searchSuccess(tx, results) {
+	var len = results.rows.length;
+	result=new Array();
+	for (var i=0; i<len; i++){
+		result[i]=results.rows.item(i).uri;
+	}
+	clause="";
+	showResults(result);
+}
+
+function deleteTags(){
+	db.transaction(deleteTagRecords, errorCB, successCB);
+}
+
+function deleteTagRecords(tx){
+	tx.executeSql('DELETE FROM PEOPLE WHERE URI="'+uri+'"');
+}
+
+//remove all records with current uri
+function removeFromDB(){
+	db.transaction(deleteRecords, errorCB, successCB);
+}
+
+function deleteRecords(tx) {
+	tx.executeSql('DELETE FROM PEOPLE WHERE URI="'+uri+'"');
+	tx.executeSql('DELETE FROM MAIN WHERE URI="'+uri+'"');
+}
+
+
+
+
+
+
+
+

Added: incubator/photark/mobile/trunk/assets/www/scripts/photark_geoLocation.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/photark_geoLocation.js?rev=1376362&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/photark_geoLocation.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/photark_geoLocation.js Thu Aug 23 04:27:53 2012
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//<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);
+	updateLocation();
+
+}
+
+function onGeoError(error) {
+    alert('code: '    + error.code    + '\n' +
+          'message: ' + error.message + '\n');
+}
+
+//Get device location (using GPS,Wi-Fi,etc.)
+function getGeoLocation(){
+	try{
+	navigator.geolocation.getCurrentPosition(onGeoSuccess,onGeoError,{ enableHighAccuracy: false });
+	}
+	catch(error){
+		alert('fail');
+	}
+}
+
+function addLocation(){
+	$.mobile.showPageLoadingMsg();
+	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);
+	var geocoder = new google.maps.Geocoder();
+	geocoder.geocode({'latLng': latlng}, function(results, status) {
+	  if (status == google.maps.GeocoderStatus.OK) {
+		  var address= (results[0].formatted_address);
+		  loc = address;
+		  updateDB();
+		  alert("Location updated:"+address);
+	  } else {
+	    alert("Geocoder failed due to: " + status);
+	  }
+	});
+	$.mobile.hidePageLoadingMsg();
+	$.mobile.changePage("#main");
+}
+
+//reverse geocoding using google maps API
+function adressToCoordinate(address) {
+	var loc;
+	var geocoder = new google.maps.Geocoder();
+	geocoder.geocode({'address': address}, function(results, status) {
+	    if (status == google.maps.GeocoderStatus.OK) {
+	        lat=results[0].geometry.location.lat();
+	        long=results[0].geometry.location.lng();
+	        
+	        alert(lat+","+long);
+	    } else {
+	        alert(address + " cannot be found on Google Maps. Map view will be not available for this photo.");
+	    }
+	});
+}
+
+

Added: incubator/photark/mobile/trunk/assets/www/scripts/photark_search.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/photark_search.js?rev=1376362&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/photark_search.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/photark_search.js Thu Aug 23 04:27:53 2012
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+function doSearch(){
+	
+	//initialize search parameters
+	var name=$("#searchName").val();
+	var startDate=$("#searchStartDate").val();
+	var endDate=$("#searchEndDate").val();
+	var location=$("#searchLocation").val();
+	var temp=$("#searchPeople").val();
+	var people=new Array();
+	
+	if(temp!=undefined && temp!=""){
+		people=temp.split(",");
+	}
+	if(name=="" && startDate=="" && endDate=="" && location=="" && temp==""){
+		alert("Fill the information!");
+		return;
+	}
+	if(startDate=="" && endDate=="" && temp==""){
+		searchDB('SELECT * FROM MAIN WHERE nickname LIKE "%'+name+'%" AND location LIKE "%'+location+'%";');		
+	}else if(name=="" && (startDate!="" || endDate!="") && location=="" && temp==""){
+		if(startDate!="" && endDate==""){
+			searchDB('SELECT * FROM MAIN WHERE date >= date("'+startDate+'");');
+		}else if(startDate=="" && endDate!=""){
+			searchDB('SELECT * FROM MAIN WHERE date <= date("'+endDate+'");');
+		}else{
+			searchDB('SELECT * FROM MAIN WHERE date >= date("'+startDate+'") and date <= date("'+endDate+'");');
+		}		
+	}else if(temp!=undefined && temp!="" && name=="" && startDate=="" && endDate=="" && location==""){
+		var temp2='SELECT * FROM PEOPLE WHERE ';
+		for ( var int = 0; int < people.length; int++) {
+			if (int != people.length-1) {
+				temp2+='name LIKE "%'+people[int]+'%" AND ';
+			} else{
+				temp2+='name LIKE "%'+people[int]+'%"; ';
+			}
+		}
+		searchDB(temp2);
+	}else if(temp=="" && (startDate!="" || endDate!="") && (name!="" || location!="")){
+		if(startDate!="" && endDate==""){
+			searchDB('SELECT * FROM MAIN WHERE date >= date("'+startDate+'") AND nickname LIKE "%'+name+'%" AND location LIKE "%'+location+'%";');
+		}else if(startDate=="" && endDate!=""){
+			searchDB('SELECT * FROM MAIN WHERE date <= date("'+endDate+'") AND nickname LIKE "%'+name+'%" AND location LIKE "%'+location+'%";');
+		}else{
+			searchDB('SELECT * FROM MAIN WHERE date >= date("'+startDate+'") and date <= date("'+endDate+'") AND nickname LIKE "%'+name+'%" AND location LIKE "%'+location+'%";');
+		}	
+	}else if(temp!="" && (startDate!="" || endDate!="")){
+		var temp3='SELECT * FROM MAIN NATURAL JOIN PEOPLE WHERE nickname LIKE "%'+name+'%" AND location LIKE "%'+location+'%" AND';
+		for ( var int = 0; int < people.length; int++) {
+				temp3+='name LIKE "%'+people[int]+'%" AND ';
+		}
+		if(startDate!="" && endDate==""){
+			temp3+=' date >= date("'+startDate+'");';
+		}else if(startDate=="" && endDate!=""){
+			temp3+=' date <= date("'+endDate+'");';
+		}else{
+			temp3+=' date >= date("'+startDate+'") and date <= date("'+endDate+'");';
+		}	
+		searchDB(temp3);
+	}else if(temp!="" && startDate=="" && endDate==""){
+		var temp4='SELECT * FROM MAIN NATURAL JOIN PEOPLE WHERE nickname LIKE "%'+name+'%" AND location LIKE "%'+location+'%" AND';
+		for ( var int = 0; int < people.length; int++) {
+			if (int != people.length-1) {
+				temp4+='name LIKE "%'+people[int]+'%" AND ';
+			} else{
+				temp4+='name LIKE "%'+people[int]+'%"; ';
+			}
+		}
+		searchDB(temp4);
+	}
+}
+
+
+function showResults(results) {
+	//clear and populate search results page
+	
+	$("#resultGallery").html("");
+	$("#Gallery").html("");
+
+		for ( var int = 0; int < results.length; int++) {
+			if(results.length==0){
+				alert("Sorry, no results found");
+			}
+			if (i % 2 == 0) {
+				$("#resultGallery").append('<div class="ui-block-a" ><div style="padding:5px !important;"><img src="'+results[int]+'"  style="height:150px !important; width:100% !important;" onclick=\'selectResult("'+results[int]+'")\' /></div></div>');
+			} else {
+				$("#resultGallery").append('<div class="ui-block-b" ><div style="padding:5px !important;"><img src="'+results[int]+'"  style="height:150px !important; width:100% !important;" onclick=\'selectResult("'+results[int]+'")\' /></div></div>');
+			}
+			$("#Gallery").append('<li><a href="'+results[int]+'" ><img src="'+results[int]+'"  alt="Photark" /></a></li>');
+		}
+		if(results.length==0){
+			alert("Sorry, no results found");
+		}else{
+			$.mobile.changePage($('#searchResults'));
+		}
+}
+
+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); });
+//	
+//	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);
+	
+	$.mobile.changePage( $("#main") );
+}
+
+function viewAllImages(){
+	//do a search which matches any image
+	searchDB('SELECT * FROM MAIN WHERE nickname LIKE "%";');
+}
+
+
+	
\ No newline at end of file

Added: incubator/photark/mobile/trunk/assets/www/scripts/photark_tagging.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/photark_tagging.js?rev=1376362&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/photark_tagging.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/photark_tagging.js Thu Aug 23 04:27:53 2012
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+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){		
+		eValue=e;
+		xValue=x;
+		yValue=y;
+		
+		$.mobile.changePage("#NewTag");
+	}else{
+		alert("Tagging not enabled.");
+	}
+}
+
+function TagObject(name, x, y) {
+	this.name = name;
+	this.x = x;		//x coordinate of clicked point
+	this.y = y;		//y coordinate of clicked point
+}
+
+function saveTags() {
+	for (i = 0; i < tagObjects.length; i++) {
+		if(tagObjects.length==0){
+			alert("No new tags has been added.");
+		}
+		addTag(tagObjects[i].name, tagObjects[i].x, tagObjects[i].y);
+		tagObjectsSaved.push(tagObjects[i]);
+	}
+	tagObjects=new Array();	//buffer has to be cleared 
+	alert("Tags Saved Successfully.");
+	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),
+				parseInt(tagObjectsSaved[i].y));
+	}
+}
+
+function showTag(name, x, y) {
+	var img = $('<p>' + name + '</p>');
+	img.css('top', y);
+	img.css('left', x);
+	img.css('color', 'purple');
+	img.appendTo('#tagPicture');
+}
+
+//Delete all tags associated with current photo from the database
+function clearTags() {
+	$('<div>').simpledialog2({
+	    mode: 'button',
+	    headerText: 'Delete Tags',
+	    headerClose: true,
+	    buttonPrompt: 'Are you sure you want to delete all the tags in this photo?',
+	    buttons : {
+	      'OK': {
+	        click: function () { 
+	        	deleteTags();
+	        	$('#tagPicture').html('<img id="tagImage"/>');
+	        	displayTagImage(getURI());
+	        }
+	      },
+	      'Cancel': {
+	        click: function () { 
+	        	//Do nothing
+	        },
+	        icon: "delete",
+	      }
+	    }
+	})
+}
+
+function displayTagImage(uri) {
+	var tagImage = document.getElementById('tagImage');
+	tagImage.style.display = 'block';
+	tagImage.src = uri;
+
+	$('#tagImage').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 - 30),
+		'height' : 'auto'
+	});
+
+}
+
+//toggle UI controls
+function enableTagging() {
+	if(!tagEnabled){
+		tagEnabled=true;
+		$('#saveTagsButton').show();
+		$('#clearTagsButton').hide();
+		$('#cancelTaggingButton').show();	
+		$('#enableTaggingButton').hide();
+	}else{
+		tagEnabled=false;
+		$('#saveTagsButton').hide();
+		$('#clearTagsButton').show();
+		$('#cancelTaggingButton').hide();		
+		$('#enableTaggingButton').show();		
+	}
+}
+
+function addTagClicked() {
+	var name = $('#editPeople').val();
+	showTag(name, xValue, yValue);
+	var tgx = new TagObject(name, xValue, yValue);
+	tagObjects.push(tgx);
+	xValue=null;
+	yValue=null;
+	$.mobile.changePage("#photoTag");
+}
+
+//Disable tag editing mode
+function cancelTagging() {
+	tagObjects=new Array();
+	enableTagging();
+}

Added: incubator/photark/mobile/trunk/assets/www/scripts/photark_utils.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/photark_utils.js?rev=1376362&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/photark_utils.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/photark_utils.js Thu Aug 23 04:27:53 2012
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+var fileURI;
+
+//Delete a photo from the phone
+function deleteFile() {
+	window.resolveLocalFileSystemURI(uri, deleteEntry, function() {
+		alert('error: unable to resovle local fs uri')
+	});
+	
+}
+
+function deleteEntry(entry) {
+	entry.remove(function(entry) {
+		alert('Removal succeeded');
+		removeFromDB();
+		onHomeButtonClicked();
+	}, function(error) {
+		alert('Error removing file: ' + error.code);
+	});
+}
+
+function reset() {
+	$('#toolbar_icons').hide();
+	$('#toolbar_message').show();
+	$('#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
+					+ '"  alt="Photark" /></a></li>');
+	var myPhotoSwipe = Code.PhotoSwipe.attach(window.document
+			.querySelectorAll('#Gallery a'), {
+		enableMouseWheel : false,
+		enableKeyboard : false
+	});
+	myPhotoSwipe.show(0);
+}
+
+function fulllScreen() {
+	var myPhotoSwipe = Code.PhotoSwipe.attach(window.document
+			.querySelectorAll('#Gallery a'), {
+		enableMouseWheel : false,
+		enableKeyboard : false
+	});
+	myPhotoSwipe.show();
+}
+
+function scaleImageWidth(maxWidth, width, height, image) {
+	if (width > maxWidth) {
+		var ratio = maxWidth / width; // get ratio for scaling image
+		image.width = maxWidth;
+		image.height = height * ratio; // Scale height based on ratio
+
+	}
+}
+
+//Adjust UI elements according to the screen size
+function adjustScreenLayout() {
+	windowWidth = $(window).width();
+	windowHeight = $(window).height();
+	// document.getElementById('largeImage').width = windowWidth;
+	// // 3:4 is the most common aspect ratio
+	// document.getElementById('largeImage').height = windowWidth * (3 / 4);
+
+	$('#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'
+	});
+
+	$('#map_canvas').css('width', windowWidth * (7 / 8));
+	$('#map_canvas').css('height', windowHeight * (5 / 6));
+	$('#map_canvas').css('margin-left', 'auto');
+	$('#map_canvas').css('margin-right', 'auto');
+}
+
+//TODO not working
+function loadjscssfile(scriptUrl) {
+	var head = document.getElementsByTagName("head")[0];
+	script = document.createElement('script');
+	script.type = 'text/javascript';
+	script.src = scriptUrl;
+	head.appendChild(script);
+}
+
+function validate(variable) {
+	if (variable == "") {
+		return 'undifined';
+	} else {
+		return variable;
+	}
+}
+
+//returns system date
+function getCurrentDate() {
+	var currentTime = new Date()
+	var month = currentTime.getMonth() + 1
+	var day = currentTime.getDate()
+	var year = currentTime.getFullYear()
+	return (month + "/" + day + "/" + year);
+}
+
+//returns system time
+function getCurrentTime() {
+	var time = "";
+	var currentTime = new Date();
+	var hours = currentTime.getHours();
+	var minutes = currentTime.getMinutes();
+	if (minutes < 10) {
+		minutes = "0" + minutes;
+	}
+	var h;
+	if (hours > 12) {
+		h = hours - 12;
+	}
+	if (h < 10) {
+		h = '0' + h;
+	}
+	time += (h + ":" + minutes + " ");
+	if (hours > 11) {
+		time += ("PM");
+	} else {
+		time += ("AM");
+	}
+	return time;
+}
+
+//Check whether a data network is available
+function checkNetwork() {
+	var networkState = navigator.network.connection.type;
+	if (networkState == Connection.NONE) {
+		alert("Cannot connect to internet. Some functionalities may not available");
+	}	
+}
+
+function onHomeButtonClicked(){
+	$("#largeImage").attr("src","images/home.png");
+	
+	$('#imageInfoButton').hide();
+	$('#photoTagButton').hide();
+	$('#deleteButton').hide();
+	$('#homeButton').hide();
+	$('#editDataButton').hide();
+	
+	$('#captureButton').show();
+	$('#galleryButton').show();
+	$('#webAlbumButton').show();
+	$('#searchButton').show();
+	$('#helpButton').show();
+}
+
+function onImageUpdated(){
+	$('#imageInfoButton').show();
+	$('#photoTagButton').show();
+	$('#homeButton').show();
+	$('#deleteButton').show();
+	$('#editDataButton').show();
+	$('#searchButton').show();
+	
+	$('#captureButton').hide();
+	$('#galleryButton').hide();
+	$('#webAlbumButton').hide();
+	$('#toolbar_message').hide();
+	$('#helpButton').hide();
+	$('#searchButton').hide();
+}