From c7b4b53dba94bb8aaeb5277a3c5b0ed0f0a40865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Mon, 3 May 2021 16:32:15 +0200 Subject: [PATCH] Add: Design for minutes, content rating and rating --- plex-meets-homeassistant.js | 42 +++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/plex-meets-homeassistant.js b/plex-meets-homeassistant.js index 4fa7dd5..bb74d7a 100644 --- a/plex-meets-homeassistant.js +++ b/plex-meets-homeassistant.js @@ -82,7 +82,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { }); } const endElem = document.createElement("div"); - endElem.style = "clear:both;"; + endElem.className = "clear"; this.content.appendChild(endElem); this.calculatePositions(); @@ -324,7 +324,24 @@ class PlexMeetsHomeAssistant extends HTMLElement { _this.detailElem.children[0].innerHTML = _this.escapeHtml(data.title); _this.detailElem.children[1].innerHTML = _this.escapeHtml(data.year); _this.detailElem.children[2].innerHTML = - _this.escapeHtml(data.duration) / 60 / 1000 + " min"; + (data.duration !== undefined + ? "" + + Math.round(_this.escapeHtml(data.duration) / 60 / 1000) + + " min" + : "") + + (data.contentRating !== undefined + ? "" + + _this.escapeHtml(data.contentRating) + + "" + : "") + + (data.rating !== undefined + ? "" + + (data.rating < 5 ? "🗑" : "⭐") + + " " + + _this.escapeHtml(data.rating) + + "" + : "") + + "
"; _this.detailElem.children[3].innerHTML = _this.escapeHtml(data.summary); _this.detailElem.style.color = "rgba(255,255,255,1)"; _this.detailElem.style["z-index"] = "4"; @@ -460,8 +477,29 @@ class PlexMeetsHomeAssistant extends HTMLElement { let style = document.createElement("style"); style.textContent = ` + .ratingDetail { + background: #ffffff24; + padding: 5px 10px; + border-radius: 5px; + } + .contentRatingDetail { + background: #ffffff24; + padding: 5px 10px; + border-radius: 5px; + margin-right: 10px; + } + .clear { + clear:both; + } + .minutesDetail { + background: #ffffff24; + padding: 5px 10px; + border-radius: 5px; + margin-right: 10px; + } .detail .metaInfo { display: block; + margin-bottom: 15px; } .detail h2 { text-overflow: ellipsis;