From a99600b708713cc15325dfd8d4888234dde1a839 Mon Sep 17 00:00:00 2001
From: MueJosh <145150281+MueJosh@users.noreply.github.com>
Date: Wed, 10 Jul 2024 16:36:59 +0200
Subject: [PATCH 1/3] Update index.html
Removing comma with dashes in the first row of all cells.
new export for CSV
removing quote marks so other programs can handle the data correctly
CSV = Comma-separated values and not quotation-seperated values
---
index.html | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/index.html b/index.html
index d0d11da..928ab24 100644
--- a/index.html
+++ b/index.html
@@ -77,7 +77,7 @@
- Version 1.11
+ Version 1.1
@@ -191,30 +191,31 @@
console.error(e);
return;
}
-
+
// With valid JSON, attempt to load waypoints and create list.
if (typeof data.timelineObjects == "undefined") {
alert("Invalid data: must contain 'timelineObjects' array.");
return;
}
-
+
// Iterate all objects inside timelineObjects, adding all 'placeVisit' objects as locations.
for (let d of data.timelineObjects) {
if (typeof d.placeVisit == "undefined") { continue; } // Skip this object.
const place = d.placeVisit;
-
+
// Load the object as a location:
let l = $("#lstLocations .location.template").clone(true);
$("#lstLocations").append(l);
-
+
l.removeClass('template');
l.prop('locationData', place); // Save the data structure with the object.
- l.find('.location-name').text(place.location.address);
+
+ // Replace commas with dashes in the first row cells
+ l.find('.location-name').text(place.location.address.replace(/,/g, '-'));
const start = moment(place.duration.startTimestamp);
const end = moment(place.duration.endTimestamp);
-
- l.find('.arrived').text(start.format('Y-M-D H:m:s'));
- l.find('.departed').text(end.format('Y-M-D H:m:s'));
+ l.find('.arrived').text(start.format('Y-M-D H:m:s').replace(/,/g, '-'));
+ l.find('.departed').text(end.format('Y-M-D H:m:s').replace(/,/g, '-'));
l.find('.duration').text(end.diff(start, 'minutes') + " min");
l.find('.longitude').text(place.location.longitudeE7 / 10000000.0);
l.find('.latitude').text(place.location.latitudeE7 / 10000000.0);
@@ -279,21 +280,21 @@
let results = "";
if (format === "csv") {
- results = `"Address","Arrival","Departure","Duration","Description"`;
+ results = "Address,Arrival,Departure,Duration,Description";
if (includeCoordinates) {
- results += `,"Longitude","Latitude"`;
+ results += ",Longitude,Latitude";
}
- results += `\n`;
+ results += "\n";
// Iterate location list, extracting all selected items.
$(".locations .location").not('.template').each(function() {
let el = $(this);
if (el.find('.selected').is(':checked')) {
- results += `"${el.find('.location-name').text()}","${el.find('.arrived').text()}","${el.find('.departed').text()}","${el.find('.duration').text()}","${el.find('.description').val()}"`;
+ results += `${el.find('.location-name').text()},${el.find('.arrived').text()},${el.find('.departed').text()},${el.find('.duration').text()},${el.find('.description').val()}`;
if (includeCoordinates) {
- results += `,"${el.find('.longitude').text()}","${el.find('.latitude').text()}"`;
+ results += `,${el.find('.longitude').text()},${el.find('.latitude').text()}`;
}
- results += `\n`;
+ results += "\n";
}
});
} else if (format === "gpx") {
@@ -324,10 +325,10 @@
}
// Return file:
- const blob = new Blob([results], { type: format === "csv" ? "text/csv": "application/xml" });
+ const blob = new Blob([results], { type: "text/csv" });
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
- link.download = `results.${format}`; // Corrected syntax for setting filename
+ link.download = `results.${format}`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
@@ -410,4 +411,3 @@