Files
whoswhip.dev/html/r/index.html
T
2026-12-05 12:46:16 -05:00

211 lines
6.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RRBA Shortener</title>
<link rel="stylesheet" href="/assets/css/tom-select.css">
<script src="/assets/js/tom-select.complete.min.js"></script>
<script defer src="https://analytics.whoswhip.dev/script.js" data-website-id="5a44cf17-caa9-48e6-b213-6259bb015e59"
data-do-not-track="true"></script>
<style>
:root {
/* rrba's theme */
color-scheme: dark;
--bg: #0a0a0a;
--surface: #171717;
--border: #404040;
--hover: #262626;
--text: #f5f5f5;
--muted: #a3a3a3;
--link: #60a5fa;
}
* {
box-sizing: border-box;
}
body {
min-height: 100dvh;
background: var(--bg);
color: var(--text);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 12px;
margin: 0;
font-family: ui-sans-serif, system-ui, sans-serif;
}
.ts-wrapper {
width: min(600px, calc(100% - 32px));
}
.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control,
.ts-dropdown {
background: var(--surface);
color: var(--text);
border: 1px solid var(--border);
border-radius: 6px;
box-shadow: none;
}
.ts-control {
padding: 10px 12px;
}
.ts-control>input {
color: var(--text);
}
.ts-control>input::placeholder {
color: var(--muted);
}
.ts-dropdown .option {
padding: 10px 12px;
}
.ts-dropdown .active,
.ts-dropdown .selected {
background: var(--hover);
color: var(--text);
}
.ts-dropdown .highlight {
background: #1e40af;
}
.ts-dropdown-content {
max-height: 40dvh;
}
.build-date {
font-size: 12px;
color: var(--muted);
}
a {
color: var(--link);
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<select id="builds" name="build" placeholder="Search builds...">
<option value="">Select a build</option>
</select>
<a href="#" id="output">select a build...</a>
</body>
<script src="/assets/js/b58.js"></script>
<script>
///how the shortener works:
// using the first recroom release date as the start, we measure the amount of seconds between the start
// and the date of the build being shortened. then we encode that difference using base58 (specifically because it's human readable)
// this results in fairly short identifiers for each build, but it does get longer for older builds.
///to decode:
// convert the base58 string to base10, then add that value + the unix timestamp (in seconds) of the first build release date
// then you have the date of build and now you can construct a url using it, as seen below.
///side note:
// this could obviously be smaller if we just identified them by where they are in the list e.g. build #1 or #2, but this is more fun
///heavily inspired by https://tantek.com/w/Whistle
const firstRelease = Date.parse("2016-06-29T03:56:39Z") / 1000;
const outputElement = document.getElementById("output")
if (window.location.hash) {
const hash = window.location.hash;
try {
const value = Number(base58ToBase10(hash.slice(1)));
const timestamp = firstRelease + value;
const date = new Date(timestamp * 1000);
const year = date.getUTCFullYear();
const month = String(date.getUTCMonth() + 1).padStart(2, "0");
const day = String(date.getUTCDate()).padStart(2, "0");
const hour = String(date.getUTCHours()).padStart(2, "0")
const minutes = String(date.getUTCMinutes()).padStart(2, "0");
const seconds = String(date.getUTCSeconds()).padStart(2, "0");
const url = `https://archive.recagain.site/${year}/${month}/${day}/${hour}${minutes}${seconds}`;
window.location.href = url;
} catch (error) {
console.error(error);
}
}
document.getElementById("builds").addEventListener("change", e => {
const date = Date.parse(e.target.value) / 1000;
const timestamp = date - firstRelease;
const id = base10ToBase58(timestamp);
const baseUrl = window.location.href.split("#")[0];
const url = `${baseUrl}#${id}`;
outputElement.textContent = url;
outputElement.href = url;
});
async function loadBuilds() {
const response = await fetch(
"https://archive.recagain.site/api/v1/builds"
);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const builds = await response.json();
const options = builds.map(build => ({
value: build.timestamp,
name: build.updateName || "No Name",
date: build.timestamp.split("T")[0]
}));
new TomSelect("#builds", {
options: options,
valueField: "value",
labelField: "name",
searchField: ["name", "date", "value"],
maxItems: 1,
maxOptions: null,
create: false,
render: {
option(data, escape) {
return `
<div>
<strong>${escape(data.name)}</strong>
<div class="build-date">
${escape(data.date)}
</div>
</div>
`;
},
item(data, escape) {
return `
<div>
${escape(data.date)} - ${escape(data.name)}
</div>
`;
}
}
});
}
if (!window.location.hash) {
loadBuilds().catch(console.error);
}
</script>
</html>