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/21 17:16:08 UTC
svn commit: r1375669 - in
/incubator/photark/mobile/trunk/assets/www/scripts: MapView.js contacts.js
dataAccess.js geoLocation.js photark_events.js search.js tagging.js utils.js
Author: prabhathp
Date: Tue Aug 21 17:16:07 2012
New Revision: 1375669
URL: http://svn.apache.org/viewvc?rev=1375669&view=rev
Log:
Added missing comments
Modified:
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/photark_events.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/scripts/MapView.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/MapView.js?rev=1375669&r1=1375668&r2=1375669&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/MapView.js (original)
+++ incubator/photark/mobile/trunk/assets/www/scripts/MapView.js Tue Aug 21 17:16:07 2012
@@ -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 {
Modified: incubator/photark/mobile/trunk/assets/www/scripts/contacts.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/contacts.js?rev=1375669&r1=1375668&r2=1375669&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/contacts.js (original)
+++ incubator/photark/mobile/trunk/assets/www/scripts/contacts.js Tue Aug 21 17:16:07 2012
@@ -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 @@ function gcsSuccess(contacts) {
$('#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") );
Modified: incubator/photark/mobile/trunk/assets/www/scripts/dataAccess.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/dataAccess.js?rev=1375669&r1=1375668&r2=1375669&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/dataAccess.js (original)
+++ incubator/photark/mobile/trunk/assets/www/scripts/dataAccess.js Tue Aug 21 17:16:07 2012
@@ -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 db;
var clause;
var result=new Array();
+//getter methods
function getNickname(){
return nickname;
@@ -58,16 +63,17 @@ 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 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 @@ function successCB() {
//Do nothing
}
+
+//gets data of a image and initialize variables
function viewData(img){
uri=img;
clearData();
@@ -123,8 +131,8 @@ function queryPeopleSuccess(tx, results)
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 @@ function insertToDB(tx) {
}
}
+//update page with loaded data
function updateHome(){
temp4="";
for (i = 0; i < tagObjectsSaved.length; i++) {
@@ -150,6 +159,7 @@ function updateHome(){
$("#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 @@ function deleteTagRecords(tx){
tx.executeSql('DELETE FROM PEOPLE WHERE URI="'+uri+'"');
}
+//remove all records with current uri
function removeFromDB(){
db.transaction(deleteRecords, errorCB, successCB);
}
Modified: incubator/photark/mobile/trunk/assets/www/scripts/geoLocation.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/geoLocation.js?rev=1375669&r1=1375668&r2=1375669&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/geoLocation.js (original)
+++ incubator/photark/mobile/trunk/assets/www/scripts/geoLocation.js Tue Aug 21 17:16:07 2012
@@ -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 @@ function onGeoError(error) {
'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 @@ function addLocation(){
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 @@ function updateLocation(){
$.mobile.changePage("#main");
}
+//reverse geocoding using google maps API
function adressToCoordinate(address) {
var loc;
var geocoder = new google.maps.Geocoder();
Modified: incubator/photark/mobile/trunk/assets/www/scripts/photark_events.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/photark_events.js?rev=1375669&r1=1375668&r2=1375669&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/photark_events.js (original)
+++ incubator/photark/mobile/trunk/assets/www/scripts/photark_events.js Tue Aug 21 17:16:07 2012
@@ -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 initilizeClickEvents() {
}
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 @@ function initializePageShowFunctions() {
// 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();
});
}
-
-
-
-
Modified: incubator/photark/mobile/trunk/assets/www/scripts/search.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/search.js?rev=1375669&r1=1375668&r2=1375669&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/search.js (original)
+++ incubator/photark/mobile/trunk/assets/www/scripts/search.js Tue Aug 21 17:16:07 2012
@@ -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 doSearch(){
function showResults(results) {
+ //clear and populate search results page
+
$("#resultGallery").html("");
$("#Gallery").html("");
@@ -110,32 +114,34 @@ function showResults(results) {
}
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) ;
+// $("#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);
- 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 "%";');
}
Modified: incubator/photark/mobile/trunk/assets/www/scripts/tagging.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/tagging.js?rev=1375669&r1=1375668&r2=1375669&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/tagging.js (original)
+++ incubator/photark/mobile/trunk/assets/www/scripts/tagging.js Tue Aug 21 17:16:07 2012
@@ -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 showDialog(e, x, y) {
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 @@ function saveTags() {
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 @@ function showTag(name, x, y) {
img.appendTo('#tagPicture');
}
+//Delete all tags associated with current photo from the database
function clearTags() {
$('<div>').simpledialog2({
mode: 'button',
@@ -127,6 +111,7 @@ function displayTagImage(uri) {
}
+//toggle UI controls
function enableTagging() {
if(!tagEnabled){
tagEnabled=true;
@@ -153,6 +138,7 @@ function addTagClicked() {
$.mobile.changePage("#photoTag");
}
+//Disable tag editing mode
function cancelTagging() {
tagObjects=new Array();
enableTagging();
Modified: incubator/photark/mobile/trunk/assets/www/scripts/utils.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/utils.js?rev=1375669&r1=1375668&r2=1375669&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/utils.js (original)
+++ incubator/photark/mobile/trunk/assets/www/scripts/utils.js Tue Aug 21 17:16:07 2012
@@ -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 @@ function reset() {
$('#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 @@ function scaleImageWidth(maxWidth, width
}
}
+//Adjust UI elements according to the screen size
function adjustScreenLayout() {
windowWidth = $(window).width();
windowHeight = $(window).height();
@@ -94,6 +97,7 @@ function adjustScreenLayout() {
$('#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 @@ function validate(variable) {
}
}
+//returns system date
function getCurrentDate() {
var currentTime = new Date()
var month = currentTime.getMonth() + 1
@@ -118,6 +123,7 @@ function getCurrentDate() {
return (month + "/" + day + "/" + year);
}
+//returns system time
function getCurrentTime() {
var time = "";
var currentTime = new Date();
@@ -142,6 +148,7 @@ function getCurrentTime() {
return time;
}
+//Check whether a data network is available
function checkNetwork() {
var networkState = navigator.network.connection.type;
if (networkState == Connection.NONE) {