Skip to content

Instantly share code, notes, and snippets.

View simonmorley's full-sized avatar

Simon Morley simonmorley

  • London
View GitHub Profile
@simonmorley
simonmorley / gist:fc2def2b5f528172cf04
Created January 23, 2015 01:53
Medium, creating a facebook splash page, directive basic
function statusChangeCallback(response) {
if (response.status === 'connected') {
console.log('connected')
fetchUser().then(function(resp) {
var template = '<div><h2>Hi ' + resp.name + ', nice to see you again.</h2></div>';
var templateObj = $compile(template)(scope);
element.html(templateObj);
});
} else {
@simonmorley
simonmorley / gist:0170fc5e126216cedcaf
Created January 23, 2015 01:54
Medium, creating a facebook splash page, fetch user basic
function fetchUser() {
var deferred = $q.defer();
FB.api('/me', function(response) {
deferred.resolve(response)
});
return deferred.promise;
};
@simonmorley
simonmorley / gist:a54b6d47055095b13881
Last active August 29, 2015 14:13
Medium, creating a facebook splash page, login user basic
function login() {
FB.login(function(response){
console.log(response);
});
};
@simonmorley
simonmorley / gist:bbbf7e964e1f4e1b034a
Last active August 29, 2015 14:13
Medium, creating a facebook splash page, login user basic 2
function login() {
FB.login(function(response){
console.log(response);
},{scope: "email,publish_stream,user_checkins"});
};
@simonmorley
simonmorley / gist:63d10144f748a52ae6e7
Last active August 29, 2015 14:13
Medium, creating a facebook splash page, login user basic 3
scope.login = function() {
login().then(validateAuth);
};
function login() {
var deferred = $q.defer();
FB.login(function(response){
deferred.resolve(response)
},{scope: "email,publish_stream,user_checkins"});
return deferred.promise;
@simonmorley
simonmorley / gist:f7f0e3b726f5cf07ef32
Created January 23, 2015 02:17
Medium, facebook logins, user cancels
function userCanceled() {
var template = '<div><p>Looks like you canceled the request</p><div id=\'sign_in\' ng-click=\'login()\'>Sign In</div></div>';
var templateObj = $compile(template)(scope);
element.html(templateObj);
}
@simonmorley
simonmorley / gist:126fb612813a991fe197
Created January 23, 2015 14:14
Medium, creating Facebook Captive Portal, CT Service
'use strict';
var app = angular.module('ctLoginsApp.tony.services', ['ngResource']);
app.factory('CT', ['$routeParams', '$q', '$rootScope', '$location',
function() {
var login = function() {
};
@simonmorley
simonmorley / gist:3c404facafb9aab9ef17
Last active August 29, 2015 14:14
Medium, creating a facebook login, auto login function II
if (response.status === 'connected') {
fetchUser().then(function(resp) {
var msg =
'<h2>Hi ' + resp.name + ', nice to see you again.</h2>' +
'<a href=\'\' ng-click=\'ctLogin()\' class=\'button\'>Login</a>';
compileTemplate(msg);
});
} else { ...
@simonmorley
simonmorley / gist:3e6f70242d556b10fec8
Last active August 29, 2015 14:14
Medium, facebook splash page, checkin function
var doCtLogin = function(params) {
CT.login(params).then(function() {
console.log('You logged in');
checkinForm(params);
}, function(err) {
console.log(err);
});
};
function checkinForm(params) {
@simonmorley
simonmorley / gist:b959c157a9a168e2ff30
Last active August 29, 2015 14:14
Medium, autologin facebook checkin
scope.doCheckin = function() {
var options = {
pageId: attrs.fbPageId,
accessToken: authResponse.accessToken,
message: scope.message
};
CT.checkin(options).then(function(msg) {
console.log(msg)
// do stuff
}, function(err) {