-
Notifications
You must be signed in to change notification settings - Fork 0
/
info.js
74 lines (42 loc) · 1.59 KB
/
info.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
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
var weatherContainer = document.getElementById('weather');
var homeButton = document.getElementById('homeBtn');
// time:
const format2 = "YYYY-MM-DD"
var date2 = new Date();
dateTime2 = moment(date2).format(format2);
document.getElementById("demo2").innerHTML = "As of :"+"" +dateTime2;
homeButton.addEventListener('click', function(e){
console.log("test")
window.location = "index.html";
});
var menuButton = document.getElementById('menuBtn');
menuButton.addEventListener('click', function(e){
console.log("test")
window.location ="menu.html";
});
var nameEl = document.getElementById('name').value;
var divEl =document.getElementById('divtest');
var enterBtn = document.getElementById('enterbtn');
var form =document.querySelector('.space-y-6')
enterBtn.addEventListener('click', getInfo);
function getInfo(){
var nameEl = document.getElementById('name').value;
var phoneNumber = document.getElementById('phone').value;
localStorage.setItem('name',JSON.stringify(nameEl));
localStorage.setItem('phone',JSON.stringify(phoneNumber))
}
// weather
function getApiW(){
fetch('https://api.openweathermap.org/data/2.5/weather?lat=40&lon=-75&appid=6939a1ebe83748be1cc4bbe471aef1a9&units=imperial')
.then(function(response){
return response.json();
})
.then(function(data){
console.log(data);
var wthEl = document.createElement('h2');
wthEl.setAttribute('style', ' display: block;font-size: 3.5rem;line-height: .96em;font-weight: 500;');
wthEl.textContent =data.main.temp+"°";
weatherContainer.append(wthEl);
})
}
getApiW();