forked from SantiagoTZ8899/Project2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
44 lines (40 loc) · 1.63 KB
/
Copy pathtest.js
File metadata and controls
44 lines (40 loc) · 1.63 KB
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
const apiKey = require('./config');
function initWolfram(location) {
$("#spinnerTemp").hide(); //hides the spinner once results load
$.ajax({
url: `http://api.wolframalpha.com/v2/query?${apiKey.config.wolfram}=DEMO&input=${query}`,
method: "GET"
}).then(function(response) {
const tempK = response.list[0].main.temp;
console.log(tempK);
const tempF = Math.round((tempK - 273.15) * 9/5 + 32);
console.log(tempF);
$("#temp-card").append("<h3 id='temp-val'>" + tempF + "° F</h3>");
$("#temp-val").css("margin-left", "30%");
$("#temp-val").css("margin-right", "30%");
tempColor(tempF);
}).catch(function(error) {
console.log("AJAX GET failed");
});
}
function tempColor(temp) {
if (temp > 110) {
$("#temp-val").css("background-color", "rgba(150,0,0,0.66)");
} else if (temp > 100) {
$("#temp-val").css("background-color", "rgba(200,0,0,0.66)");
} else if (temp > 90) {
$("#temp-val").css("background-color", "rgba(255,0,0,0.66)");
} else if (temp > 80) {
$("#temp-val").css("background-color", "rgba(255,130,0,0.66)");
} else if (temp > 70) {
$("#temp-val").css("background-color", "rgba(255,192,0,0.66)");
} else if (temp > 60) {
$("#temp-val").css("background-color", "rgba(255,255,0,0.66)");
} else if (temp > 50) {
$("#temp-val").css("background-color", "rgba(204,230,40,0.66)");
} else if (temp > 40) {
$("#temp-val").css("background-color", "rgba(146,208,80,0.66)");
} else {
$("#temp-val").css("background-color", "rgba(115,190,211,0.66)");
};
}