Move home page into svelte and remove some old junk

This commit is contained in:
2022-02-21 23:25:44 +01:00
parent e4e061869e
commit 692c96eb63
27 changed files with 1497 additions and 2564 deletions

View File

@@ -10,6 +10,7 @@ import { fade } from 'svelte/transition';
export let title = "";
export let width = "800px";
export let height = "auto";
export let padding = false;
let visible = false;
const load_bg = background => {
@@ -56,7 +57,7 @@ const keydown = e => {
</button>
</slot>
</div>
<div class="body">
<div class="body" class:padding>
<slot></slot>
</div>
</div>
@@ -120,4 +121,7 @@ const keydown = e => {
flex-shrink: 1;
overflow: auto;
}
.padding {
padding: 10px;
}
</style>

View File

@@ -35,4 +35,28 @@ export function domain_url() {
return url;
}
export const add_upload_history = id => {
// Make sure the user is not logged in, for privacy. This keeps the
// files uploaded while logged in and anonymously uploaded files
// separated
if (document.cookie.includes("pd_auth_key")) { return; }
let uploads = localStorage.getItem("uploaded_files");
if (uploads === null) { uploads = ""; }
// Check if there are not too many values stored
if (uploads.length > 3600) {
// 3600 characters is enough to store 400 file IDs. If we exceed that
// number we'll drop the last two items
uploads = uploads.substring(
uploads.indexOf(",") + 1
).substring(
uploads.indexOf(",") + 1
);
}
// Save the new ID
localStorage.setItem("uploaded_files", id + "," + uploads);
}
</script>