mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #1736 from Camc314/migrate-to-ES6-54
Migration of xmltv and schedulesdirect to ES6 modules
This commit is contained in:
commit
b6befd29a8
3 changed files with 455 additions and 446 deletions
|
@ -167,6 +167,8 @@
|
||||||
"src/components/syncPlay/playbackPermissionManager.js",
|
"src/components/syncPlay/playbackPermissionManager.js",
|
||||||
"src/components/syncPlay/syncPlayManager.js",
|
"src/components/syncPlay/syncPlayManager.js",
|
||||||
"src/components/syncPlay/timeSyncManager.js",
|
"src/components/syncPlay/timeSyncManager.js",
|
||||||
|
"src/components/tvproviders/schedulesdirect.js",
|
||||||
|
"src/components/tvproviders/xmltv.js",
|
||||||
"src/components/toast/toast.js",
|
"src/components/toast/toast.js",
|
||||||
"src/components/upnextdialog/upnextdialog.js",
|
"src/components/upnextdialog/upnextdialog.js",
|
||||||
"src/components/viewContainer.js",
|
"src/components/viewContainer.js",
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emby-input', 'emby-select', 'emby-button', 'flexStyles'], function ($, loading, globalize) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-input';
|
||||||
|
import 'listViewStyle';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
import 'emby-select';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'flexStyles';
|
||||||
|
|
||||||
loading = loading.default || loading;
|
export default function (page, providerId, options) {
|
||||||
|
|
||||||
return function (page, providerId, options) {
|
|
||||||
function reload() {
|
function reload() {
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
||||||
var info = config.ListingProviders.filter(function (i) {
|
const info = config.ListingProviders.filter(function (i) {
|
||||||
return i.Id === providerId;
|
return i.Id === providerId;
|
||||||
})[0] || {};
|
})[0] || {};
|
||||||
listingsId = info.ListingsId;
|
listingsId = info.ListingsId;
|
||||||
|
@ -37,12 +43,12 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
|
||||||
|
|
||||||
function setCountry(info) {
|
function setCountry(info) {
|
||||||
ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).then(function (result) {
|
ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).then(function (result) {
|
||||||
var i;
|
let i;
|
||||||
var length;
|
let length;
|
||||||
var countryList = [];
|
const countryList = [];
|
||||||
|
|
||||||
for (var region in result) {
|
for (const region in result) {
|
||||||
var countries = result[region];
|
const countries = result[region];
|
||||||
|
|
||||||
if (countries.length && region !== 'ZZZ') {
|
if (countries.length && region !== 'ZZZ') {
|
||||||
for (i = 0, length = countries.length; i < length; i++) {
|
for (i = 0, length = countries.length; i < length; i++) {
|
||||||
|
@ -82,20 +88,20 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
|
||||||
return Promise.resolve('');
|
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 crypto.subtle.digest('SHA-256', buffer).then(function (hash) {
|
||||||
return hex(hash);
|
return hex(hash);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function hex(buffer) {
|
function hex(buffer) {
|
||||||
var hexCodes = [];
|
const hexCodes = [];
|
||||||
var view = new DataView(buffer);
|
const view = new DataView(buffer);
|
||||||
|
|
||||||
for (var i = 0; i < view.byteLength; i += 4) {
|
for (let i = 0; i < view.byteLength; i += 4) {
|
||||||
var value = view.getUint32(i);
|
const value = view.getUint32(i);
|
||||||
var stringValue = value.toString(16);
|
const stringValue = value.toString(16);
|
||||||
var paddedValue = ('00000000' + stringValue).slice(-'00000000'.length);
|
const paddedValue = ('00000000' + stringValue).slice(-'00000000'.length);
|
||||||
hexCodes.push(paddedValue);
|
hexCodes.push(paddedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,14 +111,14 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
|
||||||
function submitLoginForm() {
|
function submitLoginForm() {
|
||||||
loading.show();
|
loading.show();
|
||||||
sha256(page.querySelector('.txtPass').value).then(function (passwordHash) {
|
sha256(page.querySelector('.txtPass').value).then(function (passwordHash) {
|
||||||
var info = {
|
const info = {
|
||||||
Type: 'SchedulesDirect',
|
Type: 'SchedulesDirect',
|
||||||
Username: page.querySelector('.txtUser').value,
|
Username: page.querySelector('.txtUser').value,
|
||||||
EnableAllTuners: true,
|
EnableAllTuners: true,
|
||||||
Password: passwordHash,
|
Password: passwordHash,
|
||||||
Pw: page.querySelector('.txtPass').value
|
Pw: page.querySelector('.txtPass').value
|
||||||
};
|
};
|
||||||
var id = providerId;
|
const id = providerId;
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
info.Id = id;
|
info.Id = id;
|
||||||
|
@ -139,7 +145,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitListingsForm() {
|
function submitListingsForm() {
|
||||||
var selectedListingsId = $('#selectListing', page).val();
|
const selectedListingsId = $('#selectListing', page).val();
|
||||||
|
|
||||||
if (!selectedListingsId) {
|
if (!selectedListingsId) {
|
||||||
return void Dashboard.alert({
|
return void Dashboard.alert({
|
||||||
|
@ -148,9 +154,9 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
|
||||||
}
|
}
|
||||||
|
|
||||||
loading.show();
|
loading.show();
|
||||||
var id = providerId;
|
const id = providerId;
|
||||||
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
||||||
var info = config.ListingProviders.filter(function (i) {
|
const info = config.ListingProviders.filter(function (i) {
|
||||||
return i.Id === id;
|
return i.Id === id;
|
||||||
})[0];
|
})[0];
|
||||||
info.ZipCode = page.querySelector('.txtZipCode').value;
|
info.ZipCode = page.querySelector('.txtZipCode').value;
|
||||||
|
@ -233,14 +239,14 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshTunerDevices(page, providerInfo, devices) {
|
function refreshTunerDevices(page, providerInfo, devices) {
|
||||||
var html = '';
|
let html = '';
|
||||||
|
|
||||||
for (var i = 0, length = devices.length; i < length; i++) {
|
for (let i = 0, length = devices.length; i < length; i++) {
|
||||||
var device = devices[i];
|
const device = devices[i];
|
||||||
html += '<div class="listItem">';
|
html += '<div class="listItem">';
|
||||||
var enabledTuners = providerInfo.EnabledTuners || [];
|
const enabledTuners = providerInfo.EnabledTuners || [];
|
||||||
var isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
|
const isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
|
||||||
var checkedAttribute = isChecked ? ' checked' : '';
|
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 += '<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="listItemBody two-line">';
|
||||||
html += '<div class="listItemBodyText">';
|
html += '<div class="listItemBodyText">';
|
||||||
|
@ -256,8 +262,8 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
|
||||||
page.querySelector('.tunerList').innerHTML = html;
|
page.querySelector('.tunerList').innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
var listingsId;
|
let listingsId;
|
||||||
var self = this;
|
const self = this;
|
||||||
|
|
||||||
self.submit = function () {
|
self.submit = function () {
|
||||||
page.querySelector('.btnSubmitListingsContainer').click();
|
page.querySelector('.btnSubmitListingsContainer').click();
|
||||||
|
@ -268,10 +274,10 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
|
||||||
|
|
||||||
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
|
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
|
||||||
// FIXME: rename this option to clarify logic
|
// FIXME: rename this option to clarify logic
|
||||||
var hideCancelButton = options.showCancelButton === false;
|
const hideCancelButton = options.showCancelButton === false;
|
||||||
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
|
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
|
||||||
|
|
||||||
var hideSubmitButton = options.showSubmitButton === false;
|
const hideSubmitButton = options.showSubmitButton === false;
|
||||||
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
|
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
|
||||||
|
|
||||||
$('.formLogin', page).on('submit', function () {
|
$('.formLogin', page).on('submit', function () {
|
||||||
|
@ -295,5 +301,4 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
|
||||||
$('.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>'));
|
$('.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();
|
reload();
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listViewStyle', 'paper-icon-button-light'], function ($, loading, globalize) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-input';
|
||||||
|
import 'listViewStyle';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
|
||||||
loading = loading.default || loading;
|
export default function (page, providerId, options) {
|
||||||
|
|
||||||
return function (page, providerId, options) {
|
|
||||||
function getListingProvider(config, id) {
|
function getListingProvider(config, id) {
|
||||||
if (config && id) {
|
if (config && id) {
|
||||||
var result = config.ListingProviders.filter(function (provider) {
|
const result = config.ListingProviders.filter(function (provider) {
|
||||||
return provider.Id === id;
|
return provider.Id === id;
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
|
@ -46,7 +49,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listVi
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCategories(txtInput) {
|
function getCategories(txtInput) {
|
||||||
var value = txtInput.value;
|
const value = txtInput.value;
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
return value.split('|');
|
return value.split('|');
|
||||||
|
@ -57,9 +60,9 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listVi
|
||||||
|
|
||||||
function submitListingsForm() {
|
function submitListingsForm() {
|
||||||
loading.show();
|
loading.show();
|
||||||
var id = providerId;
|
const id = providerId;
|
||||||
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
||||||
var info = config.ListingProviders.filter(function (provider) {
|
const info = config.ListingProviders.filter(function (provider) {
|
||||||
return provider.Id === id;
|
return provider.Id === id;
|
||||||
})[0] || {};
|
})[0] || {};
|
||||||
info.Type = 'xmltv';
|
info.Type = 'xmltv';
|
||||||
|
@ -114,14 +117,14 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listVi
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshTunerDevices(page, providerInfo, devices) {
|
function refreshTunerDevices(page, providerInfo, devices) {
|
||||||
var html = '';
|
let html = '';
|
||||||
|
|
||||||
for (var i = 0, length = devices.length; i < length; i++) {
|
for (let i = 0, length = devices.length; i < length; i++) {
|
||||||
var device = devices[i];
|
const device = devices[i];
|
||||||
html += '<div class="listItem">';
|
html += '<div class="listItem">';
|
||||||
var enabledTuners = providerInfo.EnabledTuners || [];
|
const enabledTuners = providerInfo.EnabledTuners || [];
|
||||||
var isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
|
const isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
|
||||||
var checkedAttribute = isChecked ? ' checked' : '';
|
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 += '<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="listItemBody two-line">';
|
||||||
html += '<div class="listItemBodyText">';
|
html += '<div class="listItemBodyText">';
|
||||||
|
@ -138,15 +141,15 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listVi
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSelectPathClick(e) {
|
function onSelectPathClick(e) {
|
||||||
var page = $(e.target).parents('.xmltvForm')[0];
|
const page = $(e.target).parents('.xmltvForm')[0];
|
||||||
|
|
||||||
require(['directorybrowser'], function (directoryBrowser) {
|
import('directorybrowser').then(({default: directoryBrowser}) => {
|
||||||
var picker = new directoryBrowser.default();
|
const picker = new directoryBrowser();
|
||||||
picker.show({
|
picker.show({
|
||||||
includeFiles: true,
|
includeFiles: true,
|
||||||
callback: function (path) {
|
callback: function (path) {
|
||||||
if (path) {
|
if (path) {
|
||||||
var txtPath = page.querySelector('.txtPath');
|
const txtPath = page.querySelector('.txtPath');
|
||||||
txtPath.value = path;
|
txtPath.value = path;
|
||||||
txtPath.focus();
|
txtPath.focus();
|
||||||
}
|
}
|
||||||
|
@ -156,7 +159,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listVi
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
const self = this;
|
||||||
|
|
||||||
self.submit = function () {
|
self.submit = function () {
|
||||||
page.querySelector('.btnSubmitListings').click();
|
page.querySelector('.btnSubmitListings').click();
|
||||||
|
@ -167,10 +170,10 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listVi
|
||||||
|
|
||||||
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
|
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
|
||||||
// FIXME: rename this option to clarify logic
|
// FIXME: rename this option to clarify logic
|
||||||
var hideCancelButton = options.showCancelButton === false;
|
const hideCancelButton = options.showCancelButton === false;
|
||||||
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
|
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
|
||||||
|
|
||||||
var hideSubmitButton = options.showSubmitButton === false;
|
const hideSubmitButton = options.showSubmitButton === false;
|
||||||
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
|
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
|
||||||
|
|
||||||
$('form', page).on('submit', function () {
|
$('form', page).on('submit', function () {
|
||||||
|
@ -187,5 +190,4 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listVi
|
||||||
});
|
});
|
||||||
reload();
|
reload();
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue