-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
134 lines (116 loc) · 3.08 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!doctype html>
<html>
<head>
<title>GEO</title>
<link rel="stylesheet" type="text/css" href="styles/style.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://cdn.socket.io/socket.io-1.3.4.js"></script>
<script src="scripts/weather_api.js"></script>
</head>
<body>
<input autocomplete="off" id="city" placeholder="Enter your city" type="text">
<ul id="suggest"></ul>
<section class="conditions">
<h2>Conditions</h2>
<p>Temperature: <span class="temperature"></span></p>
<p>Weather: <span class="weather"></span></p>
</section>
<button id="rain">Rain</button>
<button id="sunrise">Day</button>
<button id="sunset">Night</button>
<button id="clouds">Clouds</button>
<ul id="messages"></ul>
<script>
var rain = false;
var sunrise = false;
var sunset = false;
var clouds = false;
$(document).ready( function () {
$('#city').on( 'input', function () {
if (city_query != this.value) {
city_query = this.value;
auto_complete(this.value);
}
});
$('#rain').click(function () {
rain = !rain;
socket.emit('rain', rain);
$(this).toggleClass('active');
});
$('#sunrise').click(function () {
sunrise = !sunrise;
//socket.emit('sunrise', sunrise);
$('#sunset').removeClass('active');
sunset = false;
socket.emit('daytime', true);
$(this).toggleClass('active');
});
$('#sunset').click(function () {
sunset = !sunset;
sunrise = false;
$('#sunrise').removeClass('active');
//socket.emit('sunset', sunset);
socket.emit('daytime', false);
$(this).toggleClass('active');
});
$('#clouds').click(function () {
clouds = !clouds;
socket.emit('clouds', clouds);
$(this).toggleClass('active');
});
});
socket.on('rain', function (msg) {
$('#messages').append($('<li>').text('Raining: ' + msg));
if(msg === true) {
rain = true;
$('#rain').addClass('active');
} else {
rain = false;
$('#rain').removeClass('active');
}
});
socket.on('daytime', function (msg) {
$('#messages').append($('<li>').text('Daytime: ' + msg));
if(msg === true) {
sunrise = true;
$('#sunrise').addClass('active');
$('#sunset').removeClass('active');
} else {
sunrise = false;
$('#sunset').addClass('active');
$('#sunrise').removeClass('active');
}
});
socket.on('sunrise', function (msg) {
$('#messages').append($('<li>').text('Sunrise: ' + msg));
if(msg === true) {
sunrise = true;
$('#sunrise').addClass('active');
} else {
sunrise = false;
$('#sunrise').removeClass('active');
}
});
socket.on('sunset', function (msg) {
$('#messages').append($('<li>').text('Sunset: ' + msg));
if(msg === true) {
sunset = true;
$('#sunset').addClass('active');
} else {
sunset = false;
$('#sunset').removeClass('active');
}
});
socket.on('clouds', function (msg) {
$('#messages').append($('<li>').text('Cloudy: ' + msg));
if(msg === true) {
clouds = true;
$('#clouds').addClass('active');
} else {
clouds = false;
$('#clouds').removeClass('active');
}
});
</script>
</body>
</html>