-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
64 lines (60 loc) · 2.7 KB
/
script.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
var x = document.getElementById("town");
var y = document.getElementById("weather");
var z = document.getElementById("temp");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
w.innerHTML = "Geolocation is not supported by this browser.";
}
};
function showPosition(position) {
var url = "https://fcc-weather-api.glitch.me/api/current?lat=" + position.coords.latitude + "&lon=" + position.coords.longitude;
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function() {
var data = JSON.parse(this.response);
x.innerHTML = data.name + ", " + data.sys.country;
y.innerHTML = data.weather["0"].main;
z.innerHTML = data.main.temp.toString().split(".")[0] + "°C";
if (request.status >= 200 && request.status < 400) {
console.log("hello");
} else {
console.log('error');
}
}
request.send();
console.log(url);
};
function myFunction(x) {
x.classList.toggle("change");
if (document.getElementById("navbar-list_items__one").style.opacity === "0") {
console.log("turning on");
document.getElementById("navbar-list_items__one").style.opacity = "1";
document.getElementById("navbar-list_items__two").style.opacity = "1";
document.getElementById("navbar-list_items__three").style.opacity = "1";
document.getElementById("navbar-list_items__four").style.opacity = "1";
document.getElementById("navbar-list_items__five").style.opacity = "1";
} else if (document.getElementById("navbar-list_items__one").style.opacity === "1"){
console.log("turning off");
document.getElementById("navbar-list_items__one").style.opacity = "0";
document.getElementById("navbar-list_items__two").style.opacity = "0";
document.getElementById("navbar-list_items__three").style.opacity = "0";
document.getElementById("navbar-list_items__four").style.opacity = "0";
document.getElementById("navbar-list_items__five").style.opacity = "0";
}
};
function personalProjectsFunc() {
console.log("this is a personal project");
if (document.getElementById('groupportfolio').style.display === "none") {
console.log("group none");
document.getElementById('groupportfolio').style.display = "block";
document.getElementById('portfolio').style.display = "none";
document.getElementById('personal-button').textContent = "Show Personal Projects";
} else if (document.getElementById('groupportfolio').style.display === "block"){
console.log("group block");
document.getElementById('groupportfolio').style.display = "none";
document.getElementById('portfolio').style.display = "block";
document.getElementById('personal-button').textContent = "Show Group Projects";
}
};