Caution. Tangent ahead...
Most Rich Text Editors for the web are pretty friendly to preformatted code. Take for example Visual Studio Code, which is built on top of Electron, which is basically a browser. When you copy code from the IDE, and paste it somewhere like Jive or Gmail, it keeps most of the formatting (Jive got rid of indents), Gmail does not.
This won't work in Canvas.
This snippet was just sent to me via Gmail.
// hide all other roles except for the role passed in ("Staff Admin")
function hideRoles(role) {
let i = 0, optionLength=0;
let roleSelect = document.getElementById('admin_role_id');
optionLength = roleSelect.length;
for (i=0; i<optionLength; i++) {
if(roleSelect[i].innerHTML !== role) {
roleSelect[i].style.display = 'none';
} else {
roleSelect.selectedIndex = i;
}
}
}
// start sequence when user clicks on Admin tab,
// and confirm user is on settings page.
if(document.getElementById("tab-users-link")) {
document.getElementById("tab-users-link").onclick = function() {
ccsd.util.onPage(/\/accounts\/\d+\/settings/, function() {
if(!(ccsd.util.hasAnyRole("root_admin"))) {
hideRoles("Staff Admin");
}
});
};
}
})();
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.