blob: 749b23d961030aa2dc5d6f87fb18e28fef02052b (
plain)
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
|
function load_random_site() {
const webring_all_url = "https://aidang.cc/webring/all";
fetch(webring_all_url)
.then((response) => response.json())
.then((obj) => {
const entries = obj; // TODO: remove myself from the list
const entries_cleaned = obj.filter((item) => {
return item.url !== "https://jjanzen.ca";
});
console.log(entries_cleaned);
const entry = entries[Math.floor(Math.random() * entries.length)];
// window.location.href = entry.url;
});
}
function load_webring() {
const webring_url = "https://aidang.cc/webring/https://jjanzen.ca";
const webring_container = document.getElementById("cssa-webring-container");
fetch(webring_url)
.then((response) => response.json())
.then((obj) => {
const webring_html = `
<section class='cssa-webring-description'>
"Official" CSSA Webring
</section>
<ul class='cssa-webring-site-links'>
<li class='cssa-webring-prev-site'><a href='${obj.left.url}'>${obj.left.name}</a></li>
<li class='cssa-webring-rand-site'><a href='javascript:load_random_site()'>Random Site</a></li>
<li class='cssa-webring-next-site'><a href='${obj.right.url}'>${obj.right.name}</a></li>
</ul>`;
webring_container.innerHTML = webring_html;
});
}
document.addEventListener("DOMContentLoaded", load_webring, false);
|