-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
233 lines (215 loc) · 8.32 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!DOCTYPE html>
<html>
<head>
<title>Homepage</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="assets/home1.png" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="https://apis.google.com/js/api.js"></script>
<script src="js/index.js"></script>
<script src="js/weather.js"></script>
<script src="js/calendar.js"></script>
<script src="js/bookmarks.js"></script>
<script src="js/news.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<div id="datetime" class="navbar-brand"></div>
</div>
<div class="collapse navbar-collapse" id="navbarNav">
<form class="navbar-form navbar-right" onsubmit="return false">
<div class="form-group">
<input type="text" id="search" name="search" class="form-control" onkeyup="if (event.key == 'Enter')
searchGoogle(this.form.search.value);" placeholder="Search" autofocus>
</div>
<button type="button" class="btn btn-success" onclick="searchGoogle(this.form.search.value)">Search</button>
<div id="suggestions" class="panel panel-default">
<!-- Suggestion list inserted here -->
</div>
</form>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-4">
<div id="weather" class="panel panel-default">
<div class="panel-heading">
<a href="https://weather.gc.ca/en/location/index.html?coords=43.655,-79.383" target="_blank">Погода</a>
</div>
<!-- Weather table inserted here -->
</div>
<div id="calendar" class="panel panel-default">
<div class="panel-heading">
<a href="https://calendar.google.com/calendar/u/0/r" target="_blank">Календарь</a>
</div>
<!-- Calendar table inserted here -->
</div>
<div id="events" class="panel panel-default">
<div class="panel-heading">
<a href="https://calendar.google.com/calendar/u/0/r" target="_blank">Запланированные события</a>
</div>
<!-- Events list inserted here -->
</div>
</div>
<div class="col-md-4">
<div id="bookmarks1" class="panel panel-default">
<div class="panel-heading">
<a href="https://www.circulars.ca/" target="_blank">Флаерсы</a>
</div>
<!-- Bookmarks list inserted here -->
</div>
<div id="bookmarks2" class="panel panel-default">
<div class="panel-heading">
<a href="https://flyers.smartcanucks.ca/" target="_blank">Магазины</a>
</div>
<!-- Bookmarks list inserted here -->
</div>
<div id="bookmarks3" class="panel panel-default">
<div class="panel-heading">Сервисы</div>
<!-- Bookmarks list inserted here -->
</div>
</div>
<div class="col-md-4">
<div id="news1" class="panel panel-default">
<div class="panel-heading">
<a href="https://news.knopka.ca/" target="_blank">Канадские новости</a>
</div>
<!-- News list inserted here -->
</div>
<div id="news2" class="panel panel-default">
<div class="panel-heading">
<a href="https://www.foxnews.com/" target="_blank">Последние новости</a>
</div>
<!-- News list inserted here -->
</div>
</div>
</div>
</div>
<script type="text/javascript">
// Get elements by ID
const datetime1 = document.getElementById('datetime');
const search1 = document.getElementById('search');
const weather1 = document.getElementById('weather');
const calendar1 = document.getElementById('calendar');
const events1 = document.getElementById('events');
const bookmarks1 = document.getElementById('bookmarks1');
const bookmarks2 = document.getElementById('bookmarks2');
const bookmarks3 = document.getElementById('bookmarks3');
const news1 = document.getElementById('news1');
const news2 = document.getElementById('news2');
const suggestions1 = document.getElementById('suggestions');
// Credentials to authenticate with Google API
const CLIENT_ID = '84522859201-slrv8op1uu6h1v48kl9emla38ft78ois.apps.googleusercontent.com';
const API_KEY = 'AIzaSyBCIyH5szmkAwnMtNqGsjdruUvmnCEdSH8';
const DISCOVERY_DOCS = ['https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest'];
const SCOPES = 'https://www.googleapis.com/auth/calendar.readonly';
// Load the API client and authenticate the user
function handleClientLoad() {
gapi.load('client:auth2', initClient);
}
// Initialize GAPI client
async function initClient() {
const response = await gapi.client.init({
apiKey: API_KEY,
clientId: CLIENT_ID,
discoveryDocs: DISCOVERY_DOCS,
scope: SCOPES
});
// Listen for sign-in state changes
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle the initial sign-in state
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
}
function updateSigninStatus(isSignedIn) {
if (isSignedIn) {
createAllContent();
} else {
removeAllContent();
handleSignin();
}
}
function handleSignin() {
gapi.auth2.getAuthInstance().signIn();
}
function handleSignout() {
gapi.auth2.getAuthInstance().signOut();
}
// Create all content
function createAllContent() {
document.body.style.display = 'block';
getDateTime(datetime1);
getWeather(weather1);
getCalendar(calendar1, events1);
getBookmarks(bookmarks1, 'Флаерсы');
getBookmarks(bookmarks2, 'Магазины');
getBookmarks(bookmarks3, 'Сервисы');
getNews(news1, 'https://news.knopka.ca/rss', 7);
getNews(news2, 'https://moxie.foxnews.com/google-publisher/latest.xml', 7);
}
// Remove all content
function removeAllContent() {
const panels = document.getElementsByClassName('panel');
for (let index = 0; index < panels.length; index++) {
const panel = panels[index];
while (panel.children.length > 1) {
panel.removeChild(panel.lastChild);
}
}
document.body.style.display = 'none';
}
let index = search1.attributes['index'] = -1;
let element;
/*
function onKeyUp(event) {
if (search1.value === '') {
suggestions1.innerHTML = '';
suggestions1.style.display = 'none';
return;
}
if (event.key == 'Enter')
searchGoogle(search1.value);
switch (event.key) {
case 'Enter':
searchGoogle(search1.value);
break;
case ' ':
getSuggestions(suggestions1, search1.value);
getTranslation(suggestions1, search1.value);
break;
case 'ArrowUp':
index--;
if (index < 0) index = 9;
element = suggestions1.firstChild.children[index];
for (let i = 0; i < suggestions1.firstChild.children.length; i++) {
suggestions1.firstChild.children[i].style.backgroundColor = '#778899';
}
element.style.backgroundColor = '#667788';
search1.value = element.textContent;
break;
case 'ArrowDown':
index++;
if (index > 9) index = 0;
element = suggestions1.firstChild.children[index];
for (let i = 0; i < suggestions1.firstChild.children.length; i++) {
suggestions1.firstChild.children[i].style.backgroundColor = '#778899';
}
element.style.backgroundColor = '#667788';
search1.value = element.textContent;
break;
default:
getSuggestions(suggestions1, search1.value);
break;
}
}
*/
</script>
<script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>
</body>
</html>