1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Migrated livetvtuner.js file to es6 module

This commit is contained in:
matjaz321 2020-07-29 22:18:34 +02:00
parent ade438f53d
commit c5e6b5d95d
2 changed files with 217 additions and 220 deletions

View file

@ -193,6 +193,7 @@
"src/controllers/playback/queue/index.js", "src/controllers/playback/queue/index.js",
"src/controllers/playback/video/index.js", "src/controllers/playback/video/index.js",
"src/controllers/searchpage.js", "src/controllers/searchpage.js",
"src/controllers/livetvtuner.js",
"src/controllers/shows/episodes.js", "src/controllers/shows/episodes.js",
"src/controllers/shows/tvgenres.js", "src/controllers/shows/tvgenres.js",
"src/controllers/shows/tvlatest.js", "src/controllers/shows/tvlatest.js",

View file

@ -1,5 +1,10 @@
define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button', 'emby-checkbox', 'emby-select'], function (globalize, loading, libraryMenu, dom) { import globalize from 'globalize';
'use strict'; import loading from 'loading';
import dom from 'dom';
import 'emby-input';
import 'emby-button';
import 'emby-checkbox';
import 'emby-select';
function isM3uVariant(type) { function isM3uVariant(type) {
return ['nextpvr'].indexOf(type || '') !== -1; return ['nextpvr'].indexOf(type || '') !== -1;
@ -7,8 +12,8 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
function fillTypes(view, currentId) { function fillTypes(view, currentId) {
return ApiClient.getJSON(ApiClient.getUrl('LiveTv/TunerHosts/Types')).then(function (types) { return ApiClient.getJSON(ApiClient.getUrl('LiveTv/TunerHosts/Types')).then(function (types) {
var selectType = view.querySelector('.selectType'); const selectType = view.querySelector('.selectType');
var html = ''; let html = '';
html += types.map(function (tuner) { html += types.map(function (tuner) {
return '<option value="' + tuner.Id + '">' + tuner.Name + '</option>'; return '<option value="' + tuner.Id + '">' + tuner.Name + '</option>';
}).join(''); }).join('');
@ -29,7 +34,7 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
if (providerId) { if (providerId) {
ApiClient.getNamedConfiguration('livetv').then(function (config) { ApiClient.getNamedConfiguration('livetv').then(function (config) {
var info = config.TunerHosts.filter(function (i) { const info = config.TunerHosts.filter(function (i) {
return i.Id === providerId; return i.Id === providerId;
})[0]; })[0];
fillTunerHostInfo(view, info); fillTunerHostInfo(view, info);
@ -38,8 +43,8 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
} }
function fillTunerHostInfo(view, info) { function fillTunerHostInfo(view, info) {
var selectType = view.querySelector('.selectType'); const selectType = view.querySelector('.selectType');
var type = info.Type || ''; let type = info.Type || '';
if (info.Source && isM3uVariant(info.Source)) { if (info.Source && isM3uVariant(info.Source)) {
type = info.Source; type = info.Source;
@ -59,7 +64,7 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
function submitForm(page) { function submitForm(page) {
loading.show(); loading.show();
var info = { const info = {
Type: page.querySelector('.selectType').value, Type: page.querySelector('.selectType').value,
Url: page.querySelector('.txtDevicePath').value || null, Url: page.querySelector('.txtDevicePath').value || null,
UserAgent: page.querySelector('.txtUserAgent').value || null, UserAgent: page.querySelector('.txtUserAgent').value || null,
@ -76,10 +81,8 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
info.Type = 'm3u'; info.Type = 'm3u';
} }
var id = getParameterByName('id'); if (getParameterByName('id')) {
info.Id = getParameterByName('id');
if (id) {
info.Id = id;
} }
ApiClient.ajax({ ApiClient.ajax({
@ -98,14 +101,8 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
}); });
} }
function getRequirePromise(deps) {
return new Promise(function (resolve, reject) {
require(deps, resolve);
});
}
function getDetectedDevice() { function getDetectedDevice() {
return getRequirePromise(['tunerPicker']).then(function (tunerPicker) { return import('tunerPicker').then(({default: tunerPicker}) => {
return new tunerPicker().show({ return new tunerPicker().show({
serverId: ApiClient.serverId() serverId: ApiClient.serverId()
}); });
@ -113,19 +110,19 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
} }
function onTypeChange() { function onTypeChange() {
var value = this.value; const value = this.value;
var view = dom.parentWithClass(this, 'page'); const view = dom.parentWithClass(this, 'page');
var mayIncludeUnsupportedDrmChannels = 'hdhomerun' === value; const mayIncludeUnsupportedDrmChannels = 'hdhomerun' === value;
var supportsTranscoding = 'hdhomerun' === value; const supportsTranscoding = 'hdhomerun' === value;
var supportsFavorites = 'hdhomerun' === value; const supportsFavorites = 'hdhomerun' === value;
var supportsTunerIpAddress = 'hdhomerun' === value; const supportsTunerIpAddress = 'hdhomerun' === value;
var supportsTunerFileOrUrl = 'm3u' === value; const supportsTunerFileOrUrl = 'm3u' === value;
var supportsStreamLooping = 'm3u' === value; const supportsStreamLooping = 'm3u' === value;
var supportsTunerCount = 'm3u' === value; const supportsTunerCount = 'm3u' === value;
var supportsUserAgent = 'm3u' === value; const supportsUserAgent = 'm3u' === value;
var suppportsSubmit = 'other' !== value; const suppportsSubmit = 'other' !== value;
var supportsSelectablePath = supportsTunerFileOrUrl; const supportsSelectablePath = supportsTunerFileOrUrl;
var txtDevicePath = view.querySelector('.txtDevicePath'); const txtDevicePath = view.querySelector('.txtDevicePath');
if (supportsTunerIpAddress) { if (supportsTunerIpAddress) {
txtDevicePath.label(globalize.translate('LabelTunerIpAddress')); txtDevicePath.label(globalize.translate('LabelTunerIpAddress'));
@ -190,13 +187,13 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
} }
} }
return function (view, params) { export default function (view, params) {
if (!params.id) { if (!params.id) {
view.querySelector('.btnDetect').classList.remove('hide'); view.querySelector('.btnDetect').classList.remove('hide');
} }
view.addEventListener('viewshow', function () { view.addEventListener('viewshow', function () {
var currentId = params.id; const currentId = params.id;
fillTypes(view, currentId).then(function () { fillTypes(view, currentId).then(function () {
reload(view, currentId); reload(view, currentId);
}); });
@ -214,8 +211,8 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
}); });
}); });
view.querySelector('.btnSelectPath').addEventListener('click', function () { view.querySelector('.btnSelectPath').addEventListener('click', function () {
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) {
@ -229,4 +226,3 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
}); });
}); });
}; };
});