forked from kotajacob/homepage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomepage.html
211 lines (181 loc) · 7.26 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
<!doctype html>
<!--
========================================
oooo oooo .
`888 .8P' .o8
888 d8' .ooooo. .o888oo .oooo.
88888[ d88' `88b 888 `P )88b
888`88b. 888 888 888 .oP"888
888 `88b. 888 888 888 . d8( 888
o888o o888o `Y8bod8P' "888" `Y888""8o
@nilsu.org
=== 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>
<div class="color-container">
<div class="color-rect" id="color1"></div>
<div class="color-rect" id="color2"></div>
<div class="color-rect" id="color3"></div>
<div class="color-rect" id="color4"></div>
<div class="color-rect" id="color5"></div>
<div class="color-rect" id="color6"></div>
</div>
<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: 'gh', name: 'GitHub', url: 'https://github.com', search: '/search?q=' },
{ key: 'apo', name: 'Apollo', url: 'https://apollo.rip', search: '/torrents.php?action=advanced&groupname=' },
{ key: 'ru', name: 'ruTorrent', url: 'https://star.seedhost.eu/blahsd/rutorrent/', search: '/' },
] },
{ name: "News", commands: [
{ key: 'r', name: 'Reddit', url: 'https://www.reddit.com', search: '/r/' },
{ key: 'fb', name: 'Facebook', url: 'https://www.facebook.com', search: '/search/top/?q=' },
{ key: 'v', name: 'The Vision', url: 'http://thevision.com', search: '/' },
{ key: 'sl', name: 'Slashdot', url: 'https://slashdot.org/', search: '/index2.pl?fhfilter=' },
] },
{ name: "Social", commands: [
{ key: 'p', name: 'ProtonMail', url: 'https://mail.protonmail.com/inbox', search: '/' },
{ key: 'ma', name: 'Mastodon', url: 'https://mastodon.technology', search: '/search/top/?q=' },
{ key: 'tw', name: 'Twitter', url: 'https://twitter.com', search: '/search?q=' },
{ key: 'le', name: 'Level1Techs', url: 'https://forum.level1techs.com', search: '/search?q=' },
] },
{ name: "Media", commands: [
{ key: 't', name: 'TorrentProject', url: 'https://torrentproject.se', search: '/?t=' },
{ key: 'yo', name: 'YouTube', url: 'https://www.youtube.com', search: '/results?search_query=' },
{ key: 'vi', name: 'Vimeo', url: 'https://vimeo.com', search: '/search?q=' },
{ key: 'so', name: 'SoundCloud', url: 'https://soundcloud.com', search: '/search?q=' },
] },
{ name: "Education", commands: [
{ key: 'a', name: 'ArchWiki', url: 'https://wiki.archlinux.org', search: '/index.php?title=Special%3ASearch&search=' },
{ key: 'ha', name: 'Hacc', url: 'https://my.hacc.edu/', search: '' },
{ key: 'lo', name: 'LÖVEWiki', url: 'https://love2d.org/wiki', search: '/' },
{ key: 'wi', name: 'Wikipedia', url: 'https://en.wikipedia.org', search: '/wiki/' },
] },
{ name: "Shopping", commands: [
{ key: 'm', name: 'Massdrop', url: 'https://www.massdrop.com', search: '/search/' },
{ key: 'am', name: 'Amazon', url: 'https://smile.amazon.com', search: '/s/field-keywords=' },
{ key: 'eb', name: 'Ebay', url: 'https://www.ebay.com', search: '/sch/' },
{ key: 'ne', name: 'Newegg', url: 'https://www.newegg.com', search: '/Product/ProductList.aspx?Submit=ENE&DEPA=0&Order=BESTMATCH&Description=' },
] },
],
// if none of the keys are matched, this is used for searching
defaultSearch: 'https://www.google.it/search?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>