Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get ready for packing this up and auto run the tests

  • Loading branch information...
commit ef5d475244c324a9100279857b16e46501e420f7 1 parent 8e36f79
Dave Johnson authored
View
3  .gitignore
@@ -1 +1,2 @@
-.DS_Store
+.DS_Store
+test/www/*.js
View
0  www/facebook.js → app/facebook.js
File renamed without changes
View
0  www/icon.png → app/icon.png
File renamed without changes
View
0  www/index.html → app/index.html
File renamed without changes
View
BIN  example/LoginWithFacebookNormal.png
Deleted file not rendered
View
BIN  example/LogoutNormal.png
Deleted file not rendered
View
289 example/index.html
@@ -1,289 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<html>
- <head>
- <!-- Change this if you want to allow scaling -->
- <meta name="viewport" content="width=default-width; user-scalable=no" />
-
- <meta http-equiv="Content-type" content="text/html; charset=utf-8">
-
- <title>GapFacebookConnect</title>
-
- <!-- iPad/iPhone specific css below, add after your main css >
- <link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="ipad.css" type="text/css" />
- <link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" />
- -->
- <!-- If you application is targeting iOS BEFORE 4.0 you MUST put json2.js from http://www.JSON.org/json2.js into your www directory and include it here -->
- <script type="text/javascript" charset="utf-8" src="phonegap.0.9.4.min.js"></script>
- <script type="text/javascript" charset="utf-8" src="FacebookConnectPlugin.js"></script>
-
- <style>
-
-* {
- -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
- /*-webkit-text-size-adjust: none; *//* prevent webkit from resizing text to fit */
- -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
- -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
-
- margin:0;
- padding:0;
-}
-
- body
- {
- background-color:#3B5998;
- color:#FFF;
- font-family: Helvetica, Verdana;
- margin-bottom:20px;
- }
-
- #loading
- {
- z-index:1;
- width:100%;
- top:200px;
- position:absolute;
- text-align:center;
- }
-
- #gbWrap
- {
- overflow:hidden;
- position:absolute;
- top:60px;
- bottom:0px;
- }
-
- .view
- {
- width:320px;
- float:left;
- clear:none;
-
- }
-
- #buttonBar
- {
- width:100%;
- top:0px;
- min-height:32px;
- background-color:#333;
- text-align:center;
- }
-
- #buttonBar img
- {
- margin:4px auto;
- }
-
- #btnLogin
- {
-
- }
-
- #btnLogOut
- {
- display:none;
- }
-
- #fbFriends li
- {
- list-style:none;
-
- height:56px;
- width:320px;
- float:left;
- clear:none;
- border-top:dashed 1px rgba(255,255,255,0.1);
- }
-
- #fbFriends li:active
- {
- background-color:rgba(255,255,255,0.5);
- }
-
- #fbFriends li img
- {
- margin:2px 12px;
- min-height:48px;
- min-width:48px;s
- }
-
- #fbFriends li span
- {
- position:relative;
- top:-12px;
- }
-
- #details
- {
- position:absolute;
- left:320px;
- height:100%;
- }
-
-
- </style>
-
- <script type="text/javascript" charset="utf-8">
-
- // If you want to prevent dragging, uncomment this section
- /*
- function preventBehavior(e)
- {
- e.preventDefault();
- };
- document.addEventListener("touchmove", preventBehavior, false);
- */
-
- var facebook = FB; // Facebook plugin object ( we create it )
- var friendsMap = {}; // map to store friend info
- var APP_ID = "126462174095513"; // replace this with your own APP_ID, this is the PhoneGap-Facebook app
-
- function onBodyLoad()
- {
- document.addEventListener("deviceready",onDeviceReady,false);
- }
-
- /* When this function is called, PhoneGap has been initialized and is ready to roll */
- function onDeviceReady()
- {
- // do your thing!
- showHideLoadingScreen(false);
- }
-
- function loginToFacebook()
- {
- facebook.initWithAppId(APP_ID);
- facebook.authorize("email","read_stream","publish_stream","offline_access");
- facebook.onLogin = onFBLogin;
- facebook.onDidNotLogin = onFBDidNotLogin;
- facebook.onLogout = onFBLogout;
- showHideLoadingScreen(true);
- }
-
- function logOutOfFacebook()
- {
- facebook.logout();
- }
-
- function showHideLoadingScreen(bShow)
- {
- document.getElementById("loading").style.display = bShow ? "block" : "none";
- }
-
- function handleOpenUrl(url)
- {
- // handleOpenUrl MUST return immediately, so we cannot do any blocking methods in here -jm
- setTimeout(
- function()
- {
- facebook.handleOpenUrl(url);
- },
- 0);
- return true;
- }
-
- function onFBLogin()
- {
-
- document.getElementById("btnLogOut").style.display = "block";
- document.getElementById("btnLogin").style.display = "none";
-
- var req = facebook.getFriends();
- req.onload = onGotFriends; // should handle errors as well
- }
-
- function onFBDidNotLogin(result)
- {
- alert("onFBDidNotLogin :: " + result.error_description);
- }
-
- function onFBLogout()
- {
- document.getElementById("btnLogOut").style.display = "none";
- document.getElementById("btnLogin").style.display = "block";
- document.getElementById("fbFriends").innerHTML = "";
- }
-
- function onGotMyInfo(evt)
- {
- var json = JSON.parse(evt.target.responseText);
-
- if(json.error)
- {
- facebook.initWithAppId(APP_ID,true);
-
- }
- else
- {
- var req = facebook.getFriends();
- req.onload = onGotFriends;
- }
- }
-
- function onGotFriends(evt)
- {
- // example friend rendering code
- var json = JSON.parse(evt.target.responseText);
-
- var listItems = [];
- var template = "<li id='FBID' onclick='showUser(\"FBID\")'><img src='https://graph.facebook.com/FBID/picture'/><span>NAME</span></li>";
- for(var n = 0, len = json.data.length; n < len; n++)
- {
- var friend = json.data[n];
- friendsMap[friend.id] = friend; // store friend info for later ( right now it will just be id:name pairs
- listItems.push(template.replace(/FBID/g,friend.id).replace(/NAME/g,friend.name));
- }
- document.getElementById("fbFriends").innerHTML = listItems.join("");
-
- showHideLoadingScreen(false);
-
- }
-
- function showUser(userId)
- {
- var message = prompt("Enter your message to post.");
-
- if(message)
- {
- // this requires 'publish_stream' permission
- var req = facebook.getGraphRequest(userId + "/feed",{message:message});
- req.onload = function(evt)
- {
- alert(evt.target.responseText);
- }
- }
- }
-
- function onGotFriendInfo(evt)
- {
- // console.log(evt.target.responseText);
- // var json = JSON.parse(evt.target.responseText);
- // TODO: render info on the friend
- // TODO: update the friendsMap with more info
-
- }
-
- function onGotNewsFeed(evt)
- {
- // alert(evt.target.responseText);
- // var json = JSON.parse(evt.target.responseText);
- // TODO: render the news feed
- }
-
- </script>
- </head>
- <body onload="onBodyLoad()">
-
- <h3 id="loading">Loading ...</h3>
-
- <div id="buttonBar">
- <img id="btnLogin" src="LoginWithFacebookNormal.png" onclick="loginToFacebook()"/>
- <img id="btnLogOut" src="LogoutNormal.png" onclick="logOutOfFacebook()"/>
- </div>
-
- <ul id="fbFriends">
- <!-- Placeholder for later -->
- </ul>
- </body>
-</html>
View
0  www/facebook-connect-0.0.1.js → lib/pg-plugin-fb-connect.js
File renamed without changes
View
14 run-tests
@@ -3,13 +3,17 @@
# generate the native src
cd test
./bin/create/ios
-cd ../
+./bin/create/android
+cd ..
-# copy ios objc into ios proj
+# copy plugin into proj
cp -r ./native/ios/* ./tmp/ios/Plugins
+cp -r ./native/android/* ./tmp/android
-# copy js into ios proj
-cp ./www/facebook-connect-0.0.1.js ./test/www/facebook-connect-0.0.1.js
+# copy js into proj
+cp ./lib/pg-plugin-fb-connect.js ./test/www/pg-plugin-fb-connect.js
# ...and compile
-cd test && ./bin/debug/ios
+cd test
+./bin/debug/ios
+./bin/debug/android
View
92 test/www/facebook-connect-0.0.1.js
@@ -1,92 +0,0 @@
-// FIXME we shouldn't clobber any existing FB global...
-var FB = {
- appId:null,
- accessToken:null,
- expiresIn:null,
- onFBLogin:null,
- onDidNotLogin:null,
- onFBLogout:null,
-
- initWithAppId:function(appId) {
- this.appId = appId;
- PhoneGap.exec("FacebookConnectPlugin.initWithAppId",appId);
- },
-
- // array of permission strings: ex. 'email','feed',...
- // for details see: http://developers.facebook.com/docs/authentication/permissions/
- authorize:function() {
- var args = Array.prototype.slice.apply(arguments,[0]);
- args.unshift("FacebookConnectPlugin.authorize");
- PhoneGap.exec.apply(null,args);
- },
-
- showFeedPublishDialog:function(){
- PhoneGap.exec("FacebookConnectPlugin.showFeedPublishDialog");
- },
-
- logout:function(){
- PhoneGap.exec("FacebookConnectPlugin.logout");
- },
-
- // TODO: implement limit | offset | until | since
- getGraphRequest:function(path,postData) {
- var postDataStr;
- if(postData){
- var arr = [];
- for(var s in postData){
- postData.push(s + "=" + encodeURIComponent(postData[s]));
- }
- postDataStr = arr.join("&");
- }
-
- var url = "https://graph.facebook.com/" + path + "?access_token=" + this.accessToken;
- var req = new XMLHttpRequest();
- req.open((postDataStr ? "post" : "get"),url,true);
- req.send(postDataStr);
- return req;
- },
-
- getMyInfo:function(){
- return this.getGraphRequest("me");
- },
-
- getMyNewsFeed:function(){
- return this.getGraphRequest("me/home");
- },
-
- getUserInfo:function(userId){
- return this.getGraphRequest(userId);
- },
-
- getFriends:function(){
- console.log("appid = " + this.appId);
- return this.getGraphRequest("me/friends");
- },
-
- handleOpenUrl:function(url){
- var paramsToObject = function(params){
- var parts = params.split("&");
- var result = {};
- for(var n=0; n < parts.length; n++){
- var arg = parts[n].split("=");
- result[arg[0]] = arg[1].split("+").join(" ");
- }
- return result;
- }
-
- var decodedURL = decodeURI(url);
-
- var params = decodedURL.split("#")[1];
- if(params){
- var result = paramsToObject(params);
- this.accessToken = result.access_token;
- this.expiresIn = result.expires_in;
- PhoneGap.exec("FacebookConnectPlugin.handleOpenUrl",url);
- } else {
- PhoneGap.exec("FacebookConnectPlugin.handleOpenUrl",url);
- params = decodedURL.split("?")[1];
- this.lastError = paramsToObject(params);
- this.onDidNotLogin(this.lastError);
- }
- }
-};
View
4 test/www/index.html
@@ -4,8 +4,8 @@
<title>QUnit Test Suite</title>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
<script src="qunit.js"></script>
- <script src="facebook-connect-0.0.1.js"></script>
- <script src="facebook-connect-tests.js"></script>
+ <script src="pg-plugin-fb-connect.js"></script>
+ <script src="pg-plugin-fb-connect-tests.js"></script>
</head>
<body>
<h1 id="qunit-header">PhoneGap Facebook Connect Test Suite</h1>
Please sign in to comment.
Something went wrong with that request. Please try again.