aboutsummaryrefslogtreecommitdiffstats
path: root/view/tpl/regate_pre.tpl
blob: 790dec4b9ee79a1b68b910fddc6d631fffd05bea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<div class="generic-content-wrapper">
	<div class="section-title-wrapper">
		<h2>{{$title}}</h2>
	</div>
	<div class="section-content-wrapper">
		{{if $now}}
		<div class="section-content-danger-wrapper">
			<div class="h3">{{$now}}</div>
		</div>
		{{else}}
		<div class="section-content-warning-wrapper">
			{{$strings.0}}
			<div id="countdown" class="h3"></div>
		</div>
		<div class="section-content-info-wrapper">
			{{$strings.1}} {{$id}}
			<div class="h3">{{$pin}}</div>
			{{if $strings.2}}<b>{{$strings.2}}</b>{{/if}}
		</div>
		<div class="d-none">
			{{$strings.3}}<br>
			<span id="register_start" data-utc="{{$regdelay}}" class="register_date">
				{{$regdelay}}
			</span>
			&nbsp;&dash;&nbsp;
			<span data-utc="{{$regexpire}}" class="register_date">
				{{$regexpire}}
			</span>
		</div>
		{{/if}}
	</div>
</div>

<script>
	$('.register_date').each( function () {
		var date = new Date($(this).data('utc'));
		$(this).html(date.toLocaleString(undefined, {weekday: 'short', hour: 'numeric', minute: 'numeric'}));
	});

	var date = '{{$countdown}}';
	date = date !== '' ? date : $('#register_start').data('utc');

	if(date) {
		doCountDown(date, 'countdown');
		var x = setInterval(doCountDown, 1000, date, 'countdown');
	}

	function doCountDown(date, id) {
		var countDownDate = new Date(date).getTime();
		var now = new Date().getTime();
		var distance = countDownDate - now;
		var days = Math.floor(distance / (1000 * 60 * 60 * 24));
		var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
		var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
		var seconds = Math.floor((distance % (1000 * 60)) / 1000);

		document.getElementById(id).innerHTML = days + "d " + hours + "h "+ minutes + "m " + seconds + "s ";

		if (distance < 0) {
			clearInterval(x);
			document.getElementById(id).innerHTML = 'Reloading...';
			window.location.reload();
		}
	}
</script>