From 75251bb2309505c20dc7500117a17649d41412d8 Mon Sep 17 00:00:00 2001 From: Florrie Date: Mon, 25 Feb 2019 11:27:11 -0400 Subject: Metadata (in memory) --- players.js | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) (limited to 'players.js') diff --git a/players.js b/players.js index e9cf76e..0c980e7 100644 --- a/players.js +++ b/players.js @@ -3,46 +3,7 @@ const { spawn } = require('child_process') const FIFO = require('fifo-js') const EventEmitter = require('events') -const { commandExists, killProcess } = require('./general-util') - -function getTimeStrings({curHour, curMin, curSec, lenHour, lenMin, lenSec}) { - // Multiplication casts to numbers; addition prioritizes strings. - // Thanks, JavaScript! - const curSecTotal = (3600 * curHour) + (60 * curMin) + (1 * curSec) - const lenSecTotal = (3600 * lenHour) + (60 * lenMin) + (1 * lenSec) - const percentVal = (100 / lenSecTotal) * curSecTotal - const percentDone = ( - (Math.trunc(percentVal * 100) / 100).toFixed(2) + '%' - ) - - const leftSecTotal = lenSecTotal - curSecTotal - let leftHour = Math.floor(leftSecTotal / 3600) - let leftMin = Math.floor((leftSecTotal - leftHour * 3600) / 60) - let leftSec = Math.floor(leftSecTotal - leftHour * 3600 - leftMin * 60) - - const pad = val => val.toString().padStart(2, '0') - curMin = pad(curMin) - curSec = pad(curSec) - lenMin = pad(lenMin) - lenSec = pad(lenSec) - leftMin = pad(leftMin) - leftSec = pad(leftSec) - - // We don't want to display hour counters if the total length is less - // than an hour. - let timeDone, timeLeft, duration - if (parseInt(lenHour) > 0) { - timeDone = `${curHour}:${curMin}:${curSec}` - timeLeft = `${leftHour}:${leftMin}:${leftSec}` - duration = `${lenHour}:${lenMin}:${lenSec}` - } else { - timeDone = `${curMin}:${curSec}` - timeLeft = `${leftMin}:${leftSec}` - duration = `${lenMin}:${lenSec}` - } - - return {percentDone, timeDone, timeLeft, duration, curSecTotal, lenSecTotal} -} +const { commandExists, killProcess, getTimeStrings } = require('./general-util') class Player extends EventEmitter { constructor() { -- cgit 1.3.0-6-gf8a5