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')
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('pageshowready', "#liveTvTunerProviderM3UPage", function () {
|
|
|
|
|
|
|
|
|
|
var providerId = getParameterByName('id');
|
|
|
|
|
var page = this;
|
|
|
|
|
reload(page, providerId);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|