-
Notifications
You must be signed in to change notification settings - Fork 0
/
datetime.coffee
88 lines (53 loc) · 1.23 KB
/
datetime.coffee
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# settings
offsetY = 0
baseSize = 32
colour = '#2E3440'
# ======================================= #
# date stuff
date = new Date()
day = date.getDate()
month = date.getMonth()
year = date.getFullYear()
months = ['Jan', 'Feb', 'March', 'April', 'May', 'June', 'July', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec']
# widget stuff
command: "date +'%H:%M'"
refreshFrequency: 60000
# create me
render: (output) -> """
<div id="time">#{output}</div>
<div id="date"></div>
"""
# update me
update: () ->
document.getElementById("date").innerHTML = day + ' ' + months[month] + ' ' + year
# make me pretty
style: (->
return """
postion absolute
left: 50%
top: 50%
font-family: Josefin Sans, Helvetica Neue
font-weight: 900
text-align: center
line-height: .8
color: #{colour}
transform: translate(-50%, calc(-50% + #{offsetY}px))
#time
font-size: #{baseSize * 4}px
#date
font-size: #{baseSize}px
#time::before
#date::after
position: absolute
left: 50%
width: 150px
height: 1px
background: #{colour}
transform: translateX(-50%)
content: ''
#time::before
top: -20px
#date::after
bottom: -15px
"""
)()