allow update for uploaded routes and implement creator id for routes
This commit is contained in:
@@ -3,6 +3,7 @@ globalThis.Wegwichtel ??= {};
|
||||
'use strict';
|
||||
const INTERVAL_MS = 30000;
|
||||
let id = null;
|
||||
let editingId = null;
|
||||
let status = 'idle';
|
||||
let timer = null;
|
||||
let generation = 0;
|
||||
@@ -79,9 +80,21 @@ globalThis.Wegwichtel ??= {};
|
||||
function start(routeId) {
|
||||
lastPosition = null;
|
||||
id = String(routeId);
|
||||
editingId = id;
|
||||
resume();
|
||||
}
|
||||
|
||||
function beginEditing(routeId) {
|
||||
if (editingId === String(routeId)) return;
|
||||
stop();
|
||||
start(routeId);
|
||||
}
|
||||
|
||||
function endEditing() {
|
||||
editingId = null;
|
||||
stop();
|
||||
}
|
||||
|
||||
function addPositionField(position = {}, index = null) {
|
||||
const container = document.getElementById('editor-recorded-positions');
|
||||
if (!container) return;
|
||||
@@ -132,6 +145,7 @@ globalThis.Wegwichtel ??= {};
|
||||
}
|
||||
|
||||
function bind() {
|
||||
globalThis.addEventListener?.('pagehide', endEditing);
|
||||
const activate = (elementId, action) => {
|
||||
const element = document.getElementById(elementId);
|
||||
element?.addEventListener('pointerup', event => {
|
||||
@@ -153,7 +167,7 @@ globalThis.Wegwichtel ??= {};
|
||||
});
|
||||
}
|
||||
|
||||
ns.RouteRecorder = Object.freeze({ start, pause, resume, stop, renderPoints, editGpx, get status() { return status; }, get routeId() { return id; }, get position() { return lastPosition; } });
|
||||
ns.RouteRecorder = Object.freeze({ start, pause, resume, stop, beginEditing, endEditing, renderPoints, editGpx, get status() { return status; }, get routeId() { return id; }, get position() { return lastPosition; } });
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', bind, { once: true });
|
||||
else bind();
|
||||
}(globalThis.Wegwichtel));
|
||||
|
||||
Reference in New Issue
Block a user