2014-03-26 12:21:29 -07:00
|
|
|
|
(function ($, document, window) {
|
|
|
|
|
|
2014-03-28 11:17:18 -07:00
|
|
|
|
var currentProfile;
|
|
|
|
|
|
2014-03-26 12:21:29 -07:00
|
|
|
|
function loadProfile(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2014-03-26 13:14:47 -07:00
|
|
|
|
getProfile().done(function (result) {
|
2014-03-26 12:21:29 -07:00
|
|
|
|
|
2014-03-28 11:17:18 -07:00
|
|
|
|
currentProfile = result;
|
|
|
|
|
|
2014-03-26 12:21:29 -07:00
|
|
|
|
renderProfile(page, result);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-03-26 13:14:47 -07:00
|
|
|
|
|
|
|
|
|
function getProfile() {
|
|
|
|
|
|
|
|
|
|
var id = getParameterByName('id');
|
|
|
|
|
var url = id ? 'Dlna/Profiles/' + id :
|
|
|
|
|
'Dlna/Profiles/Default';
|
|
|
|
|
|
|
|
|
|
return $.getJSON(ApiClient.getUrl(url));
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-26 12:21:29 -07:00
|
|
|
|
function renderProfile(page, profile) {
|
2014-03-26 13:14:47 -07:00
|
|
|
|
|
|
|
|
|
if (profile.ProfileType == 'User' || !profile.Id) {
|
|
|
|
|
$('.btnSave', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.btnSave', page).hide();
|
|
|
|
|
}
|
2014-03-27 12:30:21 -07:00
|
|
|
|
|
2014-03-26 13:14:47 -07:00
|
|
|
|
$('#txtName', page).val(profile.Name);
|
|
|
|
|
|
2014-03-27 12:30:21 -07:00
|
|
|
|
$('.chkMediaType', page).each(function () {
|
|
|
|
|
this.checked = (profile.SupportedMediaTypes || '').split(',').indexOf(this.getAttribute('data-value')) != -1;
|
2014-03-28 11:17:18 -07:00
|
|
|
|
|
2014-03-27 12:30:21 -07:00
|
|
|
|
}).checkboxradio('refresh');
|
2014-03-28 11:17:18 -07:00
|
|
|
|
|
|
|
|
|
$('#chkEnableAlbumArtInDidl', page).checked(profile.EnableAlbumArtInDidl).checkboxradio('refresh');
|
|
|
|
|
|
|
|
|
|
var idInfo = profile.Identification || {};
|
|
|
|
|
|
|
|
|
|
$('#txtIdFriendlyName', page).val(idInfo.FriendlyName || '');
|
|
|
|
|
$('#txtIdModelName', page).val(idInfo.ModelName || '');
|
|
|
|
|
$('#txtIdModelNumber', page).val(idInfo.ModelNumber || '');
|
|
|
|
|
$('#txtIdModelDescription', page).val(idInfo.ModelDescription || '');
|
|
|
|
|
$('#txtIdModelUrl', page).val(idInfo.ModelUrl || '');
|
|
|
|
|
$('#txtIdManufacturer', page).val(idInfo.Manufacturer || '');
|
|
|
|
|
$('#txtIdManufacturerUrl', page).val(idInfo.ManufacturerUrl || '');
|
|
|
|
|
$('#txtIdSerialNumber', page).val(idInfo.SerialNumber || '');
|
|
|
|
|
$('#txtIdDeviceDescription', page).val(idInfo.DeviceDescription || '');
|
|
|
|
|
|
|
|
|
|
profile.DirectPlayProfiles = (profile.DirectPlayProfiles || []);
|
|
|
|
|
profile.TranscodingProfiles = (profile.TranscodingProfiles || []);
|
|
|
|
|
profile.ContainerProfiles = (profile.ContainerProfiles || []);
|
|
|
|
|
profile.CodecProfiles = (profile.CodecProfiles || []);
|
|
|
|
|
profile.MediaProfiles = (profile.MediaProfiles || []);
|
|
|
|
|
|
|
|
|
|
renderDirectPlayProfiles(page, profile.DirectPlayProfiles);
|
|
|
|
|
renderTranscodingProfiles(page, profile.TranscodingProfiles);
|
|
|
|
|
renderContainerProfiles(page, profile.ContainerProfiles);
|
|
|
|
|
renderCodecProfiles(page, profile.CodecProfiles);
|
|
|
|
|
renderMediaProfiles(page, profile.MediaProfiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderDirectPlayProfiles(page, profiles) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
|
|
|
|
|
|
|
|
|
|
var currentType;
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = profiles.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var profile = profiles[i];
|
|
|
|
|
|
|
|
|
|
if (profile.Type !== currentType) {
|
|
|
|
|
|
|
|
|
|
html += '<li data-role="list-divider">' + profile.Type + '</li>';
|
|
|
|
|
currentType = profile.Type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<li>';
|
|
|
|
|
html += '<a href="#">';
|
|
|
|
|
|
|
|
|
|
html += '<p>Container: ' + (profile.Container || 'All') + '</p>';
|
|
|
|
|
|
|
|
|
|
if (profile.Type == 'Video') {
|
|
|
|
|
html += '<p>Video Codec: ' + (profile.VideoCodec || 'All') + '</p>';
|
|
|
|
|
html += '<p>Audio Codec: ' + (profile.AudioCodec || 'All') + '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (profile.Type == 'Audio') {
|
|
|
|
|
html += '<p>Codec: ' + (profile.AudioCodec || 'All') + '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-icon="delete" class="btnDeleteProfile" data-profileIndex="' + i + '">Delete</a>';
|
|
|
|
|
|
|
|
|
|
html += '</li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
|
|
var elem = $('.directPlayProfiles', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.btnDeleteProfile', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var index = this.getAttribute('data-profileIndex');
|
|
|
|
|
deleteDirectPlayProfile(page, index);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteDirectPlayProfile(page, index) {
|
|
|
|
|
|
|
|
|
|
currentProfile.DirectPlayProfiles.splice(index, 1);
|
|
|
|
|
|
|
|
|
|
renderDirectPlayProfiles(page, currentProfile.DirectPlayProfiles);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderTranscodingProfiles(page, profiles) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
|
|
|
|
|
|
|
|
|
|
var currentType;
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = profiles.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var profile = profiles[i];
|
|
|
|
|
|
|
|
|
|
if (profile.Type !== currentType) {
|
|
|
|
|
|
|
|
|
|
html += '<li data-role="list-divider">' + profile.Type + '</li>';
|
|
|
|
|
currentType = profile.Type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<li>';
|
|
|
|
|
html += '<a href="#">';
|
|
|
|
|
|
2014-03-28 12:58:18 -07:00
|
|
|
|
html += '<p>Protocol: ' + (profile.Protocol || 'Http') + '</p>';
|
2014-03-28 11:17:18 -07:00
|
|
|
|
html += '<p>Container: ' + (profile.Container || 'All') + '</p>';
|
|
|
|
|
|
|
|
|
|
if (profile.Type == 'Video') {
|
|
|
|
|
html += '<p>Video Codec: ' + (profile.VideoCodec || 'All') + '</p>';
|
|
|
|
|
html += '<p>Audio Codec: ' + (profile.AudioCodec || 'All') + '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (profile.Type == 'Audio') {
|
|
|
|
|
html += '<p>Codec: ' + (profile.AudioCodec || 'All') + '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-icon="delete" class="btnDeleteProfile" data-profileIndex="' + i + '">Delete</a>';
|
|
|
|
|
|
|
|
|
|
html += '</li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
|
|
var elem = $('.transcodingProfiles', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.btnDeleteProfile', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var index = this.getAttribute('data-profileIndex');
|
|
|
|
|
deleteTranscodingProfile(page, index);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteTranscodingProfile(page, index) {
|
|
|
|
|
|
|
|
|
|
currentProfile.TranscodingProfiles.splice(index, 1);
|
|
|
|
|
|
|
|
|
|
renderTranscodingProfiles(page, currentProfile.TranscodingProfiles);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderContainerProfiles(page, profiles) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
|
|
|
|
|
|
|
|
|
|
var currentType;
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = profiles.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var profile = profiles[i];
|
|
|
|
|
|
|
|
|
|
if (profile.Type !== currentType) {
|
|
|
|
|
|
|
|
|
|
html += '<li data-role="list-divider">' + profile.Type + '</li>';
|
|
|
|
|
currentType = profile.Type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<li>';
|
|
|
|
|
html += '<a href="#">';
|
|
|
|
|
|
|
|
|
|
html += '<p>Container: ' + (profile.Container || 'All') + '</p>';
|
|
|
|
|
|
|
|
|
|
if (profile.Conditions && profile.Conditions.length) {
|
|
|
|
|
|
|
|
|
|
html += '<p>Conditions: ';
|
|
|
|
|
html += profile.Conditions.map(function (c) {
|
|
|
|
|
return c.Property;
|
|
|
|
|
}).join(', ');
|
|
|
|
|
html += '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-icon="delete" class="btnDeleteProfile" data-profileIndex="' + i + '">Delete</a>';
|
|
|
|
|
|
|
|
|
|
html += '</li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
|
|
var elem = $('.containerProfiles', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.btnDeleteProfile', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var index = this.getAttribute('data-profileIndex');
|
|
|
|
|
deleteContainerProfile(page, index);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteContainerProfile(page, index) {
|
|
|
|
|
|
|
|
|
|
currentProfile.ContainerProfiles.splice(index, 1);
|
|
|
|
|
|
|
|
|
|
renderContainerProfiles(page, currentProfile.ContainerProfiles);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderCodecProfiles(page, profiles) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
|
|
|
|
|
|
|
|
|
|
var currentType;
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = profiles.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var profile = profiles[i];
|
|
|
|
|
|
|
|
|
|
var type = profile.Type.replace("VideoAudio", "Video Audio");
|
|
|
|
|
|
|
|
|
|
if (type !== currentType) {
|
|
|
|
|
|
|
|
|
|
html += '<li data-role="list-divider">' + type + '</li>';
|
|
|
|
|
currentType = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<li>';
|
|
|
|
|
html += '<a href="#">';
|
|
|
|
|
|
|
|
|
|
html += '<p>Codec: ' + (profile.Codec || 'All') + '</p>';
|
|
|
|
|
|
|
|
|
|
if (profile.Conditions && profile.Conditions.length) {
|
|
|
|
|
|
|
|
|
|
html += '<p>Conditions: ';
|
|
|
|
|
html += profile.Conditions.map(function (c) {
|
|
|
|
|
return c.Property;
|
|
|
|
|
}).join(', ');
|
|
|
|
|
html += '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-icon="delete" class="btnDeleteProfile" data-profileIndex="' + i + '">Delete</a>';
|
|
|
|
|
|
|
|
|
|
html += '</li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
|
|
var elem = $('.codecProfiles', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.btnDeleteProfile', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var index = this.getAttribute('data-profileIndex');
|
|
|
|
|
deleteCodecProfile(page, index);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteCodecProfile(page, index) {
|
|
|
|
|
|
|
|
|
|
currentProfile.CodecProfiles.splice(index, 1);
|
|
|
|
|
|
|
|
|
|
renderCodecProfiles(page, currentProfile.CodecProfiles);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderMediaProfiles(page, profiles) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
|
|
|
|
|
|
|
|
|
|
var currentType;
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = profiles.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var profile = profiles[i];
|
|
|
|
|
|
|
|
|
|
if (profile.Type !== currentType) {
|
|
|
|
|
|
|
|
|
|
html += '<li data-role="list-divider">' + profile.Type + '</li>';
|
|
|
|
|
currentType = profile.Type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<li>';
|
|
|
|
|
html += '<a href="#">';
|
|
|
|
|
|
|
|
|
|
html += '<p>Container: ' + (profile.Container || 'All') + '</p>';
|
|
|
|
|
|
|
|
|
|
if (profile.Type == 'Video') {
|
|
|
|
|
html += '<p>Video Codec: ' + (profile.VideoCodec || 'All') + '</p>';
|
|
|
|
|
html += '<p>Audio Codec: ' + (profile.AudioCodec || 'All') + '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (profile.Type == 'Audio') {
|
|
|
|
|
html += '<p>Codec: ' + (profile.AudioCodec || 'All') + '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (profile.Conditions && profile.Conditions.length) {
|
|
|
|
|
|
|
|
|
|
html += '<p>Conditions: ';
|
|
|
|
|
html += profile.Conditions.map(function (c) {
|
|
|
|
|
return c.Property;
|
|
|
|
|
}).join(', ');
|
|
|
|
|
html += '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-icon="delete" class="btnDeleteProfile" data-profileIndex="' + i + '">Delete</a>';
|
|
|
|
|
|
|
|
|
|
html += '</li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
|
|
var elem = $('.mediaProfiles', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.btnDeleteProfile', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var index = this.getAttribute('data-profileIndex');
|
|
|
|
|
deleteMediaProfile(page, index);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteMediaProfile(page, index) {
|
|
|
|
|
|
|
|
|
|
currentProfile.MediaProfiles.splice(index, 1);
|
|
|
|
|
|
|
|
|
|
renderMediaProfiles(page, currentProfile.MediaProfiles);
|
|
|
|
|
|
2014-03-26 13:14:47 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function saveProfile(page, profile) {
|
|
|
|
|
|
|
|
|
|
updateProfile(page, profile);
|
|
|
|
|
|
|
|
|
|
var id = getParameterByName('id');
|
|
|
|
|
|
|
|
|
|
if (id) {
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: ApiClient.getUrl("Dlna/Profiles/" + id),
|
|
|
|
|
data: JSON.stringify(profile),
|
|
|
|
|
contentType: "application/json"
|
|
|
|
|
|
|
|
|
|
}).done(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.alert('Settings saved.');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: ApiClient.getUrl("Dlna/Profiles"),
|
|
|
|
|
data: JSON.stringify(profile),
|
|
|
|
|
contentType: "application/json"
|
|
|
|
|
|
|
|
|
|
}).done(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.navigate('dlnaprofiles.html');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateProfile(page, profile) {
|
|
|
|
|
|
|
|
|
|
profile.Name = $('#txtName', page).val();
|
2014-03-28 11:17:18 -07:00
|
|
|
|
profile.EnableAlbumArtInDidl = $('#chkEnableAlbumArtInDidl', page).checked();
|
|
|
|
|
|
|
|
|
|
profile.SupportedMediaTypes = $('.chkMediaType:checked', page).get().map(function (c) {
|
|
|
|
|
return c.getAttribute('data-value');
|
|
|
|
|
}).join(',');
|
|
|
|
|
|
|
|
|
|
profile.Identification = profile.Identification || {};
|
|
|
|
|
|
|
|
|
|
profile.Identification.FriendlyName = $('#txtIdFriendlyName', page).val();
|
|
|
|
|
profile.Identification.ModelName = $('#txtIdModelName', page).val();
|
|
|
|
|
profile.Identification.ModelNumber = $('#txtIdModelNumber', page).val();
|
|
|
|
|
profile.Identification.ModelDescription = $('#txtIdModelDescription', page).val();
|
|
|
|
|
profile.Identification.ModelUrl = $('#txtIdModelUrl', page).val();
|
|
|
|
|
profile.Identification.Manufacturer = $('#txtIdManufacturer', page).val();
|
|
|
|
|
profile.Identification.ManufacturerUrl = $('#txtIdManufacturerUrl', page).val();
|
|
|
|
|
profile.Identification.SerialNumber = $('#txtIdSerialNumber', page).val();
|
|
|
|
|
profile.Identification.DeviceDescription = $('#txtIdDeviceDescription', page).val();
|
2014-03-26 12:21:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-27 12:30:21 -07:00
|
|
|
|
$(document).on('pageinit', "#dlnaProfilePage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.radioProfileTab', page).on('change', function () {
|
|
|
|
|
|
|
|
|
|
$('.profileTab', page).hide();
|
|
|
|
|
$('.' + this.value, page).show();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('pageshow', "#dlnaProfilePage", function () {
|
2014-03-26 12:21:29 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
loadProfile(page);
|
|
|
|
|
|
2014-03-27 12:30:21 -07:00
|
|
|
|
}).on('pagebeforeshow', "#dlnaProfilePage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.radioSeriesTimerTab', page).checked(false).checkboxradio('refresh');
|
|
|
|
|
$('#radioInfo', page).checked(true).checkboxradio('refresh').trigger('change');
|
|
|
|
|
|
2014-03-26 12:21:29 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-03-26 13:14:47 -07:00
|
|
|
|
window.DlnaProfilePage = {
|
|
|
|
|
|
|
|
|
|
onSubmit: function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var form = this;
|
|
|
|
|
var page = $(form).parents('.page');
|
|
|
|
|
|
2014-03-28 11:17:18 -07:00
|
|
|
|
saveProfile(page, currentProfile);
|
2014-03-26 12:21:29 -07:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|