Subversion Repositories SmartDukaan

Rev

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

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