From 83b23be05a3fcd69cb659591404a14771a9dcd64 Mon Sep 17 00:00:00 2001 From: FabriceKurmann Date: Tue, 2 Jul 2024 10:36:00 -0700 Subject: [PATCH 1/4] Removing leading + from coordinates. --- static/js/main.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/static/js/main.js b/static/js/main.js index 703aa54..40990f5 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -136,6 +136,14 @@ function initVideo(info) { let video_location = metadata.location ?? {}; let latitude = video_location.latitude ?? undefined; let longitude = video_location.longitude ?? undefined; + + // Remove leading "+" + if (latitude != undefined) { + latitude = latitude.replace('+', ''); + } + if (longitude != undefined) { + longitude = longitude.replace('+', ''); + } window.shark.info['video'] = { id: info.video_id, From 299ec17d2b39efd018dc06387658868da563dd1a Mon Sep 17 00:00:00 2001 From: FabriceKurmann Date: Tue, 2 Jul 2024 10:39:04 -0700 Subject: [PATCH 2/4] Using strict equality checks. --- static/js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index 40990f5..9d3dec3 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -138,10 +138,10 @@ function initVideo(info) { let longitude = video_location.longitude ?? undefined; // Remove leading "+" - if (latitude != undefined) { + if (latitude !== undefined) { latitude = latitude.replace('+', ''); } - if (longitude != undefined) { + if (longitude !== undefined) { longitude = longitude.replace('+', ''); } From 37c9d035031adb2faba1cfc348d052c9782333fe Mon Sep 17 00:00:00 2001 From: FabriceKurmann Date: Tue, 2 Jul 2024 14:24:03 -0700 Subject: [PATCH 3/4] Moving lat/long conversion into function. --- static/js/main.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index 9d3dec3..b3efb57 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -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; @@ -183,14 +177,14 @@ function initVideo(info) { + value='${latitude_input_value}' />
+ value='${longitude_input_value}' />
`; @@ -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', { From fead479e12b69a3cb8dfd4947a48a6b1cf0798ef Mon Sep 17 00:00:00 2001 From: FabriceKurmann Date: Tue, 2 Jul 2024 18:16:50 -0700 Subject: [PATCH 4/4] Adding a regex for + removal. --- static/js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index b3efb57..f53f925 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -426,8 +426,8 @@ function convertCoordinatesForInput(coordinates) { return undefined; } - // Remove leading "+" from coordinates. - return coordinates.replace('+', ''); + // Remove the leading + from coordinates. + return coordinates.replace(/^\+/, ''); } // Fetch the server's version and add it to the page's title.