';
for (var i = 0, length = items.length; i < length; i++) {
var item = items[i];
var checkedAttribute = -1 != user.Policy.BlockUnratedItems.indexOf(item.value) ? ' checked="checked"' : "";
html += '";
}
html += "
";
$(".blockUnratedItems", page).html(html).trigger("create");
}
function loadUser(page, user, allParentalRatings) {
page.querySelector(".username").innerHTML = user.Name;
libraryMenu.setTitle(user.Name);
loadUnratedItems(page, user);
loadBlockedTags(page, user.Policy.BlockedTags);
populateRatings(allParentalRatings, page);
var ratingValue = "";
if (user.Policy.MaxParentalRating) {
for (var i = 0, length = allParentalRatings.length; i < length; i++) {
var rating = allParentalRatings[i];
if (user.Policy.MaxParentalRating >= rating.Value) {
ratingValue = rating.Value;
}
}
}
$("#selectMaxParentalRating", page).val(ratingValue);
if (user.Policy.IsAdministrator) {
$(".accessScheduleSection", page).hide();
} else {
$(".accessScheduleSection", page).show();
}
renderAccessSchedule(page, user.Policy.AccessSchedules || []);
loading.hide();
}
function loadBlockedTags(page, tags) {
var html = tags.map(function (h) {
var li = '
';
li += '
';
li += '
';
li += h;
li += "
";
li += "
";
li += '';
return li += "
";
}).join("");
if (html) {
html = '
' + html + "
";
}
var elem = $(".blockedTags", page).html(html).trigger("create");
$(".btnDeleteTag", elem).on("click", function () {
var tag = this.getAttribute("data-tag");
var newTags = tags.filter(function (t) {
return t != tag;
});
loadBlockedTags(page, newTags);
});
}
function deleteAccessSchedule(page, schedules, index) {
schedules.splice(index, 1);
renderAccessSchedule(page, schedules);
}
function renderAccessSchedule(page, schedules) {
var html = "";
var index = 0;
html += schedules.map(function (a) {
var itemHtml = "";
itemHtml += '