Subversion Repositories SmartDukaan

Rev

Rev 24056 | Rev 24077 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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