-
Notifications
You must be signed in to change notification settings - Fork 2
/
events.html
71 lines (62 loc) · 2.64 KB
/
events.html
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
66
67
68
69
70
71
---
layout: default
permalink: /events/
title: "Настани"
---
<div class="page">
<h3>Настани во #хаклаб <a style="margin-left: 5px; font-size: medium; text-decoration: underline; color: #999" href="/feed/events.xml">feed</a></h3>
{% assign id = 0 %}
{% assign sorted = site.events | sort: 'start_date' | reverse %}
{% if sorted.first != nil %}
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Наслов</th>
<th scope="col">Датум</th>
<th scope="col">Време</th>
<th scope="col">Статус</th>
</tr>
</thead>
<tbody>
{% for post in sorted limit:15 %}
<tr>
<td><a href="{{ post.url | prepend: site.url }}">{{ post.title }}</a></td>
<td >{{ post.start_date | date: "%a, %b %d, %Y" }}</td>
<td>{{ post.start_date | date: "%H:%M" }} - {{ post.end_date | date: "%H:%M" }}</td>
<th id="{{ id }}" start_date="{{ post.start_date | date: '%Y%m%d%H%M' }}" end_date="{{ post.end_date | date: '%Y%m%d%H%M' }}" scope="row"></th>
</tr>
{% capture id %}{{ id | plus:1 }}{% endcapture %}
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info mt-5" role="alert">
Сѐ уште нема објавени настани.
</div>
{% endif %}
</div>
<script>
function getCompareDate() {
var d = new Date(),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
hour = d.getHours();
minutes = d.getMinutes();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
return [year, month, day, hour, minutes].join('');
}
document.querySelectorAll('th[start_date]').forEach(node => {
if (getCompareDate() < node.attributes['start_date'].value) {
$("#" + node.id).html("ПРЕТСТОЕН");
$("#" + node.id).addClass("text-info");
} else if (getCompareDate() > node.attributes['end_date'].value) {
$("#" + node.id).html("МИНАТ");
$("#" + node.id).addClass("text-muted");
} else {
$("#" + node.id).html("ВО ТЕК");
$("#" + node.id).addClass("text-success");
}
})
</script>