PageSourceSearch

https://www.ripleychurch.org.uk/js/time_handler.js

js ripleychurch.org.uk collected 2026-09-26 15:20:45 UTC 2,448 bytes, 120 lines download raw bytes

1$(function() {
2	
3	//Requires jquery.numeric.js
4	$.getScript("./js/jquery.numeric.js", function() {
5		$('.time_hour, .time_min').numeric();
6	});
7	
8	function start($input)
9	{
10		if ($input.hasClass('time_hour')) {
11			return 12;
12		}
13		else if($input.hasClass('time_min')) {
14			return pad(00);
15		}
16	}
17	
18	function total($input) {
19		if ($input.hasClass('time_hour')) {
20			return 23;
21		}
22		else if($input.hasClass('time_min')) {
23			return 59;
24		}
25	}
26	
27	function pad(num) {
28		var size = 2;
29		var s = "000000000" + num;
30		return s.substr(s.length-size);
31	}
32
33	$('.time_hour, .time_min').keydown(function(e) {
34		var key = String.fromCharCode(e.keyCode);
35
36		if (isNaN(key / 1) == false) {
37			e.preventDefault();
38			var val = $(this).val();
39			var new_val = val.substr(val.length - 1) + key;
40		
41			if (new_val.length > 2) {
42				$(this).val(new_val.substr(new_val.length - 2));
43			}
44			else {
45				$(this).val(new_val);
46			}
47
48			if (parseInt(new_val, 10) > total($(this))) {
49				var last = new_val.substr(new_val.length - 1);
50				$(this).val('0' + last);
51			}
52		}
53	});
54
55	$('.time_hour, .time_min').keyup(function(e) {
56		if ($(this).val() == "") {
57                	$(this).val(start($(this)));
58        	}
59	});
60	
61	$('.time_container .add').click(function(e) {
62		var $input = $(this).parent().prev('.time_val');
63		
64		if ($input.val() == "Hour")
65		{
66			$input.val(12);
67		}
68		else if($input.val() == "Mins")
69		{
70			$input.val("00");
71		}
72		else
73		{
74			var input_val = parseInt($input.val(), 10);
75				
76			if (isNaN(input_val) || input_val == total($input)) {
77				var $nv = 0;
78			}
79			else {
80				var $nv = input_val + 1;
81			}
82			$input.val(pad($nv));
83		}	
84        $input.focus()
85	});
86	
87	$('.time_container .sub').click(function(e) {
88		var $input = $(this).parent().prev('.time_val');
89		var input_val = parseInt($input.val(), 10);
90				
91		if (isNaN(input_val) || input_val == 0) {
92			var $nv = total($input);
93		}
94		else {
95			var $nv = input_val - 1;
96		}
97		
98		$input.val(pad($nv));
99        $input.focus()
100	});
101	
102	$('.time_hour, .time_min').mouseup(function() {
103		if ($(this).val() == "") {
104			$(this).val(pad(start($(this))));
105		}
106	});
107	
108	$('.time_hour').click(function() {
109		if ($(this).val() == "Hour") {
110			$(this).val(pad('12'));
111		}
112	});
113	
114	$('.time_min').click(function() {
115		if ($(this).val() == "Mins") {
116			$(this).val(pad('00'));
117		}
118	});
119	
120});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.