jellyfin-web/dashboard-ui/scripts/livetvtunerprovider-m3u.js

71 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-07-25 11:11:46 -07:00
(function ($, document, window) {
function reload(page, providerId) {
2015-07-25 13:41:29 -07:00
page.querySelector('.txtDevicePath').value = '';
2015-07-25 11:11:46 -07:00
if (providerId) {
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("livetv").then(function (config) {
2015-07-25 11:11:46 -07:00
var info = config.TunerHosts.filter(function (i) {
return i.Id == providerId;
})[0];
2015-07-25 13:41:29 -07:00
page.querySelector('.txtDevicePath').value = info.Url || '';
2015-07-25 11:11:46 -07:00
});
}
}
function submitForm(page) {
Dashboard.showLoadingMsg();
var info = {
Type: 'm3u',
2015-07-25 13:41:29 -07:00
Url: page.querySelector('.txtDevicePath').value
2015-07-25 11:11:46 -07:00
};
var id = getParameterByName('id');
if (id) {
info.Id = id;
}
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl('LiveTv/TunerHosts'),
data: JSON.stringify(info),
contentType: "application/json"
2015-12-14 08:43:03 -07:00
}).then(function () {
2015-07-25 11:11:46 -07:00
Dashboard.processServerConfigurationUpdateResult();
Dashboard.navigate('livetvstatus.html');
2015-12-14 08:43:03 -07:00
}, function () {
2015-07-25 11:42:39 -07:00
Dashboard.hideLoadingMsg();
2015-07-25 11:11:46 -07:00
Dashboard.alert({
message: Globalize.translate('ErrorSavingTvProvider')
});
});
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#liveTvTunerProviderM3UPage", function () {
2015-07-25 11:11:46 -07:00
var page = this;
$('form', page).on('submit', function () {
submitForm(page);
return false;
});
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#liveTvTunerProviderM3UPage", function () {
2015-07-25 11:11:46 -07:00
var providerId = getParameterByName('id');
var page = this;
reload(page, providerId);
});
})(jQuery, document, window);