diff --git a/src/front/index.html b/src/front/index.html index eb78268..2c7660d 100644 --- a/src/front/index.html +++ b/src/front/index.html @@ -4,7 +4,6 @@ - @@ -17,7 +16,7 @@ - + diff --git a/src/front/index.tsx b/src/front/index.tsx index a153222..c93aa9d 100644 --- a/src/front/index.tsx +++ b/src/front/index.tsx @@ -1,29 +1,20 @@ import "tsx-dom"; +import "beercss"; + import App from "./App"; import colors from "./utilities/colors.module.css"; -import { snacker } from "./utilities/snackbar"; document.documentElement.className = colors.offline || ""; document.body.appendChild(); -let clicks = 0; -let resetCount = ""; - +const effectTick = new Audio("https://no.ipv4.army/raw/Effect_Tick.ogg"); document.onclick = () => { "vibrate" in navigator && navigator.vibrate(1); - new Audio("https://no.ipv4.army/raw/Effect_Tick.ogg").play(); - - clicks++; - - if (clicks % 10 === 0) { - snacker({ - message: `Please stop.${resetCount}`, - }); - resetCount += "."; - } + effectTick.currentTime = 0; + effectTick.play() }; // You're garbage, let me collect you. -fetch("/api/gc"); +fetch("/api/gc"); \ No newline at end of file diff --git a/src/front/utilities/snackbar/index.ts b/src/front/utilities/snackbar/index.ts deleted file mode 100644 index 721100a..0000000 --- a/src/front/utilities/snackbar/index.ts +++ /dev/null @@ -1,104 +0,0 @@ -import type { Snackbar } from "mdui"; -import { snackbar } from "mdui"; - -interface Options { - /** - * The text to display in the snackbar. - */ - message: string; - /** - * The position of the snackbar. Defaults to `bottom`. Possible values are: - * * `top`: Aligned to the top, centered - * * `top-start`: Aligned to the top, left - * * `top-end`: Aligned to the top, right - * * `bottom`: Aligned to the bottom, centered - * * `bottom-start`: Aligned to the bottom, left - * * `bottom-end`: Aligned to the bottom, right - */ - placement?: - | "top" - | "top-start" - | "top-end" - | "bottom" - | "bottom-start" - | "bottom-end"; - /** - * The text for the action button. - */ - action?: string; - /** - * Whether to show a close button on the right. - */ - closeable?: boolean; - /** - * The maximum number of lines to display for the message text. Defaults to no limit. Possible values are: - * * `1`: The message text will be displayed on one line at most. - * * `2`: The message text will be displayed on two lines at most. - */ - messageLine?: 1 | 2; - /** - * The duration (in milliseconds) after which the snackbar will automatically close. If set to 0, it will not close automatically. Defaults to 5 seconds. - */ - autoCloseDelay?: number; - /** - * Whether to close the snackbar when clicking or touching outside of it. - */ - closeOnOutsideClick?: boolean; - /** - * The name of the queue. - * By default, queues are not enabled. When calling this function multiple times, multiple snackbars will be displayed simultaneously. - * You can pass a queue name as an argument. Snackbar functions with the same queue name will only open after the previous snackbar has closed. - */ - queue?: string; - /** - * The callback function to be executed when the snackbar is clicked. - * The function parameter is the snackbar instance, and `this` also points to the snackbar instance. - * @param snackbar - */ - onClick?: (snackbar: Snackbar) => void; - /** - * The callback function to be executed when the action button is clicked. - * The function parameter is the snackbar instance, and `this` also points to the snackbar instance. - * By default, clicking the action button will close the snackbar. If the return value is false, the snackbar will not close. If the return value is a promise, the snackbar will close after the promise is resolved. - * @param snackbar - */ - onActionClick?: (snackbar: Snackbar) => void | boolean | Promise; - /** - * The callback function to be executed when the snackbar is opened. - * The function parameter is the snackbar instance, and `this` also points to the snackbar instance. - * @param snackbar - */ - onOpen?: (snackbar: Snackbar) => void; - /** - * The callback function to be executed when the snackbar's show animation is complete. - * The function parameter is the snackbar instance, and `this` also points to the snackbar instance. - * @param snackbar - */ - onOpened?: (snackbar: Snackbar) => void; - /** - * The callback function to be executed when the snackbar is about to be closed. - * The function parameter is the snackbar instance, and `this` also points to the snackbar instance. - * @param snackbar - */ - onClose?: (snackbar: Snackbar) => void; - /** - * The callback function to be executed when the snackbar's hide animation is complete. - * The function parameter is the snackbar instance, and `this` also points to the snackbar instance. - * @param snackbar - */ - onClosed?: (snackbar: Snackbar) => void; -} - -export const snacker = (opts: Options) => { - snackbar({ - closeable: true, - messageLine: 2, - queue: "snacker", - autoCloseDelay: 1600, - onOpen: () => { - new Audio("https://no.ipv4.army/raw/Popcorn.ogg").play(); - }, - - ...opts, - }); -}; diff --git a/src/front/utilities/socket/index.ts b/src/front/utilities/socket/index.ts index b5f0c9a..9e213bd 100644 --- a/src/front/utilities/socket/index.ts +++ b/src/front/utilities/socket/index.ts @@ -37,15 +37,6 @@ class Socket extends EventTarget { } }; - this._socket.onclose = () => { - const willRefresh = confirm( - "Realtime Data Connection closed\nWould you like to reconnect?", - ); - if (willRefresh) { - location.reload(); - } - }; - setInterval(() => { this._socket.send("ping"); }, 10 * 1000); diff --git a/src/index.ts b/src/index.ts index 7fa2998..3991156 100644 --- a/src/index.ts +++ b/src/index.ts @@ -85,8 +85,16 @@ const server = serve({ ); }, message: (ws, msg: string) => { - if (msg === "ping") ws.send("pong", true); - if (msg === "pong") ws.send("ping", true); + switch (msg) { + case "ping": + ws.send("pong", true); + break; + case "pong": + ws.send("ping", true); + break; + default: + break; + } return; },