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 bh...@apache.org on 2012/08/13 09:18:46 UTC

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

Author: bhargav
Date: Mon Aug 13 09:18:46 2012
New Revision: 1372337

URL: http://svn.apache.org/viewvc?rev=1372337&view=rev
Log:
Adding the modified Assets folder. Picasa Functionality acheived and facebook.js modified to suit uniform UI

Added:
    incubator/photark/mobile/trunk/assets/www/childbrowser/
    incubator/photark/mobile/trunk/assets/www/childbrowser/icon_arrow_left.png   (with props)
    incubator/photark/mobile/trunk/assets/www/childbrowser/icon_arrow_right.png   (with props)
    incubator/photark/mobile/trunk/assets/www/childbrowser/icon_close.png   (with props)
    incubator/photark/mobile/trunk/assets/www/scripts/childbrowser.js
    incubator/photark/mobile/trunk/assets/www/scripts/flickr.js
    incubator/photark/mobile/trunk/assets/www/scripts/jquery.md5.js
    incubator/photark/mobile/trunk/assets/www/scripts/picasa.js
    incubator/photark/mobile/trunk/assets/www/scripts/sha1.js
Modified:
    incubator/photark/mobile/trunk/assets/www/index.html
    incubator/photark/mobile/trunk/assets/www/scripts/facebook.js

Added: incubator/photark/mobile/trunk/assets/www/childbrowser/icon_arrow_left.png
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/childbrowser/icon_arrow_left.png?rev=1372337&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/photark/mobile/trunk/assets/www/childbrowser/icon_arrow_left.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/photark/mobile/trunk/assets/www/childbrowser/icon_arrow_right.png
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/childbrowser/icon_arrow_right.png?rev=1372337&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/photark/mobile/trunk/assets/www/childbrowser/icon_arrow_right.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/photark/mobile/trunk/assets/www/childbrowser/icon_close.png
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/childbrowser/icon_close.png?rev=1372337&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/photark/mobile/trunk/assets/www/childbrowser/icon_close.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/photark/mobile/trunk/assets/www/index.html
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/index.html?rev=1372337&r1=1372336&r2=1372337&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/index.html (original)
+++ incubator/photark/mobile/trunk/assets/www/index.html Mon Aug 13 09:18:46 2012
@@ -11,18 +11,36 @@
 		type="text/css" />
 		<link href="css/custom.css" rel="stylesheet"
 		type="text/css" />
+		<style>
+			.more
+			{
+				text-align:right;
+			}
+		</style>
 		<script type="text/javascript" src="scripts/jquery-1.7.2.min.js"></script>
 		<script type="text/javascript" src="scripts/jquery.mobile-1.1.0.min.js"></script>
 		<script type="text/javascript" src="scripts/mobiscroll-2.0.full.min.js"></script>
 		<script type="text/javascript" charset="utf-8" src="scripts/cordova-1.8.0.js" ></script>
 		<script type="text/javascript" charset="utf-8" src="scripts/klass.min.js"></script>
 		<script type="text/javascript" charset="utf-8" src="scripts/code.photoswipe-3.0.5.min.js"></script>
+		<!--For Facebook Implementation Start-->
 		<script type="text/javascript" src="scripts/cdv-plugin-fb-connect.js"></script><!--Facebook Connect Plugin-->
 		<script type="text/javascript" src="scripts/facebook_js_sdk.js"></script><!--Facebook JS SDK-->
+		<script type="text/javascript" src="scripts/facebook.js"></script><!--Facebook Implementation-->
+		<!--For Facebook Implementation End-->
 		<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/dataAccess.js"></script>
 		<script type="text/javascript" charset="utf-8" src="scripts/search.js"></script>
+		<!--For Flickr Implementation Start-->
+		<script type="text/javascript" charset="utf-8" src="scripts/childbrowser.js"></script>
+		<script type="text/javascript" charset="utf-8" src="scripts/jquery.md5.js"></script>
+		<script type="text/javascript" charset="utf-8" src="scripts/sha1.js"></script>
+		<script type="text/javascript" charset="utf-8" src="scripts/flickr.js"></script>
+		<!--For Flickr Implementation End-->
+		<!--For Picasa Implementation Start-->
+		<script type="text/javascript" charset="utf-8" src="scripts/picasa.js"></script>
+		<!--For Picasa Implementation End-->
 		<script type="text/javascript" charset="utf-8" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true"></script>
 		<script type="text/javascript" charset="utf-8" src="scripts/geoLocation.js" ></script>
 		<script type="text/javascript" charset="utf-8" src="scripts/jquery.ui.map.js"></script>
@@ -378,15 +396,22 @@
 			</div>
 			<!-- Page Header End -->
 			<!-- Content Start-->
