Update var declerations

This commit is contained in:
Cameron 2020-08-03 07:40:48 +01:00
parent a7ad147aad
commit 4af9b91c3b
2 changed files with 46 additions and 46 deletions

View File

@ -13,7 +13,7 @@ export default function (page, providerId, options) {
function reload() {
loading.show();
ApiClient.getNamedConfiguration('livetv').then(function (config) {
var info = config.ListingProviders.filter(function (i) {
const info = config.ListingProviders.filter(function (i) {
return i.Id === providerId;
})[0] || {};
listingsId = info.ListingsId;
@ -43,12 +43,12 @@ export default function (page, providerId, options) {
function setCountry(info) {
ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).then(function (result) {
var i;
var length;
var countryList = [];
let i;
let length;
const countryList = [];
for (var region in result) {
var countries = result[region];
for (const region in result) {
const countries = result[region];
if (countries.length && region !== 'ZZZ') {
for (i = 0, length = countries.length; i < length; i++) {
@ -88,20 +88,20 @@ export default function (page, providerId, options) {
return Promise.resolve('');
}
var buffer = new TextEncoder('utf-8').encode(str);
const buffer = new TextEncoder('utf-8').encode(str);
return crypto.subtle.digest('SHA-256', buffer).then(function (hash) {
return hex(hash);
});
}
function hex(buffer) {
var hexCodes = [];
var view = new DataView(buffer);
const hexCodes = [];
const view = new DataView(buffer);
for (var i = 0; i < view.byteLength; i += 4) {
var value = view.getUint32(i);
var stringValue = value.toString(16);
var paddedValue = ('00000000' + stringValue).slice(-'00000000'.length);
for (let i = 0; i < view.byteLength; i += 4) {
const value = view.getUint32(i);
const stringValue = value.toString(16);
const paddedValue = ('00000000' + stringValue).slice(-'00000000'.length);
hexCodes.push(paddedValue);
}
@ -111,14 +111,14 @@ export default function (page, providerId, options) {
function submitLoginForm() {
loading.show();
sha256(page.querySelector('.txtPass').value).then(function (passwordHash) {
var info = {
const info = {
Type: 'SchedulesDirect',
Username: page.querySelector('.txtUser').value,
EnableAllTuners: true,
Password: passwordHash,
Pw: page.querySelector('.txtPass').value
};
var id = providerId;
const id = providerId;
if (id) {
info.Id = id;
@ -145,7 +145,7 @@ export default function (page, providerId, options) {
}
function submitListingsForm() {
var selectedListingsId = $('#selectListing', page).val();
const selectedListingsId = $('#selectListing', page).val();
if (!selectedListingsId) {
return void Dashboard.alert({
@ -154,9 +154,9 @@ export default function (page, providerId, options) {
}
loading.show();
var id = providerId;
const id = providerId;
ApiClient.getNamedConfiguration('livetv').then(function (config) {
var info = config.ListingProviders.filter(function (i) {
const info = config.ListingProviders.filter(function (i) {
return i.Id === id;
})[0];
info.ZipCode = page.querySelector('.txtZipCode').value;
@ -239,14 +239,14 @@ export default function (page, providerId, options) {
}
function refreshTunerDevices(page, providerInfo, devices) {
var html = '';
let html = '';
for (var i = 0, length = devices.length; i < length; i++) {
var device = devices[i];
for (let i = 0, length = devices.length; i < length; i++) {
const device = devices[i];
html += '<div class="listItem">';
var enabledTuners = providerInfo.EnabledTuners || [];
var isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
var checkedAttribute = isChecked ? ' checked' : '';
const enabledTuners = providerInfo.EnabledTuners || [];
const isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
const checkedAttribute = isChecked ? ' checked' : '';
html += '<label class="checkboxContainer listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" data-id="' + device.Id + '" class="chkTuner" ' + checkedAttribute + '/><span></span></label>';
html += '<div class="listItemBody two-line">';
html += '<div class="listItemBodyText">';
@ -262,8 +262,8 @@ export default function (page, providerId, options) {
page.querySelector('.tunerList').innerHTML = html;
}
var listingsId;
var self = this;
let listingsId;
const self = this;
self.submit = function () {
page.querySelector('.btnSubmitListingsContainer').click();
@ -274,10 +274,10 @@ export default function (page, providerId, options) {
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
// FIXME: rename this option to clarify logic
var hideCancelButton = options.showCancelButton === false;
const hideCancelButton = options.showCancelButton === false;
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
var hideSubmitButton = options.showSubmitButton === false;
const hideSubmitButton = options.showSubmitButton === false;
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
$('.formLogin', page).on('submit', function () {
@ -301,4 +301,4 @@ export default function (page, providerId, options) {
$('.createAccountHelp', page).html(globalize.translate('MessageCreateAccountAt', '<a is="emby-linkbutton" class="button-link" href="http://www.schedulesdirect.org" target="_blank">http://www.schedulesdirect.org</a>'));
reload();
};
};
}

View File

@ -9,7 +9,7 @@ import 'paper-icon-button-light';
export default function (page, providerId, options) {
function getListingProvider(config, id) {
if (config && id) {
var result = config.ListingProviders.filter(function (provider) {
const result = config.ListingProviders.filter(function (provider) {
return provider.Id === id;
})[0];
@ -49,7 +49,7 @@ export default function (page, providerId, options) {
}
function getCategories(txtInput) {
var value = txtInput.value;
const value = txtInput.value;
if (value) {
return value.split('|');
@ -60,9 +60,9 @@ export default function (page, providerId, options) {
function submitListingsForm() {
loading.show();
var id = providerId;
const id = providerId;
ApiClient.getNamedConfiguration('livetv').then(function (config) {
var info = config.ListingProviders.filter(function (provider) {
const info = config.ListingProviders.filter(function (provider) {
return provider.Id === id;
})[0] || {};
info.Type = 'xmltv';
@ -117,14 +117,14 @@ export default function (page, providerId, options) {
}
function refreshTunerDevices(page, providerInfo, devices) {
var html = '';
let html = '';
for (var i = 0, length = devices.length; i < length; i++) {
var device = devices[i];
for (let i = 0, length = devices.length; i < length; i++) {
const device = devices[i];
html += '<div class="listItem">';
var enabledTuners = providerInfo.EnabledTuners || [];
var isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
var checkedAttribute = isChecked ? ' checked' : '';
const enabledTuners = providerInfo.EnabledTuners || [];
const isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
const checkedAttribute = isChecked ? ' checked' : '';
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkTuner" data-id="' + device.Id + '" ' + checkedAttribute + '><span></span></label>';
html += '<div class="listItemBody two-line">';
html += '<div class="listItemBodyText">';
@ -141,15 +141,15 @@ export default function (page, providerId, options) {
}
function onSelectPathClick(e) {
var page = $(e.target).parents('.xmltvForm')[0];
const page = $(e.target).parents('.xmltvForm')[0];
import('directorybrowser').then(({default: directoryBrowser}) => {
var picker = new directoryBrowser();
const picker = new directoryBrowser();
picker.show({
includeFiles: true,
callback: function (path) {
if (path) {
var txtPath = page.querySelector('.txtPath');
const txtPath = page.querySelector('.txtPath');
txtPath.value = path;
txtPath.focus();
}
@ -159,7 +159,7 @@ export default function (page, providerId, options) {
});
}
var self = this;
const self = this;
self.submit = function () {
page.querySelector('.btnSubmitListings').click();
@ -170,10 +170,10 @@ export default function (page, providerId, options) {
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
// FIXME: rename this option to clarify logic
var hideCancelButton = options.showCancelButton === false;
const hideCancelButton = options.showCancelButton === false;
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
var hideSubmitButton = options.showSubmitButton === false;
const hideSubmitButton = options.showSubmitButton === false;
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
$('form', page).on('submit', function () {
@ -190,4 +190,4 @@ export default function (page, providerId, options) {
});
reload();
};
};
}