| 1831 |
varun.gupt |
1 |
$(function(){
|
| 1842 |
varun.gupt |
2 |
$('#frmRegister').submit(function(){
|
|
|
3 |
trackEventWithGA('Account', 'New User Register', $('#frmRegister #email').val());
|
| 2110 |
vikas |
4 |
trackPageWithGA("/register"); // For registration goal.
|
| 1842 |
varun.gupt |
5 |
});
|
|
|
6 |
|
| 1831 |
varun.gupt |
7 |
$('#frmLogin').validate({
|
|
|
8 |
loginEmail: {
|
|
|
9 |
required: true,
|
|
|
10 |
email: true
|
|
|
11 |
},
|
|
|
12 |
loginPassword: {
|
|
|
13 |
required: true,
|
|
|
14 |
minlength: 6,
|
|
|
15 |
maxlength: 20
|
|
|
16 |
}
|
|
|
17 |
});
|
|
|
18 |
|
|
|
19 |
$("#frmRegister").validate({
|
|
|
20 |
rules: {
|
|
|
21 |
email: {
|
|
|
22 |
required: true,
|
|
|
23 |
email: true
|
|
|
24 |
},
|
|
|
25 |
txtPassword: {
|
|
|
26 |
required: true,
|
|
|
27 |
minlength: 6,
|
|
|
28 |
maxlength: 20
|
|
|
29 |
}
|
|
|
30 |
}
|
|
|
31 |
});
|
| 7825 |
amar.kumar |
32 |
|
|
|
33 |
$('.loginregister').live('click', function(){
|
|
|
34 |
if($('input[name=loginregister]:checked').val() == "register") {
|
|
|
35 |
$('#signin').hide();
|
|
|
36 |
$('#signup').show();
|
|
|
37 |
} else {
|
|
|
38 |
$('#signin').show();
|
|
|
39 |
$('#signup').hide();
|
|
|
40 |
}
|
|
|
41 |
});
|
|
|
42 |
|
|
|
43 |
});
|
|
|
44 |
|
| 20203 |
aman.kumar |
45 |
/*function loginToSaholicByFacebook(userDetails, authResponse){
|
| 7825 |
amar.kumar |
46 |
var longLivedToken = null;
|
|
|
47 |
|
|
|
48 |
if(authResponse!==null) {
|
|
|
49 |
$.ajax({
|
|
|
50 |
type : "GET",
|
|
|
51 |
url : "https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id="+
|
|
|
52 |
'${in.shop2020.appId}' + "&client_secret="+'${in.shop2020.appSecret}'+
|
|
|
53 |
"&fb_exchange_token="+authResponse.accessToken,
|
|
|
54 |
|
|
|
55 |
success : function(response) {
|
|
|
56 |
longLivedToken = response.substring(0,response.indexOf("&expires")).split("=")[1];
|
|
|
57 |
},
|
|
|
58 |
|
|
|
59 |
complete: function() {
|
|
|
60 |
$.ajax({
|
|
|
61 |
type : "POST",
|
|
|
62 |
url : "/login/?email="+userDetails.email+"&name="+userDetails.name+"&gender="+userDetails.gender+"&isFacebookUser=True&accessToken="+longLivedToken+"&facebookId="+authResponse.userID,
|
|
|
63 |
success : function(response) {
|
|
|
64 |
window.location = "/";
|
|
|
65 |
}
|
|
|
66 |
});
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
});
|
|
|
70 |
} else {
|
|
|
71 |
$.ajax({
|
|
|
72 |
type : "POST",
|
|
|
73 |
url : "/login/?email="+userDetails.email+"&name="+userDetails.name+"&gender="+userDetails.gender+"&isFacebookUser=True",
|
|
|
74 |
success : function(response) {
|
|
|
75 |
window.location = "/";
|
|
|
76 |
}
|
|
|
77 |
});
|
|
|
78 |
}
|
| 20203 |
aman.kumar |
79 |
}*/
|
|
|
80 |
|
| 20212 |
aman.kumar |
81 |
|
| 20203 |
aman.kumar |
82 |
var LoginNamespace={};
|
|
|
83 |
var authDetails=null;
|
|
|
84 |
var userDetails=null;
|
| 20208 |
aman.kumar |
85 |
var sourceShip=false;
|
| 20203 |
aman.kumar |
86 |
$(document).ready(function() {
|
|
|
87 |
$.ajaxSetup({ cache: true });
|
|
|
88 |
$.getScript('//connect.facebook.net/en_US/sdk.js', function(){
|
|
|
89 |
FB.init({
|
| 20245 |
aman.kumar |
90 |
appId: '{'+'${in.shop2020.appId}'+'}',
|
| 20203 |
aman.kumar |
91 |
version: 'v2.7' // or v2.0, v2.1, v2.2, v2.3
|
|
|
92 |
});
|
|
|
93 |
$('#loginbutton,#feedbutton').removeAttr('disabled');
|
|
|
94 |
|
|
|
95 |
});
|
|
|
96 |
|
|
|
97 |
(function(d, s, id) {
|
|
|
98 |
var js, fjs = d.getElementsByTagName(s)[0];
|
|
|
99 |
if (d.getElementById(id)) return;
|
|
|
100 |
js = d.createElement(s); js.id = id;
|
| 20245 |
aman.kumar |
101 |
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.7&appId="+'${in.shop2020.appId}';
|
| 20203 |
aman.kumar |
102 |
fjs.parentNode.insertBefore(js, fjs);
|
|
|
103 |
}(document, 'script', 'facebook-jssdk'));
|
|
|
104 |
});
|
|
|
105 |
|
|
|
106 |
var mode = '';
|
|
|
107 |
function checkAndCallFacebookLogin() {
|
|
|
108 |
mode = $('#loginText').html();
|
| 20208 |
aman.kumar |
109 |
|
| 20203 |
aman.kumar |
110 |
$('#errormessage').hide();
|
|
|
111 |
$('#errormessage').html('');
|
|
|
112 |
//window.fbAsyncInit();
|
|
|
113 |
FB.getLoginStatus(function(response) {
|
|
|
114 |
// Check login status on load, and if the user is
|
|
|
115 |
// already logged in, go directly to the welcome message.
|
|
|
116 |
authDetails = response;
|
|
|
117 |
if (authDetails.status == 'connected') {
|
|
|
118 |
|
|
|
119 |
getCurrentUserInfo();
|
|
|
120 |
} else {
|
|
|
121 |
// Otherwise, show Login dialog first.
|
|
|
122 |
FB.login(function(response) {
|
|
|
123 |
authDetails=response;
|
|
|
124 |
getCurrentUserInfo();
|
|
|
125 |
}, {scope: 'user_friends, email'});
|
|
|
126 |
}
|
|
|
127 |
});
|
|
|
128 |
}
|
|
|
129 |
|
| 20225 |
aman.kumar |
130 |
function loginregister(src){
|
| 20203 |
aman.kumar |
131 |
mode = $('#loginText').html();
|
|
|
132 |
$('#errormessage').hide();
|
|
|
133 |
$('#errormessage').html('');
|
| 20225 |
aman.kumar |
134 |
var email;
|
|
|
135 |
var password;
|
|
|
136 |
if(src&&src!=undefined){
|
|
|
137 |
email = $('#lemail').val();;
|
|
|
138 |
password = $('#lpassword').val();
|
|
|
139 |
}else{
|
|
|
140 |
email = $('#email').val();;
|
|
|
141 |
password = $('#password').val();
|
|
|
142 |
}
|
| 20203 |
aman.kumar |
143 |
if(mode =='Login'){
|
| 20225 |
aman.kumar |
144 |
try{ trackEventWithGA('Account', 'Login from '+window.location.pathname, $('#email').val());}catch(e){}
|
| 20203 |
aman.kumar |
145 |
$.ajax({
|
|
|
146 |
type : "POST",
|
| 20225 |
aman.kumar |
147 |
url : "/login?email="+email+"&password="+password,
|
| 20203 |
aman.kumar |
148 |
success : function(response) {
|
|
|
149 |
response = JSON.parse(response);
|
|
|
150 |
if(response.status=='success'){
|
| 20208 |
aman.kumar |
151 |
if(sourceShip)
|
|
|
152 |
window.location.href='/shipping';
|
|
|
153 |
else
|
|
|
154 |
window.location.reload();
|
| 20203 |
aman.kumar |
155 |
}else{
|
|
|
156 |
$('#errormessage').html(response.message);
|
|
|
157 |
$('#errormessage').show();
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
}
|
|
|
161 |
});
|
|
|
162 |
}else{
|
| 20225 |
aman.kumar |
163 |
try{trackEventWithGA('Account', 'Register from '+window.location.pathname, $('#email').val());}catch(e){}
|
| 20203 |
aman.kumar |
164 |
$.ajax({
|
|
|
165 |
type : "POST",
|
| 20225 |
aman.kumar |
166 |
url : "/register?redirectUrl=/&email="+email+"&password="+password,
|
| 20203 |
aman.kumar |
167 |
success : function(response) {
|
|
|
168 |
response = JSON.parse(response);
|
|
|
169 |
if(response.status=='success'){
|
| 20208 |
aman.kumar |
170 |
if(sourceShip)
|
|
|
171 |
window.location.href='/shipping';
|
|
|
172 |
else
|
|
|
173 |
window.location.reload();
|
| 20203 |
aman.kumar |
174 |
}else{
|
|
|
175 |
$('#errormessage').html(response.message);
|
|
|
176 |
$('#errormessage').show();
|
|
|
177 |
}
|
|
|
178 |
}
|
|
|
179 |
});
|
|
|
180 |
}
|
|
|
181 |
}
|
|
|
182 |
|
| 20208 |
aman.kumar |
183 |
$('#poplogin').click(function(){
|
|
|
184 |
loginsignup('ship');
|
|
|
185 |
});
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
| 20203 |
aman.kumar |
189 |
|
|
|
190 |
function getCurrentUserInfo() {
|
|
|
191 |
FB.api('/me?fields=id,name,email,permissions', function(userInfo) {
|
|
|
192 |
userDetails = userInfo;
|
|
|
193 |
if(authDetails && authDetails.status=='connected' && userDetails && userDetails.email){
|
|
|
194 |
if(mode=='Login'){
|
| 20222 |
aman.kumar |
195 |
$.ajax({
|
| 20203 |
aman.kumar |
196 |
type : "POST",
|
|
|
197 |
url : "/login!verifyFbUser?accessToken="+authDetails.authResponse.accessToken+"&email="+userDetails.email,
|
|
|
198 |
success : function(response) {
|
|
|
199 |
response = JSON.parse(response);
|
|
|
200 |
if(response.status=='success'){
|
| 20208 |
aman.kumar |
201 |
if(sourceShip)
|
|
|
202 |
window.location.href='/shipping';
|
|
|
203 |
else
|
|
|
204 |
window.location.reload();
|
|
|
205 |
|
| 20203 |
aman.kumar |
206 |
}else{
|
|
|
207 |
$('#errormessage').html(response.message);
|
|
|
208 |
$('#errormessage').show();
|
|
|
209 |
}
|
|
|
210 |
}
|
|
|
211 |
});
|
|
|
212 |
}else{
|
|
|
213 |
$.ajax({
|
|
|
214 |
type : "POST",
|
|
|
215 |
url : "/login!signupFacebookUser?accessToken="+authDetails.authResponse.accessToken+"&email="+userDetails.email,
|
|
|
216 |
success : function(response) {
|
|
|
217 |
response = JSON.parse(response);
|
|
|
218 |
if(response.status=='success'){
|
| 20208 |
aman.kumar |
219 |
if(sourceShip)
|
|
|
220 |
window.location.href='/shipping';
|
|
|
221 |
else
|
|
|
222 |
window.location.reload();
|
| 20203 |
aman.kumar |
223 |
}else{
|
|
|
224 |
$('#errormessage').html(response.message);
|
|
|
225 |
$('#errormessage').show();
|
|
|
226 |
}
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
});
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
}else{
|
|
|
234 |
//retry
|
|
|
235 |
//login unsuccessful
|
|
|
236 |
}
|
|
|
237 |
});
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
|
242 |
function openpopup(){
|
|
|
243 |
$('#register-login-popup').show();
|
|
|
244 |
toggleLoginRegisterView('login');
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
function closepopup(){
|
|
|
248 |
$('#register-login-popup').hide();
|
|
|
249 |
toggleLoginRegisterView('login');
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
function toggleLoginRegisterView(view){
|
|
|
253 |
$('#errormessage').hide();
|
|
|
254 |
$('#email').html('');
|
|
|
255 |
$('#password').html('');
|
|
|
256 |
$('#errormessage').html('');
|
|
|
257 |
|
|
|
258 |
if(view=='register'){
|
|
|
259 |
$('#registerlogin').html('REGISTER');
|
|
|
260 |
$('#loginText').html('Register');
|
| 20223 |
aman.kumar |
261 |
$('#fbloginbtn').html('Register with Facebook');
|
| 20203 |
aman.kumar |
262 |
$('#loginregistertext').html('Already a member? <a href="javascript: void(0);" style="color:#069" onclick="toggleLoginRegisterView(\'login\')">Login</a></div>');
|
|
|
263 |
$('#forgotPassword').hide();
|
|
|
264 |
}else{
|
|
|
265 |
$('#registerlogin').html('LOGIN');
|
|
|
266 |
$('#loginText').html('Login');
|
| 20223 |
aman.kumar |
267 |
$('#fbloginbtn').html('Login with Facebook');
|
| 20203 |
aman.kumar |
268 |
$('#loginregistertext').html('Do not have an account?<a href="javascript: void(0);" style="color:#069" onclick="toggleLoginRegisterView(\'register\')">Register</a></div>');
|
|
|
269 |
$('#forgotPassword').show();
|
|
|
270 |
}
|
|
|
271 |
}
|
|
|
272 |
|
| 20208 |
aman.kumar |
273 |
function loginsignup(source){
|
|
|
274 |
if(source)
|
|
|
275 |
sourceShip=true;
|
|
|
276 |
else
|
|
|
277 |
sourceShip = false;
|
| 20203 |
aman.kumar |
278 |
if($('#register-login-popup').length==0){
|
| 20254 |
aman.kumar |
279 |
$('<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}.inactivelabel{position:absolute;top:0;font-size:16px;margin:21px 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}.activelabel{top:-30px;font-size:20px;color:#069}div.wrap input{width:100%;margin:20px 20px 5px 5px;border:none;border-bottom:1px solid grey;font-size:16px;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:51px}#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="inactivelabel" >Email</label> <input id="email" name="email" type="text" autocomplete = "off" class="cool" value=""/> </div><div> <label class="inactivelabel" >Password</label> <input id="password" name="password" autocomplete="off" type="password" class="cool" value=""/> </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;">Login with Facebook</div></div></div></div></div></div></div></div></html>').insertAfter('#footer');
|
| 20203 |
aman.kumar |
280 |
$(document).ready(function(){
|
|
|
281 |
$('input').focusin( function() {
|
| 20226 |
aman.kumar |
282 |
$(this).parent().find('label').addClass('activelabel');
|
| 20203 |
aman.kumar |
283 |
|
|
|
284 |
});
|
|
|
285 |
|
|
|
286 |
$('input').focusout( function() {
|
|
|
287 |
if (!this.value) {
|
| 20226 |
aman.kumar |
288 |
$(this).parent().find('label').removeClass('activelabel');
|
| 20203 |
aman.kumar |
289 |
}
|
|
|
290 |
});
|
|
|
291 |
|
|
|
292 |
});
|
|
|
293 |
}
|
| 20206 |
aman.kumar |
294 |
openpopup();
|
| 20203 |
aman.kumar |
295 |
}
|
| 20225 |
aman.kumar |
296 |
|
|
|
297 |
$(document).ready(function(){
|
|
|
298 |
$('input').focusin( function() {
|
| 20226 |
aman.kumar |
299 |
$(this).parent().find('label').addClass('activelabel');
|
| 20225 |
aman.kumar |
300 |
|
|
|
301 |
});
|
| 20203 |
aman.kumar |
302 |
|
| 20225 |
aman.kumar |
303 |
$('input').focusout( function() {
|
|
|
304 |
if (!this.value) {
|
| 20226 |
aman.kumar |
305 |
$(this).parent().find('label').removeClass('activelabel');
|
| 20225 |
aman.kumar |
306 |
}
|
|
|
307 |
});
|
|
|
308 |
|
|
|
309 |
});
|
|
|
310 |
|