Subversion Repositories SmartDukaan

Rev

Rev 20207 | Rev 20212 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20207 Rev 20208
Line 79... Line 79...
79
}*/
79
}*/
80
 
80
 
81
var LoginNamespace={};
81
var LoginNamespace={};
82
var authDetails=null;
82
var authDetails=null;
83
var userDetails=null;
83
var userDetails=null;
84
 
-
 
-
 
84
var sourceShip=false;
85
$(document).ready(function() {
85
$(document).ready(function() {
86
	  $.ajaxSetup({ cache: true });
86
	  $.ajaxSetup({ cache: true });
87
	  $.getScript('//connect.facebook.net/en_US/sdk.js', function(){
87
	  $.getScript('//connect.facebook.net/en_US/sdk.js', function(){
88
	    FB.init({
88
	    FB.init({
89
	      appId: '{716370691734306}',
89
	      appId: '{716370691734306}',
Line 103... Line 103...
103
	});
103
	});
104
 
104
 
105
var mode = '';
105
var mode = '';
106
  function checkAndCallFacebookLogin() {
106
  function checkAndCallFacebookLogin() {
107
	  mode = $('#loginText').html();
107
	  mode = $('#loginText').html();
-
 
108
	 
108
	  $('#errormessage').hide();
109
	  $('#errormessage').hide();
109
	  $('#errormessage').html('');
110
	  $('#errormessage').html('');
110
	  	//window.fbAsyncInit();
111
	  	//window.fbAsyncInit();
111
	    FB.getLoginStatus(function(response) {
112
	    FB.getLoginStatus(function(response) {
112
	  	  // Check login status on load, and if the user is
113
	  	  // Check login status on load, and if the user is
Line 128... Line 129...
128
  function loginregister(){
129
  function loginregister(){
129
	  mode = $('#loginText').html();
130
	  mode = $('#loginText').html();
130
	  $('#errormessage').hide();
131
	  $('#errormessage').hide();
131
	  $('#errormessage').html('');
132
	  $('#errormessage').html('');
132
	  if(mode =='Login'){
133
	  if(mode =='Login'){
-
 
134
		  trackEventWithGA('Account', 'Login from '+window.location.pathname, $('#email').val());
133
		  $.ajax({
135
		  $.ajax({
134
				type : "POST",
136
				type : "POST",
135
				url : "/login?email="+$('#email').val()+"&password="+$('#password').val(),
137
				url : "/login?email="+$('#email').val()+"&password="+$('#password').val(),
136
				success : function(response) {
138
				success : function(response) {
137
					response = JSON.parse(response);
139
					response = JSON.parse(response);
138
					if(response.status=='success'){
140
					if(response.status=='success'){
-
 
141
						if(sourceShip)
-
 
142
  							window.location.href='/shipping';
-
 
143
  						else
139
						window.location.reload();
144
  							window.location.reload();
140
					}else{
145
					}else{
141
						$('#errormessage').html(response.message);
146
						$('#errormessage').html(response.message);
142
					$('#errormessage').show();
147
					$('#errormessage').show();
143
					}
148
					}
144
					
149
					
145
				}
150
				}
146
			});
151
			});
147
	  }else{
152
	  }else{
-
 
153
		  trackEventWithGA('Account', 'Register from '+window.location.pathname, $('#email').val());
148
		  $.ajax({
154
		  $.ajax({
149
				type : "POST",
155
				type : "POST",
150
				url : "/register?redirectUrl=/&email="+$('#email').val()+"&password="+$('#password').val(),
156
				url : "/register?redirectUrl=/&email="+$('#email').val()+"&password="+$('#password').val(),
151
				success : function(response) {
157
				success : function(response) {
152
					response = JSON.parse(response);
158
					response = JSON.parse(response);
153
					if(response.status=='success'){
159
					if(response.status=='success'){
-
 
160
						if(sourceShip)
-
 
161
  							window.location.href='/shipping';
-
 
162
  						else
154
						window.location.reload();
163
  							window.location.reload();
155
					}else{
164
					}else{
156
						$('#errormessage').html(response.message);
165
						$('#errormessage').html(response.message);
157
					$('#errormessage').show();
166
					$('#errormessage').show();
158
					}
167
					}
159
				}
168
				}
160
			});
169
			});
161
	  }
170
	  }
162
  }
171
  }
163
  
172
  
-
 
173
	$('#poplogin').click(function(){
-
 
174
		loginsignup('ship');
-
 
175
	});
-
 
176
  
-
 
177
  
-
 
178
  
164
 
179
 
165
	function getCurrentUserInfo() {
180
	function getCurrentUserInfo() {
166
	      FB.api('/me?fields=id,name,email,permissions', function(userInfo) {
181
	      FB.api('/me?fields=id,name,email,permissions', function(userInfo) {
167
	    	  userDetails = userInfo;
182
	    	  userDetails = userInfo;
168
	    	  if(authDetails && authDetails.status=='connected' && userDetails && userDetails.email){
183
	    	  if(authDetails && authDetails.status=='connected' && userDetails && userDetails.email){
169
	  			if(mode=='Login'){
184
	  			if(mode=='Login'){
-
 
185
	  				trackEventWithGA('Account', 'Facebook Login from '+window.location.pathname, $('#email').val());
170
	    		  $.ajax({
186
	    		  $.ajax({
171
	  				type : "POST",
187
	  				type : "POST",
172
	  				url : "/login!verifyFbUser?accessToken="+authDetails.authResponse.accessToken+"&email="+userDetails.email,
188
	  				url : "/login!verifyFbUser?accessToken="+authDetails.authResponse.accessToken+"&email="+userDetails.email,
173
	  				success : function(response) {
189
	  				success : function(response) {
174
	  					response = JSON.parse(response);
190
	  					response = JSON.parse(response);
175
	  					if(response.status=='success'){
191
	  					if(response.status=='success'){
-
 
192
	  						if(sourceShip)
-
 
193
	  							window.location.href='/shipping';
-
 
194
	  						else
176
	  						window.location.reload();
195
	  							window.location.reload();
-
 
196
	  						
177
	  					}else{
197
	  					}else{
178
	  						$('#errormessage').html(response.message);
198
	  						$('#errormessage').html(response.message);
179
	  						$('#errormessage').show();
199
	  						$('#errormessage').show();
180
	  					}
200
	  					}
181
	  				}
201
	  				}
182
	  			});
202
	  			});
183
	  			}else{
203
	  			}else{
-
 
204
	  				trackEventWithGA('Account', 'Facebook Register from '+window.location.pathname, $('#email').val());
184
	  				$.ajax({
205
	  				$.ajax({
185
		  				type : "POST",
206
		  				type : "POST",
186
		  				url : "/login!signupFacebookUser?accessToken="+authDetails.authResponse.accessToken+"&email="+userDetails.email,
207
		  				url : "/login!signupFacebookUser?accessToken="+authDetails.authResponse.accessToken+"&email="+userDetails.email,
187
		  				success : function(response) {
208
		  				success : function(response) {
188
		  					response = JSON.parse(response);
209
		  					response = JSON.parse(response);
189
		  					if(response.status=='success'){
210
		  					if(response.status=='success'){
-
 
211
		  						if(sourceShip)
-
 
212
		  							window.location.href='/shipping';
-
 
213
		  						else
190
		  						window.location.reload();
214
		  							window.location.reload();
191
		  					}else{
215
		  					}else{
192
		  						$('#errormessage').html(response.message);
216
		  						$('#errormessage').html(response.message);
193
		  						$('#errormessage').show();
217
		  						$('#errormessage').show();
194
		  					}
218
		  					}
195
		  				}
219
		  				}
Line 234... Line 258...
234
		$('#loginregistertext').html('Do not have an account?<a href="javascript: void(0);" style="color:#069" onclick="toggleLoginRegisterView(\'register\')">Register</a></div>');
258
		$('#loginregistertext').html('Do not have an account?<a href="javascript: void(0);" style="color:#069" onclick="toggleLoginRegisterView(\'register\')">Register</a></div>');
235
		$('#forgotPassword').show();
259
		$('#forgotPassword').show();
236
		}
260
		}
237
		}
261
		}
238
	
262
	
239
	function loginsignup(){
263
	function loginsignup(source){
-
 
264
		if(source) 
-
 
265
			sourceShip=true;
-
 
266
		else 
-
 
267
			sourceShip = false;
240
		if($('#register-login-popup').length==0){
268
		if($('#register-login-popup').length==0){
241
			$('<html><style>#register-login-popup{width:100%;height:100%;position:fixed;top:0;left:0;background:rgba(102,102,102,.55)}.login-container{margin:0 auto;width:740px;z-index:10;height:auto;top:40px;position:relative;background:0 0}.login-inner-container{z-index:95;width:660px;min-height:400px;left:0;right:0;top:0;margin:auto;height:auto;background:#fff;position:relative}div.wrap{width:250px;margin-left:45px}div.wrap div{position:relative;margin:20px 0}.label{position:absolute;top:0;font-size:16px;margin:25px 25px 25px -5px;color:grey;padding:0 10px;background-color:#fff;-webkit-transition:top .2s ease-in-out,font-size .2s ease-in-out;transition:top .2s ease-in-out,font-size .2s ease-in-out}.active{top:-30px;font-size:20px;color:#069}div.wrap input{width:100%;padding:20px 20px 5px 5px;border:none;border-bottom:1px solid grey;font-size:20px;background-color:transparent;color:grey;position:relative;outline:0}div.wrap input:focus{border-color:#069;font-size:16px;-webkit-transition:border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s;transition:border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s}#loginBtn{cursor:pointer;border-radius:5px;width:250px;background-color:#069;padding:5 0;border:2px solid #069;text-align:center;margin-top:40px}#loginBtn:hover{border-color:grey;-webkit-transition:border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s;transition:border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s}#loginText{font-size:24px;color:#fff;margin:10px 0}</style><script src="http://code.jquery.com/jquery-2.1.1.min.js" ></script><div id="register-login-popup" style="display:none"> <div id="iframeContainer" class="login-container"> <div class="login-inner-container"> <div onclick="closepopup()" id="closepopup" style="background-color: #333232;color: #fff;font-size: 24px;padding: 8px;position: absolute;right: -33px;cursor: pointer;">X</div><div style="height:10px;width:100%;margin:0 auto;padding:5px"></div><div id="registerlogin" style="width:100%;margin:0 auto;text-align: center;color:#069;float:left;padding-bottom:5px;font-size:26px;"> LOGIN </div><div style="width:100%;margin:0 auto;text-align: center;float: left;margin-top: 2px;"> <div style="width: 50%;height:auto;background-color: white;float:left;"> <div id="loginCreate" class="register-login" > <div id="errormessage" style="width:100%;text-align:center;font-size:12px;color:red;display:none"> email/password is wrong</div><div class="wrap"> <div> <label class="label" >Email</label> <input id="email" name="email" type="text" autocomplete = "off" class="cool"/> </div><div> <label class="label" >Password</label> <input id="password" name="password" autocomplete="off" type="password" class="cool"/> </div><div id="forgotPassword" style="margin: 0px;margin-top: -19px;margin-right: -162px;font-size: 12px;font-style: italic;"> <a href="/forgot-password" style="color:#069">forgot password?</a></div><div class="loginBtn" id="loginBtn" onclick="loginregister()"> <div id="loginText" > Login </div></div><div id="loginregistertext" style="width:100%;text-align:center;font-size:14px;font-weight:bold;"> Do not have an account? <a href="javascript: void(0);" style="color:#069" onclick="toggleLoginRegisterView(\'register\')">Register</a></div></div></div></div><div style="width:1px;height:300px;background-color: white;float: left;border-left: 1px solid grey;margin-top: 7px;margin-left: 3px;"></div><div style="width: 48%;height:300px;background-color: white;float:right;text-align:center;"><div style="width: 100%;font-size: 23px;color: #069;margin-top: 17px;"> Or Try </div><div onclick="checkAndCallFacebookLogin()" style="text-align:right;background: url(\'/unversioned/images/facebookconnect.png\');cursor:pointer;background-repeat: no-repeat;height: 42px;background-size: 250px 43px;margin-top: 162px;border-radius: 5px;width: 250px;margin-left: 29px;"><div id="fbloginbtn" style="color:white;font-weight:bold;font-size: 16px;padding: 8px;padding-top: 12px;">Connect with Facebook</div></div></div></div></div></div></div></div></html>').insertAfter('#footer');
269
			$('<html><style>#register-login-popup{width:100%;height:100%;position:fixed;top:0;left:0;background:rgba(102,102,102,.55)}.login-container{margin:0 auto;width:740px;z-index:10;height:auto;top:40px;position:relative;background:0 0}.login-inner-container{z-index:95;width:660px;min-height:400px;left:0;right:0;top:0;margin:auto;height:auto;background:#fff;position:relative}div.wrap{width:250px;margin-left:45px}div.wrap div{position:relative;margin:20px 0}.label{position:absolute;top:0;font-size:16px;margin:25px 25px 25px -5px;color:grey;padding:0 10px;background-color:#fff;-webkit-transition:top .2s ease-in-out,font-size .2s ease-in-out;transition:top .2s ease-in-out,font-size .2s ease-in-out}.active{top:-30px;font-size:20px;color:#069}div.wrap input{width:100%;padding:20px 20px 5px 5px;border:none;border-bottom:1px solid grey;font-size:20px;background-color:transparent;color:grey;position:relative;outline:0}div.wrap input:focus{border-color:#069;font-size:16px;-webkit-transition:border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s;transition:border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s}#loginBtn{cursor:pointer;border-radius:5px;width:250px;background-color:#069;padding:5 0;border:2px solid #069;text-align:center;margin-top:40px}#loginBtn:hover{border-color:grey;-webkit-transition:border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s;transition:border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s}#loginText{font-size:24px;color:#fff;margin:10px 0}</style><script src="http://code.jquery.com/jquery-2.1.1.min.js" ></script><div id="register-login-popup" style="display:none"> <div id="iframeContainer" class="login-container"> <div class="login-inner-container"> <div onclick="closepopup()" id="closepopup" style="background-color: #333232;color: #fff;font-size: 24px;padding: 8px;position: absolute;right: -33px;cursor: pointer;">X</div><div style="height:10px;width:100%;margin:0 auto;padding:5px"></div><div id="registerlogin" style="width:100%;margin:0 auto;text-align: center;color:#069;float:left;padding-bottom:5px;font-size:26px;"> LOGIN </div><div style="width:100%;margin:0 auto;text-align: center;float: left;margin-top: 2px;"> <div style="width: 50%;height:auto;background-color: white;float:left;"> <div id="loginCreate" class="register-login" > <div id="errormessage" style="width:100%;text-align:center;font-size:12px;color:red;display:none"> email/password is wrong</div><div class="wrap"> <div> <label class="label" >Email</label> <input id="email" name="email" type="text" autocomplete = "off" class="cool"/> </div><div> <label class="label" >Password</label> <input id="password" name="password" autocomplete="off" type="password" class="cool"/> </div><div id="forgotPassword" style="margin: 0px;margin-top: -19px;margin-right: -162px;font-size: 12px;font-style: italic;"> <a href="/forgot-password" style="color:#069">forgot password?</a></div><div class="loginBtn" id="loginBtn" onclick="loginregister()"> <div id="loginText" > Login </div></div><div id="loginregistertext" style="width:100%;text-align:center;font-size:14px;font-weight:bold;"> Do not have an account? <a href="javascript: void(0);" style="color:#069" onclick="toggleLoginRegisterView(\'register\')">Register</a></div></div></div></div><div style="width:1px;height:300px;background-color: white;float: left;border-left: 1px solid grey;margin-top: 7px;margin-left: 3px;"></div><div style="width: 48%;height:300px;background-color: white;float:right;text-align:center;"><div style="width: 100%;font-size: 23px;color: #069;margin-top: 17px;"> Or Try </div><div onclick="checkAndCallFacebookLogin()" style="text-align:right;background: url(\'/unversioned/images/facebookconnect.png\');cursor:pointer;background-repeat: no-repeat;height: 42px;background-size: 250px 43px;margin-top: 162px;border-radius: 5px;width: 250px;margin-left: 29px;"><div id="fbloginbtn" style="color:white;font-weight:bold;font-size: 16px;padding: 8px;padding-top: 12px;">Connect with Facebook</div></div></div></div></div></div></div></div></html>').insertAfter('#footer');
242
			$(document).ready(function(){
270
			$(document).ready(function(){
243
				$('input').focusin( function() {
271
				$('input').focusin( function() {
244
				  $(this).parent().find('label').addClass('active');
272
				  $(this).parent().find('label').addClass('active');