-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.njk
More file actions
149 lines (99 loc) · 3.94 KB
/
Copy pathindex.njk
File metadata and controls
149 lines (99 loc) · 3.94 KB
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
<!DOCTYPE html>
<html lang="en" data-theme="light">
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
<script src="../weather_data.js"></script>
<script src="../weatherCode_weatherForecast.js"></script>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Whether Weather App</title>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/images/sun_logo.png"
/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Data</title>
<script>
document.addEventListener('DOMContentLoaded', () =>
{
// NAVBURGER
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Add a click event on each of them
$navbarBurgers.forEach(el =>
{
el.addEventListener('click', () =>
{
// Get the target from the "data-target" attribute
const target = el.dataset.target;
const $target = document.getElementById(target);
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
});
</script>
</head>
<div id= "main-body">
{% include "navbar.njk" %}
<main class="columns is-multiline box has-background-white">
<div class="column is-12 has-text-centered has-text-black">
<p class="is-size-1">DASHBOARD</p>
<p class="is-size-0.5">Click on each image for CityFocus</p>
<script>
document.addEventListener("DOMContentLoaded", () => {
const countryArray = ["waterford", "amsterdam", "berlin", "copenhagen"];
const timeArray = new Array(4);
const temperatureArray = new Array(4);
const weatherCodeArray = new Array(4);
//const weatherTypeArray = new Array(4);
const timeNow = document.getElementById("newCurrentTime");
timeNow.innerHTML = dayjs().format('dddd, MMMM D, YYYY h:mm A');
const CardInfo = ( day, temperature, weatherType, country, imageURL ) => {
return `<div class="column is-1.5">
<section class="card has-text-centered">
<section class="card has-background-light">
<header class="card-header">
<p class="card-header-title is-size-6 is-centered">
${country}
</p>
</header>
<div class="card-image">
<figure class="image">
<a href="/cityfocus_Menu/?name=${country}"> <img src="/images/${imageURL}" style="width:500px;height:300px;"></a>
</figure>
</div>
<article class="card-content">
<p class="content is-size-4">
<p> ${day}</p>
<p>Temp: ${temperature}°C</p>
<p>weatherCode: ${weatherType} </p>
</p>
</article>
</section>
</section>
</div>`
};
let allCardsHTML = "";
for (let i = 0; i < 4; i++)
{
const cityData = weatherData[countryArray[i] + "_daily"]
timeArray[i] = cityData.daily.time[0];
temperatureArray[i] = cityData.daily.temperature_2m_max[i];
weatherCodeArray[i] = cityData.daily.weather_code[i];
const weatherInfo = rightWeatherForecast(weatherCodeArray[i]);
allCardsHTML += CardInfo(timeArray[i], temperatureArray[i], (weatherInfo[0]), countryArray[i], weatherInfo[1] );
}
const container = document.getElementById("dashboard-cards");
container.innerHTML = allCardsHTML;
});
</script>
<p>The date is <span id="newCurrentTime"></span></p>
<div id="dashboard-cards" class="columns is-multiline"></div>
{% include "footer.njk" %}
</body>
</html>