Subversion Repositories SmartDukaan

Rev

Rev 24072 | Rev 24159 | 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) {
24077 amit.gupta 32
			navigator.geolocation.getCurrentPosition(function(position) {
33
				if (typeof latitude == "undefined") {
34
					alert("Unable to fetch your device location");
35
				} else {
36
					distance = getDistance(latitude, longitude, position.coords.latitude, position.coords.longitude);
37
					if (distance < 500) {
38
						doPostAjaxRequestWithParamsHandler(context + "/createPunchInOut", {}, function(response) {
39
							$('#main-content').html(response);
40
							alert("Punch " + inOut + " done successfully");
41
						});
42
					} else {
43
						alert("Punch " + inOut + " can only be done from store.");
44
					}
45
 
46
				}
47
			});
24072 amit.gupta 48
		} else {
49
			alert("Location cant be tracked. Please enable location");
23834 ashik.ali 50
		}
51
	}
52
}
53
 
24072 amit.gupta 54
function loadPunchInOuts(domId) {
55
	doGetAjaxRequestHandler(context + "/getPunchInOuts", function(response) {
23834 ashik.ali 56
		$('#' + domId).html(response);
57
	});
58
}