function load() { let headers = document.querySelectorAll('h2'); headers = Array.prototype.slice.call(headers); let headers3 = document.querySelectorAll('h3'); headers3 = Array.prototype.slice.call(headers3); headers = headers.concat(headers3); headers.forEach(function(header) { header.addEventListener('click', function() { let article = this.nextElementSibling; if (article.style.display === 'none') { article.style.display = ''; } else { article.style.display = 'none'; } }); }); } function perm_change(row) { let user_perms = users_perms[row.children[0].textContent]; let row_perms = {}; for (let child of row.children) { if (child.firstChild.type == "checkbox") { if (child.firstChild.checked) { row_perms[child.firstChild.dataset.appName] = true; } else { row_perms[child.firstChild.dataset.appName] = false; } } } let perms_changed = false; for (let app_name of Object.keys(user_perms)) { if (user_perms[app_name] != row_perms[app_name]) { perms_changed = true; } } console.log("perms_changed = " + perms_changed); } function submit_user_perms(row) { let row_perms = {}; for (let child of row.children) { if (child.firstChild.type == "checkbox") { if (child.firstChild.checked) { row_perms[child.firstChild.dataset.appName] = true; } else { row_perms[child.firstChild.dataset.appName] = false; } } } console.log(row_perms); fetch(window.location.pathname, { method: 'POST', headers: {'Content-Type': 'application/json'}, body: row_perms }); }