2014-03-26 12:21:29 -07:00
|
|
|
|
(function ($, document, window) {
|
|
|
|
|
|
|
|
|
|
function loadProfiles(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
$.getJSON(ApiClient.getUrl("Dlna/ProfileInfos")).done(function (result) {
|
|
|
|
|
|
|
|
|
|
renderProfiles(page, result);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderProfiles(page, profiles) {
|
|
|
|
|
|
|
|
|
|
renderUserProfiles(page, profiles);
|
|
|
|
|
renderSystemProfiles(page, profiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderUserProfiles(page, profiles) {
|
|
|
|
|
|
|
|
|
|
profiles = profiles.filter(function (p) {
|
|
|
|
|
return p.Type == 'User';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = profiles.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var profile = profiles[i];
|
|
|
|
|
|
|
|
|
|
html += '<li>';
|
2014-04-20 18:36:12 -07:00
|
|
|
|
html += '<a href="dlnaprofile.html?id=' + profile.Id + '" style="font-size:14px;">';
|
2014-03-26 12:21:29 -07:00
|
|
|
|
html += profile.Name;
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-icon="delete" class="btnDeleteProfile" data-profileid="' + profile.Id + '">Delete</a>';
|
|
|
|
|
|
|
|
|
|
html += '</li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
|
|
var elem = $('.customProfiles', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.btnDeleteProfile', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var id = this.getAttribute('data-profileid');
|
|
|
|
|
deleteProfile(page, id);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderSystemProfiles(page, profiles) {
|
|
|
|
|
|
|
|
|
|
profiles = profiles.filter(function (p) {
|
|
|
|
|
return p.Type == 'System';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true">';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = profiles.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var profile = profiles[i];
|
|
|
|
|
|
|
|
|
|
html += '<li>';
|
2014-04-20 18:36:12 -07:00
|
|
|
|
html += '<a href="dlnaprofile.html?id=' + profile.Id + '" style="font-size:14px;">';
|
2014-03-26 12:21:29 -07:00
|
|
|
|
html += profile.Name;
|
|
|
|
|
html += '</a>';
|
|
|
|
|
html += '</li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
|
|
$('.systemProfiles', page).html(html).trigger('create');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteProfile(page, id) {
|
|
|
|
|
|
|
|
|
|
Dashboard.confirm("Are you sure you wish to delete this profile?", "Confirm Profile Deletion", function (result) {
|
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
url: ApiClient.getUrl("Dlna/Profiles/" + id)
|
|
|
|
|
|
|
|
|
|
}).done(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
|
|
|
|
|
loadProfiles(page);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('pageshow', "#dlnaProfilesPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
loadProfiles(page);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|