Subversion Repositories SmartDukaan

Rev

Rev 7016 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7007 amar.kumar 1
var userDetails = null;
2
var authDetails = null;
3
 
4
  window.fbAsyncInit = function() {
5
    FB.init({
6
      appId      : '${in.shop2020.appId}', // App ID
7
      //channelUrl : '//local.shop2020.in:8080/channel.html', // Channel File
8
      status     : true, // check login status
9
      cookie     : true, // enable cookies to allow the server to access the session
10
      xfbml      : true,  // parse XFBML
11
      oauth  	 : true
12
    });
13
  	};
14
 
15
  // Load the SDK Asynchronously
16
  (function(d){
17
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
18
     if (d.getElementById(id)) {return;}
19
     js = d.createElement('script'); js.id = id; js.async = true;
20
     js.src = "//connect.facebook.net/en_US/all.js";
21
     ref.parentNode.insertBefore(js, ref);
22
   }(document));
23
 
24
  function login() {
25
	    FB.login(function(response) {
26
	    	if (response.authResponse) {
27
	    		authDetails = response.authResponse;
28
	    		FB.api('/me', function(response){
29
	    			  userDetails = response;
30
	    			  if(userDetails!==null) {
31
	    				  loginToSaholicByFacebook(userDetails, authDetails);
32
	  	    		  }
33
	    		});
34
	        } else {
35
	            // cancelled
36
	        }
37
	    },{scope: 'email,publish_stream'});
38
  }
39
 
40
  function checkAndCallFacebookLogin() {
41
	  	window.fbAsyncInit();
42
	    FB.getLoginStatus(function(response) {
43
	    	  if (response.status === 'connected') {
44
	    		  FB.api('/me', function(response){
45
	    			  userDetails = response;
46
	    			  if(userDetails!==null) {
47
	  	    			loginToSaholicByFacebook(userDetails, authDetails);
48
	  	    		  }
49
	    		  });
50
	    	  } else if (response.status === 'not_authorized') {
51
	    		  login();
52
	    	  } else {
53
	    		  login();
54
	    	  }
55
	    });
56
  }