replace for with for...of

This commit is contained in:
Cameron 2020-08-05 09:13:46 +01:00
parent fbb98bdd2f
commit 1b69c89b31
2 changed files with 38 additions and 42 deletions

View File

@ -12,10 +12,10 @@ function saveCategories(context, options) {
const categories = [];
const chkCategorys = context.querySelectorAll('.chkCategory');
for (let i = 0, length = chkCategorys.length; i < length; i++) {
const type = chkCategorys[i].getAttribute('data-type');
for (const chkCategory of chkCategorys) {
const type = chkCategory.getAttribute('data-type');
if (chkCategorys[i].checked) {
if (chkCategory.checked) {
categories.push(type);
}
}
@ -33,47 +33,43 @@ function loadCategories(context, options) {
const selectedCategories = options.categories || [];
const chkCategorys = context.querySelectorAll('.chkCategory');
for (let i = 0, length = chkCategorys.length; i < length; i++) {
const type = chkCategorys[i].getAttribute('data-type');
for (const chkCategory of chkCategorys) {
const type = chkCategory.getAttribute('data-type');
chkCategorys[i].checked = !selectedCategories.length || selectedCategories.indexOf(type) !== -1;
chkCategory.checked = !selectedCategories.length || selectedCategories.indexOf(type) !== -1;
}
}
function save(context) {
let i;
let length;
const chkIndicators = context.querySelectorAll('.chkIndicator');
for (i = 0, length = chkIndicators.length; i < length; i++) {
const type = chkIndicators[i].getAttribute('data-type');
userSettings.set('guide-indicator-' + type, chkIndicators[i].checked);
for (const chkIndicator of chkIndicators) {
const type = chkIndicator.getAttribute('data-type');
userSettings.set('guide-indicator-' + type, chkIndicator.checked);
}
userSettings.set('guide-colorcodedbackgrounds', context.querySelector('.chkColorCodedBackgrounds').checked);
userSettings.set('livetv-favoritechannelsattop', context.querySelector('.chkFavoriteChannelsAtTop').checked);
const sortBys = context.querySelectorAll('.chkSortOrder');
for (i = 0, length = sortBys.length; i < length; i++) {
if (sortBys[i].checked) {
userSettings.set('livetv-channelorder', sortBys[i].value);
for (const sortBy of sortBys) {
if (sortBy.checked) {
userSettings.set('livetv-channelorder', sortBy.value);
break;
}
}
}
function load(context) {
let i;
let length;
const chkIndicators = context.querySelectorAll('.chkIndicator');
for (i = 0, length = chkIndicators.length; i < length; i++) {
const type = chkIndicators[i].getAttribute('data-type');
if (chkIndicators[i].getAttribute('data-default') === 'true') {
chkIndicators[i].checked = userSettings.get('guide-indicator-' + type) !== 'false';
for (const chkIndicator of chkIndicators) {
const type = chkIndicator.getAttribute('data-type');
if (chkIndicator.getAttribute('data-default') === 'true') {
chkIndicator.checked = userSettings.get('guide-indicator-' + type) !== 'false';
} else {
chkIndicators[i].checked = userSettings.get('guide-indicator-' + type) === 'true';
chkIndicator.checked = userSettings.get('guide-indicator-' + type) === 'true';
}
}
@ -83,8 +79,8 @@ function load(context) {
const sortByValue = userSettings.get('livetv-channelorder') || 'Number';
const sortBys = context.querySelectorAll('.chkSortOrder');
for (i = 0, length = sortBys.length; i < length; i++) {
sortBys[i].checked = sortBys[i].value === sortByValue;
for (const sortBy of sortBys) {
sortBy.checked = sortBy.value === sortByValue;
}
}
@ -92,7 +88,7 @@ function showEditor(options) {
return new Promise(function (resolve, reject) {
let settingsChanged = false;
import('text!./guide-settings.template.html').then(({default: template}) => {
import('text!./guide-settings.template.html').then(({ default: template }) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false

View File

@ -88,8 +88,8 @@ function updateProgramCellsOnScroll(programGrid, programCells) {
const scrollPct = scrollLeft ? (scrollLeft / programGrid.scrollWidth) * 100 : 0;
for (let i = 0, length = programCells.length; i < length; i++) {
updateProgramCellOnScroll(programCells[i], scrollPct);
for (const programCell of programCells) {
updateProgramCellOnScroll(programCell, scrollPct);
}
isUpdatingProgramCellScroll = false;
@ -588,8 +588,7 @@ function Guide(options) {
function renderChannelHeaders(context, channels, apiClient) {
let html = '';
for (let i = 0, length = channels.length; i < length; i++) {
const channel = channels[i];
for (const channel of channels) {
const hasChannelImage = channel.ImageTags.Primary;
let cssClass = 'guide-channelHeaderCell itemAction';
@ -641,8 +640,8 @@ function Guide(options) {
const html = [];
for (let i = 0, length = channels.length; i < length; i++) {
html.push(getChannelProgramsHtml(context, date, channels[i], programs, options, listInfo));
for (const channel of channels) {
html.push(getChannelProgramsHtml(context, date, channel, programs, options, listInfo));
}
programGrid.innerHTML = html.join('');
@ -888,11 +887,10 @@ function Guide(options) {
// add 1 to avoid programs that are out of view to the left
const currentScrollXPct = scrollXPct + 1;
for (let i = 0, length = elements.length; i < length; i++) {
const elem = elements[i];
for (const elem of elements) {
let left = (elem.style.left || '').replace('%', '');
left = left ? parseFloat(left) : 0;
let width = (elem.style.width || '').replace('%', '');
width = width ? parseFloat(width) : 0;
@ -1047,9 +1045,7 @@ function Guide(options) {
// find guide cells by program id, ensure timer icon
const cells = options.element.querySelectorAll('.programCell[data-id="' + programId + '"]');
for (let i = 0, length = cells.length; i < length; i++) {
const cell = cells[i];
for (const cell of cells) {
const icon = cell.querySelector('.timerIcon');
if (!icon) {
cell.querySelector('.guideProgramName').insertAdjacentHTML('beforeend', '<span class="timerIcon material-icons programIcon fiber_manual_record"></span>');
@ -1068,12 +1064,14 @@ function Guide(options) {
const id = data.Id;
// find guide cells by timer id, remove timer icon
const cells = options.element.querySelectorAll('.programCell[data-timerid="' + id + '"]');
for (let i = 0, length = cells.length; i < length; i++) {
const cell = cells[i];
for (const cell of cells) {
const icon = cell.querySelector('.timerIcon');
if (icon) {
icon.parentNode.removeChild(icon);
}
cell.removeAttribute('data-timerid');
}
}
@ -1082,12 +1080,14 @@ function Guide(options) {
const id = data.Id;
// find guide cells by timer id, remove timer icon
const cells = options.element.querySelectorAll('.programCell[data-seriestimerid="' + id + '"]');
for (let i = 0, length = cells.length; i < length; i++) {
const cell = cells[i];
for (const cell of cells) {
const icon = cell.querySelector('.seriesTimerIcon');
if (icon) {
icon.parentNode.removeChild(icon);
}
cell.removeAttribute('data-seriestimerid');
}
}