Skip to content

Commit

Permalink
files
Browse files Browse the repository at this point in the history
  • Loading branch information
strukturart committed Jan 1, 2024
1 parent 6d9336b commit 2b5577e
Show file tree
Hide file tree
Showing 19 changed files with 221 additions and 200 deletions.
3 changes: 2 additions & 1 deletion application/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
--color-seven: gainsboro;
--color-eight: rgb(241, 86, 24);
--color-ten: rgb(218, 229, 253);
--color-eleven: rgb(44, 83, 17);
}

*,
Expand Down Expand Up @@ -650,7 +651,7 @@ div#intro div#icon img {
}

div#intro div#icon {
background: var(--color-ten);
background: var(--color-eleven);
border-radius: 10px;
width: 70px;
display: block;
Expand Down
11 changes: 8 additions & 3 deletions application/assets/js/exportGeoJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const geojson = ((_) => {
if (type == "path") {
let p = geoJSON_group.toGeoJSON();
extData = JSON.stringify(p);
console.log(p);
}

if (type == "tracking") {
Expand Down Expand Up @@ -57,6 +56,8 @@ const geojson = ((_) => {
extData = JSON.stringify(collection);
}

console.log(extData);

let geojson_file = new Blob([extData], {
type: "application/json",
});
Expand Down Expand Up @@ -89,10 +90,14 @@ const geojson = ((_) => {
module.measure_distance("destroy");
}
helper.side_toaster("saved", 5000);
let filename = file_path_name.split("/");
filename = filename[filename.length - 1];
// files_.push({ name: filename, path: file_path_name, type: "geoJSON" });
};

requestAdd.onerror = function () {
helper.toaster(
requestAdd.onerror = function (e) {
console.log(e);
helper.side_toaster(
file_path_name +
" Unable to write the file, the file name may already be used",
10000
Expand Down
10 changes: 4 additions & 6 deletions application/assets/js/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ const maps = (() => {
let overlayer = "";

let addMap = function (url, attribution, max_zoom, type) {
if (attribution == null) attribution = "";
if (max_zoom == null) max_zoom = 12;
//remove layer
if (url == "") {
if (map.hasLayer(tilesLayer)) {
Expand Down Expand Up @@ -325,13 +327,9 @@ const maps = (() => {
if (overpass_query == url) {
overpass.call(map, url, "climbing_icon");
general.active_layer.splice(general.active_layer.indexOf(url), 1);
return false;
}

map.setZoom(14);
setTimeout(function () {
} else {
overpass.call(map, url, "climbing_icon");
}, 1000);
}
}
};

Expand Down
37 changes: 21 additions & 16 deletions application/assets/js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,21 @@ const module = (() => {
////////////////////
// Flag to keep track of the need
// of generating the new marker list
var f_upd_markers_list = true;
let set_f_upd_markers = function () {
f_upd_markers_list = true;
let markers_updated = function () {
marker_list_updated = false;
};

let marker_list_updated = false;

let markers_collection = []; //makers in map boundingbox
let l = [];
let index = -1;
let select_marker = function () {
if (f_upd_markers_list) {
index++;

if (marker_list_updated == false) {
// Reset contained list
markers_collection = [];

//merge markers in viewport
if (overpass_group != "") {
overpass_group.eachLayer(function (l) {
markers_collection.push(l);
Expand All @@ -402,14 +403,13 @@ const module = (() => {
markers_collection.push(l);
});

// Clear flag
f_upd_markers_list = false;
marker_list_updated = true;
}

status.marker_selection = true;
status.windowOpen = "marker";

index++;
console.log(markers_collection, index);

if (index >= markers_collection.length) index = 0;
map.setView(markers_collection[index]._latlng, map.getZoom());
Expand Down Expand Up @@ -461,6 +461,7 @@ const module = (() => {
}
return markers_collection[index];
};

//remove GPX
let remove_gpx = function () {
let i = 0;
Expand Down Expand Up @@ -523,7 +524,9 @@ const module = (() => {

let update_gpx_info = function () {
document.getElementById("gpx-name").innerText = gpx_selection_info.name;
document.getElementById("gpx-time").innerText = format_ms(gpx_selection_info.duration);
document.getElementById("gpx-time").innerText = format_ms(
gpx_selection_info.duration
);

document.querySelector("#gpx-evo-up span").innerText =
gpx_selection_info.elevation_gain.toFixed(2);
Expand Down Expand Up @@ -732,7 +735,7 @@ const module = (() => {
if (altitudeDifference > 0) {
gain += altitudeDifference;
} else {
loss += Math.abs(altitudeDifference);
loss += Math.abs(altitudeDifference);
}
}
}
Expand Down Expand Up @@ -813,9 +816,12 @@ const module = (() => {
document.querySelector("#tracking-view .average-speed div").innerText =
isNaN(tracking.speed_average) ? "-" : tracking.speed_average;

document.querySelector("#tracking-evo-down span").innerText = tracking.loss.toFixed(2);
document.querySelector("#tracking-evo-up span").innerText = tracking.gain.toFixed(2);
document.getElementById("tracking-altitude").innerText = tracking.altitude.toFixed(2);
document.querySelector("#tracking-evo-down span").innerText =
tracking.loss.toFixed(2);
document.querySelector("#tracking-evo-up span").innerText =
tracking.gain.toFixed(2);
document.getElementById("tracking-altitude").innerText =
tracking.altitude.toFixed(2);

document.querySelector("#tracking-speed-average-time").innerText = isNaN(
tracking.speed_average
Expand Down Expand Up @@ -928,7 +934,6 @@ const module = (() => {

if (mainmarker.device_alt && !isNaN(mainmarker.device_alt)) {
alt = mainmarker.device_alt;
// tracking_altitude.push(alt);
}

polyline_tracking.addLatLng([
Expand Down Expand Up @@ -1191,7 +1196,7 @@ const module = (() => {
return {
hotline,
convert_units,
set_f_upd_markers,
markers_updated,
select_marker,
select_gpx,
calc_distance,
Expand Down
35 changes: 16 additions & 19 deletions application/assets/js/osm.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ const osm = (() => {
}
};

const get_user = function () {
if (!general.osm_token) {
const get_user = function (notification = true) {
if (!general.osm_token && notification) {
helper.side_toaster(
"looks like you are not connected to openstreetmap",
5000
Expand Down Expand Up @@ -246,7 +246,7 @@ const osm = (() => {
///List files
/////////////

let osm_server_list_gpx = function () {
let osm_server_list_gpx = function (callback) {
let n = "Bearer " + localStorage.getItem("openstreetmap_token");

const myHeaders = new Headers({
Expand All @@ -272,8 +272,12 @@ const osm = (() => {
id: s[i].getAttribute("id"),
};

files.push({ name: m.name, id: m.id, type: "osm_sever" });
files_.push({ name: m.name, id: m.id, type: "osm_sever" });
files.push({
name: "_" + m.name,
path: m.id,
id: m.id,
type: "osm_sever",
});

files.sort((a, b) => {
return b.name.localeCompare(a.name);
Expand All @@ -287,8 +291,12 @@ const osm = (() => {
id: s[i].getAttribute("id"),
};

files.push({ name: m.name, id: m.id, type: "osm_sever" });
files_.push({ name: m.name, id: m.id, type: "osm_sever" });
files.push({
name: m.name,
path: m.id,
id: m.id,
type: "osm_sever",
});

files.sort((a, b) => {
return b.name.localeCompare(a.name);
Expand All @@ -298,18 +306,7 @@ const osm = (() => {
}
}
}
files.forEach((e) => {
document
.querySelector("div#osm-server-gpx")
.insertAdjacentHTML(
"afterend",
'<div class="item" data-id=' +
e.id +
' data-map="gpx-osm">' +
e.name +
"</div>"
);
});
callback(files);
})

.catch((error) => {
Expand Down
16 changes: 9 additions & 7 deletions application/assets/js/overpass.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const overpass = (() => {
function call(map, overpassQuery, icon) {
console.log(general.zoomlevel);
//clear group before ad new items

if (general.zoomlevel > 13) {
helper.side_toaster(
"Please zoom, otherwise too much data will be loaded",
2000
);
return false;
}
if (overpass_group != "") {
overpass_group.clearLayers();
contained = [];
Expand Down Expand Up @@ -42,10 +49,6 @@ const overpass = (() => {
fetch(resultUrl)
.then((response) => response.json())
.then(function (data) {
if (!data) {
return false;
}

let no_data = false;
data.elements.forEach((element) => {
if (element.type == "node") {
Expand All @@ -54,9 +57,8 @@ const overpass = (() => {
.addTo(overpass_group)
.setIcon(maps[icon]);
try {
} catch (e) {
k.bindPopup(element.tags.name);
}
} catch (e) {}
}
});

Expand Down
3 changes: 2 additions & 1 deletion application/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,6 @@ <h2>Thank You!</h2>
<script src="http://127.0.0.1/api/v1/apps/service.js"></script>

<script defer src="assets/js/keepalive.js"></script>
<script defer src="assets/js/osm.js"></script>

<script defer src="assets/js/suncalc.js"></script>
<script defer src="assets/js/jsQR.js"></script>
Expand All @@ -883,8 +882,10 @@ <h2>Thank You!</h2>
<script defer src="assets/js/L.TileLayer.PouchDBCached.js"></script>
<script defer src="assets/js/gpx.js"></script>
<script defer src="assets/js/route-service.js"></script>
<script defer src="assets/js/osm.js"></script>

<script defer src="index.js"></script>

<script defer src="assets/js/overpass.js"></script>

<script defer src="assets/js/module.js"></script>
Expand Down
Loading

0 comments on commit 2b5577e

Please sign in to comment.