This repository has been archived by the owner on Sep 1, 2020. It is now read-only.
forked from kotajacob/homepage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homepage.html
220 lines (183 loc) · 7.79 KB
/
homepage.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
<!doctype html>
<!--
#----------------------------------#
# ,--. ,--. ,--. #
# | .' / ,---. ,-' '-. ,--,--. #
# | . ' | .-. |'-. .-'' ,-. | #
# | |\ \' '-' ' | | \ '-' | #
# `--' '--' `---' `--' `--`--' #
# kotajacob.tk #
# Copyright (C) 2017 Dakota Walsh #
#----------------------------------#
-->
<head>
<title>~</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<script>WebFontConfig={google:{families:['Roboto:300:latin']}};</script>
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js" async></script>
</head>
<main>
<time id="js-clock"></time>
<form id="js-search-form" autocomplete="off">
<input id="js-search-input" type="text" autofocus>
</form>
</main>
<aside id="js-overlay" class="overlay">
<ul id="js-lists" class="lists"></ul>
</aside>
<script>
'use strict';
var config = {
categories: [
{ name: "Tools", commands: [
{ key: 'g', name: 'GitHub', url: 'https://github.com', search: '/search?q=' },
{ key: 'cl', name: 'Cloud', url: 'http://174.55.203.212/nextcloud/', search: '/' },
{ key: 'gl', name: 'GitLab', url: 'https://gitlab.com', search: '/search?utf8=✓&search=' },
{ key: 'st', name: 'StackExchange', url: 'https://stackexchange.com', search: '/search?q=' },
{ key: 'al', name: 'Alternative To', url: 'http://alternativeto.net', search: '/browse/search?q=' },
] },
{ name: "Entertainment", commands: [
{ key: 'r', name: 'Reddit', url: 'https://www.reddit.com', search: '/r/' },
{ key: 'yt', name: 'YouTube', url: 'https://www.youtube.com', search: '/results?search_query=' },
{ key: 'tw', name: 'Twitch', url: 'https://www.twitch.tv/directory/following' },
] },
{ name: "TF2", commands: [
{ key: 'tfc', name: 'TF2Center', url: 'https://tf2center.com/lobbies' },
{ key: 'tfo', name: 'TF2 Outpost', url: 'https://tf2outpost.com' },
{ key: 'bp', name: 'Backpack.tf', url: 'https://backpack.tf' },
{ key: 'sc', name: 'Scrap.tf', url: 'https://scrap.tf' },
] },
{ name: "Social", commands: [
{ key: 'w', name: 'Wire', url: 'https://app.wire.com', search: '/' },
{ key: 'ma', name: 'Mastodon', url: 'https://mastodon.technology', search: '/search/top/?q=' },
{ key: 'gm', name: 'Gmail', url: 'https://mail.google.com', search: '/#search/' },
] },
{ name: "Media", commands: [
{ key: 't', name: 'TorrentProject', url: 'https://torrentproject.se/', search: '/?t=' },
{ key: 'so', name: 'SoundCloud', url: 'https://soundcloud.com', search: '/search?q=' },
{ key: 'ae', name: 'AlbumArtExchange', url: 'https://albumartexchange.com', search: '/covers?fltr=ALL&sort=TITLE&q=' },
{ key: 'lf', name: 'Last.fm', url: 'https://www.last.fm', search: '/search?q=' },
{ key: 'li', name: 'Libre.fm', url: 'https://www.libre.fm', search: '/user/' },
{ key: 'bc', name: 'Bandcamp', url: 'https://www.bandcamp.com', search: '/search?q=' },
] },
{ name: "Education", commands: [
{ key: 'aw', name: 'ArchWiki', url: 'https://wiki.archlinux.org', search: '/index.php?title=Special%3ASearch&search=' },
{ key: 'kh', name: 'KhanAcademy', url: 'https://www.khanacademy.org', search: '/search?page_search_query=' },
{ key: 'wi', name: 'Wikipedia', url: 'https://en.wikipedia.org', search: '/wiki/' },
{ key: 'ha', name: 'Harrisburg Academy', url: 'https://harrisburgacademy.org', search: '/page.aspx?pid=295&txtSearch=' },
{ key: 'on', name: 'School', url: 'https://harrisburgacademy.myschoolapp.com/app/student#studentmyday/schedule', search: ''},
{ key: 'pr', name: 'Print', url: 'http://print.harrisburgacademy.org/app?service=page/UserWebPrint', search: ''},
{ key: 'cs', name: 'Coursera', url: 'https://www.coursera.org', search: '/courses?languages=en&query='},
] },
{ name: "Shopping", commands: [
{ key: 'm', name: 'Massdrop', url: 'https://www.massdrop.com', search: '/' },
{ key: 'pc', name: 'Pcpartpicker', url: 'https://pcpartpicker.com/', search: '/search/?cc=us&q=' },
{ key: 'ne', name: 'Newegg', url: 'https://www.newegg.com/', search: '/' },
{ key: 'az', name: 'Amazon', url: 'https://www.amazon.com', search: '/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=' },
] },
],
// if none of the keys are matched, this is used for searching
defaultSearch: 'https://duckduckgo.com/?q=',
// the delimiter between the key and your search query
// e.g. to search GitHub for potatoes you'd type "g/:potatoes"
searchDelimiter: '/'
};
function $(s) {
return document.querySelector(s);
};
var Clock = (function() {
var clock = $('#js-clock');
function pad(num) {
return ('0' + num.toString()).slice(-2);
}
function setTime() {
var date = new Date();
clock.innerHTML = pad(date.getHours()) + ':' + pad(date.getMinutes());
}
setTime();
setInterval(setTime, 1000);
})();
var Help = (function(config) {
var charRegex = /[a-zA-Z0-9-_ ]/;
var head = $('head');
var overlay = $('#js-overlay');
var lists = $('#js-lists');
var categoryItems = '';
config.categories.forEach(function(category) {
var commandItems = '';
category.commands.forEach(function(command) {
var prerenderLink = '<link rel="prerender" href="' + command.url + '">';
head.insertAdjacentHTML('beforeend', prerenderLink);
commandItems += (
'<li class="command">' +
'<a href="' + command.url + '">' +
'<span class="command-key">' + command.key + '</span>' +
'<span class="command-name">' + command.name + '</span>' +
'</a>' +
'</li>'
);
});
lists.insertAdjacentHTML(
'beforeend',
'<li class="category">' +
'<h2 class="category-name">' + category.name + '</h2>' +
'<ul>' + commandItems + '</ul>' +
'</li>'
);
});
document.addEventListener('keydown', function(event) {
var isEscape = event.keyCode === 27;
var isAlphaNum = charRegex.test(String.fromCharCode(event.keyCode));
if (isEscape || isAlphaNum) {
overlay.removeAttribute('data-toggled');
Form.focus();
}
});
return {
toggle: function() {
var toggle = overlay.getAttribute('data-toggled') !== 'true';
overlay.setAttribute('data-toggled', toggle);
}
};
})(config);
var Form = (function(config) {
var urlRegex = /(\b(https?|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i;
var searchForm = $('#js-search-form');
var searchInput = $('#js-search-input');
searchForm.addEventListener('submit', function(event) {
event.preventDefault();
var q = searchInput.value.trim();
if (q === '' || q === '?') {
Help.toggle();
searchInput.value = '';
} else {
var qSplit = q.split(config.searchDelimiter);
var qIsUrl = q.match(new RegExp(urlRegex));
var redirect = '';
if (qIsUrl) redirect = q;
else redirect = config.defaultSearch + encodeURIComponent(q);
config.categories.forEach(function(category) {
category.commands.forEach(function(command) {
if (qSplit[0] === command.key) {
if (qSplit[1] && command.search) {
qSplit.shift();
var search = encodeURIComponent(qSplit[0].trim());
redirect = command.url + command.search + search;
} else {
redirect = command.url;
}
}
});
});
window.location.href = redirect;
}
}, false);
return {
focus: function() {
searchInput.focus();
}
};
})(config);
</script>