Delete templates
Browse filesFiles changed (2)
- templates/login.htmlDeleted-358
- templates/uploader.htmlDeleted-937
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"> <title>Uplink · Sign in</title> <meta name="theme-color" content="#f0eee6"> <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%23c9603b'/%3E%3Cpath d='M32 46V20M20 30l12-12 12 12' stroke='%23faf9f4' stroke-width='6' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E"> <script> (function () { var theme; try { theme = localStorage.getItem('uplink-theme'); } catch (e) { /* private mode */ } if (theme !== 'dark' && theme !== 'light') { theme = window.matchMedia && matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; } document.documentElement.dataset.theme = theme; var meta = document.querySelector('meta[name="theme-color"]'); if (meta) meta.content = theme === 'dark' ? '#262521' : '#f0eee6'; })(); </script> <style> :root { --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif; --serif: Georgia, "Times New Roman", "Songti SC", "STSong", "SimSun", serif; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; --ease: cubic-bezier(0.25, 0.7, 0.3, 1); } :root, [data-theme="light"] { color-scheme: light; --bg: #f0eee6; --panel: #faf9f4; --ink: #1f1e1a; --sub: #6b675c; --faint: #a49d8d; --line: #e0dbcd; --line-2: #ccc4b1; --acc: #c9603b; --acc-ink: #a84d2c; --acc-soft: rgba(201, 96, 59, 0.09); --err: #a83a24; --err-bg: rgba(168, 58, 36, 0.07); --ok: #3f7d54; --grain-opacity: 0.32; } [data-theme="dark"] { color-scheme: dark; --bg: #262521; --panel: #2d2c27; --ink: #eceae1; --sub: #a8a295; --faint: #6f6a5d; --line: rgba(236, 234, 225, 0.11); --line-2: rgba(236, 234, 225, 0.24); --acc: #e08862; --acc-ink: #eda385; --acc-soft: rgba(224, 136, 98, 0.12); --err: #ee8a70; --err-bg: rgba(238, 138, 112, 0.1); --ok: #83bd97; --grain-opacity: 0.22; } *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; } body { font-family: var(--sans); background: var(--bg); color: var(--ink); line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; transition: background-color 0.3s ease, color 0.3s ease; } @supports (min-height: 100dvh) { body { min-height: 100dvh; } } button, a, input { touch-action: manipulation; } ::selection { background: color-mix(in srgb, var(--acc) 24%, transparent); } body::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: var(--grain-opacity); mix-blend-mode: soft-light; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E"); }
.icon { width: 1.2em; height: 1.2em; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.ornament { position: fixed; right: -80px; bottom: -60px; width: 320px; height: 320px; color: var(--acc); opacity: 0.07; transform: rotate(12deg); pointer-events: none; }
.topline { display: flex; justify-content: space-between; align-items: center; max-width: 880px; width: 100%; margin: 0 auto; padding: 22px max(28px, env(safe-area-inset-right)) 0 max(28px, env(safe-area-inset-left)); } .wordmark { font-family: var(--serif); font-size: 21px; font-weight: 700; line-height: 1; letter-spacing: 0.005em; } .theme-toggle { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; border: none; background: none; color: var(--sub); cursor: pointer; transition: color 0.2s, background-color 0.2s; } .theme-toggle:hover { color: var(--ink); background: var(--acc-soft); } .theme-toggle .icon { width: 16px; height: 16px; }
.center { flex-grow: 1; display: grid; place-items: center; padding: 2rem 1.25rem; } .card { width: 100%; max-width: 360px; animation: rise 0.55s var(--ease) both; } @keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } } .card h1 { font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1.2; } .card h1 em { font-style: italic; color: var(--acc); } .card .sub { color: var(--sub); font-size: 14px; margin-top: 8px; }
form { margin-top: 26px; } .input-field { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font: inherit; font-size: 16px; transition: border-color 0.2s, box-shadow 0.2s; } .input-field::placeholder { color: var(--faint); } .input-field:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); } .input-field[aria-invalid="true"] { border-color: color-mix(in srgb, var(--err) 42%, var(--line-2)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 8%, transparent); } .input-field[aria-invalid="true"]:focus { border-color: color-mix(in srgb, var(--err) 58%, var(--line-2)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 11%, transparent); }
.submit-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; padding: 12px 20px; border: none; border-radius: 10px; cursor: pointer; background: var(--acc); color: #fff; font: inherit; font-size: 15px; font-weight: 600; transition: background-color 0.2s, transform 0.15s var(--ease), opacity 0.2s; } .submit-button:hover:not(:disabled) { background: var(--acc-ink); } .submit-button:active:not(:disabled) { transform: scale(0.985); } .submit-button:disabled { opacity: 0.6; cursor: not-allowed; } .submit-button.success { background: var(--ok); } .spinner { width: 1em; height: 1em; border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
.caps-hint { margin-top: 10px; font-size: 12.5px; color: var(--sub); } .caps-hint::before { content: "⇪ "; color: var(--acc); }
.error-message { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: start; gap: 10px; margin-top: 14px; padding: 12px 13px; border-radius: 10px; background: color-mix(in srgb, var(--err-bg) 70%, var(--panel)); border: 1px solid color-mix(in srgb, var(--err) 20%, var(--line)); color: var(--ink); } .error-message[hidden] { display: none; } .error-message:not([hidden]) { animation: notice-in 0.24s var(--ease) both; } .error-mark { display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; border: 1px solid color-mix(in srgb, var(--err) 30%, transparent); border-radius: 50%; background: color-mix(in srgb, var(--err) 9%, transparent); color: var(--err); font-family: var(--serif); font-size: 14px; font-weight: 700; line-height: 1; } .error-title { font-size: 13.5px; font-weight: 600; line-height: 1.4; } .error-detail { margin-top: 2px; color: var(--sub); font-size: 12.5px; line-height: 1.45; } @keyframes notice-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.footer { border-top: 1px solid var(--line); padding: 14px 0 calc(16px + env(safe-area-inset-bottom)); } .footer-inner { max-width: 880px; margin: 0 auto; padding: 0 28px; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--faint); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
@media (max-width: 640px) { .ornament { width: 210px; height: 210px; right: -60px; bottom: -46px; } .card h1 { font-size: 30px; } .footer-inner { padding: 0 18px; } } @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } } </style></head><body> <svg style="display:none" aria-hidden="true"> <symbol id="i-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></symbol> <symbol id="i-moon" viewBox="0 0 24 24"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></symbol> </svg>
<noscript><div style="max-width:880px;margin:16px auto 0;padding:10px 28px;font-size:14px">Uplink requires JavaScript.</div></noscript> <svg class="ornament" viewBox="0 0 100 100" aria-hidden="true"> <g stroke="currentColor" stroke-width="6" stroke-linecap="round" fill="none"> <path d="M50 6v88"/><path d="M6 50h88"/><path d="M19 19l62 62"/><path d="M81 19 19 81"/> </g> </svg>
<div class="topline"> <div class="wordmark">Uplink</div> <button id="themeToggle" class="theme-toggle" type="button" title="Toggle theme" aria-label="Toggle theme"></button> </div>
<div class="center"> <main class="card"> <h1>Welcome <em>back.</em></h1> <p class="sub">Enter your access password to continue</p>
<form id="loginForm"> <input type="password" id="passwordInput" class="input-field" autocomplete="current-password" placeholder="Access password" aria-errormessage="errorMessage" required> <button type="submit" id="submitButton" class="submit-button"> <span class="button-text">Sign in</span> </button> </form>
<div id="capsHint" class="caps-hint" hidden>Caps Lock is on</div> <div id="errorMessage" class="error-message" role="alert" aria-live="polite" aria-atomic="true" hidden> <span class="error-mark" aria-hidden="true">!</span> <div> <p id="errorTitle" class="error-title"></p> <p id="errorDetail" class="error-detail"></p> </div> </div> </main> </div>
<footer class="footer"> <div class="footer-inner"><span>UPLINK ARCHIVE v3</span><span>PRIVATE</span></div> </footer>
<script> (() => { 'use strict';
/* ---------- theme ---------- */ const SVG_NS = 'http://www.w3.org/2000/svg'; const icon = (name) => { const svg = document.createElementNS(SVG_NS, 'svg'); svg.setAttribute('class', 'icon'); svg.setAttribute('aria-hidden', 'true'); const use = document.createElementNS(SVG_NS, 'use'); use.setAttribute('href', '#i-' + name); svg.appendChild(use); return svg; }; const themeButton = document.getElementById('themeToggle'); const renderTheme = () => { const dark = document.documentElement.dataset.theme === 'dark'; themeButton.replaceChildren(icon(dark ? 'sun' : 'moon')); const meta = document.querySelector('meta[name="theme-color"]'); if (meta) meta.content = dark ? '#262521' : '#f0eee6'; }; themeButton.addEventListener('click', () => { const next = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark'; document.documentElement.dataset.theme = next; try { localStorage.setItem('uplink-theme', next); } catch (e) { /* private mode */ } renderTheme(); if (themeButton.animate) { themeButton.animate( [{ transform: 'rotate(-40deg)', opacity: 0.3 }, { transform: 'rotate(0deg)', opacity: 1 }], { duration: 280, easing: 'ease-out' } ); } }); renderTheme();
/* ---------- login ---------- */ const loginForm = document.getElementById('loginForm'); const passwordInput = document.getElementById('passwordInput'); const submitButton = document.getElementById('submitButton'); const buttonText = submitButton.querySelector('.button-text'); const errorMessage = document.getElementById('errorMessage'); const errorTitle = document.getElementById('errorTitle'); const errorDetail = document.getElementById('errorDetail'); const capsHint = document.getElementById('capsHint'); const LOGIN_ERRORS = { 401: { title: 'That password didn’t work', detail: 'Check it and try again.' }, 429: { title: 'Too many attempts', detail: 'Wait a moment before trying again.' }, network: { title: 'We couldn’t reach Uplink', detail: 'Check your connection and try again.' }, default: { title: 'Something went wrong', detail: 'Please try again in a moment.' }, };
const clearError = () => { errorMessage.hidden = true; errorTitle.textContent = ''; errorDetail.textContent = ''; passwordInput.removeAttribute('aria-invalid'); }; const showError = ({ title, detail }) => { errorTitle.textContent = title; errorDetail.textContent = detail; errorMessage.hidden = false; passwordInput.setAttribute('aria-invalid', 'true'); };
['keydown', 'keyup', 'focus'].forEach((eventName) => { passwordInput.addEventListener(eventName, (e) => { if (typeof e.getModifierState === 'function') { capsHint.hidden = !e.getModifierState('CapsLock'); } }); }); passwordInput.addEventListener('blur', () => { capsHint.hidden = true; }); passwordInput.addEventListener('input', clearError);
loginForm.addEventListener('submit', async (e) => { e.preventDefault(); if (submitButton.disabled) return; clearError();
submitButton.disabled = true; buttonText.style.display = 'none'; const spinner = document.createElement('div'); spinner.className = 'spinner'; submitButton.prepend(spinner); let accessGranted = false;
try { const response = await fetch('/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ password: passwordInput.value }), });
if (response.ok) { accessGranted = true; submitButton.classList.add('success'); spinner.remove(); buttonText.textContent = 'Access granted'; buttonText.style.display = 'inline'; setTimeout(() => window.location.reload(), 650); } else { showError(LOGIN_ERRORS[response.status] || LOGIN_ERRORS.default); } } catch (error) { showError(error instanceof TypeError ? LOGIN_ERRORS.network : LOGIN_ERRORS.default); } finally { if (!accessGranted) { submitButton.disabled = false; spinner.remove(); buttonText.style.display = 'inline'; passwordInput.focus(); passwordInput.select(); } } }); })(); </script></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"> <title>Uplink — Upload, then share.</title> <meta name="theme-color" content="#f0eee6"> <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%23c9603b'/%3E%3Cpath d='M32 46V20M20 30l12-12 12 12' stroke='%23faf9f4' stroke-width='6' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E"> <script> // Apply the theme before first paint to avoid a flash of wrong colors. (function () { var theme; try { theme = localStorage.getItem('uplink-theme'); } catch (e) { /* private mode */ } if (theme !== 'dark' && theme !== 'light') { theme = window.matchMedia && matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; } document.documentElement.dataset.theme = theme; var meta = document.querySelector('meta[name="theme-color"]'); if (meta) meta.content = theme === 'dark' ? '#262521' : '#f0eee6'; })(); </script> <style> :root { --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif; --serif: Georgia, "Times New Roman", "Songti SC", "STSong", "SimSun", serif; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; --ease: cubic-bezier(0.25, 0.7, 0.3, 1); } :root, [data-theme="light"] { color-scheme: light; --bg: #f0eee6; --panel: #faf9f4; --panel-2: #f4f2ea; --ink: #1f1e1a; --sub: #6b675c; --faint: #a49d8d; --line: #e0dbcd; --line-2: #ccc4b1; --acc: #c9603b; --acc-ink: #a84d2c; --acc-soft: rgba(201, 96, 59, 0.09); --ok: #3f7d54; --err: #a83a24; --err-bg: rgba(168, 58, 36, 0.07); --grain-opacity: 0.32; --dash-idle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='%23CBC3B0' stroke-width='1.5' stroke-dasharray='2 8' stroke-linecap='round'/%3E%3C/svg%3E"); --dash-active: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='%23C9603B99' stroke-width='1.5' stroke-dasharray='2 8' stroke-linecap='round'/%3E%3C/svg%3E"); } [data-theme="dark"] { color-scheme: dark; --bg: #262521; --panel: #2d2c27; --panel-2: #34322b; --ink: #eceae1; --sub: #a8a295; --faint: #6f6a5d; --line: rgba(236, 234, 225, 0.11); --line-2: rgba(236, 234, 225, 0.24); --acc: #e08862; --acc-ink: #eda385; --acc-soft: rgba(224, 136, 98, 0.12); --ok: #83bd97; --err: #ee8a70; --err-bg: rgba(238, 138, 112, 0.1); --grain-opacity: 0.22; --dash-idle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='%23ECEAE140' stroke-width='1.5' stroke-dasharray='2 8' stroke-linecap='round'/%3E%3C/svg%3E"); --dash-active: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='%23E08862BB' stroke-width='1.5' stroke-dasharray='2 8' stroke-linecap='round'/%3E%3C/svg%3E"); } *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; } html { scrollbar-gutter: stable; } body { font-family: var(--sans); background: var(--bg); color: var(--ink); line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; transition: background-color 0.3s ease, color 0.3s ease; } @supports (min-height: 100dvh) { body { min-height: 100dvh; } } button, a, input, textarea { touch-action: manipulation; } ::selection { background: color-mix(in srgb, var(--acc) 24%, transparent); } body::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: var(--grain-opacity); mix-blend-mode: soft-light; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E"); } ::-webkit-scrollbar { width: 10px; } ::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; } ::-webkit-scrollbar-track { background: transparent; }
.icon { width: 1.2em; height: 1.2em; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; fill: none; flex-shrink: 0; }
.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 28px; flex-grow: 1; }
/* ---------- nav ---------- */ .nav { display: flex; align-items: center; justify-content: space-between; padding: 22px 0 16px; border-bottom: 1px solid var(--line); animation: fade 0.5s var(--ease) both; } @keyframes fade { from { opacity: 0; } to { opacity: 1; } } .brand { font-family: var(--serif); font-size: 21px; font-weight: 700; line-height: 1; letter-spacing: 0.005em; } .nav-actions { display: flex; align-items: center; gap: 4px; } .nav-button { display: inline-flex; align-items: center; gap: 6px; height: 38px; min-width: 38px; justify-content: center; padding: 0 10px; border: none; background: none; border-radius: 8px; cursor: pointer; text-decoration: none; font: inherit; font-size: 13.5px; color: var(--sub); transition: color 0.2s, background-color 0.2s; } .nav-button:hover { color: var(--ink); background: var(--acc-soft); } .nav-button .icon { width: 16px; height: 16px; } .nav-button .arrow { font-family: var(--serif); }
/* ---------- hero ---------- */ .hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 52px 0 34px; border-bottom: 1px solid var(--line); animation: rise 0.55s 0.05s var(--ease) both; } @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } } .hero h1 { font-family: var(--serif); font-size: clamp(30px, 5.4vw, 48px); font-weight: 600; line-height: 1.18; letter-spacing: 0.002em; } .hero h1 em { font-style: italic; color: var(--acc); } .hero-sub { color: var(--sub); font-size: 13.5px; margin-top: 10px; letter-spacing: 0.04em; } .hero-meta { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; color: var(--faint); text-align: right; line-height: 2.1; white-space: nowrap; padding-bottom: 6px; } .hero-meta::before { content: ""; display: block; width: 30px; height: 2px; background: var(--acc); margin: 0 0 10px auto; }
/* ---------- upload panel ---------- */ .upload-panel { margin-top: 26px; animation: rise 0.55s 0.1s var(--ease) both; }
/* ---------- drop zone ---------- */ .drop { position: relative; height: 316px; border-radius: 12px; background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; cursor: pointer; padding: 1.5rem; transition: background-color 0.25s; } .drop::before, .drop::after { content: ""; position: absolute; inset: 0; border-radius: 12px; pointer-events: none; transition: opacity 0.25s; } .drop::before { background-image: var(--dash-idle); } .drop::after { background-image: var(--dash-active); opacity: 0; } .drop:hover::before, .drop.drag-over::before { opacity: 0; } .drop:hover::after, .drop.drag-over::after { opacity: 1; } .drop.drag-over { background: var(--acc-soft); } .drop-arrow { color: var(--acc); margin-bottom: 2px; animation: bob 3.6s ease-in-out infinite; } .drop-arrow .icon { width: 24px; height: 24px; stroke-width: 1.6; } @keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } } .drop h3 { font-family: var(--serif); font-size: 19.5px; font-weight: 600; } .drop .hint { font-size: 13px; color: var(--sub); } .drop .hint u { color: var(--ink); text-decoration-color: var(--acc); text-underline-offset: 3px; } .hint-touch { display: none; } kbd { font-family: var(--mono); font-size: 10.5px; padding: 1.5px 6px; margin: 0 1px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: var(--panel); color: var(--sub); } .url-wrap { position: relative; width: min(440px, 100%); margin-top: 14px; } #urlInput { width: 100%; padding: 10px 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); font: inherit; font-size: 13.5px; text-align: center; transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s; } #urlInput::placeholder { color: var(--faint); } #urlInput:not(:placeholder-shown) { text-align: left; } #urlInput:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); background: var(--panel); }
/* ---------- file list ---------- */ .file-list { margin-top: 36px; margin-bottom: 30px; } .file-list:not(:empty) { border-top: 2px solid var(--ink); animation: fade 0.4s var(--ease) both; } .file-row { position: relative; display: flex; align-items: center; gap: 14px; padding: 11px 6px; border-bottom: 1px solid var(--line); animation: rowIn 0.35s var(--ease) both; transition: background-color 0.15s; } .file-row:hover { background: color-mix(in srgb, var(--panel) 65%, transparent); } @keyframes rowIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } } .file-row .idx { font-family: var(--mono); font-size: 11px; color: var(--acc); flex-shrink: 0; width: 26px; } .thumb { width: 38px; height: 38px; border-radius: 7px; overflow: hidden; flex-shrink: 0; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; } .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; } .thumb .ext { font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em; color: var(--sub); } .file-row .name { flex-grow: 1; min-width: 0; font-size: 13.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .file-row .name a { color: var(--ink); text-decoration: none; } .file-row .name a:hover { color: var(--acc-ink); text-decoration: underline; text-decoration-color: var(--acc); text-underline-offset: 3px; } .row-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity 0.2s; } .file-row:hover .row-actions, .file-row:focus-within .row-actions { opacity: 1; } .file-row.is-error .row-actions { opacity: 1; } .file-row:not(.is-success) .copy-button:not(.retry-button):not(.remove-button) { display: none; } .retry-button { color: var(--err); border-color: color-mix(in srgb, var(--err) 42%, transparent); } .retry-button:hover { color: var(--err); border-color: var(--err); } .remove-button:hover { color: var(--err); border-color: var(--err); } @media (hover: none) { .file-row .row-actions { opacity: 1; } } .copy-button { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; padding: 4px 8px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel); color: var(--sub); cursor: pointer; min-width: 42px; transition: color 0.15s, border-color 0.15s, background-color 0.15s; } .copy-button:hover { color: var(--ink); border-color: var(--ink); } .copy-button.copied { color: var(--bg); background: var(--ok); border-color: var(--ok); } .file-row .meta { font-family: var(--mono); font-size: 11px; color: var(--faint); flex-shrink: 0; text-align: right; min-width: 84px; letter-spacing: 0.03em; } .file-row.is-error .meta { color: var(--err); font-family: var(--sans); font-size: 12px; min-width: 0; max-width: 46%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .progress-bar { position: absolute; bottom: -1px; left: 0; height: 2px; width: 0; background: var(--acc); transition: width 0.2s; z-index: 2; } .file-row.is-success .progress-bar { display: none; } .file-row.is-error .progress-bar { background: var(--err); width: 100% !important; }
.list-tools { display: flex; justify-content: flex-end; padding: 8px 2px 0; } .list-tools[hidden] { display: none; } .list-clear { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; padding: 5px 8px; border: none; background: none; color: var(--faint); cursor: pointer; border-radius: 6px; transition: color 0.15s; } .list-clear:hover { color: var(--err); }
/* ---------- full-page drop overlay ---------- */ .page-drop { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; text-align: center; background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); } .page-drop.active { display: flex; } .page-drop::before { content: ""; position: absolute; inset: 14px; border-radius: 14px; background-image: var(--dash-active); pointer-events: none; } .page-drop .drop-arrow .icon { width: 34px; height: 34px; } .page-drop h2 { font-family: var(--serif); font-size: 30px; font-weight: 600; margin-top: 6px; } .page-drop p { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.18em; color: var(--sub); margin-top: 8px; }
/* ---------- footer ---------- */ .footer { border-top: 1px solid var(--line); margin-top: auto; padding: 14px 0 calc(16px + env(safe-area-inset-bottom)); } .footer-inner { max-width: 880px; margin: 0 auto; padding: 0 28px; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--faint); } .footer-inner a { color: var(--faint); text-decoration: none; } .footer-inner a:hover { color: var(--acc-ink); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
/* ---------- touch devices ---------- */ @media (hover: none), (pointer: coarse) { .hint-desktop { display: none; } .hint-touch { display: block; } }
/* ---------- small screens ---------- */ @media (max-width: 640px) { .wrap { padding: 0 max(18px, env(safe-area-inset-left)) 0 max(18px, env(safe-area-inset-right)); } .nav { padding-top: 16px; } .hero { padding: 32px 0 24px; } .hero-meta { display: none; } .hero-sub { font-size: 12.5px; } .upload-panel { margin-top: 20px; } .drop { height: 248px; } .drop h3 { font-size: 17.5px; } /* 16px inputs prevent iOS Safari from auto-zooming on focus. */ #urlInput { font-size: 16px; } .file-list { margin-top: 26px; } .file-row { flex-wrap: wrap; row-gap: 7px; padding: 11px 2px; } .file-row .idx { display: none; } .file-row .meta { min-width: 0; } .row-actions { display: none; } .file-row .row-actions { display: flex; opacity: 1; order: 6; flex-basis: 100%; padding-left: 52px; } .copy-button { padding: 7px 12px; font-size: 10.5px; } .footer-inner { padding: 0 18px; } } @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } } </style></head><body> <svg style="display:none" aria-hidden="true"> <symbol id="i-arrow-up" viewBox="0 0 24 24"><path d="M12 19V5"/><path d="m5 12 7-7 7 7"/></symbol> <symbol id="i-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></symbol> <symbol id="i-moon" viewBox="0 0 24 24"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></symbol> </svg>
<noscript><div style="max-width:880px;margin:16px auto 0;padding:10px 28px;font-size:14px">Uplink requires JavaScript.</div></noscript> <div class="wrap"> <nav class="nav"> <div class="brand">Uplink</div> <div class="nav-actions"> <button id="themeToggle" class="nav-button" type="button" title="Toggle theme" aria-label="Toggle theme"></button> <button id="logoutButton" class="nav-button" type="button"><span>Logout</span><span class="arrow">→</span></button> </div> </nav>
<header class="hero"> <div> <h1>Upload, <em>then share.</em></h1> <p class="hero-sub">Private · Encrypted · Instant links</p> </div> <div class="hero-meta">EST. 2026<br>PRIVATE ARCHIVE<br>UPLINK v3.2</div> </header>
<div class="upload-panel"> <div class="drop" id="dropZone" tabindex="0" role="button" aria-label="Upload files"> <div class="drop-arrow"><svg class="icon"><use href="#i-arrow-up"/></svg></div> <h3 id="dropTitle">Drag & drop files here</h3> <p class="hint hint-desktop">or <u>browse files</u>, or paste with <kbd id="kbdMod">Ctrl</kbd><kbd>V</kbd></p> <p class="hint hint-touch">Photos, documents, archives — anything.</p> <input type="file" id="fileInput" multiple style="display:none"> <div class="url-wrap"> <input type="text" id="urlInput" maxlength="2048" inputmode="url" autocapitalize="none" autocorrect="off" spellcheck="false" placeholder="Or paste a URL and press Enter"> </div> </div> </div>
<div class="list-tools" id="listTools" hidden> <button id="clearHistory" class="list-clear" type="button" title="Remove saved upload history from this browser">CLEAR HISTORY</button> </div> <div class="file-list" id="fileList" aria-live="polite"></div> </div>
<div class="page-drop" id="pageDrop" aria-hidden="true"> <div> <div class="drop-arrow"><svg class="icon"><use href="#i-arrow-up"/></svg></div> <h2>Drop anywhere</h2> <p>RELEASE TO ADD TO THE ARCHIVE</p> </div> </div>
<footer class="footer"> <div class="footer-inner"> <span>UPLINK ARCHIVE v3</span> <span>CRAFTED BY <a href="https://github.com/musifei" target="_blank" rel="noopener noreferrer">MUSIFEI</a></span> </div> </footer>
<script>(() => { 'use strict'; const config = { maxConcurrentUploads: 3, uploadEndpoint: '/upload/', fetchUrlEndpoint: '/fetch-url/', copySuccessDuration: 1200 };
const IS_TOUCH = window.matchMedia && matchMedia('(hover: none), (pointer: coarse)').matches;
const STRINGS = { dropIdle: IS_TOUCH ? 'Tap to choose files' : 'Drag & drop files here', dropRelease: 'Release to upload', uploading: 'Uploading', queued: 'Queued', error: 'Error', invalidUrl: 'Please enter a valid URL.', invalidResponse: 'Invalid response.', networkError: 'Network error.', serverError: 'Server error', fetchFailed: 'URL fetch failed.', copyUrl: 'Copy URL', copyMd: 'Copy Markdown', copyHtml: 'Copy HTML', };
/* ---------- icons ---------- */ const SVG_NS = 'http://www.w3.org/2000/svg'; function icon(name) { const svg = document.createElementNS(SVG_NS, 'svg'); svg.setAttribute('class', 'icon'); svg.setAttribute('aria-hidden', 'true'); const use = document.createElementNS(SVG_NS, 'use'); use.setAttribute('href', '#i-' + name); svg.appendChild(use); return svg; }
/* ---------- theme ---------- */ function setupTheme() { const button = document.getElementById('themeToggle'); const render = () => { const dark = document.documentElement.dataset.theme === 'dark'; button.replaceChildren(icon(dark ? 'sun' : 'moon')); const meta = document.querySelector('meta[name="theme-color"]'); if (meta) meta.content = dark ? '#262521' : '#f0eee6'; }; button.addEventListener('click', () => { const next = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark'; document.documentElement.dataset.theme = next; try { localStorage.setItem('uplink-theme', next); } catch (e) { /* private mode */ } render(); if (button.animate) { button.animate( [{ transform: 'rotate(-40deg)', opacity: 0.3 }, { transform: 'rotate(0deg)', opacity: 1 }], { duration: 280, easing: 'ease-out' } ); } }); try { if (!localStorage.getItem('uplink-theme') && window.matchMedia) { matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => { document.documentElement.dataset.theme = e.matches ? 'dark' : 'light'; render(); }); } } catch (e) { /* ignore */ } render(); }
/* ---------- state ---------- */ let uploadQueue = []; let activeUploads = 0; let fileCounter = 0; const fileList = document.getElementById('fileList'); const retryFiles = new WeakMap(); const activeRequests = new WeakMap();
/* ---------- persistent history ---------- */ const HISTORY_KEY = 'uplink-history'; const HISTORY_LIMIT = 50;
const history = { load() { try { const raw = JSON.parse(localStorage.getItem(HISTORY_KEY) || '[]'); if (!Array.isArray(raw)) return []; const entries = raw .filter((e) => e && typeof e.u === 'string' && /^https?:\/\//i.test(e.u) && typeof e.n === 'string') .map((e) => ({ ...e, id: historyId(e), n: e.n.slice(0, 255) })) .slice(0, HISTORY_LIMIT); if (entries.some((entry, index) => raw[index]?.id !== entry.id)) { localStorage.setItem(HISTORY_KEY, JSON.stringify(entries)); } return entries; } catch (e) { return []; } }, add(entry) { try { const entries = this.load(); entries.unshift(entry); localStorage.setItem(HISTORY_KEY, JSON.stringify(entries.slice(0, HISTORY_LIMIT))); } catch (e) { /* storage unavailable */ } }, remove(id) { if (!id) return; try { const entries = this.load().filter((entry) => entry.id !== id); if (entries.length) localStorage.setItem(HISTORY_KEY, JSON.stringify(entries)); else localStorage.removeItem(HISTORY_KEY); } catch (e) { /* storage unavailable */ } }, clear() { try { localStorage.removeItem(HISTORY_KEY); } catch (e) { /* ignore */ } }, };
function historyId(entry) { return entry.id || `${entry.ts || 0}:${entry.u}`; }
function renumberRows() { const rows = Array.from(fileList.querySelectorAll('.file-row')); rows.slice().reverse().forEach((row, index) => { row.querySelector('.idx').textContent = String(index + 1).padStart(3, '0'); }); fileCounter = rows.length; document.getElementById('listTools').hidden = !fileList.querySelector('[data-history="1"]'); }
function renderHistory() { const entries = history.load(); if (!entries.length) return; // Oldest first so index numbers ascend chronologically, newest on top. for (let i = entries.length - 1; i >= 0; i--) { const entry = entries[i]; entry.id = historyId(entry); const isImage = (entry.t || '').startsWith('image/'); const element = utils.createFileElement( { name: entry.n, type: entry.t || '' }, `hist-${i}-${entry.ts || 0}`, isImage ? entry.u : null ); element.dataset.history = '1'; element.dataset.historyId = entry.id; fileList.prepend(element); ui.showSuccess(element, entry.u, entry.n, entry.s || 0); } renumberRows(); }
function setupHistoryTools() { document.getElementById('clearHistory').addEventListener('click', () => { history.clear(); fileList.querySelectorAll('[data-history="1"]').forEach((el) => el.remove()); renumberRows(); }); }
/* ---------- utils ---------- */ const utils = { escapeHtml(value) { return String(value).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); }, escapeMarkdown(value) { return String(value).replace(/[\\[\]]/g, '\\$&'); }, formatFileSize(bytes) { if (!Number.isFinite(bytes) || bytes <= 0) return '0 B'; const k = 1024, sizes = ['B', 'KB', 'MB', 'GB', 'TB']; const i = Math.min(Math.floor(Math.log(bytes) / Math.log(k)), sizes.length - 1); return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`; }, extBadge(fileName) { const parts = (fileName || '').split('.'); const ext = parts.length > 1 ? parts.pop() : ''; return (ext || 'FILE').slice(0, 4).toUpperCase(); }, // Builds preview nodes with DOM APIs (never string-interpolated HTML) so // attacker-controlled URLs/filenames cannot inject markup or handlers. buildThumb(file, directUrl = null) { const thumb = document.createElement('div'); thumb.className = 'thumb'; const badge = document.createElement('span'); badge.className = 'ext'; badge.textContent = this.extBadge(file.name);
const attachImage = (src, revoke) => { const img = document.createElement('img'); img.alt = ''; const release = () => { if (revoke) URL.revokeObjectURL(src); }; img.onload = release; img.onerror = () => { release(); img.remove(); thumb.appendChild(badge); }; img.src = src; thumb.appendChild(img); }; if (directUrl) attachImage(directUrl, false); else if (file.type && file.type.startsWith('image/') && typeof URL !== 'undefined' && file instanceof Blob) attachImage(URL.createObjectURL(file), true); else thumb.appendChild(badge); return thumb; }, createFileElement(file, id, directPreviewUrl = null) { const element = document.createElement('div'); element.className = 'file-row'; element.id = id; element.dataset.fileType = file.type || '';
const idx = document.createElement('span'); idx.className = 'idx'; idx.textContent = String(++fileCounter).padStart(3, '0');
const thumb = this.buildThumb(file, directPreviewUrl);
const name = document.createElement('span'); name.className = 'name'; name.textContent = file.name;
const actions = document.createElement('span'); actions.className = 'row-actions'; const makeCopyButton = (type, label, title) => { const button = document.createElement('button'); button.className = 'copy-button'; button.type = 'button'; button.dataset.type = type; button.dataset.label = label; button.title = title; button.textContent = label; return button; }; actions.appendChild(makeCopyButton('url', 'URL', STRINGS.copyUrl)); actions.appendChild(makeCopyButton('markdown', 'MD', STRINGS.copyMd)); actions.appendChild(makeCopyButton('html', 'HTML', STRINGS.copyHtml)); const removeButton = makeCopyButton('remove', 'REMOVE', 'Remove from this list and browser history; the remote file stays'); removeButton.classList.add('remove-button'); actions.appendChild(removeButton);
const meta = document.createElement('span'); meta.className = 'meta'; const statusEl = document.createElement('span'); statusEl.className = 'status-text'; statusEl.textContent = STRINGS.queued; meta.appendChild(statusEl);
const progress = document.createElement('div'); progress.className = 'progress-bar';
element.appendChild(idx); element.appendChild(thumb); element.appendChild(name); element.appendChild(actions); element.appendChild(meta); element.appendChild(progress); return element; }, async copyToClipboard(button) { const item = button.closest('.file-row'); const url = item.dataset.url; if (!url) return; const name = item.dataset.fileName; const type = button.dataset.type; const fileType = item.dataset.fileType || ''; const isImage = fileType.startsWith('image/'); const isAudio = fileType.startsWith('audio/'); const isVideo = fileType.startsWith('video/'); let textToCopy = url; if (type === 'markdown') { const mdName = utils.escapeMarkdown(name); textToCopy = isImage ? `` : `[${mdName}](<${url}>)`; } else if (type === 'html') { const eUrl = utils.escapeHtml(url); const eName = utils.escapeHtml(name); if (isImage) textToCopy = `<img src="${eUrl}" alt="${eName}">`; else if (isAudio) textToCopy = `<audio controls src="${eUrl}"></audio>`; else if (isVideo) textToCopy = `<video controls width="640" src="${eUrl}"></video>`; else textToCopy = `<a href="${eUrl}" title="${eName}" target="_blank" rel="noopener">${eName}</a>`; } if (button.classList.contains('copied')) return; try { await navigator.clipboard.writeText(textToCopy); button.classList.add('copied'); button.textContent = '✓'; setTimeout(() => { button.classList.remove('copied'); button.textContent = button.dataset.label; }, config.copySuccessDuration); } catch (err) { console.error('Clipboard copy failed:', err); } }, };
/* ---------- ui ---------- */ const ui = { updateStatusText: (el, text) => { el.querySelector('.status-text').textContent = text; }, updateProgress: (el, progress, extra) => { el.querySelector('.progress-bar').style.width = `${progress}%`; const suffix = extra ? ` · ${extra}` : ''; ui.updateStatusText(el, `${STRINGS.uploading} ${Math.round(progress)}%${suffix}`); }, showSuccess: (el, url, filename, size) => { if (el.dataset.removed === '1') return; el.classList.add('is-success'); el.dataset.url = url; el.dataset.fileName = filename; ui.updateStatusText(el, utils.formatFileSize(size || 0)); const nameEl = el.querySelector('.name'); nameEl.replaceChildren(); const link = document.createElement('a'); link.href = url; link.target = '_blank'; link.rel = 'noopener noreferrer'; link.textContent = filename; nameEl.appendChild(link); if (!el.dataset.history) { const entry = { id: `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u: url, n: filename, s: size || 0, t: el.dataset.fileType || '', ts: Date.now() }; history.add(entry); // Mark newly completed rows too, so CLEAR HISTORY has an // immediate visible effect instead of only changing storage. el.dataset.history = '1'; el.dataset.historyId = entry.id; document.getElementById('listTools').hidden = false; } }, showError: (el, message, retryFile) => { if (el.dataset.removed === '1') return; el.classList.add('is-error'); ui.updateStatusText(el, `${STRINGS.error}: ${message}`); if (retryFile instanceof Blob && !el.querySelector('.retry-button')) { retryFiles.set(el, retryFile); const button = document.createElement('button'); button.className = 'copy-button retry-button'; button.type = 'button'; button.textContent = 'RETRY'; button.title = 'Retry this upload'; el.querySelector('.row-actions').appendChild(button); } }, resetForRetry: (el) => { el.classList.remove('is-error'); const retryButton = el.querySelector('.retry-button'); if (retryButton) retryButton.remove(); el.querySelector('.progress-bar').style.width = '0%'; ui.updateStatusText(el, STRINGS.queued); }, };
/* ---------- handlers ---------- */ const handlers = { handleFiles(files) { if (!files || files.length === 0) return; for (const file of files) { const fileId = `file-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`; const element = utils.createFileElement(file, fileId); fileList.prepend(element); uploadQueue.push({ file, element }); } renumberRows(); this.processQueue(); }, processQueue() { while (uploadQueue.length > 0 && activeUploads < config.maxConcurrentUploads) { const task = uploadQueue.shift(); activeUploads++; void this.uploadFile(task.file, task.element) .catch(() => { /* the row already displays the error */ }) .finally(() => { activeUploads--; this.processQueue(); }); } }, uploadFile(file, element) { ui.updateStatusText(element, STRINGS.uploading); const formData = new FormData(); formData.append('file', file); return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); activeRequests.set(element, xhr); let lastLoaded = 0; let lastTime = performance.now(); let speedText = ''; xhr.upload.onprogress = (e) => { if (!e.lengthComputable) return; const now = performance.now(); if (now - lastTime >= 500) { const bytesPerSecond = (e.loaded - lastLoaded) / ((now - lastTime) / 1000); if (bytesPerSecond > 0) speedText = `${utils.formatFileSize(bytesPerSecond)}/s`; lastLoaded = e.loaded; lastTime = now; } ui.updateProgress(element, (e.loaded / e.total) * 100, speedText); }; xhr.onload = () => { activeRequests.delete(element); try { if (xhr.status >= 200 && xhr.status < 300) { const res = JSON.parse(xhr.responseText); if (res.url) { ui.showSuccess(element, res.url, file.name, res.size); resolve(); } else throw new Error(STRINGS.invalidResponse); } else { let msg = `${STRINGS.serverError} (${xhr.status})`; try { msg = JSON.parse(xhr.responseText).detail || msg; } catch (e) { /* not json */ } throw new Error(msg); } } catch (error) { ui.showError(element, error.message, file); reject(error); } }; xhr.onerror = () => { activeRequests.delete(element); ui.showError(element, STRINGS.networkError, file); reject(new Error('network')); }; xhr.onabort = () => { activeRequests.delete(element); reject(new Error('aborted')); }; xhr.open('POST', config.uploadEndpoint, true); xhr.send(formData); }); }, async fetchAndUploadUrl(url) { const tempName = url.split('/').pop().split('?')[0] || url; const isLikelyImage = /\.(jpg|jpeg|png|gif|webp|avif)$/i.test(tempName); const pseudoFileType = isLikelyImage ? 'image/jpeg' : 'application/octet-stream'; const directPreviewUrl = isLikelyImage ? url : null; const element = utils.createFileElement({ name: tempName, type: pseudoFileType }, `file-${Date.now()}`, directPreviewUrl); fileList.prepend(element); renumberRows(); ui.updateStatusText(element, STRINGS.uploading); try { const response = await fetch(config.fetchUrlEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ url }), }); const data = await response.json().catch(() => ({})); if (!response.ok) throw new Error(data.detail || STRINGS.fetchFailed); if (data.url) { element.dataset.fileType = data.contentType || pseudoFileType; ui.showSuccess(element, data.url, data.filename, data.size); } else { throw new Error(STRINGS.invalidResponse); } } catch (error) { ui.showError(element, error.message); } }, };
/* ---------- events ---------- */ function setupEventListeners() { const dz = document.getElementById('dropZone'); const fi = document.getElementById('fileInput'); const urlInputEl = document.getElementById('urlInput'); const dropTitle = document.getElementById('dropTitle');
document.getElementById('logoutButton').addEventListener('click', async (e) => { const button = e.currentTarget; button.disabled = true; try { const response = await fetch('/logout', { method: 'POST', credentials: 'same-origin' }); if (!response.ok) throw new Error(`Logout failed (${response.status})`); window.location.replace('/'); } catch (error) { window.location.assign('/logout'); } });
dropTitle.textContent = STRINGS.dropIdle; const isApple = /mac|iphone|ipad|ipod/i.test(navigator.platform || ''); document.getElementById('kbdMod').textContent = isApple ? '⌘' : 'Ctrl';
['dragenter', 'dragover', 'dragleave', 'drop'].forEach((e) => dz.addEventListener(e, (p) => p.preventDefault())); ['dragenter', 'dragover'].forEach((e) => dz.addEventListener(e, () => { dz.classList.add('drag-over'); dropTitle.textContent = STRINGS.dropRelease; })); ['dragleave', 'drop'].forEach((e) => dz.addEventListener(e, () => { dz.classList.remove('drag-over'); dropTitle.textContent = STRINGS.dropIdle; })); dz.addEventListener('drop', (e) => { // Stop the event reaching the window-level drop handler below, so a // file dropped directly on the zone isn't uploaded twice. e.stopPropagation(); handlers.handleFiles(e.dataTransfer.files); }); dz.addEventListener('click', (e) => { if (e.target.closest('.url-wrap') === null) fi.click(); }); dz.addEventListener('keydown', (e) => { if ((e.key === 'Enter' || e.key === ' ') && e.target === dz) { e.preventDefault(); fi.click(); } }); urlInputEl.addEventListener('click', (e) => e.stopPropagation()); fi.addEventListener('change', (e) => { handlers.handleFiles(e.target.files); e.target.value = null; });
urlInputEl.addEventListener('keydown', async (e) => { if (e.key !== 'Enter') return; e.preventDefault(); const url = urlInputEl.value.trim(); if (!url) return; let parsed = null; try { parsed = new URL(url); if (!['http:', 'https:'].includes(parsed.protocol)) parsed = null; } catch (error) { /* handled below */ } if (!parsed) { urlInputEl.setCustomValidity(STRINGS.invalidUrl); urlInputEl.reportValidity(); setTimeout(() => urlInputEl.setCustomValidity(''), 2000); } if (parsed) { await handlers.fetchAndUploadUrl(url); urlInputEl.value = ''; } });
document.addEventListener('paste', (e) => { const items = e.clipboardData?.items; if (!items) return; const files = Array.from(items).filter((i) => i.kind === 'file').map((i) => i.getAsFile()).filter(Boolean); if (files.length > 0) { handlers.handleFiles(files); return; } const textItem = Array.from(items).find((i) => i.kind === 'string' && i.type === 'text/plain'); if (!textItem) return; textItem.getAsString((txt) => { const value = txt.trim(); if (!/^https?:\/\//i.test(value)) return; urlInputEl.value = value; urlInputEl.focus(); urlInputEl.select(); }); });
fileList.addEventListener('click', (e) => { const removeButton = e.target.closest('.remove-button'); if (removeButton) { const row = removeButton.closest('.file-row'); row.dataset.removed = '1'; history.remove(row.dataset.historyId); uploadQueue = uploadQueue.filter((task) => task.element !== row); const xhr = activeRequests.get(row); if (xhr) xhr.abort(); row.remove(); renumberRows(); return; } const retryButton = e.target.closest('.retry-button'); if (retryButton) { const row = retryButton.closest('.file-row'); const file = retryFiles.get(row); if (file) { ui.resetForRetry(row); uploadQueue.push({ file, element: row }); handlers.processQueue(); } return; } const button = e.target.closest('.copy-button'); if (button) utils.copyToClipboard(button); }); // Full-page drag & drop: files can be dropped anywhere, not just the zone. const pageDrop = document.getElementById('pageDrop'); let dragDepth = 0; const hasFiles = (e) => e.dataTransfer && Array.from(e.dataTransfer.types || []).includes('Files'); window.addEventListener('dragenter', (e) => { if (!hasFiles(e)) return; e.preventDefault(); dragDepth++; pageDrop.classList.add('active'); }); window.addEventListener('dragover', (e) => { if (hasFiles(e)) e.preventDefault(); }); window.addEventListener('dragleave', (e) => { if (!hasFiles(e)) return; dragDepth = Math.max(0, dragDepth - 1); if (dragDepth === 0) pageDrop.classList.remove('active'); }); window.addEventListener('drop', (e) => { if (!hasFiles(e)) return; e.preventDefault(); dragDepth = 0; pageDrop.classList.remove('active'); handlers.handleFiles(e.dataTransfer.files); }); window.addEventListener('keydown', (e) => { if (e.key === 'Escape') { dragDepth = 0; pageDrop.classList.remove('active'); } });
// Warn before leaving while uploads are still in flight. window.addEventListener('beforeunload', (e) => { if (activeUploads > 0 || uploadQueue.length > 0) { e.preventDefault(); e.returnValue = ''; } }); }
/* ---------- init ---------- */ setupTheme(); setupEventListeners(); setupHistoryTools(); renderHistory();})();</script></body></html>templates/login.htmlDeleted-358
templates/uploader.htmlDeleted-937