Subversion Repositories SmartDukaan

Rev

Rev 35458 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35458 Rev 35459
Line 5... Line 5...
5
 
5
 
6
	$('form').on('submit', function() {
6
	$('form').on('submit', function() {
7
		if($(this).find("#password").length > 0) {
7
		if($(this).find("#password").length > 0) {
8
			login();
8
			login();
9
		} else {
9
		} else {
10
			var email = $("#email").val();
10
			var email=$("#email").val();
-
 
11
			console.log(email);
11
			if(!email || email.trim() === '') {
12
			if(email==""|email==null||email==undefined)
-
 
13
				{
12
				alert("Input field email can't be empty");
14
					alert("Input field email can't be empty");
13
				return false;
15
					return;
14
			}
16
				}
15
			forgetPassword(email);
17
			forgetPassword(email);
16
		}
18
		}
17
		return false;
19
		return false;
18
	});
20
	});
19
	
21
	
20
	$(document).on('click', ".forgetPassword", function() {
22
	$(document).on('click', ".forgetPassword", function() {
21
		$("#auth").toggle();
23
		$("#auth").toggle();
22
		$('#forget-password').toggle();
24
		$('#forget-password').toggle();
23
	});
25
	});
24
});
26
});
-
 
27
$(document).ajaxComplete(function() {
-
 
28
});
25
 
29
 
26
function login() {
30
function login() {
-
 
31
	console.log("Login DashBoard");
27
	var emailIdOrMobileNumber = $("#emailormobile").val();
32
	var emailIdOrMobileNumber = $("#emailormobile").val();
-
 
33
	console.log(emailormobile);
28
	var password = $("input[type='password']").val();
34
	var password = $("input[type='password']").val();
29
	if (!emailIdOrMobileNumber || emailIdOrMobileNumber.trim() === '') {
35
	if (emailIdOrMobileNumber == "" || emailIdOrMobileNumber == undefined || emailIdOrMobileNumber == null) {
-
 
36
		
30
		alert("Input field emailIdOrMobileNumber can't be empty");
37
			alert("Input field emailIdOrMobileNumber can't be empty")
31
		return;
38
			return;
32
	}
39
		}
33
	if (!password || password.trim() === '') {
40
	if (password == "" || password == null || password == undefined) {
34
		alert("Password can't be empty");
41
		alert("password can't be empty")
35
		return;
42
		return;
36
	}
43
	}
37
	submitUser(null, emailIdOrMobileNumber, password);
44
	submitUser(null, emailIdOrMobileNumber, password)
38
}
45
}
39
 
46
 
40
function onSignIn(googleUser) {
47
function onSignIn(googleUser) {
41
	var profile = googleUser.getBasicProfile();
48
	var profile = googleUser.getBasicProfile();
42
	submitUser(googleUser, profile.getEmail(), null);
49
	submitUser(googleUser, profile.getEmail(), null);
Line 106... Line 113...
106
					alert("Retailer not found, Please login");
113
					alert("Retailer not found, Please login");
107
				}
114
				}
108
			});
115
			});
109
 
116
 
110
}
117
}
111
function forgetPassword(emailId) {
118
function forgetPassword(emailId)
-
 
119
{
112
	var params = {"emailId": emailId};
120
	var params={"emailId":emailId };
113
	doAjaxRequestWithParamsHandler(context + "/forgetPassword", "POST", params, function(response) {
121
	doAjaxRequestWithParamsHandler(context + "/forgetPassword", "POST", params, function(response) {
-
 
122
		console.log(response, typeof response);
114
		if(response === "true") {
123
		if(response=="true") {
115
			alert("Your password has been sent to your email, Please login");
124
			alert("Your password has been sent to your email, Please login");
116
			setTimeout(function() { window.location.reload(); }, 5000);
125
			setTimeout(function(){ window.location.reload(); }, 5000);
117
		}
126
		}
118
	});
127
	});
119
}
128
}
120
 
129
 
121
function addProfileInLocalDb() {
130
function addProfileInLocalDb() {
122
	var profile;
-
 
123
	if(googleProfile) {
131
	if(googleProfile){
124
		profile = {
132
	var profile = {
125
			'image_url': googleProfile.getImageUrl(),
133
		'image_url' : googleProfile.getImageUrl(),
126
			'name': googleProfile.getName()
134
		'name' : googleProfile.getName()
127
		};
135
	};
128
	} else {
-
 
129
		profile = {
-
 
130
			'image_url': "",
136
	console.log(googleProfile.getImageUrl);
131
			'name': partnerName
137
	console.log(googleProfile.getName());
132
		};
-
 
133
	}
-
 
134
	localStorage.setItem("profile", JSON.stringify(profile));
138
	localStorage.setItem("profile", JSON.stringify(profile));
135
}
-
 
136
139
}
-
 
140
	else
-
 
141
		{
-
 
142
		var profile = {
-
 
143
				'image_url' : "",
-
 
144
				'name' : partnerName
-
 
145
			};
-
 
146
			console.log(partnerName);
-
 
147
			//console.log(googleProfile.getName());
-
 
148
			localStorage.setItem("profile", JSON.stringify(profile));
-
 
149
		}
-
 
150
	}
-
 
151
137
152