uh
This commit is contained in:
parent
784c1c1c56
commit
a341bdde08
5 changed files with 17 additions and 132 deletions
|
@ -4,7 +4,6 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="renderer" content="webkit" />
|
||||
<meta name="theme-color" content="#000000">
|
||||
<meta name="description"
|
||||
content="A Dedicated Backend Developer, with a passion for high-fidelity audio, gaming, and development.">
|
||||
|
@ -17,7 +16,7 @@
|
|||
<link rel="stylesheet" href="index.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body class="dark">
|
||||
<script src="./index.tsx" type="module"></script>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -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(<App />);
|
||||
|
||||
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");
|
|
@ -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<void>;
|
||||
/**
|
||||
* 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,
|
||||
});
|
||||
};
|
|
@ -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);
|
||||
|
|
12
src/index.ts
12
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;
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue