Skip to content

Commit

Permalink
Moving lat/long conversion into function.
Browse files Browse the repository at this point in the history
  • Loading branch information
fkurmannucsc committed Jul 2, 2024
1 parent 299ec17 commit 37c9d03
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +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;

// Remove leading "+"
if (latitude !== undefined) {
latitude = latitude.replace('+', '');
}
if (longitude !== undefined) {
longitude = longitude.replace('+', '');
}
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 @@ -183,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 @@ -427,6 +421,15 @@ function convertUnixSecsForInput(unixSeconds) {
return offsetDate.toISOString().slice(0, 19);
}

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

// Remove 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 37c9d03

Please sign in to comment.