-			<div id="a" data-role="content" align="center">
-				<h3>Facebook</h3>
-				<a href="#" data-role="button" onclick="login()"
-				data-theme="b">Login</a>
-				<a href="#" data-role="button" onclick="me(0)"
-				data-theme="b">Get Photos</a>
-				<div id="data">loading ...</div>
-				
+				<!--Facebook Start-->
+				<div data-role="fieldcontain" class="switch">
+					<fieldset data-role="controlgroup">
+						<label for="facebookSwitch">Facebook</label>
+						<select name="facebookSwitch" id="facebookSwitch" data-theme="a" data-role="slider" data-mini="true">
+							<option value="off" selected="true">
+									Off
+							</option>
+							<option value="on">
+									On
+							</option>
+						</select>
+					</fieldset>
 				</div>
+				<div id="facebook"></div>
+				<!--Facebook End-->
 				<hr />
 				<!--Picasa Begin-->
 				<div data-role="fieldcontain" class="switch">
@@ -406,7 +431,20 @@
 				<hr />
 				<!--Picasa End-->
 				<!--Flickr Begin-->
-				
+				<div data-role="fieldcontain" class="switch">
+					<fieldset data-role="controlgroup">
+						<label for="flickrSwitch">Flickr</label>
+						<select name="flickrSwitch" id="flickrSwitch" data-theme="a" data-role="slider" data-mini="true">
+							<option value="off" selected="true">
+								Off
+							</option>
+							<option value="on">
+								On
+							</option>
+						</select>
+					</fieldset>
+				</div>
+				<div id="flickr"></div>
 				<!--Flickr End-->
 			<!-- Content End -->
 			<!-- Page Footer Start -->

Added: incubator/photark/mobile/trunk/assets/www/scripts/childbrowser.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/childbrowser.js?rev=1372337&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/childbrowser.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/childbrowser.js Mon Aug 13 09:18:46 2012
@@ -0,0 +1,89 @@
+/*
+ * cordova is available under *either* the terms of the modified BSD license *or* the
+ * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
+ *
+ * Copyright (c) 2005-2010, Nitobi Software Inc.
+ * Copyright (c) 2011, IBM Corporation
+ */
+
+/**
+ * Constructor
+ */
+function ChildBrowser() {
+};
+
+ChildBrowser.CLOSE_EVENT = 0;
+ChildBrowser.LOCATION_CHANGED_EVENT = 1;
+
+/**
+ * Display a new browser with the specified URL.
+ * This method loads up a new web view in a dialog.
+ *
+ * @param url           The url to load
+ * @param options       An object that specifies additional options
+ */
+ChildBrowser.prototype.showWebPage = function(url, options) {
+    if (options === null || options === "undefined") {
+        var options = new Object();
+        options.showLocationBar = true;
+    }
+    cordova.exec(this._onEvent, this._onError, "ChildBrowser", "showWebPage", [url, options]);
+};
+
+/**
+ * Close the browser opened by showWebPage.
+ */
+ChildBrowser.prototype.close = function() {
+    cordova.exec(null, null, "ChildBrowser", "close", []);
+};
+
+/**
+ * Display a new browser with the specified URL.
+ * This method starts a new web browser activity.
+ *
+ * @param url           The url to load
+ * @param usecordova   Load url in cordova webview [optional]
+ */
+ChildBrowser.prototype.openExternal = function(url, usecordova) {
+    if (usecordova === true) {
+        navigator.app.loadUrl(url);
+    }
+    else {
+        cordova.exec(null, null, "ChildBrowser", "openExternal", [url, usecordova]);
+    }
+};
+
+/**
+ * Method called when the child browser has an event.
+ */
+ChildBrowser.prototype._onEvent = function(data) {
+    if (data.type == ChildBrowser.CLOSE_EVENT && typeof window.plugins.childBrowser.onClose === "function") {
+        window.plugins.childBrowser.onClose();
+    }
+    if (data.type == ChildBrowser.LOCATION_CHANGED_EVENT && typeof window.plugins.childBrowser.onLocationChange === "function") {
+        window.plugins.childBrowser.onLocationChange(data.location);
+    }
+};
+
+/**
+ * Method called when the child browser has an error.
+ */
+ChildBrowser.prototype._onError = function(data) {
+    if (typeof window.plugins.childBrowser.onError === "function") {
+        window.plugins.childBrowser.onError(data);
+    }
+};
+
+/**
+ * Maintain API consistency with iOS
+ */
+ChildBrowser.install = function(){
+    return window.plugins.childBrowser;
+};
+
+/**
+ * Load ChildBrowser
+ */
+cordova.addConstructor(function() {
+    cordova.addPlugin("childBrowser", new ChildBrowser());
+});
\ No newline at end of file

