diff --git a/gaia/upload.js b/gaia/upload.js
index 46cddd1..f56845d 100644
--- a/gaia/upload.js
+++ b/gaia/upload.js
@@ -3,7 +3,7 @@
// @namespace https://greasyfork.org/users/583371
// @description Allow the user to upload multiple files at once and more than 1000 waypoints
// @grant none
-// @version 3.1.1
+// @version 3.1.2
// @author Franzz
// @license GNU GPLv3
// @match https://www.gaiagps.com/map/*
@@ -213,12 +213,18 @@ gpxParser.prototype.parse = function (gpxstring) {
gpxParser.prototype.getElementValue = function(parent, needle){
let elem = parent.querySelector(needle);
if(elem != null){
- return elem.innerHTML != undefined ? elem.innerHTML : elem.childNodes[0].data;
+ //Get value (in case of CDATA)
+ let sValue = (elem.innerHTML != undefined && elem.innerHTML.substring(0, 8) != '').html(sValue).text();
+
+ //Strip HTML tags & trim value
+ return $('
').html(sValue).text().trim();
}
return elem;
};
-
/**
* Search the value of a direct child XML DOM element
*
@@ -252,6 +258,10 @@ class Gaia {
static get API() { return Gaia.URL+'/api/objects'; }
constructor() {
+ this.reset();
+ }
+
+ reset() {
this.asFiles = [];
this.aoWaypoints = [];
this.aoTracks = [];
@@ -260,6 +270,7 @@ class Gaia {
}
setLayout() {
+ this.reset();
/* FIXME: adapts on GaiaGPS upgrade */
let $InputButton = $('a[href="https://help.gaiagps.com/hc/en-us/articles/360052763513"]').parent().find('button');
@@ -389,7 +400,7 @@ class Gaia {
this.asFolders[oFileReader.name] = {};
if(iCount == this.asFiles.length) {
- this.progress.total = this.aoTracks.length + this.aoWaypoints.length + this.asFiles.length * 2; //2 extra actions per file: Create folder + Assign objects to folder
+ this.progress.total = this.aoTracks.length + this.aoWaypoints.length + this.asFiles.length; //extra action per file: Create folder
this.createFolders();
}
};
@@ -718,40 +729,42 @@ class Gaia {
static getIconName(sGarminName) {
var asMapping = {
- 'Trail Head': 'trailhead',
- 'Water Source': 'water-24.png',
- 'Truck': 'car-24.png',
- 'Post Office': 'resupply',
- 'Flag, Blue': 'blue-pin-down.png',
- 'Car': 'car-24.png',
- 'Flag, Red': 'red-pin-down.png',
- 'Campground': 'campsite-24.png',
- 'Flag, Green': 'green-pin.png',
- 'Powerline': 'petroglyph',
- 'Shopping Center': 'cafe-24.png',
- 'Lodging': 'lodging-24.png',
- 'Water Hydrant': 'red-pin-down.png',
+ 'Bridge': 'bridge',
+ 'Campground': 'campsite-24',
+ 'Car': 'car-24',
+ 'Cemetery': 'cemetery-24',
+ 'Church': 'ghost-town',
+ 'City (Capitol)': 'city-24',
+ 'Convenience Store': 'market',
'Drinking Water': 'potable-water',
- 'Toll Booth': 'ranger-station',
- 'Summit': 'peak',
- 'Park': 'park-24.png',
+ 'Flag, Blue': 'blue-pin-down',
+ 'Flag, Green': 'green-pin',
+ 'Flag, Red': 'red-pin-down',
'Forest': 'forest',
- 'Cemetery': 'cemetery-24.png',
- 'Bridge': 'dam-24.png',
- 'Restaurant': 'restaurant-24.png',
+ 'Ground Transportation': 'car-24',
+ 'Lodging': 'lodging-24',
+ 'Park': 'park-24',
+ 'Pharmacy': 'hospital-24',
'Picnic Area': 'picnic',
- 'Residence': 'city-24.png',
- 'City (Capitol)': 'city-24.png',
- 'Ski Resort': 'skiing-24.png',
- 'Restroom': 'toilets-24.png',
- 'Ground Transportation': 'car-24.png',
- 'Church': 'ghost-town'
+ 'Post Office': 'resupply',
+ 'Powerline': 'petroglyph',
+ 'Residence': 'building-24',
+ 'Restaurant': 'restaurant-24',
+ 'Restroom': 'toilets-24',
+ 'Shopping Center': 'market',
+ 'Ski Resort': 'skiing-24',
+ 'Summit': 'peak',
+ 'Toll Booth': 'ranger-station',
+ 'Trail Head': 'known-route',
+ 'Truck': 'car-24',
+ 'Water Source': 'water-24'
};
- return (sGarminName in asMapping)?asMapping[sGarminName]:'red-pin-down.png';
+ return (sGarminName in asMapping)?asMapping[sGarminName]:'red-pin-down';
}
}
-console.log('Loading GaiaGps Uploader 3.1.1');
+console.log('Loading GaiaGps Uploader '+GM_info.script.version);
+
let oGaia = new Gaia();
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;