From b488fdbe6aa2c07eb53292f75db7dec181fb7877 Mon Sep 17 00:00:00 2001 From: zumbiepig <121742281+zumbiepig@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:40:20 -0700 Subject: [PATCH] make it so ppl who spam buttons dont make articles glitch out --- public/articles/index.html | 4 ++-- public/resources/styles/themes/default.css | 16 ++++++------- src/resources/scripts/main.ts | 28 ++++++++++++++++++---- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/public/articles/index.html b/public/articles/index.html index 0782a78..ef89705 100644 --- a/public/articles/index.html +++ b/public/articles/index.html @@ -66,7 +66,7 @@
- How to Set Up a Cloudflare Tunnel for an Eaglercraft Server + Setting Up a Cloudflare Tunnel for an Eaglercraft Server

This brief guide walks you through configuring a Cloudflare Tunnel for your Eaglercraft server.

@@ -169,7 +169,7 @@
× -

How to Set Up a Cloudflare Tunnel for an Eaglercraft Server

+

Setting Up a Cloudflare Tunnel for an Eaglercraft Server

Written by zumbiepig and SpeedSlicer

In this guide, we'll walk you through the steps to set up a Cloudflare Tunnel for your Eaglercraft server, which is running on ws://localhost:8081.

Prerequisites

diff --git a/public/resources/styles/themes/default.css b/public/resources/styles/themes/default.css index 2734386..97412a3 100644 --- a/public/resources/styles/themes/default.css +++ b/public/resources/styles/themes/default.css @@ -746,17 +746,15 @@ nav { .article { display: none; position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; + width: 500vw; + height: 500vh; overflow: auto; background-color: rgba(0, 0, 0, 0.5); justify-content: center; align-items: center; } -@keyframes openArticle { +@keyframes article-open { 0% { opacity: 0; scale: 0; @@ -770,7 +768,7 @@ nav { } } -@keyframes closeArticle { +@keyframes article-close { 0% { opacity: 1; scale: 1; @@ -788,9 +786,9 @@ nav { background-color: #333; padding: 20px; border: 1px solid #888; - width: 65%; - max-width: 85%; - max-height: 85%; + width: 65vw; + height: 85vh; + max-width: 85vw; border-radius: 15px; color: #fff; overflow-y: auto; diff --git a/src/resources/scripts/main.ts b/src/resources/scripts/main.ts index 7281f2a..72f826f 100644 --- a/src/resources/scripts/main.ts +++ b/src/resources/scripts/main.ts @@ -2,6 +2,7 @@ import { gt, coerce } from 'semver'; import { inflate, deflate } from 'pako'; let selectedVersion: string; +let articleClosing = false; const theme = { load: function (themeToLoad?: string) { @@ -156,15 +157,32 @@ const article = { open: function (articleId: string) { const modal = document.querySelector(`#article-${articleId}`) as HTMLElement | null; if (modal) { - modal.style.animation = 'openArticle 0.5s ease-in-out'; + modal.style.animation = 'article-open 0.5s ease-in-out'; modal.style.display = 'flex'; + const closeArticleHandler = (event: Event) => { + if (event.target === modal) { + modal.removeEventListener('click', closeArticleHandler); + article.close(articleId); + } + }; + modal.addEventListener('click', closeArticleHandler); } }, close: function (articleId: string) { - const modal = document.querySelector(`#article-${articleId}`) as HTMLElement | null; - if (modal) { - modal.style.animation = 'closeArticle 0.5s ease-in-out'; - modal.addEventListener('animationend', () => (modal.style.display = 'none'), { once: true }); + if (!articleClosing) { + articleClosing = true; + const modal = document.querySelector(`#article-${articleId}`) as HTMLElement | null; + if (modal) { + modal.style.animation = 'article-close 0.5s ease-in-out'; + modal.addEventListener( + 'animationend', + () => { + modal.style.display = 'none'; + articleClosing = false; + }, + { once: true } + ); + } } }, };