Modified: incubator/photark/mobile/trunk/assets/www/scripts/facebook.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/facebook.js?rev=1372337&r1=1372336&r2=1372337&view=diff
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/facebook.js (original)
+++ incubator/photark/mobile/trunk/assets/www/scripts/facebook.js Mon Aug 13 09:18:46 2012
@@ -1,9 +1,10 @@
+
 if ((typeof cordova == 'undefined') && (typeof Cordova == 'undefined')) alert('Cordova variable does not exist. Check that you have included cordova.js correctly');
 if (typeof CDV == 'undefined') alert('CDV variable does not exist. Check that you have included cdv-plugin-fb-connect.js correctly');
 if (typeof FB == 'undefined') alert('FB variable does not exist. Check that you have included the Facebook JS SDK file.');
 					
 FB.Event.subscribe('auth.login', function(response) {
-	/*alert('auth.login event');*/
+	//alert('auth.login event');
 });
 					
 FB.Event.subscribe('auth.logout', function(response) {
@@ -15,7 +16,7 @@ FB.Event.subscribe('auth.sessionChange',
 });
 					
 FB.Event.subscribe('auth.statusChange', function(response) {
-		   /*alert('auth.statusChange event');*/
+		   //alert('auth.statusChange event');
 });
 					
 function getLoginStatus() {
@@ -32,14 +33,18 @@ function getLoginStatus() {
 }
 var fdata;
 var count=0;
-function me(a) {
-	FB.api('/me/photos?limit=8&offset='+a, { fields: 'id, name, picture' },  function(response) {
+function me() {
+	if(count===0)
+	{
+		login();
+	}
+	FB.api('/me/photos?limit=8&offset='+count, { fields: 'id, name, picture' },  function(response) {
 	if (response.error) {
 	alert(JSON.stringify(response.error));
 	} 
 	else 
 	{
-			var data = document.getElementById('data');
+			var data = document.getElementById('facebook');
 			$('#facebookMore').remove();
 			fdata=response.data;
 			response.data.forEach(function(item) {
@@ -55,27 +60,43 @@ function me(a) {
 				data.appendChild(d);
 			});
 	}
-	count++;
-	$('#data').append($('<a id="facebookMore" onclick="me(count*8)" />').text('More..'));
+	count=count+8;
+	$('#facebook').append($('<a id="facebookMore" class="more" data-role="button" data-icon="forward" onclick="me()" />').text('More..'));
    });
 }         
 function login() {
 	FB.login(
 		function(response) {
-		 if (response.session) {
-			 alert('logged in');
-		} else {
-			 /*alert('not logged in');*/
-		}
-	 },
-	 { scope: "user_photos" }
- );
+			if (response.session) {
+				alert('logged in');
+			} 
+			else {
+				//alert('not logged in');
+			}
+		},
+		{ scope: "user_photos" }
+	);
+	//me();
 }            
 document.addEventListener('deviceready', function() {
 						  try {
 							  FB.init({ appId: "423746790989627", nativeInterface: CDV.FB, useCachedDialogs: false });
-							  document.getElementById('data').innerHTML = "";
 						  } catch (e) {
 							  alert(e);
 						  }
- }, false);
\ No newline at end of file
+ }, false);
+$(document).ready(function(){
+	$('#facebookSwitch').off('change');
+	$("#facebook").empty();
+	$('#facebookSwitch').on('change', function()
+	{
+		if($(this).val()==="off")
+		{
+			$("#facebook").empty();
+		}
+		else
+		{
+			me();
+		}
+	});
+});
\ No newline at end of file

Added: incubator/photark/mobile/trunk/assets/www/scripts/flickr.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/flickr.js?rev=1372337&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/flickr.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/flickr.js Mon Aug 13 09:18:46 2012
@@ -0,0 +1,147 @@
+var mini_token="";
+var token='';
+var api_key="29faca132af9e790d4479d374871db9d";
+var secret="2038072bc6c01e24";
+var oath_token='';
+var oauth_token_secret='';
+var page=0;
+function get_userphotos(oauth_token,oauth_token_secret)
+{
+	page=page+1;
+	var foo = new Date; // Generic JS date object
+    var unixtime_ms = foo.getTime(); // Returns milliseconds since the epoch
+    var unixtime = parseInt(unixtime_ms / 1000);
+	var method='flickr.people.getPhotos';
+	var oauth_nonce=$.md5(unixtime.toString()+Math.floor((Math.random()*40)+1).toString());
+	console.log(oauth_nonce);
+	var baseSign = "GET" + "&" + encodeURIComponent("http://api.flickr.com/services/rest").toString() + "&"+encodeURIComponent("content_type") + "%3D" + encodeURIComponent('1')
+     + "%26"+ encodeURIComponent("format") + "%3D" + encodeURIComponent('json')
+     + "%26"
+	 + encodeURIComponent("method") + "%3D" + encodeURIComponent(method)
+	 + "%26"+ encodeURIComponent("nojsoncallback") + "%3D" + encodeURIComponent('1')
+	 + "%26"+ encodeURIComponent("oauth_consumer_key") + "%3D" + encodeURIComponent(api_key)
+     + "%26"
+     + encodeURIComponent("oauth_nonce") + "%3D" + encodeURIComponent(oauth_nonce)
+     + "%26"
+     + encodeURIComponent("oauth_signature_method") + "%3D" + encodeURIComponent("HMAC-SHA1")
+     + "%26"
+     + encodeURIComponent("oauth_timestamp") + "%3D" + encodeURIComponent(unixtime)
+	 + "%26"
+     + encodeURIComponent("oauth_token") + "%3D" + encodeURIComponent(oauth_token)
+     + "%26"
+     + encodeURIComponent("oauth_version") + "%3D" + encodeURIComponent("1.0")+ "%26"
+     + encodeURIComponent("page") + "%3D" + encodeURIComponent(page)+ "%26"
+     + encodeURIComponent("per_page") + "%3D" + encodeURIComponent('8')+ "%26"
+     + encodeURIComponent("user_id") + "%3D" + encodeURIComponent('me');
+	console.log(baseSign);
+	var secret_key=secret+'&'+oauth_token_secret;
+	console.log(secret_key);
+	var oauth_signature = encodeURIComponent(b64_hmac_sha1(secret_key, baseSign)+'=');
+	console.log(oauth_signature);
+	var url='http://api.flickr.com/services/rest?nojsoncallback=1&oauth_nonce='+oauth_nonce+'&format=json&oauth_consumer_key='+api_key+'&oauth_timestamp='+unixtime+'&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_token='+oauth_token+'&user_id=me'+'&content_type=1'+'&per_page=8'+'&page='+page+'&oauth_signature='+oauth_signature+'&method='+method;
+	console.log(url);
+	$.ajax({
+		url:url,
+		success: function(data) {
+					$('#flickrMore').remove();
+					console.log(data);
+					photos_page_max = data.photos.pages;
+					console.log(photos_page_max);
+					data.photos.photo.forEach(function(item){
+						if(item.title===undefined)
+						{
+							$('#flickr').append('<img src="http://farm'+item.farm+'.staticflickr.com/'+item.server+'/'+item.id+'_'+item.secret+'_t.jpg" /><br />No Caption<br />');
+						}
+						else
+						{
+							$('#flickr').append('<img src="http://farm'+item.farm+'.staticflickr.com/'+item.server+'/'+item.id+'_'+item.secret+'_t.jpg" /><br />'+item.title+'<br />');
+						}
+					});
+					console.log(page);
+					console.log(photos_page_max);
+					if(photos_page_max!=page)
+					{
+						$('#flickr').append($('<a id="flickrMore" class="more" data-role="button" data-icon="forward" onclick="get_userphotos(oauth_token,oauth_token_secret)" />').text('More..'));
+					}
+				},
+		error: function( error ){
+
+				    	// Log any error.
+						alert("ERROR:"+error.responseText);
+				    	console.log( "ERROR:"+error.responseText,error);
+
+				},
+		async:false
+	});
+}
+function oauth_get(auth_token)
+{
+	method = 'flickr.auth.oauth.getAccessToken';
+	sig_string=secret+'api_key'+api_key+'auth_token'+auth_token+'method'+method;
+	console.log(sig_string);
+	api_sig=$.md5(sig_string);
+	url='http://api.flickr.com/services/rest/'+'?method='+method+'&api_key='+api_key+'&auth_token='+auth_token+'&api_sig='+api_sig;
+	console.log(url); 
+	$.ajax({
+		url:url,
+		success: function(data) {
+					console.log(data);
+					oauth_token = $(data).find("access_token").attr('oauth_token');
+					oauth_token_secret = $(data).find("access_token").attr('oauth_token_secret');
+					console.log(oauth_token);
+					console.log(oauth_token_secret);
+				},
+		async:false
+	});
+	console.log(oauth_token);
+	console.log(oauth_token_secret);
+	get_userphotos(oauth_token,oauth_token_secret);
+}
+function mini_token_get()
+{
+	mini_token=prompt("What is the provided Flickr minitoken?");
+	if(mini_token.length===9)
+	{
+		var method = 'flickr.auth.getFullToken';
+		var sig_string=secret+'api_key'+api_key+'method'+method+'mini_token';
+		sig_string+=mini_token;
+		console.log(sig_string);
+		var api_sig=$.md5(sig_string);
+		var url='http://api.flickr.com/services/rest/'+'?method='+method+'&api_key='+api_key+'&mini_token='+mini_token+'&api_sig='+api_sig;//+'&format=json&nojsoncallback=1';
+		var full_token='';
+		console.log(url); 
+		$.ajax({
+			url:url,
+			success: function(data) {
+						console.log(data);
+						full_token = $(data).find("token").text();
+						console.log(full_token);
+					},
+			async:   false
+		});
+		console.log(full_token);
+		oauth_get(full_token);
+	}
+	else
+	{
+		alert("Enter correct Mini-Token");
+		mini_token_get();
+	}
+}
+
+$(document).ready(function() {
+	$('#flickrSwitch').off('change');
+	$("#flickr").empty();
+	$('#flickrSwitch').on('change', function()
+	{
+		if($(this).val()==="off")
+		{
+			$("#flickr").empty();
+		}
+		else
+		{
+			window.plugins.childBrowser.showWebPage("http://www.flickr.com/auth-72157630235879408", { showLocationBar: true });
+			window.plugins.childBrowser.onClose=mini_token_get;
+		}
+	});
+});
\ No newline at end of file

Added: incubator/photark/mobile/trunk/assets/www/scripts/jquery.md5.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/jquery.md5.js?rev=1372337&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/jquery.md5.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/jquery.md5.js Mon Aug 13 09:18:46 2012
@@ -0,0 +1,269 @@
+/*
+ * jQuery MD5 Plugin 1.2.1
+ * https://github.com/blueimp/jQuery-MD5
+ *
+ * Copyright 2010, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://creativecommons.org/licenses/MIT/
+ * 
+ * Based on
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
+ * Digest Algorithm, as defined in RFC 1321.
+ * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
+ * Distributed under the BSD License
+ * See http://pajhome.org.uk/crypt/md5 for more info.
+ */
+
+/*jslint bitwise: true */
+/*global unescape, jQuery */
+
+(function ($) {
+    'use strict';
+
+    /*
+    * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+    * to work around bugs in some JS interpreters.
+    */
+    function safe_add(x, y) {
+        var lsw = (x & 0xFFFF) + (y & 0xFFFF),
+            msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+        return (msw << 16) | (lsw & 0xFFFF);
+    }
+
+    /*
+    * Bitwise rotate a 32-bit number to the left.
+    */
+    function bit_rol(num, cnt) {
+        return (num << cnt) | (num >>> (32 - cnt));
+    }
+
+    /*
+    * These functions implement the four basic operations the algorithm uses.
+    */
+    function md5_cmn(q, a, b, x, s, t) {
+        return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
+    }
+    function md5_ff(a, b, c, d, x, s, t) {
+        return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
+    }
+    function md5_gg(a, b, c, d, x, s, t) {
+        return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
+    }
+    function md5_hh(a, b, c, d, x, s, t) {
+        return md5_cmn(b ^ c ^ d, a, b, x, s, t);
+    }
+    function md5_ii(a, b, c, d, x, s, t) {
+        return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
+    }
+
+    /*
+    * Calculate the MD5 of an array of little-endian words, and a bit length.
+    */
+    function binl_md5(x, len) {
+        /* append padding */
+        x[len >> 5] |= 0x80 << ((len) % 32);
+        x[(((len + 64) >>> 9) << 4) + 14] = len;
+
+        var i, olda, oldb, oldc, oldd,
+            a =  1732584193,
+            b = -271733879,
+            c = -1732584194,
+            d =  271733878;
+
+        for (i = 0; i < x.length; i += 16) {
+            olda = a;
+            oldb = b;
+            oldc = c;
+            oldd = d;
+
+            a = md5_ff(a, b, c, d, x[i],       7, -680876936);
+            d = md5_ff(d, a, b, c, x[i +  1], 12, -389564586);
+            c = md5_ff(c, d, a, b, x[i +  2], 17,  606105819);
+            b = md5_ff(b, c, d, a, x[i +  3], 22, -1044525330);
+            a = md5_ff(a, b, c, d, x[i +  4],  7, -176418897);
+            d = md5_ff(d, a, b, c, x[i +  5], 12,  1200080426);
+            c = md5_ff(c, d, a, b, x[i +  6], 17, -1473231341);
+            b = md5_ff(b, c, d, a, x[i +  7], 22, -45705983);
+            a = md5_ff(a, b, c, d, x[i +  8],  7,  1770035416);
+            d = md5_ff(d, a, b, c, x[i +  9], 12, -1958414417);
+            c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
+            b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
+            a = md5_ff(a, b, c, d, x[i + 12],  7,  1804603682);
+            d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
+            c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
+            b = md5_ff(b, c, d, a, x[i + 15], 22,  1236535329);
+
+            a = md5_gg(a, b, c, d, x[i +  1],  5, -165796510);
+            d = md5_gg(d, a, b, c, x[i +  6],  9, -1069501632);
+            c = md5_gg(c, d, a, b, x[i + 11], 14,  643717713);
+            b = md5_gg(b, c, d, a, x[i],      20, -373897302);
+            a = md5_gg(a, b, c, d, x[i +  5],  5, -701558691);
+            d = md5_gg(d, a, b, c, x[i + 10],  9,  38016083);
+            c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
+            b = md5_gg(b, c, d, a, x[i +  4], 20, -405537848);
+            a = md5_gg(a, b, c, d, x[i +  9],  5,  568446438);
+            d = md5_gg(d, a, b, c, x[i + 14],  9, -1019803690);
+            c = md5_gg(c, d, a, b, x[i +  3], 14, -187363961);
+            b = md5_gg(b, c, d, a, x[i +  8], 20,  1163531501);
+            a = md5_gg(a, b, c, d, x[i + 13],  5, -1444681467);
+            d = md5_gg(d, a, b, c, x[i +  2],  9, -51403784);
+            c = md5_gg(c, d, a, b, x[i +  7], 14,  1735328473);
+            b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
+
+            a = md5_hh(a, b, c, d, x[i +  5],  4, -378558);
+            d = md5_hh(d, a, b, c, x[i +  8], 11, -2022574463);
+            c = md5_hh(c, d, a, b, x[i + 11], 16,  1839030562);
+            b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
+            a = md5_hh(a, b, c, d, x[i +  1],  4, -1530992060);
+            d = md5_hh(d, a, b, c, x[i +  4], 11,  1272893353);
+            c = md5_hh(c, d, a, b, x[i +  7], 16, -155497632);
+            b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
+            a = md5_hh(a, b, c, d, x[i + 13],  4,  681279174);
+            d = md5_hh(d, a, b, c, x[i],      11, -358537222);
+            c = md5_hh(c, d, a, b, x[i +  3], 16, -722521979);
+            b = md5_hh(b, c, d, a, x[i +  6], 23,  76029189);
+            a = md5_hh(a, b, c, d, x[i +  9],  4, -640364487);
+            d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
+            c = md5_hh(c, d, a, b, x[i + 15], 16,  530742520);
+            b = md5_hh(b, c, d, a, x[i +  2], 23, -995338651);
+
+            a = md5_ii(a, b, c, d, x[i],       6, -198630844);
+            d = md5_ii(d, a, b, c, x[i +  7], 10,  1126891415);
+            c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
+            b = md5_ii(b, c, d, a, x[i +  5], 21, -57434055);
+            a = md5_ii(a, b, c, d, x[i + 12],  6,  1700485571);
+            d = md5_ii(d, a, b, c, x[i +  3], 10, -1894986606);
+            c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
+            b = md5_ii(b, c, d, a, x[i +  1], 21, -2054922799);
+            a = md5_ii(a, b, c, d, x[i +  8],  6,  1873313359);
+            d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
+            c = md5_ii(c, d, a, b, x[i +  6], 15, -1560198380);
+            b = md5_ii(b, c, d, a, x[i + 13], 21,  1309151649);
+            a = md5_ii(a, b, c, d, x[i +  4],  6, -145523070);
+            d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
+            c = md5_ii(c, d, a, b, x[i +  2], 15,  718787259);
+            b = md5_ii(b, c, d, a, x[i +  9], 21, -343485551);
+
+            a = safe_add(a, olda);
+            b = safe_add(b, oldb);
+            c = safe_add(c, oldc);
+            d = safe_add(d, oldd);
+        }
+        return [a, b, c, d];
+    }
+
+    /*
+    * Convert an array of little-endian words to a string
+    */
+    function binl2rstr(input) {
+        var i,
+            output = '';
+        for (i = 0; i < input.length * 32; i += 8) {
+            output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
+        }
+        return output;
+    }
+
+    /*
+    * Convert a raw string to an array of little-endian words
+    * Characters >255 have their high-byte silently ignored.
+    */
+    function rstr2binl(input) {
+        var i,
+            output = [];
+        output[(input.length >> 2) - 1] = undefined;
+        for (i = 0; i < output.length; i += 1) {
+            output[i] = 0;
+        }
+        for (i = 0; i < input.length * 8; i += 8) {
+            output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
+        }
+        return output;
+    }
+
+    /*
+    * Calculate the MD5 of a raw string
+    */
+    function rstr_md5(s) {
+        return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
+    }
+
+    /*
+    * Calculate the HMAC-MD5, of a key and some data (raw strings)
+    */
+    function rstr_hmac_md5(key, data) {
+        var i,
+            bkey = rstr2binl(key),
+            ipad = [],
+            opad = [],
+            hash;
+        ipad[15] = opad[15] = undefined;                        
+        if (bkey.length > 16) {
+            bkey = binl_md5(bkey, key.length * 8);
+        }
+        for (i = 0; i < 16; i += 1) {
+            ipad[i] = bkey[i] ^ 0x36363636;
+            opad[i] = bkey[i] ^ 0x5C5C5C5C;
+        }
+        hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
+        return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
+    }
+
+    /*
+    * Convert a raw string to a hex string
+    */
+    function rstr2hex(input) {
+        var hex_tab = '0123456789abcdef',
+            output = '',
+            x,
+            i;
+        for (i = 0; i < input.length; i += 1) {
+            x = input.charCodeAt(i);
+            output += hex_tab.charAt((x >>> 4) & 0x0F) +
+                hex_tab.charAt(x & 0x0F);
+        }
+        return output;
+    }
+
+    /*
+    * Encode a string as utf-8
+    */
+    function str2rstr_utf8(input) {
+        return unescape(encodeURIComponent(input));
+    }
+
+    /*
+    * Take string arguments and return either raw or hex encoded strings
+    */
+    function raw_md5(s) {
+        return rstr_md5(str2rstr_utf8(s));
+    }
+    function hex_md5(s) {
+        return rstr2hex(raw_md5(s));
+    }
+    function raw_hmac_md5(k, d) {
+        return rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d));
+    }
+    function hex_hmac_md5(k, d) {
+        return rstr2hex(raw_hmac_md5(k, d));
+    }
+    
+    $.md5 = function (string, key, raw) {
+        if (!key) {
+            if (!raw) {
+                return hex_md5(string);
+            } else {
+                return raw_md5(string);
+            }
+        }
+        if (!raw) {
+            return hex_hmac_md5(key, string);
+        } else {
+            return raw_hmac_md5(key, string);
+        }
+    };
+    
+}(typeof jQuery === 'function' ? jQuery : this));
\ No newline at end of file

