text: 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}();