-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
459 lines (393 loc) · 18 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
<!DOCTYPE html>
<html lang="en">
<head>
<title>Important Zites</title>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="zite,zites,important,krixano,list,category,search,filter">
<base href="" target="_top" id="base">
<script>
base.href = document.location.href.replace("/media", "").replace("index.html", "").replace(/[&?]wrapper=False/, "").replace(/[&?]wrapper_nonce=[A-Za-z0-9]+/, "")
</script>
<style>
.table tbody th,
.table thead tr>th:first-child {
text-align: center;
}
#zite_num,
#cat_num,
#zites_table {
visibility: hidden;
}
html, body, section, table {
background: #f8f8f8 !important;
}
</style>
<script src="js/navToggle.js"></script>
<link rel="stylesheet" href="css/bulma.css" />
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<nav class="nav has-shadow">
<div class="container">
<div class="nav-left">
<a href="./" class="nav-item" style="font-weight: bold;">Important Zites</a>
<span class="nav-item"><code id="zite_num" class="tag is-light">0</code> <code id="cat_num" class="tag is-light">0</code></span>
</div>
<!-- This "nav-toggle" hamburger menu is only visible on mobile -->
<!-- You need JavaScript to toggle the "is-active" class on "nav-menu" -->
<span id="nav-toggle" class="nav-toggle">
<span></span>
<span></span>
<span></span>
</span>
<!-- This "nav-menu" is hidden on mobile -->
<!-- Add the modifier "is-active" to display it on mobile -->
<div id="nav-menu" class="nav-right nav-menu">
<a href="./" class="nav-item is-active">Home</a>
<a href="request.html" class="nav-item">Requests</a>
<a href="about.html" class="nav-item">About</a>
<span class="nav-item"><a href="#Select+user" id="select_user" class="button is-info" onclick='return page.selectUser()'>Select user</a></span>
</div>
</div>
</nav>
<section class="section">
<div class="columns">
<div class="column is-2 is-offset-1">
<aside class="menu">
<input class="input" id="search" name="search" type="search" placeholder="Search" onkeyup="search();" onchange="search();" onkeypress="if (event.keyCode == 13) loadFirstZite()" autofocus="autofocus" />
<p class="menu-label">Categories</p>
<ul class="menu-list" id="categories_list">
<li><a id="allTab" onclick="tabClick('all', this); return false;">All</a></li>
<!--<li><a onclick="tabClick('info', this); return false;">Info</a></li>-->
</ul>
</aside>
</div>
<div class="column is-8">
<!--<div class="notification is-info" style="margin-right: 50px; margin-left: 70px;">
<p>New to ZeroNet? <a href="/138R53t3ZW7KDfSfxVpWUsMXgwUnsDNXLP/">Visit the Wiki</a></p>
</div>-->
<!-- TODO -->
<table id="zites_table" class="table is-narrow is-striped" style="margin-left: 10px; margin-right: 10px;">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody id="zites_list">
<!--<tr class="social">
<th><a href="/mail.zeroverse.bit/">ZeroVerse Mail</a></th>
<td>Mail for ZeroVerse <code class="category" style="font-style: italic;">SOCIAL</code></td>
</tr>-->
<!-- Abandoned Project -->
<!--<tr class="books">
<th><a href="/1DszUR6XLMLztoPZ4q9v7Ym6916HrnUSqz">ZeroManga</a></th>
<td>Download mangas</td>
</tr>-->
<!--<tr>
<th><a href="#">ZeroNews</a></th>
<td>One of the first News zites on ZeroNet</td>
</tr>-->
<!--<tr class="other">
<th><a href="/1HPgDoReCFtE9qy71hnp55ksBVvV1gHJLQ">id@ZeroVerse</a></th>
<td>User authorization provider <code class="category" style="font-style: italic;">OTHER</code></td>
</tr>-->
<!-- Abandoned Project -->
</tbody>
</table>
</div>
</div>
</section>
<footer class="footer">
<div class="container">
<span style="text-align: center">
<small>NOTE: This zite is still a work-in-progress.</small><br>
<small>Zite created on April 12th, 2017 by <a href="/Me.ZeroNetwork.bit/?Profile/12h51ug6CcntU2aiBjhP8Ns2e5VypbWWtv/12gAes6NzDS9E2q6Q1UXrpUdbPS6nvuBPu/krixano@zeroid.bit">krixano@zeroid.bit</a> (Christian Seibold)</small><br>
<small><a href="https://github.com/krixano/ImportantZites">Github Link</a></small>
</span>
</div>
</footer>
<script type="text/javascript" src="js/ZeroFrame.js"></script>
<script type="text/javascript" src="js/gsap/TweenLite.min.js"></script>
<script type="text/javascript" src="js/gsap/plugins/CSSPlugin.min.js"></script>
<script>
var allZites;
var categoriesList;
class ZeroChat extends ZeroFrame {
onOpenWebsocket() {
this.cmd("siteInfo", {}, (site_info) => {
if (site_info.cert_user_id)
document.getElementById("select_user").innerText = site_info.cert_user_id;
this.site_info = site_info;
this.loadCategories(function() {
page.loadZites(function() {
allZites = document.querySelectorAll("#zites_list > tr");
tabClick('all', document.getElementById('allTab'));
})
});
});
}
selectUser() {
this.cmd("certSelect", {
accepted_domains: ["zeroid.bit", "kaffie.bit", "cryptoid.bit"]
})
return false;
}
onRequest(cmd, message) {
if (cmd == "setSiteInfo") {
// Save site info data to allow access it later
this.site_info = message.params;
if (message.params.cert_user_id)
document.getElementById("select_user").innerHTML = message.params.cert_user_id;
else if (!message.params.cert_user_id) {
document.getElementById("select_user").innerHTML = "Select user";
}
if (message.params.event && message.params.event[0] == "file_done") {
this.loadZites();
allZites = document.querySelectorAll("#zites_list > tr");
}
}
}
loadZites(cb) {
var zites_list = document.getElementById("zites_list");
var zites_table = document.getElementById("zites_table");
var zite_indicator = document.getElementById('zite_num');
TweenLite.set(zites_table, {
autoAlpha: 0
});
TweenLite.set(zite_indicator, {
autoAlpha: 0
});
zites_list.innerHTML = "";
page.cmd("dbQuery", ["SELECT * FROM zites"], (zites) => {
zite_indicator.innerHTML = zites.length + " zites";
for (var x in zites) {
var zite = zites[x];
zites_list.innerHTML +=
"<tr class='cat-" + zite.category + "'><th><a href='/" + zite.address + "'>" +
zite.title + "</a></th><td>" + zite.description +
" <code class='category' style='font-style: italic;'>" +
zite.category.toUpperCase() + "</code></td></tr>";
}
if (typeof cb === "function")
cb();
TweenLite.to(zites_table, 3, {
autoAlpha: 2
});
TweenLite.to(zite_indicator, 3, {
autoAlpha: 2
});
});
}
getCategoriesList(cb) {
if (categoriesList) {
if (typeof cb === "function")
cb(categoriesList);
} else {
page.cmd("dbQuery", ["SELECT * FROM categories"], (cats) => {
categoriesList = cats;
if (typeof cb === "function")
cb(cats);
})
}
}
loadCategories(cb) {
var cats_list = document.getElementById("categories_list");
var cats_indicator = document.getElementById('cat_num');
TweenLite.set(cats_indicator, {
autoAlpha: 0
});
page.getCategoriesList(function(cats) {
cats_indicator.innerHTML = cats.length + " categories";
for (var x in cats) {
var cat = cats[x];
cats_list.innerHTML += '<li><a onclick="tabClick(\'' +
cat.name + '\', this); return false;">' +
cat.name[0].toUpperCase() + cat.name.substring(1) + '</a></li>';
}
if (typeof cb === "function")
cb();
TweenLite.to(cats_indicator, 3, {
autoAlpha: 2
});
})
}
}
page = new ZeroChat();
var previousCategory;
var currentCategory;
var previousActiveTab;
function search(s) {
if (currentCategory == "all") {
var ziteList = allZites;
} else {
var ziteList = document.querySelectorAll(".cat-" + currentCategory);
}
var s = (s || document.getElementById("search").value).trim()
if (s && ziteList) {
var anystrue = false
for (var x in ziteList) {
var y = ziteList[x]
if (!y || typeof y !== "object")
continue
if (y.innerText) {
var searchables = y.innerText.split("\t")
if (searchables && searchables[1]) {
searchables[2] = searchables[1].substr(0, searchables[1].lastIndexOf(" "))
searchables[3] = searchables[1].substr(searchables[1].lastIndexOf(" ") + 1)
}
}
// if (previousCategory === searchables[3].toLowerCase() || previousCategory === "all")
// y.style.display = ""
var strue = false
for (var x2 in searchables) {
if (x2 === 1)
continue
var y2 = searchables[x2]
if (y2.match(new RegExp(s, "gmi"))) {
strue = true
anystrue = true
}
}
// console.log(y, strue, searchables)
if (!strue && s)
y.style.display = "none"
else
y.style.display = ""
}
// Show "No match"-Message
if (!anystrue)
console.log("No match")
} else if (ziteList) {
for (var x in ziteList) {
var y = ziteList[x]
if (!y || typeof y !== "object")
continue
y.style.display = ""
}
}
// "<tr class='cat-" + zite.category + "'><th><a href='/" + zite.address + "'>" +
// zite.title + "</a></th><td>" + zite.description +
// " <code class='category' style='font-style: italic;'>" +
// zite.category.toUpperCase() + "</code></td></tr>";
}
function loadFirstZite() {
var ziteList;
if (currentCategory == "all") {
ziteList = allZites;
} else {
ziteList = document.querySelectorAll(".cat-" + currentCategory);
}
var zite;
// Go through all zites in list until one is visible, then set it to the zite variable
for (var i = 0; i < ziteList.length; i++) {
if (ziteList[i].style.display != "none") {
zite = ziteList[i];
break;
}
}
if (zite) {
var link = zite.firstChild.firstChild.href;
console.log("Opening " + link + " in new tab.");
page.cmd("wrapperOpenWindow", [link]);
}
}
function tabClick(id, tabElem) {
// Don't do anything, including animations, when clicking on a tab that's already selected.
if (previousCategory == id) {
return;
}
currentCategory = id;
TweenLite.set(document.getElementById('zites_table'), {
autoAlpha: 0
});
if (id == "all") {
// Show all divs except the previousCategory (because that one is already shown)
page.getCategoriesList(function(cats) {
for (var x in cats) {
var cat = cats[x];
if (previousCategory != cat.name) {
var s = document.querySelectorAll('.cat-' + cat.name);
for (var x2 = 0; x2 < s.length; x2++) {
s[x2].style.display = "";
}
}
}
var s_category = document.querySelectorAll('.category');
for (var i = 0; i < s_category.length; i++) {
s_category[i].style.display = "";
}
// NOTE(krixano): Database Query runs asynchronously, which means putting this outside of this callback function
// would immediately run this code, and therefore change previousCategory before everything above is finished!
TweenLite.to(document.getElementById('zites_table'), 1.0, {
autoAlpha: 2
});
previousCategory = id;
toggleClass(tabElem, "is-active");
if (previousActiveTab) {
toggleClass(previousActiveTab, "is-active");
}
previousActiveTab = tabElem;
// Redo search results
if (document.getElementById("search").value.trim() != "") {
search();
}
})
// if (previousCategory != "info") {
// var s_info = document.querySelectorAll('.info');
// for (var i = 0; i < s_info.length; i++) {
// s_info[i].style.display = "";
// }
// }
} else {
page.getCategoriesList(function(cats) {
for (var x in cats) {
var cat = cats[x];
if (id != cat.name) {
var s = document.querySelectorAll('.cat-' + cat.name);
for (var x2 = 0; x2 < s.length; x2++) {
s[x2].style.display = "none";
}
}
}
if (previousCategory != id && previousCategory != "all") {
var selector = document.querySelectorAll('.cat-' + id);
for (var i = 0; i < selector.length; i++) {
selector[i].style.display = "";
}
}
var s_category = document.querySelectorAll('.category');
for (var i = 0; i < s_category.length; i++) {
s_category[i].style.display = "none";
}
// NOTE(krixano): Database Query runs asynchronously, which means putting this outside of this callback function
// would immediately run this code, and therefore change previousCategory before everything above is finished!
TweenLite.to(document.getElementById('zites_table'), 1.0, {
autoAlpha: 2
});
previousCategory = id;
toggleClass(tabElem, "is-active");
if (previousActiveTab) {
toggleClass(previousActiveTab, "is-active");
}
previousActiveTab = tabElem;
// Redo search results
if (document.getElementById("search").value.trim() != "") {
search();
}
})
// if (id != "info") {
// var s_info = document.querySelectorAll('.info');
// for (var i = 0; i < s_info.length; i++) {
// s_info[i].style.display = "none";
// }
// }
}
return false;
}
</script>
</body>
</html>