-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathring.js
44 lines (38 loc) · 2.17 KB
/
ring.js
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
// webstring by june @ webcatz.neocities.org
// webring settings
webring = {
sites: [
"https://disuko.neocities.org",
"https://voidreddev.neocities.org",
"https://midnightsyntax.neocities.org",
"https://www.redpandastudios.net",
"https://www.honeyteaaa.art/home/",
"https://thiefly.xyz/"
],
// PREV and NEXT get replaced with neighboring site urls
stylesheet: "https://disuko.neocities.org/RPSWebring.css",
widget: `
<center>
<div id="my-webring" style="display: flex; gap: 8px; align-items: center; align-content: center; align-self: center; justify-self: center; max-width: max-content;">
<a href="PREV" class="navbutton" target="_parent" ><img src="https://disuko.neocities.org/images/triangle-right.png" height="24px"></a>
<a href="https://redpandastudios.net" target="_parent"><img src="https://disuko.neocities.org/images/shiku.png" class="shiku" height="100px"></a>
<a href="NEXT" class="navbutton" target="_parent"><img src="https://disuko.neocities.org/images/triangle-left.png" height="24px"></a>
</div>
</center>
`,
error: "<a href=\"https://redpandastudios.net\" target=\"_parent\"><img src=\"https://disuko.neocities.org/images/shiku.png\" class=\"shiku\" height=\"100px\"></a>\n" +
"<div>This site isn't part of the webring yet.</div>"
};
// all of the actual code
webring.index = location.href.startsWith("file://") ? 0 : webring.sites.findIndex(url => location.href.startsWith(url));
if (webring.index == -1) document.currentScript.outerHTML = webring.error;
else {
let sheet = document.createElement("link");
sheet.rel = "stylesheet", sheet.href = webring.stylesheet;
document.head.appendChild(sheet);
webring.widget = webring.widget.replace("PREV", webring.sites.at(webring.index - 1));
webring.widget = webring.widget.replace("NEXT", webring.sites[(webring.index + 1) % webring.sites.length]);
document.currentScript.outerHTML = webring.widget;
}
delete webring;