This repository has been archived by the owner on Feb 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
103 lines (91 loc) · 3.33 KB
/
index.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html>
<head>
<title>Magic Mirror</title>
<link href="css/global.css" type="text/css" rel="stylesheet">
<script src="js/jquery-3.1.1.js"></script>
<script src="js/jquery.simpleWeather.js"></script>
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('clock').innerHTML =
h + ":" + m;
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){
dd='0'+dd;
}
if(mm<10){
mm='0'+mm;
}
var today = mm+'/'+dd+'/'+ yyyy;
document.getElementById("date").innerHTML = today;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
// v3.1.0
//Docs at http://simpleweatherjs.com
$(document).ready(function() {
getWeather(); //Get the initial weather.
setInterval(getWeather, 5000); //Update the weather every 10 minutes.
});
function getWeather(){
$.simpleWeather({
location: 'Wellesley, MA',
unit: 'f',
success: function(weather) {
console.log("retrieved info");
html = '<h2><i class="icon-'+weather.code+'"></i> '+weather.temp+'°'+weather.units.temp+'</h2>';
// html += '<ul><li>'+weather.city+', '+weather.region+'</li>';
// html += '<li class="currently">'+weather.currently+'</li>';
// html += '<li>'+weather.wind.direction+' '+weather.wind.speed+' '+weather.units.speed+'</li></ul>';
htmll = "";
for(var i=0;i<weather.forecast.length;i++) {
htmll += '<li>'+weather.forecast[i].day+': '+weather.forecast[i].high+'</li>';
}
$("#weather").html(html);
$("#forcast").html(htmll);
},
error: function(error) {
console.log(error);
}
});
};
</script>
</head>
<body onload="startTime()">
<noscript>
<h1>Y U NO HAV JAVASCRIPT</h1>
<meme></meme>
</noscript>
<div id="content">
<table>
<tr>
<td id="clock"></td>
</tr>
</table>
<table>
<tr>
<td id="date"></td>
<td id="weather"></td>
</tr>
</table>
<table>
<tr>
<td><ul id="forcast">
</ul></td>
</tr>
</table>
</div>
</body>
</html>