-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.js
37 lines (34 loc) · 1.66 KB
/
view.js
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
const serverUrl = 'https://api.openweathermap.org/data/2.5/weather';
const apiKey = "97f36208f41daeec8c857deb48d7e06c";
const BUTTONS = {
SUBMIT_BUTTON: document.querySelector(".header"),
FAVORIT_BUTTON: document.querySelector(".heart"),
DELETE_BUTTON: document.querySelectorAll(".deleteButton"),
NAVI_BUTTONS: document.querySelectorAll(".navi_btn"),
}
const UI_ELEMENTS = {
TEMPERATURA: document.querySelectorAll(".temp"),
CITY_NAME: document.querySelectorAll(".city_name"),
ATMOSFERE_NOW: document.querySelector(".atmosfere"),
FEELS_LIKE: document.querySelector(".feels"),
CLOUDS: document.querySelector(".clouds"),
SUNRISE: document.querySelector('.sunrise'),
SUNSET: document.querySelector('.sunset'),
FAVORIT_LIST: document.querySelectorAll(".enterCity"),
DATES: document.querySelectorAll(".date"),
TABS: document.querySelectorAll(".infoWeather"),
}
BUTTONS.NAVI_BUTTONS.forEach(button => button.addEventListener("click", chengingTabs))
function chengingTabs(event) {
const buttons = Array.from(BUTTONS.NAVI_BUTTONS);
const index_button = buttons.findIndex(id => id == event.currentTarget);
const tabs = Array.from(UI_ELEMENTS.TABS);
const activ_tab = tabs[index_button];
const passiv_tabs = tabs.filter(item => item !== activ_tab);
const passiv_buttons = buttons.filter(btn => btn !== event.currentTarget);
activ_tab.classList.add("infoWeatherAktiv");
passiv_tabs.forEach(item => item.classList.remove("infoWeatherAktiv"))
event.currentTarget.classList.add("aktiv_btn");
passiv_buttons.forEach(button => button.classList.remove("aktiv_btn"))
}
export { BUTTONS, UI_ELEMENTS, serverUrl, apiKey, };