Implement suggestions

This commit is contained in:
MrTimscampi 2020-03-22 17:12:34 +01:00
parent 759b3fc106
commit feeacf12a2

View File

@ -1,8 +1,8 @@
/* eslint-disable indent */ /* eslint-disable indent */
/** /**
* Card builder module. * Module for building cards from item data.
* @module cardBuilder * @module components/cardBuilder/cardBuilder
*/ */
import datetime from 'datetime'; import datetime from 'datetime';
@ -488,19 +488,12 @@ import 'programStyles';
return null; return null;
} }
/** /** Get the URL of the Card's image.
* @typedef {Object} CardImageUrl
* @property {string} imgUrl - URL of the image.
* @property {boolean} forceName - Flag to force the name to be visible.
* @property {boolean} coverImage - Acts as a cover image.
*/
/** Get the URL of the card's image.
* @param {Object} item - Item for which to generate a card. * @param {Object} item - Item for which to generate a card.
* @param {Object} apiClient - API client object. * @param {Object} apiClient - API client object.
* @param {Object} options - Options of the card. * @param {Object} options - Options of the card.
* @param {string} shape - Shape of the desired image. * @param {string} shape - Shape of the desired image.
* @returns {CardImageUrl} Object representing the URL of the card's image. * @returns {Object} Object representing the URL of the card's image.
*/ */
function getCardImageUrl(item, apiClient, options, shape) { function getCardImageUrl(item, apiClient, options, shape) {
item = item.ProgramInfo || item; item = item.ProgramInfo || item;
@ -854,15 +847,15 @@ import 'programStyles';
* @param {Object} item - Item used to generate the footer text. * @param {Object} item - Item used to generate the footer text.
* @param {Object} apiClient - API client instance. * @param {Object} apiClient - API client instance.
* @param {Object} options - Options used to generate the footer text. * @param {Object} options - Options used to generate the footer text.
* @param {string} showTitle - Title of the show. * @param {string} showTitle - Flag to show the title in the footer.
* @param {boolean} forceName - Flag to force showing the name of the item. * @param {boolean} forceName - Flag to force showing the name of the item.
* @param {boolean} overlayText - Flag to show overlay text. * @param {boolean} overlayText - Flag to show overlay text.
* @param {CardImageUrl} imgUrl - Object representing the card's image URL. * @param {Object} imgUrl - Object representing the card's image URL.
* @param {string} footerClass - CSS class of the footer. * @param {string} footerClass - CSS classes of the footer element.
* @param {string} progressHtml - HTML markup of the progress bar. * @param {string} progressHtml - HTML markup of the progress bar element.
* @param {string} logoUrl - URL of the logo for the item. * @param {string} logoUrl - URL of the logo for the item.
* @param {boolean} isOuterFooter - Flag to mark the text as outer footer. * @param {boolean} isOuterFooter - Flag to mark the text as outer footer.
* @returns {string} HTML markup of the card's footer text. * @returns {string} HTML markup of the card's footer text element.
*/ */
function getCardFooterText(item, apiClient, options, showTitle, forceName, overlayText, imgUrl, footerClass, progressHtml, logoUrl, isOuterFooter) { function getCardFooterText(item, apiClient, options, showTitle, forceName, overlayText, imgUrl, footerClass, progressHtml, logoUrl, isOuterFooter) {
let html = ''; let html = '';
@ -1635,8 +1628,8 @@ import 'programStyles';
} }
/** /**
* Builds a set of cards and inserts it into the page. * Builds a set of cards and inserts them into the page;.
* @param {Array} items - Array of items used to build cards. * @param {Array} items - Array of items used to build the cards.
* @param {options} options - Options of the cards to build. * @param {options} options - Options of the cards to build.
*/ */
export function buildCards(items, options) { export function buildCards(items, options) {
@ -1682,9 +1675,9 @@ import 'programStyles';
/** /**
* Ensures the indicators for a card exist and creates them if they don't exist. * Ensures the indicators for a card exist and creates them if they don't exist.
* @param {HTMLDivElement} card - HTML markup of the card. * @param {HTMLDivElement} card - DOM element of the card.
* @param {HTMLDivElement} indicatorsElem - HTML markup of the indicators. * @param {HTMLDivElement} indicatorsElem - DOM element of the indicators.
* @returns {HTMLDivElement} - HTML markup of the indicators. * @returns {HTMLDivElement} - DOM element of the indicators.
*/ */
function ensureIndicators(card, indicatorsElem) { function ensureIndicators(card, indicatorsElem) {
if (indicatorsElem) { if (indicatorsElem) {
@ -1706,7 +1699,7 @@ import 'programStyles';
/** /**
* Adds user data to the card such as progress indicators and played status. * Adds user data to the card such as progress indicators and played status.
* @param {HTMLDivElement} card - HTML markup of the card. * @param {HTMLDivElement} card - DOM element of the card.
* @param {Object} userData - User data to apply to the card. * @param {Object} userData - User data to apply to the card.
*/ */
function updateUserData(card, userData) { function updateUserData(card, userData) {
@ -1828,7 +1821,7 @@ import 'programStyles';
/** /**
* Handles when a timer has been cancelled. * Handles when a timer has been cancelled.
* @param {string} timerId - ID of the cancelled timer. * @param {string} timerId - ID of the cancelled timer.
* @param {HTMLElement} itemsContainer - DOM element of the items container. * @param {HTMLElement} itemsContainer - DOM element of the itemsContainer.
*/ */
export function onTimerCancelled(timerId, itemsContainer) { export function onTimerCancelled(timerId, itemsContainer) {
const cells = itemsContainer.querySelectorAll('.card[data-timerid="' + timerId + '"]'); const cells = itemsContainer.querySelectorAll('.card[data-timerid="' + timerId + '"]');
@ -1845,11 +1838,11 @@ import 'programStyles';
/** /**
* Handles when a series timer has been cancelled. * Handles when a series timer has been cancelled.
* @param {string} canceledTimerId - ID of the cancelled timer. * @param {string} cancelledTimerId - ID of the cancelled timer.
* @param {HTMLElement} itemsContainer - DOM element of the items container. * @param {HTMLElement} itemsContainer - DOM element of the itemsContainer.
*/ */
export function onSeriesTimerCancelled(canceledTimerId, itemsContainer) { export function onSeriesTimerCancelled(cancelledTimerId, itemsContainer) {
const cells = itemsContainer.querySelectorAll('.card[data-seriestimerid="' + canceledTimerId + '"]'); const cells = itemsContainer.querySelectorAll('.card[data-seriestimerid="' + cancelledTimerId + '"]');
for (let i = 0; i < cells.length; i++) { for (let i = 0; i < cells.length; i++) {
let cell = cells[i]; let cell = cells[i];