(function ($, document, window) { var currentProfile; function loadProfile(page) { Dashboard.showLoadingMsg(); getProfile().done(function (result) { currentProfile = result; renderProfile(page, result); Dashboard.hideLoadingMsg(); }); } function getProfile() { var id = getParameterByName('id'); var url = id ? 'Dlna/Profiles/' + id : 'Dlna/Profiles/Default'; return $.getJSON(ApiClient.getUrl(url)); } function renderProfile(page, profile) { if (profile.ProfileType == 'User' || !profile.Id) { $('.btnSave', page).show(); } else { $('.btnSave', page).hide(); } $('#txtName', page).val(profile.Name); $('.chkMediaType', page).each(function () { this.checked = (profile.SupportedMediaTypes || '').split(',').indexOf(this.getAttribute('data-value')) != -1; }).checkboxradio('refresh'); $('#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 += '
Container: ' + (profile.Container || 'All') + '
'; if (profile.Type == 'Video') { html += 'Video Codec: ' + (profile.VideoCodec || 'All') + '
'; html += 'Audio Codec: ' + (profile.AudioCodec || 'All') + '
'; } else if (profile.Type == 'Audio') { html += 'Codec: ' + (profile.AudioCodec || 'All') + '
'; } html += ''; html += 'Delete'; html += 'Protocol: ' + (profile.Protocol || 'Http') + '
'; html += 'Container: ' + (profile.Container || 'All') + '
'; if (profile.Type == 'Video') { html += 'Video Codec: ' + (profile.VideoCodec || 'All') + '
'; html += 'Audio Codec: ' + (profile.AudioCodec || 'All') + '
'; } else if (profile.Type == 'Audio') { html += 'Codec: ' + (profile.AudioCodec || 'All') + '
'; } html += ''; html += 'Delete'; html += 'Container: ' + (profile.Container || 'All') + '
'; if (profile.Conditions && profile.Conditions.length) { html += 'Conditions: '; html += profile.Conditions.map(function (c) { return c.Property; }).join(', '); html += '
'; } html += ''; html += 'Delete'; html += 'Codec: ' + (profile.Codec || 'All') + '
'; if (profile.Conditions && profile.Conditions.length) { html += 'Conditions: '; html += profile.Conditions.map(function (c) { return c.Property; }).join(', '); html += '
'; } html += ''; html += 'Delete'; html += 'Container: ' + (profile.Container || 'All') + '
'; if (profile.Type == 'Video') { html += 'Video Codec: ' + (profile.VideoCodec || 'All') + '
'; html += 'Audio Codec: ' + (profile.AudioCodec || 'All') + '
'; } else if (profile.Type == 'Audio') { html += 'Codec: ' + (profile.AudioCodec || 'All') + '
'; } if (profile.Conditions && profile.Conditions.length) { html += 'Conditions: '; html += profile.Conditions.map(function (c) { return c.Property; }).join(', '); html += '
'; } html += ''; html += 'Delete'; html += '