๋ฐ์ํ
[์ถ์ฒ-์ ํ๋ธ ๋ ธ๋ง๋ ์ฝ๋ Nomad Coders]
index.html
<!DOCTYPE html>
<html>
<head>
<title>Something</title>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<div class="js-clock">
<h1>00:00</h1>
</div>
<form class="js-form form">
<input type="text" placeholder="What is your name?" />
</form>
<h4 class="js-greetings greetings"></h4>
<form class="js-toDoForm">
<input type="text" placeholder="Write a to do" />
</form>
<ul class="js-toDoList">
</ul>
<script src="clock.js"></script>
<script src="greeting.js"></script>
<script src="todo.js"></script>
<script src="bg.js"></script>
<script src="weather.js"></script>
</body>
</html>
weather.js
const API_KEY = "f97c1ed1e4b50ed233ccabf8c1ea2011";
const COORDS = 'coords';
function saveCoords(coordsObj){
localStorage.setItem(COORDS, JSON.stringify(coordsObj));
}
function handleGeoSuccess(position){
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
const coordsObj = {
latitude,
longitude
};
saveCoords(coordsObj);
}
function handleGeoError(){
console.log("Cant access geo location");
}
function askForCoords(){
navigator.geolocation.getCurrentPosition(handleGeoSuccess, handleGeoError);
}
function loadCoords(){
const loadedCords = localStorage.getItem(COORDS);
if(loadedCords === null){
askForCoords();
} else {
}
}
function init(){
}
init();
์.. ์์น์ ๋ณด๊ฐ ์ ๋ฌ๋ค..
function askForCoords(){
navigator.geolocation.getCurrentPosition(handleGeoSuccess, handleGeoError);
}
์ด ์ฝ๋๊ฐ ๋์์ ์ํจ..
๋ฐ์ํ
'JavaScript > Vanilla JS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐ๋๋ผJS๋ก ๊ทธ๋ฆผํ ๋ง๋ค๊ธฐ] What are we building (0) | 2021.04.23 |
---|---|
[๋ฐ๋๋ผJS๋ก ํฌ๋กฌ ์ฑ ๋ง๋ค๊ธฐ] Getting the Weather part Two API (0) | 2021.03.03 |
[๋ฐ๋๋ผJS๋ก ํฌ๋กฌ ์ฑ ๋ง๋ค๊ธฐ] Image Background (0) | 2021.03.03 |
[๋ฐ๋๋ผJS๋ก ํฌ๋กฌ ์ฑ ๋ง๋ค๊ธฐ] Making a To Do List part Three (0) | 2021.03.03 |
[๋ฐ๋๋ผJS๋ก ํฌ๋กฌ ์ฑ ๋ง๋ค๊ธฐ] Making a To Do List part Two (0) | 2021.03.03 |
๋๊ธ