fixed HTML list view (very simple at this time)

This commit is contained in:
Daniel Schick 2022-10-18 08:27:01 +02:00
parent aceda066ce
commit 7654748a9d
4 changed files with 43 additions and 27 deletions

View File

@ -65,12 +65,19 @@ namespace bsmd.AIS2Service
_repeatIndicator = GetUInt(bits, 6, 7);
_mmsi = GetInt(bits, 8, 37);
year = GetUInt(bits, 38, 51);
if (year != 0) // year = 0 -> N/A
{
if (year > DateTime.UtcNow.Year || year < DateTime.UtcNow.Year) // liar
{
return Status.PARSE_ERROR;
}
month = GetUInt(bits, 52, 55);
day = GetUInt(bits, 56, 60);
hour = GetUInt(bits, 61, 65);
minute = GetUInt(bits, 66, 71);
second = GetUInt(bits, 72, 77);
_utcTimestamp = new DateTime((int) year, (int) month, (int) day, (int) hour, (int) minute, (int) second, DateTimeKind.Utc);
_utcTimestamp = new DateTime((int)year, (int)month, (int)day, (int)hour, (int)minute, (int)second, DateTimeKind.Utc);
}
_accuracy = GetInt(bits, 78, 78) == 1;
_longitude = GetInt(bits, 79, 106);
_latitude = GetInt(bits, 107, 133);

View File

@ -17,7 +17,7 @@ namespace bsmd.AIS2Service
{
AISManager.Start();
// TODO wait some
Thread.Sleep(180000);
Thread.Sleep(720000);
// Test finish..
AISManager.Stop();
}

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JSON Test</title>
<title>AIS List</title>
<script type="text/javascript" src="update.js"></script>
</head>
<body onload="startup()">
@ -17,6 +17,7 @@
<th>Latitude</th>
<th>Longitude</th>
<th>IMO</th>
<th>Class B</th>
</tr>
</thead>
<tbody id="aisTableBody">

View File

@ -10,26 +10,34 @@
console.log('error: ' + err);
});
function updateData(data) {
const table = document.getElementById("aisTable");
let numItems = 1;
numItems++;
const row = document.createElement('tr');
row.innerHTML = `<td>
<input type="text" id="itemDescription${numItems}" placeholder="Item" />
</td>
<td>
<input type="text" id="itemValue${numItems}" placeholder="Value" />
</td>`;
// You could also do the same for the cells and inputs
table.appendChild(row);
var table = document.getElementById('aisTable');
for (var i = 0; i < data.length; i++) {
var div = document.createElement("div");
div.innerHTML = 'Name: ' + data[i].Name;
mainContainer.appendChild(div);
let row_id = "row_" + data[i].MMSI;
row = document.getElementById(row_id);
if(row == null) { // not found, create new row
row = document.createElement('tr');
row.innerHTML = `<td>` + data[i].MMSI +
`</td><td id="name_` + data[i].MMSI + `"/>` +
`<td id="timestamp_` + data[i].MMSI + `"/>` +
`<td id="lat_` + data[i].MMSI + `"/>` +
`<td id="lon_` + data[i].MMSI + `"/>` +
`<td id="imo_` + data[i].MMSI + `"/>` +
`<td>` + data[i].IsClassB + `</td>`;
table.appendChild(row);
}
// update existing row
var td = document.getElementById("name_" + data[i].MMSI);
td.innerHTML = data[i].Name;
td = document.getElementById("timestamp_" + data[i].MMSI);
td.innerHTML = data[i].LastUpdate;
td = document.getElementById("lat_" + data[i].MMSI);
td.innerHTML = data[i].Latitude;
td = document.getElementById("lon_" + data[i].MMSI);
td.innerHTML = data[i].Longitude;
td = document.getElementById("imo_" + data[i].MMSI);
td.innerHTML = data[i].IMO;
}
}
}