diff options
Diffstat (limited to 'Resources')
| -rw-r--r-- | Resources/friendship/core/FacebookFQL.js | 43 | ||||
| -rw-r--r-- | Resources/friendship/core/core.js | 7 | ||||
| -rw-r--r-- | Resources/friendship/friendship.js | 3 | ||||
| -rw-r--r-- | Resources/friendship/ui/ApplicationWindow.js | 17 | ||||
| -rw-r--r-- | Resources/friendship/ui/LikeList.js | 36 | ||||
| -rw-r--r-- | Resources/images/fb_test_profile.jpg | bin | 0 -> 2385 bytes |
6 files changed, 103 insertions, 3 deletions
diff --git a/Resources/friendship/core/FacebookFQL.js b/Resources/friendship/core/FacebookFQL.js new file mode 100644 index 0000000..bd3e96e --- /dev/null +++ b/Resources/friendship/core/FacebookFQL.js @@ -0,0 +1,43 @@ +(function() { + fs.core.queryFQL = function(fqlQuery, fqlCallback) { + var fqlURL = "fql?q=" + fqlQuery.replace(/ /g, "+"); + Ti.API.info("https://graph.facebook.com/" + fqlURL); + Ti.Facebook.requestWithGraphPath(fqlURL, {}, 'GET', fqlCallback); + }; + + fs.core.queryAllFriendPostsFQL = function() { + var query = "SELECT page_id, name, description, page_url, pic_square, fan_count, type, website, general_info "; + query += "FROM page WHERE page_id "; + query += "IN (SELECT page_id FROM page_fan WHERE uid "; + //query += "= " + Ti.Facebook.uid + ")"; + query += "IN (SELECT uid2 FROM friend WHERE uid1 = " + Titanium.Facebook.uid + "))"; + //query += "order by last_name limit 20"; + Ti.Facebook.request('fql.query', {query: query}, fs.core.handleAllFriendPostsFQL); + // TODO: after calling this fn, display the loading animation + }; + + /* + fs.core.handleFQLResponse = function(callback) { + }; + */ + + fs.core.handleAllFriendPostsFQL = function(result) { + if (result.success) { + var postsList = JSON.parse(result.result); + Ti.API.fireEvent("processPosts", postsList); + /* + Ti.API.info(postsList.length); + Ti.API.info(postsList[0].name); + Ti.API.info(postsList[0].page_id); + Ti.API.info(postsList[0].website); + */ + } else if (result.error) { + //Ti.API.info("ERROR: " + result.error); // TODO: remove + Ti.API.fireEvent("processFQLError", {what:result.error}); + } else { + //Ti.API.info("ERROR: unknown response from FQL query"); // TODO: remove + Ti.API.fireEvent("processFQLError", {what:"unknown FQL response"}); + } + }; // TODO: handle timeouts + +})(); diff --git a/Resources/friendship/core/core.js b/Resources/friendship/core/core.js new file mode 100644 index 0000000..dd75086 --- /dev/null +++ b/Resources/friendship/core/core.js @@ -0,0 +1,7 @@ +(function() { + fs.core = {}; +})(); + +Ti.include( + '/friendship/core/FacebookFQL.js' +) diff --git a/Resources/friendship/friendship.js b/Resources/friendship/friendship.js index 8d3f437..fd61403 100644 --- a/Resources/friendship/friendship.js +++ b/Resources/friendship/friendship.js @@ -6,5 +6,6 @@ var fs = {}; Ti.include( '/friendship/config/config.js', - '/friendship/ui/ui.js' + '/friendship/ui/ui.js', + '/friendship/core/core.js' ); diff --git a/Resources/friendship/ui/ApplicationWindow.js b/Resources/friendship/ui/ApplicationWindow.js index 0211c37..fae78d4 100644 --- a/Resources/friendship/ui/ApplicationWindow.js +++ b/Resources/friendship/ui/ApplicationWindow.js @@ -3,9 +3,24 @@ var tab_group = Ti.UI.createTabGroup(); Ti.UI.currentTabGroup = tab_group; + var login_button = Ti.Facebook.createLoginButton({ + top: 50, + style: 'wide' + }); + + var debug_button = Ti.UI.createButton({title: 'Debug'}); + debug_button.addEventListener('click', function(e) { + Ti.API.info('Logged in: ' + JSON.stringify(Ti.Facebook.loggedIn)); + if (Ti.Facebook.loggedIn) { + fs.core.queryAllFriendPostsFQL(); + } + }); + var win = Ti.UI.createWindow({ title: 'FriendShip', - tabBarHidden: true + tabBarHidden: true, + leftNavButton: debug_button, + rightNavButton: login_button, }); var tab = Titanium.UI.createTab({ diff --git a/Resources/friendship/ui/LikeList.js b/Resources/friendship/ui/LikeList.js index 54da696..9ba9bd5 100644 --- a/Resources/friendship/ui/LikeList.js +++ b/Resources/friendship/ui/LikeList.js @@ -1,4 +1,35 @@ (function() { + function create_row( title ) + { + // Reason for Factory: templating format of the row + var row = Ti.UI.createTableViewRow(); + + var profile_icon = Ti.UI.createImageView({ + url:"images/fb_test_profile.jpg", + width:50, + height:50, + left:0, + top:0 + }); + + var content = Ti.UI.createLabel({ + text:title, + font:{fontSize:12,fontWeight:'bold'}, + width:'auto', + textAlign:'left', + top:2, + left:52, + height:26 + }); + + row.height = 50; + + row.add( profile_icon ); + row.add( content ); + + return row; + } + fs.ui.createLikeList = function() { var ll_view = Ti.UI.createTableView(); @@ -9,6 +40,9 @@ })); }); + ll_view.appendRow( create_row( 'OMG, I like totally like Skrillex.') ); + ll_view.appendRow( create_row( 'Seriously, this is amazing. You totally need to party.') ); + return ll_view; }; -})(); + })(); diff --git a/Resources/images/fb_test_profile.jpg b/Resources/images/fb_test_profile.jpg Binary files differnew file mode 100644 index 0000000..57a8efa --- /dev/null +++ b/Resources/images/fb_test_profile.jpg |