Added: incubator/photark/mobile/trunk/assets/www/scripts/picasa.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/picasa.js?rev=1372337&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/picasa.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/picasa.js Mon Aug 13 09:18:46 2012
@@ -0,0 +1,94 @@
+/*Picasa Connect*/
+var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/auth";
+var GOOGLE_TOKEN_URL = "https://accounts.google.com/o/oauth2/token";
+var GOOGLE_CLIENT_ID = "694561233653-n00sia1lg2cces16024ac0nfuo37ulng.apps.googleusercontent.com";
+var GOOGLE_CLIENT_SECRET='qaMMEsUoGJz9OlB0p3yCc0xU';
+var PICASA_SCOPE = "https://picasaweb.google.com/data/";
+var redirect_uri='urn:ietf:wg:oauth:2.0:oob';
+var code='';
+var access_token='';
+var refresh_token='';
+var start=-7;
+function listing_photos(access_token,refresh_token){
+	start=start+8;
+	var photos_url='https://picasaweb.google.com/data/feed/api/user/default?kind=photo&thumbsize=104&max-results=8&start-index='+start+'&access_token='+access_token+'&fields=link[@rel="next"],entry(summary,media:group(media:thumbnail))';
+	console.log(photos_url);
+	$.ajax({
+		type: "GET",
+		url:photos_url,
+		contentType: 'application/x-www-form-urlencoded',
+		success: function(data) {
+					$('#picasaMore').remove();
+					$(data).find("entry").each(function()
+					{
+						if($(this).find('summary').text()==='')
+						{
+							$('#picasa').append('<img src="'+$(this).find('thumbnail').attr('url')+'" /><br />No Caption<br />');
+						}
+						else
+						{
+							console.log($(this).find('thumbnail').attr('url')+'----'+$(this).find('summary').text());
+							$('#picasa').append('<img src="'+$(this).find('thumbnail').attr('url')+'" /><br />'+$(this).find('summary').text()+'<br />');
+						}
+					});
+					if($(data).find('link').attr('rel')!=undefined)
+					{
+						console.log($(data).find('link').attr('rel'));
+						$('#picasa').append($('<a id="picasaMore" class="more" data-role="button" data-icon="forward" onclick="listing_photos(access_token,refresh_token);" />').text('More..'));
+					}
+				},
+		error: function( error ){
+						// Log any error.
+						alert("ERROR:"+error.responseText);
+				    	console.log( "ERROR:"+error.responseText);
+						alert(JSON.stringify(error));
+				},
+		async:false
+	});
+}
+function get_accesstoken(){
+	code=prompt('Paste the authorization code received here.');
+	console.log(code);
+	var token_url=GOOGLE_TOKEN_URL;
+	var token_data='code='+encodeURIComponent(code)+'&redirect_uri='+encodeURIComponent(redirect_uri)+'&client_id='+encodeURIComponent(GOOGLE_CLIENT_ID)+'&scope='+'&client_secret='+encodeURIComponent(GOOGLE_CLIENT_SECRET)+'&grant_type=authorization_code';
+	console.log(token_url);
+	$.ajax({
+		type: "POST",
+		url:token_url,
+		contentType: 'application/x-www-form-urlencoded',
+		data: token_data,
+		success: function(data) {
+					console.log(data);
+					access_token=(data).access_token;
+					refresh_token=(data).refresh_token;
+					console.log(access_token);
+					console.log(refresh_token);
+					listing_photos(access_token,refresh_token);
+				},
+		error: function( error ){
+						// Log any error.
+						alert("ERROR:"+error.responseText);
+				    	console.log( "ERROR:"+error.responseText);
+						alert(JSON.stringify(error));
+				},
+		async:false
+	});
+}
+$(document).ready(function() {
+	$('#picasaSwitch').off('change');
+	$("#picasa").empty();
+	$('#picasaSwitch').on('change', function()
+	{
+		if($(this).val()==="off")
+		{
+			$("#picasa").empty();
+		}
+		else
+		{
+			var login_url=GOOGLE_AUTH_URL+'?scope='+PICASA_SCOPE+'&redirect_uri='+redirect_uri+'&response_type=code&client_id='+GOOGLE_CLIENT_ID+'&approval_prompt=force'+'&access_type=offline';
+			console.log(login_url);
+			window.plugins.childBrowser.showWebPage(login_url, { showLocationBar: true });
+			window.plugins.childBrowser.onClose=get_accesstoken;
+		}
+	});
+});

