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

114 lines
3.1 KiB
JavaScript
Raw Normal View History

2016-03-13 00:34:17 -07:00
(function ($, document, window) {
function reload(page, providerId) {
page.querySelector('.txtDevicePath').value = '';
if (providerId) {
ApiClient.getNamedConfiguration("livetv").then(function (config) {
var info = config.TunerHosts.filter(function (i) {
return i.Id == providerId;
})[0];
page.querySelector('.txtDevicePath').value = info.Url || '';
2016-03-13 20:32:03 -07:00
page.querySelector('.chkEnabled').checked = info.IsEnabled;
2016-03-13 00:34:17 -07:00
});
}
}
function submitForm(page) {
Dashboard.showLoadingMsg();
var id = getParameterByName('id');
if (id) {
ApiClient.getNamedConfiguration("livetv").then(function (config) {
var info = config.TunerHosts.filter(function (i) {
return i.Id == id;
})[0];
2016-03-13 20:32:03 -07:00
fillInfoFromPage(page, info);
2016-03-13 00:34:17 -07:00
submitTunerInfo(page, info);
});
} else {
var info = {
2016-03-13 20:32:03 -07:00
Type: 'satip'
2016-03-13 00:34:17 -07:00
};
2016-03-13 20:32:03 -07:00
fillInfoFromPage(page, info);
2016-03-13 00:34:17 -07:00
submitTunerInfo(page, info);
}
}
2016-03-13 20:32:03 -07:00
function fillInfoFromPage(page, info) {
info.Url = page.querySelector('.txtDevicePath').value;
info.IsEnabled = page.querySelector('.chkEnabled').checked;
}
2016-03-13 00:34:17 -07:00
function submitTunerInfo(page, info) {
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl('LiveTv/TunerHosts'),
data: JSON.stringify(info),
contentType: "application/json"
}).then(function () {
Dashboard.processServerConfigurationUpdateResult();
Dashboard.navigate('livetvstatus.html');
}, function () {
Dashboard.hideLoadingMsg();
Dashboard.alert({
message: Globalize.translate('ErrorSavingTvProvider')
});
});
}
2016-03-13 20:32:03 -07:00
function onSelectDiseqCChange(e) {
var select = e.target;
var value = select.value;
var page = $(select).parents('.page')[0];
if (value) {
page.querySelector('.fldSourceB').classList.remove('hide');
} else {
page.querySelector('.fldSourceB').classList.add('hide');
}
if (value == 'diseqc1') {
page.querySelector('.fldSourceC').classList.remove('hide');
page.querySelector('.fldSourceD').classList.remove('hide');
} else {
page.querySelector('.fldSourceC').classList.add('hide');
page.querySelector('.fldSourceD').classList.add('hide');
}
}
2016-03-13 00:34:17 -07:00
$(document).on('pageinit', "#liveTvTunerProviderSatPage", function () {
var page = this;
$('form', page).on('submit', function () {
submitForm(page);
return false;
});
2016-03-13 20:32:03 -07:00
page.querySelector('.selectDiseqC').addEventListener('change', onSelectDiseqCChange);
2016-03-13 00:34:17 -07:00
}).on('pageshow', "#liveTvTunerProviderSatPage", function () {
var providerId = getParameterByName('id');
var page = this;
reload(page, providerId);
});
})(jQuery, document, window);