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:
16
webassets/index.html
Normal file
16
webassets/index.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Spot tool</title>
|
||||
|
||||
<link rel="stylesheet" href="css/style.css" type="text/css">
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery-ui@1.13.2/dist/jquery-ui.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/moment@2.29.4/moment.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="table-container"></div>
|
||||
<script src="js/code.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
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