From 40b60594532511fe6e7686c2bb2abbe849e1a978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Mon, 7 Jun 2021 00:23:28 +0200 Subject: [PATCH] Add: Progress indicator --- dist/plex-meets-homeassistant.js | 12 ++++++++++++ src/modules/style.ts | 6 ++++++ src/plex-meets-homeassistant.ts | 7 +++++++ 3 files changed, 25 insertions(+) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 4b81ec2..ac2f3bb 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19594,6 +19594,12 @@ style.textContent = css ` white-space: nowrap; overflow: hidden; } + .viewProgress { + background: #e5a00d; + height: 3px; + bottom: 0; + position: absolute; + } .toViewEpisode { position: relative; height: 28px; @@ -20774,6 +20780,12 @@ class PlexMeetsHomeAssistant extends HTMLElement { toViewElem.innerHTML = (data.leafCount - data.viewedLeafCount).toString(); interactiveArea.appendChild(toViewElem); } + if (data.viewOffset > 0 && data.duration > 0) { + const toViewElem = document.createElement('div'); + toViewElem.className = 'viewProgress'; + toViewElem.style.width = `${(data.viewOffset / data.duration) * 100}%`; + interactiveArea.appendChild(toViewElem); + } interactiveArea.className = 'interactiveArea'; if (this.playController && this.playController.isPlaySupported(data)) { interactiveArea.append(playButton); diff --git a/src/modules/style.ts b/src/modules/style.ts index 859079f..f1bad08 100644 --- a/src/modules/style.ts +++ b/src/modules/style.ts @@ -188,6 +188,12 @@ style.textContent = css` white-space: nowrap; overflow: hidden; } + .viewProgress { + background: #e5a00d; + height: 3px; + bottom: 0; + position: absolute; + } .toViewEpisode { position: relative; height: 28px; diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 869fa3c..6a656a9 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -1171,6 +1171,13 @@ class PlexMeetsHomeAssistant extends HTMLElement { interactiveArea.appendChild(toViewElem); } + if (data.viewOffset > 0 && data.duration > 0) { + const toViewElem = document.createElement('div'); + toViewElem.className = 'viewProgress'; + toViewElem.style.width = `${(data.viewOffset / data.duration) * 100}%`; + interactiveArea.appendChild(toViewElem); + } + interactiveArea.className = 'interactiveArea'; if (this.playController && this.playController.isPlaySupported(data)) { interactiveArea.append(playButton);