var roleData = [
{ id: 1, name: 'Administrator', desc: 'Do administrator type of stuff.', privs: ['Priv A','Priv B']},
{ id: 2, name: 'Processor', desc: 'Process things and stuff.', privs: ['Priv A','Priv F']},
{ id: 3, name: 'Approver', desc: 'Check the details and then say things are good to go.', privs: ['Priv B','Priv C','Priv D']},
{ id: 4, name: 'Manager', desc: 'Make sure everybody else is doing their jobs.', privs: ['Priv C']},
{ id: 5, name: 'Submitter', desc: 'Puts things into the system.', privs: ['Priv C','Priv E']}
];
var roleMap = {};
$.each(roleData,function(){
roleMap[this.id] = this.name;
});
var data = [];
$(document).ready(function(){
// fetch data with ajax
$.ajax({
async: false,
url: 'http://linode3.purplewire.com/~jason/data/admin.json',
dataType: 'json',
success: function(d){
var id = 1;
$.each(d,function(){
var u = {
id: this.i,
firstName: this.f,
lastName: this.l,
roles: this.r,
email: this.e,
username: this.u
}
data.push(u);
});
}
});
// build the role legend
$.each(roleData,function(){
var d = $('<div class="form-check"></div>');
d.append('<input class="form-check-input" data-r="'+this.id+'" type="checkbox" id="rf'+this.id+'">');
d.append('<label class="form-check-label" for="rf'+this.id+'"><div class="roleBlock role'+this.id+'"></div>'+this.name+' </label>');
d.append(' <i class="fas fa-question-circle"></i>');
var c = d.find('i');
// add a fancy popover that shows details
// for the role.
var pc ='';
pc += '<p>'+this.desc+'</p>';
pc += '<hr>';
pc += '<ul>';
for(i=0; i<this.privs.length; i++) {
pc += '<li>'+this.privs[i]+'</li>';
}
pc += '</ul>';
c.popover({
html: true,
content: pc,
placement: 'bottom',
title: this.name
});
$('#ll').append(d);
});
// click handler for checkboxes in the legend
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.