Skip to content

Commit

Permalink
Fixed a bug where lat/long may not get displayed in some browsers bec…
Browse files Browse the repository at this point in the history
…ause of a numeric conversion issue.
  • Loading branch information
fkurmannucsc authored Jul 3, 2024
1 parent 984fbd6 commit 982636b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,16 @@ function initVideo(info) {

let video_location = metadata.location ?? {};
let latitude = video_location.latitude ?? undefined;
let latitude_input_value = convertCoordinatesForInput(latitude);
let longitude = video_location.longitude ?? undefined;
let longitude_input_value = convertCoordinatesForInput(longitude);

window.shark.info['video'] = {
id: info.video_id,
name: name,
start_time: start_time,
latitude: latitude,
longitude: longitude,
latitude: latitude_input_value,
longitude: longitude_input_value,
};

window.shark.info['key_metadata'] = info.key_metadata;
Expand Down Expand Up @@ -175,14 +177,14 @@ function initVideo(info) {
<input type='number' name='latitude' step='0.01'
data-video-id='${info.video_id}'
onchange='editVideo(this, "latitude")'
value='${latitude}' />
value='${latitude_input_value}' />
</div>
<div>
<label for='longitude'>Longitude:</label>
<input type='number' name='longitude' step='0.01'
data-video-id='${info.video_id}'
onchange='editVideo(this, "longitude")'
value='${longitude}' />
value='${longitude_input_value}' />
</div>
</div>
`;
Expand Down Expand Up @@ -419,6 +421,15 @@ function convertUnixSecsForInput(unixSeconds) {
return offsetDate.toISOString().slice(0, 19);
}

function convertCoordinatesForInput(coordinates) {
if (!coordinates) {
return undefined;
}

// Remove the leading + from coordinates.
return coordinates.replace(/^\+/, '');
}

// Fetch the server's version and add it to the page's title.
function fetchVersion() {
let promise = fetch('/version', {
Expand Down

0 comments on commit 982636b

Please sign in to comment.