define(["jQuery","globalize","loading","libraryMenu","listViewStyle","emby-linkbutton"],function($,globalize,loading,libraryMenu){"use strict";function loadProfiles(page){loading.show(),ApiClient.getJSON(ApiClient.getUrl("Dlna/ProfileInfos")).then(function(result){renderUserProfiles(page,result),renderSystemProfiles(page,result),loading.hide()})}function renderUserProfiles(page,profiles){renderProfiles(page,page.querySelector(".customProfiles"),profiles.filter(function(p){return"User"==p.Type}))}function renderSystemProfiles(page,profiles){renderProfiles(page,page.querySelector(".systemProfiles"),profiles.filter(function(p){return"System"==p.Type}))}function renderProfiles(page,element,profiles){var html="";profiles.length&&(html+='
');for(var i=0,length=profiles.length;i',html+="",html+='dvr',html+="",html+='","User"==profile.Type&&(html+=''),html+="
"}profiles.length&&(html+=""),element.innerHTML=html,$(".btnDeleteProfile",element).on("click",function(){var id=this.getAttribute("data-profileid");deleteProfile(page,id)})}function deleteProfile(page,id){require(["confirm"],function(confirm){confirm(globalize.translate("MessageConfirmProfileDeletion"),globalize.translate("HeaderConfirmProfileDeletion")).then(function(){loading.show(),ApiClient.ajax({type:"DELETE",url:ApiClient.getUrl("Dlna/Profiles/"+id)}).then(function(){loading.hide(),loadProfiles(page)})})})}function getTabs(){return[{href:"dlnasettings.html",name:globalize.translate("TabSettings")},{href:"dlnaprofiles.html",name:globalize.translate("TabProfiles")}]}$(document).on("pageshow","#dlnaProfilesPage",function(){libraryMenu.setTabs("dlna",1,getTabs);var page=this;loadProfiles(page)})});