Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7272 amit.gupta 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
  	window.fbAsyncInit();
16
 
17
  // Load the SDK Asynchronously
18
  (function(d){
19
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
20
     if (d.getElementById(id)) {return;}
21
     js = d.createElement('script'); js.id = id; js.async = true;
22
     js.src = "//connect.facebook.net/en_US/all.js";
23
     ref.parentNode.insertBefore(js, ref);
24
   }(document));
25
 
26
  function login() {
27
	    FB.login(function(response) {
28
	    	if (response.authResponse) {
29
	    		authDetails = response.authResponse;
30
	    		FB.api('/me', function(response){
31
	    			  userDetails = response;
32
	    			  if(userDetails!==null) {
33
	    				  loginToSaholicByFacebook(userDetails, authDetails);
34
	  	    		  }
35
	    		});
36
	        } else {
37
	            // cancelled
38
	        }
39
	    },{scope: 'email'});
40
  }
41
 
42
  function checkAndCallFacebookLogin() {
43
	  	//window.fbAsyncInit();
44
	    FB.getLoginStatus(function(response) {
45
	    	  if (response.status === 'connected') {
46
	    		  FB.api('/me', function(response){
47
	    			  userDetails = response;
48
	    			  if(userDetails!==null) {
49
	  	    			loginToSaholicByFacebook(userDetails, authDetails);
50
	  	    		  }
51
	    		  });
52
	    	  } else if (response.status === 'not_authorized') {
53
	    		  login();
54
	    	  } else {
55
	    		  login();
56
	    	  }
57
	    });
58
  }