From d72a903139de7740eae946d87fc0bff929952fc5 Mon Sep 17 00:00:00 2001 From: TateB Date: Thu, 19 Aug 2021 11:22:04 +1000 Subject: [PATCH 1/5] fixed nightbot issues --- src/apis/nightbot.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/apis/nightbot.js b/src/apis/nightbot.js index 05b0553..2c4af05 100644 --- a/src/apis/nightbot.js +++ b/src/apis/nightbot.js @@ -192,9 +192,7 @@ const setCommand = (command) => { }) ) .catch((err) => - Promise.reject( - "Nightbot: Error setting command " + command + " :: " + err - ) + console.error("Nightbot: Error setting command " + command + " :: " + err) ) } @@ -215,10 +213,10 @@ const generateCommandText = (command, vars) => { const [casters] = vars if (casters.length > 1) { var finalMsg = "@$(user), Your casters for today are: " - vars.map((x, i) => - i === vars.length - 1 + casters.forEach((x, i) => + i === casters.length - 1 ? (finalMsg += `${x.name}, ${x.url}`) - : (finalMsg += `${x.name}, ${x.url},`) + : (finalMsg += `${x.name}, ${x.url}, `) ) resolve(finalMsg) } else { @@ -230,13 +228,20 @@ const generateCommandText = (command, vars) => { } case "delay": { var finalMsg = "@$(user), Stream delay is set to " - if (vars[0].minutes) - finalMsg += - vars[0].minutes + " minute" + vars[0].minutes > 1 ? "s" : "" - if (vars[0].seconds && vars[0].minutes) - finalMsg += " and " + vars[0].seconds - if (vars[0].seconds && !vars[0].minutes) - finalMsg += vars[0].seconds + " seconds" + const { minutes, seconds } = vars[0] + /* eslint-disable no-unused-expressions */ + if (minutes > 0) { + finalMsg += minutes + " minute" + minutes > 1 ? (finalMsg += "s") : undefined + } + if (seconds > 0 && minutes > 0) { + finalMsg += " and " + } + if (seconds > 0) { + finalMsg += seconds + " second" + seconds > 1 ? (finalMsg += "s") : undefined + } + /* eslint-enable no-unused-expressions */ return resolve(finalMsg) } case "maps": { From d1675ee2766da9c4b8773ac575ba63754618bf0f Mon Sep 17 00:00:00 2001 From: TateB Date: Thu, 19 Aug 2021 12:43:52 +1000 Subject: [PATCH 2/5] added mapbans animation --- public/obs/mapbans.html | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/public/obs/mapbans.html b/public/obs/mapbans.html index 10d6fbf..d940775 100644 --- a/public/obs/mapbans.html +++ b/public/obs/mapbans.html @@ -15,6 +15,7 @@ flex-direction: row; justify-content: space-around; font-family: "Poppins"; + overflow: hidden; } .map { margin-top: 50px; @@ -190,6 +191,22 @@ height: inherit; } + .hidden { + opacity: 0; + margin-top: -200px !important; + } + + .hiddenAutoban { + opacity: 0; + margin-bottom: 100px !important; + } + + .bannedMap, + .map, + #autobantext { + transition: all 0.3s ease-in-out; + } + * { text-transform: uppercase; } @@ -350,12 +367,58 @@ ) spacerInnerEl.setAttribute("class", "spacer") autobanEl.setAttribute("class", "autoban") + autobanEl.setAttribute("id", "autobantext") autobanEl.appendChild(autobanText) bannedDiv.appendChild(spacerInnerEl) bannedDiv.appendChild(autobanEl) } else { bannedDiv.classList.add("autoPickedBo1") } + + if (document.visibilityState !== "visible") { + const mapDivs = document.querySelectorAll(".bannedMap, .map") + for (const mapDiv of mapDivs) { + mapDiv.classList.add("nodisplay") + mapDiv.classList.add("hidden") + } + document + .getElementById("autobantext") + .classList.add("nodisplay", "hiddenAutoban") + } + + window.addEventListener("obsSourceActiveChanged", (evt) => { + if (evt.detail.active) { + setTimeout(() => { + document + .getElementById("autobantext") + .classList.remove("nodisplay") + const mapDivs = document.querySelectorAll(".bannedMap, .map") + for (const [inx, mapDiv] of mapDivs.entries()) { + mapDiv.classList.remove("nodisplay") + setTimeout( + () => mapDiv.classList.remove("hidden"), + 300 * (inx + 1) + ) + } + setTimeout( + () => + document + .getElementById("autobantext") + .classList.remove("hiddenAutoban"), + 300 * (mapDivs.length + 1) + ) + }, 850) + } else { + const mapDivs = document.querySelectorAll(".bannedMap, .map") + for (const mapDiv of mapDivs) { + mapDiv.classList.add("nodisplay") + mapDiv.classList.add("hidden") + } + document + .getElementById("autobantext") + .classList.add("nodisplay", "hiddenAutoban") + } + }) } }) From 16f3d16941e7749645a32c3123158eb4fb2e6bb5 Mon Sep 17 00:00:00 2001 From: TateB Date: Thu, 19 Aug 2021 12:47:47 +1000 Subject: [PATCH 3/5] removed placeholder text on scores_break --- public/obs/scores_break.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/obs/scores_break.html b/public/obs/scores_break.html index 69978df..35e1572 100644 --- a/public/obs/scores_break.html +++ b/public/obs/scores_break.html @@ -82,16 +82,16 @@
-

<%= teams[0].toUpperCase() %>

-

<%= teams[1].toUpperCase() %>

+

Team A

+

Team B

- - + +
From 0445ce281c2240ccfea56653362d8ad6e8de71d7 Mon Sep 17 00:00:00 2001 From: TateB Date: Thu, 19 Aug 2021 13:28:05 +1000 Subject: [PATCH 4/5] added scores_break animation + fixed mapbans animation --- public/obs/mapbans.html | 6 +-- public/obs/scores_break.html | 71 +++++++++++++++++++++++++++++++++--- 2 files changed, 68 insertions(+), 9 deletions(-) diff --git a/public/obs/mapbans.html b/public/obs/mapbans.html index d940775..fd7cc67 100644 --- a/public/obs/mapbans.html +++ b/public/obs/mapbans.html @@ -204,7 +204,7 @@ .bannedMap, .map, #autobantext { - transition: all 0.3s ease-in-out; + transition: all 0.3s ease-out; } * { @@ -397,7 +397,7 @@ mapDiv.classList.remove("nodisplay") setTimeout( () => mapDiv.classList.remove("hidden"), - 300 * (inx + 1) + 200 * (inx + 1) ) } setTimeout( @@ -405,7 +405,7 @@ document .getElementById("autobantext") .classList.remove("hiddenAutoban"), - 300 * (mapDivs.length + 1) + 200 * (mapDivs.length + 1) ) }, 850) } else { diff --git a/public/obs/scores_break.html b/public/obs/scores_break.html index 35e1572..2193cf5 100644 --- a/public/obs/scores_break.html +++ b/public/obs/scores_break.html @@ -56,6 +56,24 @@ background-color: rgb(51, 51, 51); border-radius: 15px; } + + #leftScore, + #leftTeam, + #leftLogo, + #rightScore, + #rightTeam, + #rightLogo { + transition: all 0.35s ease-out; + } + + .nodisplay { + display: none; + } + + .hidden { + opacity: 0; + transform: translateX(-150px); + } @@ -76,22 +94,63 @@ document.getElementById("rightLogo").src = finalTeam[1].iconLink document.getElementById("leftLogo").src = finalTeam[0].iconLink }) + + window.addEventListener("load", (event) => { + const allTeams = document.querySelectorAll(".leftTeamEl, .rightTeamEl") + const leftTeamEls = document.querySelectorAll(".leftTeamEl") + const rightTeamEls = document.querySelectorAll(".rightTeamEl") + + if (document.visibilityState !== "visible") { + allTeams.forEach((el) => el.classList.add("hidden", "nodisplay")) + } + + window.addEventListener("obsSourceActiveChanged", (evt) => { + console.log("source changed", evt.detail) + if (evt.detail.active) { + setTimeout(() => { + console.log("transition finished, queueing changes") + console.log( + allTeams, + leftTeamEls, + document.querySelectorAll(".leftTeamEl") + ) + allTeams.forEach((el) => { + console.log("el got", el) + el.classList.remove("nodisplay") + }) + setTimeout( + () => + leftTeamEls.forEach((el) => el.classList.remove("hidden")), + 200 + ) + setTimeout( + () => + rightTeamEls.forEach((el) => el.classList.remove("hidden")), + 550 + ) + }, 950) + } else { + document + allTeams.forEach((el) => el.classList.add("hidden", "nodisplay")) + } + }) + })
-

Team A

-

Team B

+

Team A

+

Team B

-

-

+

+

- - + +
From 9f92ff53a6f185108c8f09c831cb346ef2becab4 Mon Sep 17 00:00:00 2001 From: TateB Date: Thu, 19 Aug 2021 13:35:24 +1000 Subject: [PATCH 5/5] nightbot auth check added --- src/apis/nightbot.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/apis/nightbot.js b/src/apis/nightbot.js index 2c4af05..b96badc 100644 --- a/src/apis/nightbot.js +++ b/src/apis/nightbot.js @@ -166,11 +166,14 @@ const setCommand = (command) => { var dbVars var userId var settingId + var settings return Promise.all(requiredVars[command].map((x) => getSpecifics(x))) .then((dbVarsRec) => (dbVars = dbVarsRec)) .then(() => getSpecifics("nbSession")) - .then((sess) => (userId = sess.session.accessToken)) + .then((sess) => (settings = sess)) + .then(() => isAuthed(settings)) + .then(() => (userId = settings.session.accessToken)) .then(() => getSpecifics("commands")) .then((nbSet) => nbSet.find((x) => x.name === command)) .then((foundCommand) => (settingId = foundCommand.id))