SpaceAlarm,
от вас требовались строки 26 - 29
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
td{
text-align: center;
border: solid 1px #0000FF;
}
table {
border-collapse: collapse;
border: 1px solid #0000FF;
width: 300px;
}
</style>
<script>
window.addEventListener("DOMContentLoaded", function() {
var data = [{client_nickname:"rrrrrrr", client_type:1}, {client_nickname:"yyyyyy", client_type:0}, {client_nickname:"yyy", client_type:0}, {client_nickname:"nnn", client_type:"x"}];
var type = {0 : "Пользователь", 1 : "Администратор"};
var thead = ["Группа","Логин"];
var filter = ["client_type", "client_nickname"];
function createTable(obj) {
var table = document.createElement("table");
if (obj.data && obj.filter && obj.type) {
obj.data.forEach(function(content, indx) {
var tr = table.insertRow(indx);
obj.filter.forEach(function(key, i) {
var td = tr.insertCell(i);
td.textContent = i ? content[key] : obj.type[content[key]] ? obj.type[content[key]] : "кто это?";
});
});
}
if (obj.thead) {
var thead = document.createElement("thead");
table.appendChild(thead);
var tr = thead.insertRow(0);
obj.thead.forEach(function(title) {
var th = document.createElement("th");
th.textContent = title;
tr.appendChild(th);
});
}
return table;
}
var table = createTable({thead:thead, data:data, filter:filter, type:type});
var parent = document.body;
parent.appendChild(table);
});
</script>
</head>
<body>
</body>
</html>