aboutsummaryrefslogtreecommitdiff
path: root/static/widgets/image/index.js
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-05-20 10:16:50 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-05-20 10:16:50 +0200
commit44445734ba4a0f05564f808c2fd34a7f23c6fafb (patch)
tree3bd22add718620cbf931286f55137bcc666100be /static/widgets/image/index.js
parent95ae9f15e1db335a7f8358d811ea37e2c89dd10f (diff)
Let's do a rewrite!
Created project structure and changed `build.zig` and added licence.
Diffstat (limited to 'static/widgets/image/index.js')
-rw-r--r--static/widgets/image/index.js108
1 files changed, 0 insertions, 108 deletions
diff --git a/static/widgets/image/index.js b/static/widgets/image/index.js
deleted file mode 100644
index b063864..0000000
--- a/static/widgets/image/index.js
+++ /dev/null
@@ -1,108 +0,0 @@
-import * as api from 'api';
-import * as sfw from 'sfw';
-import Month from '../../month.js';
-const { Div, Img, A: Link } = sfw.element.native;
-
-import stylesheet from './index.css';
-
-const css = await sfw.css.sheet(stylesheet);
-
-export default class Image extends sfw.element.Container {
- #container
- #image
- #menu
- #id
- #month
- #date
- #id_element
- #disabled
-
- constructor() {
- super ({ css })
-
- this.#disabled = false;
-
- this.body.append(
- this.#container = Div.new({
- id: 'container',
- children: [
- this.#image = Img.new({
- onload: () => this.#container.classList.add('loaded'),
- }),
- Div.new({ id: 'loading' }),
- this.#menu = Div.new({
- id: 'menu',
- children: [
- Div.new({
- id: 'label',
- children: [
- Div.new({ id: 'title', innerText: 'Id' }),
- this.#id_element = Div.new({ className: 'element id' }),
- ],
- }),
- Div.new({
- id: 'label',
- children: [
- Div.new({ id: 'title', innerText: 'Date' }),
- this.#date = Div.new({ className: 'element' }),
- ],
- }),
- Div.new({
- id: 'download',
- innerText: 'Download',
- onclick: () => {
- const a = Link.new({
- href: `/api/image/load/${this.#id}`,
- download: `${this.#id}.jpeg`
- })
- a.click()
- }
- }),
- Div.new({
- id: 'delete',
- innerText: 'Delete',
- onclick: () => {
- api.images.remove(this.#id);
- this.parentNode.removeChild(this);
- }
- }),
- ],
- ondblclick: (e) => {
- if (e.target != this.#menu) {
- e.stopPropagation();
- }
- }
- })
- ],
- ondblclick: (e) => {
- if (!this.#disabled) {
- this.#menu.classList.toggle('open');
- e.preventDefault();
- }
- }
- })
- );
- }
-
- set metadata(image) {
- const date = new Date(image.timestamp * 1000);
- this.#id = image.id;
- this.#month = Month.from_unix(image.timestamp);
- this.#container.classList.remove('loaded');
- this.#date.innerText = date.toLocaleString();
- this.#id_element.innerText = image.id;
- }
-
- load() {
- this.#image.src = `/api/image/load/${this.#id}`;
- }
-
- get month() {
- return this.#month;
- }
-
- set disabled(value) {
- this.#disabled = value;
- this.#image.setAttribute('draggable', !value);
- }
-}