Fixed rodent sneeding

pull/215/head
transbitch 2023-10-24 21:24:55 -04:00
parent ac3d9a337d
commit e5ea709a0e
2 changed files with 218 additions and 222 deletions

View File

@ -112,7 +112,8 @@ function postToastSwitch(t, url, button1, button2, cls, extraActionsOnSuccess) {
});
}
if (!location.pathname.endsWith('/submit') && !location.pathname.endsWith('/chat')) {
if (!location.pathname.endsWith('/submit') && !location.pathname.endsWith('/chat'))
{
document.addEventListener('keydown', (e) => {
if (!((e.ctrlKey || e.metaKey) && e.key === "Enter")) return;
@ -160,7 +161,8 @@ function autoExpand(field) {
window.scrollTo(xpos,ypos);
};
function smoothScrollTop() {
function smoothScrollTop()
{
window.scrollTo({ top: 0, behavior: 'smooth' });
}
@ -195,7 +197,8 @@ function expandImage(url) {
document.getElementById("expanded-image").src = '';
document.getElementById("expanded-image-wrap-link").href = '';
if (!url) {
if (!url)
{
url = e.target.dataset.src
if (!url) url = e.target.src
}
@ -424,7 +427,8 @@ if (location.pathname != '/chat' && (gbrowser == 'iphone' || gbrowser == 'mac'))
}
const screen_width = (innerWidth > 0) ? innerWidth : screen.width;
function focusSearchBar(element) {
function focusSearchBar(element)
{
if (screen_width >= 768) {
element.focus();
}
@ -467,13 +471,6 @@ function insertText(input, text) {
handle_disabled(input)
}
/** Returns a promise which can be used to await when the event loop is idle. */
const idle = () => {
return new Promise(resolve => {
requestIdleCallback(resolve);
});
}
/**
* Shamelessly copied from https://github.com/component/textarea-caret-position/blob/master/index.js
* This code makes the assumption that the style of the textarea/input won't change.
@ -702,7 +699,8 @@ function handle_files(input, newfiles) {
input.files = oldfiles[ta.id].files;
if (input.files.length > 20) {
if (input.files.length > 20)
{
window.alert("You can't upload more than 20 files at one time!")
input.value = null
oldfiles[ta.id] = new DataTransfer();
@ -731,7 +729,8 @@ file_upload = document.getElementById('file-upload');
if (file_upload) {
function display_url_image() {
if (file_upload.files) {
if (file_upload.files)
{
const file = file_upload.files[0]
const char_limit = screen_width >= 768 ? 50 : 10;
file_upload.previousElementSibling.textContent = file.name.substr(0, char_limit);

View File

@ -1,5 +1,3 @@
// How about we don't dump everything into the global scope?
{
const cursormarseyEl = document.getElementById("cursormarsey");
const heartEl = document.getElementById("cursormarsey-heart");
@ -94,7 +92,7 @@
idleAnimationFrame = 0;
}
const idle = () => {
function idle() {
idleTime += 1;
// every ~ 20 seconds
@ -146,7 +144,7 @@
idleAnimationFrame += 1;
}
const frame = () => {
function frame() {
frameCount += 1;
const diffX = cursormarseyPosX - mousePosX;
const diffY = cursormarseyPosY - mousePosY;
@ -203,4 +201,3 @@
}
cursormarseyEl.style.pointerEvents = "none";
});
}