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) {
ApiClient.getNamedConfiguration("livetv").done(function (config) {
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"
}).done(function (result) {
Dashboard.processServerConfigurationUpdateResult();
Dashboard.navigate('livetvstatus.html');
}).fail(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')
});
});
}
$(document).on('pageinitdepends', "#liveTvTunerProviderM3UPage", function () {
var page = this;
$('form', page).on('submit', function () {
submitForm(page);
return false;
});
}).on('pageshowready', "#liveTvTunerProviderM3UPage", function () {
var providerId = getParameterByName('id');
var page = this;
reload(page, providerId);
});
})(jQuery, document, window);