Added: incubator/photark/mobile/trunk/assets/www/scripts/sha1.js
URL: http://svn.apache.org/viewvc/incubator/photark/mobile/trunk/assets/www/scripts/sha1.js?rev=1372337&view=auto
==============================================================================
--- incubator/photark/mobile/trunk/assets/www/scripts/sha1.js (added)
+++ incubator/photark/mobile/trunk/assets/www/scripts/sha1.js Mon Aug 13 09:18:46 2012
@@ -0,0 +1,157 @@
+/*
+ * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
+ * in FIPS PUB 180-1
+ * Version 2.1 Copyright Paul Johnston 2000 - 2002.
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
+ * Distributed under the BSD License
+ * See http://pajhome.org.uk/crypt/md5 for details.
+ */
+
+var hexcase = 0; 
+var b64pad  = ""; 
+var chrsz   = 8; 
+
+function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
+function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
+function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
+function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
+function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
+function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
+
+function sha1_vm_test()
+{
+  return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
+}
+
+function core_sha1(x, len)
+{
+  x[len >> 5] |= 0x80 << (24 - len % 32);
+  x[((len + 64 >> 9) << 4) + 15] = len;
+
+  var w = Array(80);
+  var a =  1732584193;
+  var b = -271733879;
+  var c = -1732584194;
+  var d =  271733878;
+  var e = -1009589776;
+
+  for(var i = 0; i < x.length; i += 16)
+  {
+    var olda = a;
+    var oldb = b;
+    var oldc = c;
+    var oldd = d;
+    var olde = e;
+
+    for(var j = 0; j < 80; j++)
+    {
+      if(j < 16) w[j] = x[i + j];
+      else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
+      var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), 
+                       safe_add(safe_add(e, w[j]), sha1_kt(j)));
+      e = d;
+      d = c;
+      c = rol(b, 30);
+      b = a;
+      a = t;
+    }
+
+    a = safe_add(a, olda);
+    b = safe_add(b, oldb);
+    c = safe_add(c, oldc);
+    d = safe_add(d, oldd);
+    e = safe_add(e, olde);
+  }
+  return Array(a, b, c, d, e);
+  
+}
+
+function sha1_ft(t, b, c, d)
+{
+  if(t < 20) return (b & c) | ((~b) & d);
+  if(t < 40) return b ^ c ^ d;
+  if(t < 60) return (b & c) | (b & d) | (c & d);
+  return b ^ c ^ d;
+}
+
+function sha1_kt(t)
+{
+  return (t < 20) ?  1518500249 : (t < 40) ?  1859775393 :
+         (t < 60) ? -1894007588 : -899497514;
+}  
+
+function core_hmac_sha1(key, data)
+{
+  var bkey = str2binb(key);
+  if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
+
+  var ipad = Array(16), opad = Array(16);
+  for(var i = 0; i < 16; i++) 
+  {
+    ipad[i] = bkey[i] ^ 0x36363636;
+    opad[i] = bkey[i] ^ 0x5C5C5C5C;
+  }
+
+  var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
+  return core_sha1(opad.concat(hash), 512 + 160);
+}
+
+function safe_add(x, y)
+{
+  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
+  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+  return (msw << 16) | (lsw & 0xFFFF);
+}
+
+function rol(num, cnt)
+{
+  return (num << cnt) | (num >>> (32 - cnt));
+}
+
+function str2binb(str)
+{
+  var bin = Array();
+  var mask = (1 << chrsz) - 1;
+  for(var i = 0; i < str.length * chrsz; i += chrsz)
+    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32);
+  return bin;
+}
+
+function binb2str(bin)
+{
+  var str = "";
+  var mask = (1 << chrsz) - 1;
+  for(var i = 0; i < bin.length * 32; i += chrsz)
+    str += String.fromCharCode((bin[i>>5] >>> (24 - i%32)) & mask);
+  return str;
+}
+
+function binb2hex(binarray)
+{
+  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
+  var str = "";
+  for(var i = 0; i < binarray.length * 4; i++)
+  {
+    str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
+           hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8  )) & 0xF);
+  }
+  return str;
+}
+
+function binb2b64(binarray)
+{
+  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+  var str = "";
+  for(var i = 0; i < binarray.length * 4; i += 3)
+  {
+    var triplet = (((binarray[i   >> 2] >> 8 * (3 -  i   %4)) & 0xFF) << 16)
+                | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
+                |  ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
+    for(var j = 0; j < 4; j++)
+    {
+      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
+      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
+    }
+  }
+  return str;
+}
\ No newline at end of file