Fix: Round ratings to 1 decimal

pull/16/head
Juraj Nyíri 4 years ago
parent 31926ddf7f
commit bfea31c9a7

@ -20252,6 +20252,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.detailElem.children[0].innerHTML = escapeHtml(data.title); this.detailElem.children[0].innerHTML = escapeHtml(data.title);
this.detailElem.children[1].innerHTML = escapeHtml(data.year); this.detailElem.children[1].innerHTML = escapeHtml(data.year);
this.detailElem.children[1].dataset.year = escapeHtml(data.year); this.detailElem.children[1].dataset.year = escapeHtml(data.year);
console.log(data.rating);
this.detailElem.children[2].innerHTML = `${(data.duration !== undefined this.detailElem.children[2].innerHTML = `${(data.duration !== undefined
? `<span class='minutesDetail'>${Math.round(parseInt(escapeHtml(data.duration), 10) / 60 / 1000)} min</span>` ? `<span class='minutesDetail'>${Math.round(parseInt(escapeHtml(data.duration), 10) / 60 / 1000)} min</span>`
: '') + : '') +
@ -20259,7 +20260,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
? `<span class='contentRatingDetail'>${escapeHtml(data.contentRating)}</span>` ? `<span class='contentRatingDetail'>${escapeHtml(data.contentRating)}</span>`
: '') + : '') +
(data.rating !== undefined (data.rating !== undefined
? `<span class='ratingDetail'>${data.rating < 5 ? '&#128465;' : '&#11088;'}&nbsp;${escapeHtml(data.rating)}</span>` ? `<span class='ratingDetail'>${data.rating < 5 ? '&#128465;' : '&#11088;'}&nbsp;${Math.round(parseFloat(escapeHtml(data.rating)) * 10) / 10}</span>`
: '')}<div class='clear'></div>`; : '')}<div class='clear'></div>`;
this.detailElem.children[3].innerHTML = escapeHtml(data.summary); this.detailElem.children[3].innerHTML = escapeHtml(data.summary);
/* todo temp disabled /* todo temp disabled

@ -616,6 +616,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.detailElem.children[0].innerHTML = escapeHtml(data.title); this.detailElem.children[0].innerHTML = escapeHtml(data.title);
this.detailElem.children[1].innerHTML = escapeHtml(data.year); this.detailElem.children[1].innerHTML = escapeHtml(data.year);
(this.detailElem.children[1] as HTMLElement).dataset.year = escapeHtml(data.year); (this.detailElem.children[1] as HTMLElement).dataset.year = escapeHtml(data.year);
console.log(data.rating);
this.detailElem.children[2].innerHTML = `${(data.duration !== undefined this.detailElem.children[2].innerHTML = `${(data.duration !== undefined
? `<span class='minutesDetail'>${Math.round( ? `<span class='minutesDetail'>${Math.round(
parseInt(escapeHtml(data.duration), 10) / 60 / 1000 parseInt(escapeHtml(data.duration), 10) / 60 / 1000
@ -625,9 +626,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
? `<span class='contentRatingDetail'>${escapeHtml(data.contentRating)}</span>` ? `<span class='contentRatingDetail'>${escapeHtml(data.contentRating)}</span>`
: '') + : '') +
(data.rating !== undefined (data.rating !== undefined
? `<span class='ratingDetail'>${data.rating < 5 ? '&#128465;' : '&#11088;'}&nbsp;${escapeHtml( ? `<span class='ratingDetail'>${data.rating < 5 ? '&#128465;' : '&#11088;'}&nbsp;${Math.round(
data.rating parseFloat(escapeHtml(data.rating)) * 10
)}</span>` ) / 10}</span>`
: '')}<div class='clear'></div>`; : '')}<div class='clear'></div>`;
this.detailElem.children[3].innerHTML = escapeHtml(data.summary); this.detailElem.children[3].innerHTML = escapeHtml(data.summary);
/* todo temp disabled /* todo temp disabled

Loading…
Cancel
Save