-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathiOSWeather.coffee
160 lines (124 loc) · 4.05 KB
/
iOSWeather.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#mode of widget (light)
mode = "dark"
#api Key from OpenWeatherMap API
apiKey = ""
#list of city IDs from API database
cityList = "3060972,724443,723736"
#if you want to use imperial just change to "imperial"
units = "metric"
command: "curl -s 'http://api.openweathermap.org/data/2.5/group?id=#{cityList}&units=#{units}&appid=#{apiKey}'"
#http://api.openweathermap.org/data/2.5/group?id=7046,7049,2008861&units=metric&appid=
refreshFrequency: '15m'
#=== DO NOT EDIT AFTER THIS LINE unless you know what you're doing! ===
#======================================================================
render: (output) -> """
<div id='weather' class='#{mode}'>#{output}</div>
"""
update: (output) ->
weatherData = JSON.parse(output)
console.log(weatherData)
inner = ""
inner += "<header><img src='ubersicht-ios-clock-upnext-weather.widget/icons/weather.png' alt='icon'></img><div class='widgetName'>WEATHER</div></header>"
inner += "<div class='weatherBox'>"
for i in [0...weatherData.cnt]
city = weatherData.list[i].name
condition = weatherData.list[i].weather[0].main
temperature = Math.round(weatherData.list[i].main.temp)
rainChance = weatherData.list[i].clouds.all
windSpeed = Math.round(weatherData.list[i].wind.speed * 10) / 10
icon = weatherData.list[i].weather[0].icon
inner += "<div class='city'><div class='leftBox'><img src='ubersicht-ios-clock-upnext-weather.widget/icons/weather/#{icon}.svg' alt='#{icon}'></img></div><div class='middleBox'><div class='cityName'>"
inner += city
inner += "</div><div class='condition'>"
inner += condition
inner += "</div><div class='rainChance'>Chance of Rain "
inner += rainChance
inner += " %</div></div><div class='rightBox'><div class='temperature'>"
inner += temperature
inner += "°</div><div class='wind'>"
inner += windSpeed
inner += " km/h</div></div></div>"
console.log(city + condition + temperature)
inner += "</div>"
$(weather).html(inner)
style: """
color: white
font-family: SF Pro Rounded
font-weight: 400
width: 100%
position: absolute
top: calc(33% + 280px)
font-size: 14px
#weather
border-radius: 10px
background-color: rgba(0,0,0,0.45)
-webkit-backdrop-filter: blur(20px)
width: 410px
height: 70px
position: absolute
top: 0
left 50%
transform: translate(-50%,0)
padding: 40px 20px 20px 20px
-webkit-box-shadow: 10px 10px 47px 0px rgba(0,0,0,0.54)
letter-spacing: 1px
#weather.dark
background-color: rgba(0,0,0,0.45)
#weather.light
background-color: rgba(255,255,255,0.5)
color: black
#weather.light header
color: rgba(50,50,50,0.8)
#weather.dark header
color: rgba(200,200,200,0.8)
header
padding: 10px 0 10px 0
display: flex
flex-direction: row
position: fixed
top: 0
header img
width: 20px
margin-right: 10px
header .widgetName
line-height: 20px
.weatherBox
overflow-y: scroll
height: 100%
.city
padding: 5px
display: flex
flex-direction: row
//border-top: 1px solid rgba(200,200,200,0.3)
.city .leftBox
width: auto
padding: 0 10px 0 0
margin: 0 5px 0 0
.leftBox img
width: 57px
height: 57px
.city .middleBox
flex-grow: 1
.middleBox .cityName
font-size: 20px
line-height: 20px
font-weight: 500
.middleBox .condition
font-size: 12px
line-height: 20px
margin-top: 5px
.middleBox .rainChance
font-size: 12px
line-height: 12px
.city .rightBox
width: 20%
text-align:right
.rightBox .temperature
font-size: 40px
line-height: 45px
font-weight: 300
.rightBox .wind
font-size: 12px
line-height: 12px
text-align: center
"""