From 174f61c7d86ac63d2cf45c976cd8453f95957b7d Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Fri, 27 Dec 2019 10:39:40 -0600 Subject: [PATCH] Make clicking on news show a new piece of news --- gorge.css | 1 - gorge.js | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gorge.css b/gorge.css index 74d491b..395d009 100644 --- a/gorge.css +++ b/gorge.css @@ -526,7 +526,6 @@ div::-webkit-scrollbar-corner { } .news-text { - pointer-events: none; text-align: center; position: fixed; top: 98vh; diff --git a/gorge.js b/gorge.js index 53b573b..b23b2bf 100644 --- a/gorge.js +++ b/gorge.js @@ -28,6 +28,7 @@ const clickPowers = { clickVictim: "micro" } + let clickBonus = 0; let clickVictim = "micro"; @@ -38,6 +39,11 @@ let shiftHeld = false; let mouseTarget = undefined; +let newsShowTimer; +let newsRemoveTimer; + +const newsDelay = 8000; + const state = { ownedUpgrades: ownedUpgrades, resources: resources, @@ -1067,7 +1073,7 @@ function doNews() { showNews(options[choice](state)); - setTimeout(() => { + newsShowTimer = setTimeout(() => { doNews(); }, 8000); } @@ -1078,11 +1084,18 @@ function showNews(text) { div.classList.add("news-text"); + div.addEventListener("click", () => { + clearTimeout(newsShowTimer); + clearTimeout(newsRemoveTimer); + body.removeChild(div); + doNews(); + }); + const body = document.querySelector("body"); body.appendChild(div); - setTimeout(() => { + newsRemoveTimer = setTimeout(() => { body.removeChild(div); }, 8000); }