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:
parent
ade438f53d
commit
c5e6b5d95d
2 changed files with 217 additions and 220 deletions
|
@ -193,6 +193,7 @@
|
|||
"src/controllers/playback/queue/index.js",
|
||||
"src/controllers/playback/video/index.js",
|
||||
"src/controllers/searchpage.js",
|
||||
"src/controllers/livetvtuner.js",
|
||||
"src/controllers/shows/episodes.js",
|
||||
"src/controllers/shows/tvgenres.js",
|
||||
"src/controllers/shows/tvlatest.js",
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button', 'emby-checkbox', 'emby-select'], function (globalize, loading, libraryMenu, dom) {
|
||||
'use strict';
|
||||
import globalize from 'globalize';
|
||||
import loading from 'loading';
|
||||
import dom from 'dom';
|
||||
import 'emby-input';
|
||||
import 'emby-button';
|
||||
import 'emby-checkbox';
|
||||
import 'emby-select';
|
||||
|
||||
function isM3uVariant(type) {
|
||||
return ['nextpvr'].indexOf(type || '') !== -1;
|
||||
|
@ -7,8 +12,8 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
|
|||
|
||||
function fillTypes(view, currentId) {
|
||||
return ApiClient.getJSON(ApiClient.getUrl('LiveTv/TunerHosts/Types')).then(function (types) {
|
||||
var selectType = view.querySelector('.selectType');
|
||||
var html = '';
|
||||
const selectType = view.querySelector('.selectType');
|
||||
let html = '';
|
||||
html += types.map(function (tuner) {
|
||||
return '<option value="' + tuner.Id + '">' + tuner.Name + '</option>';
|
||||
}).join('');
|
||||
|
@ -29,7 +34,7 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
|
|||
|
||||
if (providerId) {
|
||||
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
||||
var info = config.TunerHosts.filter(function (i) {
|
||||
const info = config.TunerHosts.filter(function (i) {
|
||||
return i.Id === providerId;
|
||||
})[0];
|
||||
fillTunerHostInfo(view, info);
|
||||
|
@ -38,8 +43,8 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
|
|||
}
|
||||
|
||||
function fillTunerHostInfo(view, info) {
|
||||
var selectType = view.querySelector('.selectType');
|
||||
var type = info.Type || '';
|
||||
const selectType = view.querySelector('.selectType');
|
||||
let type = info.Type || '';
|
||||
|
||||
if (info.Source && isM3uVariant(info.Source)) {
|
||||
type = info.Source;
|
||||
|
@ -59,7 +64,7 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
|
|||
|
||||
function submitForm(page) {
|
||||
loading.show();
|
||||
var info = {
|
||||
const info = {
|
||||
Type: page.querySelector('.selectType').value,
|
||||
Url: page.querySelector('.txtDevicePath').value || null,
|
||||
UserAgent: page.querySelector('.txtUserAgent').value || null,
|
||||
|
@ -76,10 +81,8 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
|
|||
info.Type = 'm3u';
|
||||
}
|
||||
|
||||
var id = getParameterByName('id');
|
||||
|
||||
if (id) {
|
||||
info.Id = id;
|
||||
if (getParameterByName('id')) {
|
||||
info.Id = getParameterByName('id');
|
||||
}
|
||||
|
||||
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() {
|
||||
return getRequirePromise(['tunerPicker']).then(function (tunerPicker) {
|
||||
return import('tunerPicker').then(({default: tunerPicker}) => {
|
||||
return new tunerPicker().show({
|
||||
serverId: ApiClient.serverId()
|
||||
});
|
||||
|
@ -113,19 +110,19 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
|
|||
}
|
||||
|
||||
function onTypeChange() {
|
||||
var value = this.value;
|
||||
var view = dom.parentWithClass(this, 'page');
|
||||
var mayIncludeUnsupportedDrmChannels = 'hdhomerun' === value;
|
||||
var supportsTranscoding = 'hdhomerun' === value;
|
||||
var supportsFavorites = 'hdhomerun' === value;
|
||||
var supportsTunerIpAddress = 'hdhomerun' === value;
|
||||
var supportsTunerFileOrUrl = 'm3u' === value;
|
||||
var supportsStreamLooping = 'm3u' === value;
|
||||
var supportsTunerCount = 'm3u' === value;
|
||||
var supportsUserAgent = 'm3u' === value;
|
||||
var suppportsSubmit = 'other' !== value;
|
||||
var supportsSelectablePath = supportsTunerFileOrUrl;
|
||||
var txtDevicePath = view.querySelector('.txtDevicePath');
|
||||
const value = this.value;
|
||||
const view = dom.parentWithClass(this, 'page');
|
||||
const mayIncludeUnsupportedDrmChannels = 'hdhomerun' === value;
|
||||
const supportsTranscoding = 'hdhomerun' === value;
|
||||
const supportsFavorites = 'hdhomerun' === value;
|
||||
const supportsTunerIpAddress = 'hdhomerun' === value;
|
||||
const supportsTunerFileOrUrl = 'm3u' === value;
|
||||
const supportsStreamLooping = 'm3u' === value;
|
||||
const supportsTunerCount = 'm3u' === value;
|
||||
const supportsUserAgent = 'm3u' === value;
|
||||
const suppportsSubmit = 'other' !== value;
|
||||
const supportsSelectablePath = supportsTunerFileOrUrl;
|
||||
const txtDevicePath = view.querySelector('.txtDevicePath');
|
||||
|
||||
if (supportsTunerIpAddress) {
|
||||
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) {
|
||||
view.querySelector('.btnDetect').classList.remove('hide');
|
||||
}
|
||||
|
||||
view.addEventListener('viewshow', function () {
|
||||
var currentId = params.id;
|
||||
const currentId = params.id;
|
||||
fillTypes(view, currentId).then(function () {
|
||||
reload(view, currentId);
|
||||
});
|
||||
|
@ -214,8 +211,8 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
|
|||
});
|
||||
});
|
||||
view.querySelector('.btnSelectPath').addEventListener('click', function () {
|
||||
require(['directorybrowser'], function (directoryBrowser) {
|
||||
var picker = new directoryBrowser.default();
|
||||
import('directorybrowser').then(({default: directorybrowser}) => {
|
||||
const picker = new directorybrowser();
|
||||
picker.show({
|
||||
includeFiles: true,
|
||||
callback: function (path) {
|
||||
|
@ -229,4 +226,3 @@ define(['globalize', 'loading', 'libraryMenu', 'dom', 'emby-input', 'emby-button
|
|||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue