From 36b4fc3c4a5dd9f27386a2739a694ad1a70273fc Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 26 Feb 2015 09:02:19 +0100 Subject: [PATCH 1/8] Made component npm friendly and openfb.js require()-able --- Gruntfile.js | 20 ++++++++++++++++++++ openfb.js | 4 +++- package.json | 22 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 Gruntfile.js create mode 100644 package.json diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..f7f93f0 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,20 @@ +module.exports = function(grunt) { + + grunt + .initConfig({ + pkg : grunt.file.readJSON('package.json'), + // LINT + jshint : { + all : ['*.js'] + }, + release : { + options : { + npm: false, + npmtag: false + } + } + }); + grunt.loadNpmTasks('grunt-release'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.registerTask('default', ['jshint']); +}; diff --git a/openfb.js b/openfb.js index 8e7413e..05cdbad 100644 --- a/openfb.js +++ b/openfb.js @@ -284,4 +284,6 @@ var openFB = (function () { getLoginStatus: getLoginStatus } -}()); \ No newline at end of file +}()); + +module.exports = openFB; diff --git a/package.json b/package.json new file mode 100644 index 0000000..92bab17 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ + { + "name" : "open-fb", + "version" : "0.0.1", + "repository" : "jhberges/OpenFB", + "main" : "dist/openfb.min.js", + "devDependencies" : { + "grunt": "^0.4.5", + "grunt-contrib-jshint": "^0.11.0", + "grunt-release": "^0.11.0" + }, + "dependencies" : {}, + "author" : { + "name" : "ccoenraets" + }, + "contributors" : [ + { + "name" : "Jan-Helge Bergesen", + "email" : "jhberges@gmail.com", + "url" : "http://github.com/jhberges" + } + ] + } From bf183733273d8339a7550cdfdcba8486338f82f6 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 26 Feb 2015 09:14:41 +0100 Subject: [PATCH 2/8] release 0.0.2 --- dist/open-fb.min.js | 1 + package.json | 46 +++++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 dist/open-fb.min.js diff --git a/dist/open-fb.min.js b/dist/open-fb.min.js new file mode 100644 index 0000000..9f87e4e --- /dev/null +++ b/dist/open-fb.min.js @@ -0,0 +1 @@ +var openFB=function(){function a(a){if(!a.appId)throw"appId parameter not set in init()";j=a.appId,a.tokenStore&&(p=a.tokenStore)}function b(a){var b=p.fbtoken,c={};b?(c.status="connected",c.authResponse={token:b}):c.status="unknown",a&&a(c)}function c(a,b){function c(a){var b=a.url;if(b.indexOf("access_token=")>0||b.indexOf("error=")>0){var c=600-((new Date).getTime()-g);setTimeout(function(){f.close()},c>0?c:0),d(b)}}function e(){console.log("exit and remove listeners"),deferredLogin.reject({error:"user_cancelled",error_description:"User cancelled login process",error_reason:"user_cancelled"}),f.removeEventListener("loadstop",c),f.removeEventListener("exit",e),f=null,console.log("done removing listeners")}var f,g,h="";return j?(b&&b.scope&&(h=b.scope),k=a,m=!1,l&&(s="https://www.facebook.com/connect/login_success.html"),g=(new Date).getTime(),f=window.open(n+"?client_id="+j+"&redirect_uri="+s+"&response_type=token&scope="+h,"_blank","location=no"),void(l&&(f.addEventListener("loadstart",c),f.addEventListener("exit",e)))):a({status:"unknown",error:"Facebook App Id not set."})}function d(a){var b,c;m=!0,a.indexOf("access_token=")>0?(b=a.substr(a.indexOf("#")+1),c=h(b),p.fbtoken=c.access_token,k&&k({status:"connected",authResponse:{token:c.access_token}})):a.indexOf("error=")>0?(b=a.substring(a.indexOf("?")+1,a.indexOf("#")),c=h(b),k&&k({status:"not_authorized",error:c.error})):k&&k({status:"not_authorized"})}function e(a){var b,c=p.fbtoken;p.removeItem("fbtoken"),c&&(b=window.open(o+"?access_token="+c+"&next="+t,"_blank","location=no"),l&&setTimeout(function(){b.close()},700)),a&&a()}function f(a){var b,c=a.method||"GET",d=a.params||{},e=new XMLHttpRequest;d.access_token=p.fbtoken,b="https://graph.facebook.com"+a.path+"?"+i(d),e.onreadystatechange=function(){if(4===e.readyState)if(200===e.status)a.success&&a.success(JSON.parse(e.responseText));else{var b=e.responseText?JSON.parse(e.responseText).error:{message:"An error has occurred"};a.error&&a.error(b)}},e.open(c,b,!0),e.send()}function g(a,b){return f({method:"DELETE",path:"/me/permissions",success:function(){p.fbtoken=void 0,a()},error:b})}function h(a){var b=decodeURIComponent(a),c={},d=b.split("&");return d.forEach(function(a){var b=a.split("=");c[b[0]]=b[1]}),c}function i(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")}var j,k,l,m,n="https://www.facebook.com/dialog/oauth",o="https://www.facebook.com/logout.php",p=window.sessionStorage,q=window.location.pathname.substring(0,window.location.pathname.indexOf("/",2)),r=location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")+q,s=r+"/oauthcallback.html",t=r+"/logoutcallback.html";return console.log(s),console.log(t),document.addEventListener("deviceready",function(){l=!0},!1),{init:a,login:c,logout:e,revokePermissions:g,api:f,oauthCallback:d,getLoginStatus:b}}();module.exports=openFB; \ No newline at end of file diff --git a/package.json b/package.json index 92bab17..6f5c735 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,24 @@ - { - "name" : "open-fb", - "version" : "0.0.1", - "repository" : "jhberges/OpenFB", - "main" : "dist/openfb.min.js", - "devDependencies" : { - "grunt": "^0.4.5", - "grunt-contrib-jshint": "^0.11.0", - "grunt-release": "^0.11.0" - }, - "dependencies" : {}, - "author" : { - "name" : "ccoenraets" - }, - "contributors" : [ - { - "name" : "Jan-Helge Bergesen", - "email" : "jhberges@gmail.com", - "url" : "http://github.com/jhberges" - } - ] - } +{ + "name": "open-fb", + "version": "0.0.2", + "repository": "jhberges/OpenFB", + "main": "dist/openfb.min.js", + "devDependencies": { + "grunt": "^0.4.5", + "grunt-contrib-jshint": "^0.11.0", + "grunt-contrib-uglify": "^0.8.0", + "grunt-release": "^0.11.0", + "grunt-shell": "^1.1.2" + }, + "dependencies": {}, + "author": { + "name": "ccoenraets" + }, + "contributors": [ + { + "name": "Jan-Helge Bergesen", + "email": "jhberges@gmail.com", + "url": "http://github.com/jhberges" + } + ] +} From fc89d9a2d608dd09e97991e4bf2956e9b6741c7e Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 26 Feb 2015 09:15:32 +0100 Subject: [PATCH 3/8] Forgot to commit before testing release --- .gitignore | 1 + Gruntfile.js | 19 ++++++++++++++++++- openfb.js | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4d4b695..2060e58 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea .DS_Store .gitignore +node_modules diff --git a/Gruntfile.js b/Gruntfile.js index f7f93f0..eee034f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,8 +5,23 @@ module.exports = function(grunt) { pkg : grunt.file.readJSON('package.json'), // LINT jshint : { + options : { + sub : true, // Allow object['member'], and don't insist on object.member + }, all : ['*.js'] }, + uglify : { + all : { + files : { + 'dist/open-fb.min.js' : ['openfb.js'] + } + } + }, + shell : { + commit_dist : { + command : 'git commit -am "Release" dist/*.js' + } + }, release : { options : { npm: false, @@ -15,6 +30,8 @@ module.exports = function(grunt) { } }); grunt.loadNpmTasks('grunt-release'); + grunt.loadNpmTasks('grunt-shell'); grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.registerTask('default', ['jshint']); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.registerTask('default', ['jshint', 'uglify']); }; diff --git a/openfb.js b/openfb.js index 05cdbad..7d5622a 100644 --- a/openfb.js +++ b/openfb.js @@ -282,7 +282,7 @@ var openFB = (function () { api: api, oauthCallback: oauthCallback, getLoginStatus: getLoginStatus - } + }; }()); From 6812ab00a2a5fb72b174c4e5b7375eb3203413ce Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 26 Feb 2015 09:28:16 +0100 Subject: [PATCH 4/8] export within anon-fun --- openfb.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openfb.js b/openfb.js index 7d5622a..f66023b 100644 --- a/openfb.js +++ b/openfb.js @@ -274,7 +274,7 @@ var openFB = (function () { } // The public API - return { + var publicApi = { init: init, login: login, logout: logout, @@ -283,7 +283,7 @@ var openFB = (function () { oauthCallback: oauthCallback, getLoginStatus: getLoginStatus }; - + module.exports = publicApi; + return publicApi; }()); -module.exports = openFB; From 3a81f97feec706db5a12160d165545477a89ff86 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 26 Feb 2015 09:28:25 +0100 Subject: [PATCH 5/8] release 0.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f5c735..451e162 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-fb", - "version": "0.0.2", + "version": "0.0.3", "repository": "jhberges/OpenFB", "main": "dist/openfb.min.js", "devDependencies": { From e9d5fccf42fa6cfae2a8a5a46fa4e63eb9d302ec Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 26 Feb 2015 09:33:12 +0100 Subject: [PATCH 6/8] Typo --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index eee034f..5d845fe 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,7 +13,7 @@ module.exports = function(grunt) { uglify : { all : { files : { - 'dist/open-fb.min.js' : ['openfb.js'] + 'dist/openfb.min.js' : ['openfb.js'] } } }, From 2d13e00f0b527ee1b4cc5b12bd1b7ce021cfdc21 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 26 Feb 2015 09:33:23 +0100 Subject: [PATCH 7/8] release 0.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 451e162..1015b00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-fb", - "version": "0.0.3", + "version": "0.0.4", "repository": "jhberges/OpenFB", "main": "dist/openfb.min.js", "devDependencies": { From 4f17df06813c2f8c194df05ade328d7eaeaf9b7a Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 26 Feb 2015 09:35:41 +0100 Subject: [PATCH 8/8] release 0.0.5 --- dist/{open-fb.min.js => openfb.min.js} | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename dist/{open-fb.min.js => openfb.min.js} (91%) diff --git a/dist/open-fb.min.js b/dist/openfb.min.js similarity index 91% rename from dist/open-fb.min.js rename to dist/openfb.min.js index 9f87e4e..3a3db9d 100644 --- a/dist/open-fb.min.js +++ b/dist/openfb.min.js @@ -1 +1 @@ -var openFB=function(){function a(a){if(!a.appId)throw"appId parameter not set in init()";j=a.appId,a.tokenStore&&(p=a.tokenStore)}function b(a){var b=p.fbtoken,c={};b?(c.status="connected",c.authResponse={token:b}):c.status="unknown",a&&a(c)}function c(a,b){function c(a){var b=a.url;if(b.indexOf("access_token=")>0||b.indexOf("error=")>0){var c=600-((new Date).getTime()-g);setTimeout(function(){f.close()},c>0?c:0),d(b)}}function e(){console.log("exit and remove listeners"),deferredLogin.reject({error:"user_cancelled",error_description:"User cancelled login process",error_reason:"user_cancelled"}),f.removeEventListener("loadstop",c),f.removeEventListener("exit",e),f=null,console.log("done removing listeners")}var f,g,h="";return j?(b&&b.scope&&(h=b.scope),k=a,m=!1,l&&(s="https://www.facebook.com/connect/login_success.html"),g=(new Date).getTime(),f=window.open(n+"?client_id="+j+"&redirect_uri="+s+"&response_type=token&scope="+h,"_blank","location=no"),void(l&&(f.addEventListener("loadstart",c),f.addEventListener("exit",e)))):a({status:"unknown",error:"Facebook App Id not set."})}function d(a){var b,c;m=!0,a.indexOf("access_token=")>0?(b=a.substr(a.indexOf("#")+1),c=h(b),p.fbtoken=c.access_token,k&&k({status:"connected",authResponse:{token:c.access_token}})):a.indexOf("error=")>0?(b=a.substring(a.indexOf("?")+1,a.indexOf("#")),c=h(b),k&&k({status:"not_authorized",error:c.error})):k&&k({status:"not_authorized"})}function e(a){var b,c=p.fbtoken;p.removeItem("fbtoken"),c&&(b=window.open(o+"?access_token="+c+"&next="+t,"_blank","location=no"),l&&setTimeout(function(){b.close()},700)),a&&a()}function f(a){var b,c=a.method||"GET",d=a.params||{},e=new XMLHttpRequest;d.access_token=p.fbtoken,b="https://graph.facebook.com"+a.path+"?"+i(d),e.onreadystatechange=function(){if(4===e.readyState)if(200===e.status)a.success&&a.success(JSON.parse(e.responseText));else{var b=e.responseText?JSON.parse(e.responseText).error:{message:"An error has occurred"};a.error&&a.error(b)}},e.open(c,b,!0),e.send()}function g(a,b){return f({method:"DELETE",path:"/me/permissions",success:function(){p.fbtoken=void 0,a()},error:b})}function h(a){var b=decodeURIComponent(a),c={},d=b.split("&");return d.forEach(function(a){var b=a.split("=");c[b[0]]=b[1]}),c}function i(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")}var j,k,l,m,n="https://www.facebook.com/dialog/oauth",o="https://www.facebook.com/logout.php",p=window.sessionStorage,q=window.location.pathname.substring(0,window.location.pathname.indexOf("/",2)),r=location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")+q,s=r+"/oauthcallback.html",t=r+"/logoutcallback.html";return console.log(s),console.log(t),document.addEventListener("deviceready",function(){l=!0},!1),{init:a,login:c,logout:e,revokePermissions:g,api:f,oauthCallback:d,getLoginStatus:b}}();module.exports=openFB; \ No newline at end of file +var openFB=function(){function a(a){if(!a.appId)throw"appId parameter not set in init()";j=a.appId,a.tokenStore&&(p=a.tokenStore)}function b(a){var b=p.fbtoken,c={};b?(c.status="connected",c.authResponse={token:b}):c.status="unknown",a&&a(c)}function c(a,b){function c(a){var b=a.url;if(b.indexOf("access_token=")>0||b.indexOf("error=")>0){var c=600-((new Date).getTime()-g);setTimeout(function(){f.close()},c>0?c:0),d(b)}}function e(){console.log("exit and remove listeners"),deferredLogin.reject({error:"user_cancelled",error_description:"User cancelled login process",error_reason:"user_cancelled"}),f.removeEventListener("loadstop",c),f.removeEventListener("exit",e),f=null,console.log("done removing listeners")}var f,g,h="";return j?(b&&b.scope&&(h=b.scope),k=a,m=!1,l&&(s="https://www.facebook.com/connect/login_success.html"),g=(new Date).getTime(),f=window.open(n+"?client_id="+j+"&redirect_uri="+s+"&response_type=token&scope="+h,"_blank","location=no"),void(l&&(f.addEventListener("loadstart",c),f.addEventListener("exit",e)))):a({status:"unknown",error:"Facebook App Id not set."})}function d(a){var b,c;m=!0,a.indexOf("access_token=")>0?(b=a.substr(a.indexOf("#")+1),c=h(b),p.fbtoken=c.access_token,k&&k({status:"connected",authResponse:{token:c.access_token}})):a.indexOf("error=")>0?(b=a.substring(a.indexOf("?")+1,a.indexOf("#")),c=h(b),k&&k({status:"not_authorized",error:c.error})):k&&k({status:"not_authorized"})}function e(a){var b,c=p.fbtoken;p.removeItem("fbtoken"),c&&(b=window.open(o+"?access_token="+c+"&next="+t,"_blank","location=no"),l&&setTimeout(function(){b.close()},700)),a&&a()}function f(a){var b,c=a.method||"GET",d=a.params||{},e=new XMLHttpRequest;d.access_token=p.fbtoken,b="https://graph.facebook.com"+a.path+"?"+i(d),e.onreadystatechange=function(){if(4===e.readyState)if(200===e.status)a.success&&a.success(JSON.parse(e.responseText));else{var b=e.responseText?JSON.parse(e.responseText).error:{message:"An error has occurred"};a.error&&a.error(b)}},e.open(c,b,!0),e.send()}function g(a,b){return f({method:"DELETE",path:"/me/permissions",success:function(){p.fbtoken=void 0,a()},error:b})}function h(a){var b=decodeURIComponent(a),c={},d=b.split("&");return d.forEach(function(a){var b=a.split("=");c[b[0]]=b[1]}),c}function i(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")}var j,k,l,m,n="https://www.facebook.com/dialog/oauth",o="https://www.facebook.com/logout.php",p=window.sessionStorage,q=window.location.pathname.substring(0,window.location.pathname.indexOf("/",2)),r=location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")+q,s=r+"/oauthcallback.html",t=r+"/logoutcallback.html";console.log(s),console.log(t),document.addEventListener("deviceready",function(){l=!0},!1);var u={init:a,login:c,logout:e,revokePermissions:g,api:f,oauthCallback:d,getLoginStatus:b};return module.exports=u,u}(); \ No newline at end of file diff --git a/package.json b/package.json index 1015b00..e17663c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-fb", - "version": "0.0.4", + "version": "0.0.5", "repository": "jhberges/OpenFB", "main": "dist/openfb.min.js", "devDependencies": {