From 9fe6f36c1de450ddcfeaf6e8f36e10459b00b5ac Mon Sep 17 00:00:00 2001 From: jill Date: Fri, 3 Sep 2021 07:00:03 +0300 Subject: [PATCH] rename error system to popup system --- render.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/render.js b/render.js index b7c7348..7b29b8c 100644 --- a/render.js +++ b/render.js @@ -52,7 +52,7 @@ let displaytitle = ''; let displayalbum = ''; // type: 0 = error, 1 = warning, 2 = info -let errors = []; +let popups = []; function transform(old, n) { if (old.length < n.length) { @@ -142,18 +142,18 @@ function render(artist, album, title, songStart, songEnd, pauseSpot, paused) { } let i = 0; - for (let err of errors) { - err.timer -= dt; - if (err.timer < 0) { - errors.splice(i, 1); + for (let popup of popups) { + popup.timer -= dt; + if (popup.timer < 0) { + popups.splice(i, 1); } else { - let symbol = ['⚠️', '⚠️', 'ℹ'][err.type]; - let color = ['\033[41;37m', '\033[43;37m', '\033[44;37m'][err.type]; - let text = ` ${symbol} ${err.text} `; + let symbol = ['⚠️', '⚠️', 'ℹ'][popup.type]; + let color = ['\033[41;37m', '\033[43;37m', '\033[44;37m'][popup.type]; + let text = ` ${symbol} ${popup.text} `; texts.push({ value: ' '.repeat(text.length) + text, - x: -text.length * 2 + Math.round((text.length + 3) * outCirc(Math.min(err.timer, 1))), + x: -text.length * 2 + Math.round((text.length + 3) * outCirc(Math.min(popup.timer, 1))), y: 3 + i, color: color }); @@ -245,9 +245,9 @@ function render(artist, album, title, songStart, songEnd, pauseSpot, paused) { } } -function error(content) {errors.push({text: content, timer: errorDuration, type: 0});} -function warning(content) {errors.push({text: content, timer: errorDuration, type: 1});} -function info(content) {errors.push({text: content, timer: errorDuration, type: 2});} +function error(content) {popups.push({text: content, timer: errorDuration, type: 0});} +function warning(content) {popups.push({text: content, timer: errorDuration, type: 1});} +function info(content) {popups.push({text: content, timer: errorDuration, type: 2});} module.exports.render = render; module.exports.refreshrate = refreshrate;