Subversion Repositories SmartDukaan

Rev

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

Rev 24056 Rev 24072
Line 1... Line 1...
1
$(function() {
1
$(function() {
2
	
2
 
3
	$(".punch-in-outs").live('click', function() {
3
	$(".punch-in-outs").live('click', function() {
4
		loadPunchInOuts("main-content");
4
		loadPunchInOuts("main-content");
5
	});
5
	});
6
	
6
 
7
	$("#punch-in-outs-paginated .next").live('click', function() {
7
	$("#punch-in-outs-paginated .next")
-
 
8
			.live(
-
 
9
					'click',
-
 
10
					function() {
8
		loadPaginatedNextItems('/getPaginatedPunchInOuts', null, 'punch-in-outs-paginated', 'punch-in-outs-table', null);
11
						loadPaginatedNextItems('/getPaginatedPunchInOuts',
-
 
12
								null, 'punch-in-outs-paginated',
-
 
13
								'punch-in-outs-table', null);
9
		$(this).blur();
14
						$(this).blur();
10
    });
15
					});
11
	
16
 
12
	$("#punch-in-outs-paginated .previous").live('click', function() {
17
	$("#punch-in-outs-paginated .previous")
-
 
18
			.live(
-
 
19
					'click',
-
 
20
					function() {
13
		loadPaginatedPreviousItems('/getPaginatedPunchInOuts', null, 'punch-in-outs-paginated', 'punch-in-outs-table', null);
21
						loadPaginatedPreviousItems('/getPaginatedPunchInOuts',
-
 
22
								null, 'punch-in-outs-paginated',
-
 
23
								'punch-in-outs-table', null);
14
		$(this).blur();
24
						$(this).blur();
15
    });
25
					});
16
});
26
});
17
 
27
 
18
function createPunchInOut(inOut) {
28
function createPunchInOut(inOut) {
19
	if(confirm("Are you sure you want to do punch "+inOut)){
29
	if (confirm("Are you sure you want to do punch " + inOut)) {
20
		distance = undefined;
30
		distance = undefined;
21
		if (navigator.geolocation) {
31
		if (navigator.geolocation) {
22
		        navigator.geolocation.getCurrentPosition(showPosition);
32
			navigator.geolocation
23
		    } else {
33
					.getCurrentPosition(function(position) {
24
		        alert("Location cant be tracked. Please enable location");
34
						alert("Unable to fetch your device location");
25
		    }
-
 
26
		if(distance == undefined){
35
						if (typeof latitude == "undefined") {
27
			alert("Unable to fetch your device location");
36
							distance = getDistance(latitude, longitude,
28
			return;
37
									position.coords.latitude,
29
		}
38
									position.coords.longitude);
30
		if(distance < 500){
39
							if (distance < 500) {
31
			doPostAjaxRequestWithParamsHandler(context+"/createPunchInOut", {}, function(response){
40
								doPostAjaxRequestWithParamsHandler(context
-
 
41
										+ "/createPunchInOut", {}, function(
-
 
42
										response) {
32
				$('#main-content').html(response);
43
									$('#main-content').html(response);
-
 
44
									alert("Punch " + inOut
33
				alert("Punch "+inOut+" done successfully");
45
											+ " done successfully");
-
 
46
								});
-
 
47
							} else {
-
 
48
								alert("Punch " + inOut
-
 
49
										+ " can only be done from store.");
-
 
50
							}
-
 
51
						} else {
-
 
52
							alert("Location cant be tracked. Please enable location");
-
 
53
							return;
-
 
54
						}
34
			});
55
					});
35
		}else{
56
		} else {
36
			alert("Punch "+inOut+" can only be done from store.");
57
			alert("Location cant be tracked. Please enable location");
37
		}
58
		}
38
	}
59
	}
39
}
60
}
40
 
61
 
41
function loadPunchInOuts(domId){
62
function loadPunchInOuts(domId) {
42
	doGetAjaxRequestHandler(context+"/getPunchInOuts", function(response){
63
	doGetAjaxRequestHandler(context + "/getPunchInOuts", function(response) {
43
		$('#' + domId).html(response);
64
		$('#' + domId).html(response);
44
	});
65
	});
45
}
66
}
46
 
-