mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Start of web interface
This commit is contained in:
13
webassets/js/code.js
Normal file
13
webassets/js/code.js
Normal file
@@ -0,0 +1,13 @@
|
||||
$.getJSON('/api/spots', function(jsonData) {
|
||||
let headers = Object.keys(jsonData[0]);
|
||||
let table = $('<table>').append('<thead><tr></tr></thead><tbody></tbody>');
|
||||
headers.forEach(header => table.find('thead tr').append(`<th>${header}</th>`));
|
||||
|
||||
jsonData.forEach(row => {
|
||||
let $tr = $('<tr>');
|
||||
headers.forEach(header => $tr.append(`<td>${row[header]}</td>`));
|
||||
table.find('tbody').append($tr);
|
||||
});
|
||||
|
||||
$('#table-container').html(table);
|
||||
});
|
||||
Reference in New Issue
Block a user