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 = '';
|
|
|
|
|
page.querySelector('.chkFavorite').checked = false;
|
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 || '';
|
|
|
|
|
page.querySelector('.chkFavorite').checked = info.ImportFavoritesOnly;
|
2015-07-27 09:25:45 -07:00
|
|
|
|
page.querySelector('.chkEnabled').checked = info.IsEnabled;
|
2015-07-25 11:11:46 -07:00
|
|
|
|
|
|
|
|
|
});
|
2015-08-20 10:40:11 -07:00
|
|
|
|
} else {
|
|
|
|
|
page.querySelector('.chkEnabled').checked = true;
|
2015-07-25 11:11:46 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function submitForm(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var info = {
|
|
|
|
|
Type: 'hdhomerun',
|
2015-07-25 13:41:29 -07:00
|
|
|
|
Url: page.querySelector('.txtDevicePath').value,
|
2015-07-27 09:25:45 -07:00
|
|
|
|
ImportFavoritesOnly: page.querySelector('.chkFavorite').checked,
|
|
|
|
|
IsEnabled: page.querySelector('.chkEnabled').checked
|
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 () {
|
|
|
|
|
Dashboard.alert({
|
|
|
|
|
message: Globalize.translate('ErrorSavingTvProvider')
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#liveTvTunerProviderHdHomerunPage", function () {
|
2015-07-25 11:11:46 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('form', page).on('submit', function () {
|
|
|
|
|
submitForm(page);
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('pageshowready', "#liveTvTunerProviderHdHomerunPage", function () {
|
|
|
|
|
|
|
|
|
|
var providerId = getParameterByName('id');
|
|
|
|
|
var page = this;
|
|
|
|
|
reload(page, providerId);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|