mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
replace for with for...of
This commit is contained in:
parent
fbb98bdd2f
commit
1b69c89b31
2 changed files with 38 additions and 42 deletions
|
@ -12,10 +12,10 @@ function saveCategories(context, options) {
|
||||||
const categories = [];
|
const categories = [];
|
||||||
|
|
||||||
const chkCategorys = context.querySelectorAll('.chkCategory');
|
const chkCategorys = context.querySelectorAll('.chkCategory');
|
||||||
for (let i = 0, length = chkCategorys.length; i < length; i++) {
|
for (const chkCategory of chkCategorys) {
|
||||||
const type = chkCategorys[i].getAttribute('data-type');
|
const type = chkCategory.getAttribute('data-type');
|
||||||
|
|
||||||
if (chkCategorys[i].checked) {
|
if (chkCategory.checked) {
|
||||||
categories.push(type);
|
categories.push(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,47 +33,43 @@ function loadCategories(context, options) {
|
||||||
const selectedCategories = options.categories || [];
|
const selectedCategories = options.categories || [];
|
||||||
|
|
||||||
const chkCategorys = context.querySelectorAll('.chkCategory');
|
const chkCategorys = context.querySelectorAll('.chkCategory');
|
||||||
for (let i = 0, length = chkCategorys.length; i < length; i++) {
|
for (const chkCategory of chkCategorys) {
|
||||||
const type = chkCategorys[i].getAttribute('data-type');
|
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) {
|
function save(context) {
|
||||||
let i;
|
|
||||||
let length;
|
|
||||||
|
|
||||||
const chkIndicators = context.querySelectorAll('.chkIndicator');
|
const chkIndicators = context.querySelectorAll('.chkIndicator');
|
||||||
for (i = 0, length = chkIndicators.length; i < length; i++) {
|
|
||||||
const type = chkIndicators[i].getAttribute('data-type');
|
for (const chkIndicator of chkIndicators) {
|
||||||
userSettings.set('guide-indicator-' + type, chkIndicators[i].checked);
|
const type = chkIndicator.getAttribute('data-type');
|
||||||
|
userSettings.set('guide-indicator-' + type, chkIndicator.checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
userSettings.set('guide-colorcodedbackgrounds', context.querySelector('.chkColorCodedBackgrounds').checked);
|
userSettings.set('guide-colorcodedbackgrounds', context.querySelector('.chkColorCodedBackgrounds').checked);
|
||||||
userSettings.set('livetv-favoritechannelsattop', context.querySelector('.chkFavoriteChannelsAtTop').checked);
|
userSettings.set('livetv-favoritechannelsattop', context.querySelector('.chkFavoriteChannelsAtTop').checked);
|
||||||
|
|
||||||
const sortBys = context.querySelectorAll('.chkSortOrder');
|
const sortBys = context.querySelectorAll('.chkSortOrder');
|
||||||
for (i = 0, length = sortBys.length; i < length; i++) {
|
for (const sortBy of sortBys) {
|
||||||
if (sortBys[i].checked) {
|
if (sortBy.checked) {
|
||||||
userSettings.set('livetv-channelorder', sortBys[i].value);
|
userSettings.set('livetv-channelorder', sortBy.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function load(context) {
|
function load(context) {
|
||||||
let i;
|
|
||||||
let length;
|
|
||||||
|
|
||||||
const chkIndicators = context.querySelectorAll('.chkIndicator');
|
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') {
|
for (const chkIndicator of chkIndicators) {
|
||||||
chkIndicators[i].checked = userSettings.get('guide-indicator-' + type) !== 'false';
|
const type = chkIndicator.getAttribute('data-type');
|
||||||
|
|
||||||
|
if (chkIndicator.getAttribute('data-default') === 'true') {
|
||||||
|
chkIndicator.checked = userSettings.get('guide-indicator-' + type) !== 'false';
|
||||||
} else {
|
} 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 sortByValue = userSettings.get('livetv-channelorder') || 'Number';
|
||||||
|
|
||||||
const sortBys = context.querySelectorAll('.chkSortOrder');
|
const sortBys = context.querySelectorAll('.chkSortOrder');
|
||||||
for (i = 0, length = sortBys.length; i < length; i++) {
|
for (const sortBy of sortBys) {
|
||||||
sortBys[i].checked = sortBys[i].value === sortByValue;
|
sortBy.checked = sortBy.value === sortByValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +88,7 @@ function showEditor(options) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
let settingsChanged = false;
|
let settingsChanged = false;
|
||||||
|
|
||||||
import('text!./guide-settings.template.html').then(({default: template}) => {
|
import('text!./guide-settings.template.html').then(({ default: template }) => {
|
||||||
const dialogOptions = {
|
const dialogOptions = {
|
||||||
removeOnClose: true,
|
removeOnClose: true,
|
||||||
scrollY: false
|
scrollY: false
|
||||||
|
|
|
@ -88,8 +88,8 @@ function updateProgramCellsOnScroll(programGrid, programCells) {
|
||||||
|
|
||||||
const scrollPct = scrollLeft ? (scrollLeft / programGrid.scrollWidth) * 100 : 0;
|
const scrollPct = scrollLeft ? (scrollLeft / programGrid.scrollWidth) * 100 : 0;
|
||||||
|
|
||||||
for (let i = 0, length = programCells.length; i < length; i++) {
|
for (const programCell of programCells) {
|
||||||
updateProgramCellOnScroll(programCells[i], scrollPct);
|
updateProgramCellOnScroll(programCell, scrollPct);
|
||||||
}
|
}
|
||||||
|
|
||||||
isUpdatingProgramCellScroll = false;
|
isUpdatingProgramCellScroll = false;
|
||||||
|
@ -588,8 +588,7 @@ function Guide(options) {
|
||||||
function renderChannelHeaders(context, channels, apiClient) {
|
function renderChannelHeaders(context, channels, apiClient) {
|
||||||
let html = '';
|
let html = '';
|
||||||
|
|
||||||
for (let i = 0, length = channels.length; i < length; i++) {
|
for (const channel of channels) {
|
||||||
const channel = channels[i];
|
|
||||||
const hasChannelImage = channel.ImageTags.Primary;
|
const hasChannelImage = channel.ImageTags.Primary;
|
||||||
|
|
||||||
let cssClass = 'guide-channelHeaderCell itemAction';
|
let cssClass = 'guide-channelHeaderCell itemAction';
|
||||||
|
@ -641,8 +640,8 @@ function Guide(options) {
|
||||||
|
|
||||||
const html = [];
|
const html = [];
|
||||||
|
|
||||||
for (let i = 0, length = channels.length; i < length; i++) {
|
for (const channel of channels) {
|
||||||
html.push(getChannelProgramsHtml(context, date, channels[i], programs, options, listInfo));
|
html.push(getChannelProgramsHtml(context, date, channel, programs, options, listInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
programGrid.innerHTML = html.join('');
|
programGrid.innerHTML = html.join('');
|
||||||
|
@ -888,11 +887,10 @@ function Guide(options) {
|
||||||
// add 1 to avoid programs that are out of view to the left
|
// add 1 to avoid programs that are out of view to the left
|
||||||
const currentScrollXPct = scrollXPct + 1;
|
const currentScrollXPct = scrollXPct + 1;
|
||||||
|
|
||||||
for (let i = 0, length = elements.length; i < length; i++) {
|
for (const elem of elements) {
|
||||||
const elem = elements[i];
|
|
||||||
|
|
||||||
let left = (elem.style.left || '').replace('%', '');
|
let left = (elem.style.left || '').replace('%', '');
|
||||||
left = left ? parseFloat(left) : 0;
|
left = left ? parseFloat(left) : 0;
|
||||||
|
|
||||||
let width = (elem.style.width || '').replace('%', '');
|
let width = (elem.style.width || '').replace('%', '');
|
||||||
width = width ? parseFloat(width) : 0;
|
width = width ? parseFloat(width) : 0;
|
||||||
|
|
||||||
|
@ -1047,9 +1045,7 @@ function Guide(options) {
|
||||||
|
|
||||||
// find guide cells by program id, ensure timer icon
|
// find guide cells by program id, ensure timer icon
|
||||||
const cells = options.element.querySelectorAll('.programCell[data-id="' + programId + '"]');
|
const cells = options.element.querySelectorAll('.programCell[data-id="' + programId + '"]');
|
||||||
for (let i = 0, length = cells.length; i < length; i++) {
|
for (const cell of cells) {
|
||||||
const cell = cells[i];
|
|
||||||
|
|
||||||
const icon = cell.querySelector('.timerIcon');
|
const icon = cell.querySelector('.timerIcon');
|
||||||
if (!icon) {
|
if (!icon) {
|
||||||
cell.querySelector('.guideProgramName').insertAdjacentHTML('beforeend', '<span class="timerIcon material-icons programIcon fiber_manual_record"></span>');
|
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;
|
const id = data.Id;
|
||||||
// find guide cells by timer id, remove timer icon
|
// find guide cells by timer id, remove timer icon
|
||||||
const cells = options.element.querySelectorAll('.programCell[data-timerid="' + id + '"]');
|
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');
|
const icon = cell.querySelector('.timerIcon');
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
icon.parentNode.removeChild(icon);
|
icon.parentNode.removeChild(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
cell.removeAttribute('data-timerid');
|
cell.removeAttribute('data-timerid');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1082,12 +1080,14 @@ function Guide(options) {
|
||||||
const id = data.Id;
|
const id = data.Id;
|
||||||
// find guide cells by timer id, remove timer icon
|
// find guide cells by timer id, remove timer icon
|
||||||
const cells = options.element.querySelectorAll('.programCell[data-seriestimerid="' + id + '"]');
|
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');
|
const icon = cell.querySelector('.seriesTimerIcon');
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
icon.parentNode.removeChild(icon);
|
icon.parentNode.removeChild(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
cell.removeAttribute('data-seriestimerid');
|
cell.removeAttribute('data-seriestimerid');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue