Skip to content

Commit c521875

Browse files
authored
Create main.js
1 parent 65503cc commit c521875

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Projects/Weather APP/main.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import CurrentLocation from "./currentLocation.js";
2+
import { getDataFromApi } from "./DataFunction.js";
3+
import { getDataFromSearch, DisplayDataInApp } from "./domFunction.js";
4+
5+
const currentLoc = new CurrentLocation();
6+
7+
const initApp = () => {
8+
const searchBar = document.getElementById("search__form");
9+
searchBar.addEventListener("submit", getDataFromUser);
10+
getDataFromApi(currentLoc);
11+
DisplayDataInApp(currentLoc);
12+
};
13+
14+
const getDataFromUser = (event) => {
15+
event.preventDefault();
16+
const location = getDataFromSearch();
17+
currentLoc.location = location;
18+
initApp();
19+
};
20+
initApp();

0 commit comments

Comments
 (0)