gaia uploader v3.1.1

This commit is contained in:
2022-02-07 19:22:28 +01:00
parent 7188174ccb
commit b9a63caa2a

View File

@@ -3,8 +3,9 @@
// @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
// @version 3.1.1
// @author Franzz
// @license GNU GPLv3
// @match https://www.gaiagps.com/map/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
// ==/UserScript==
@@ -109,13 +110,13 @@ gpxParser.prototype.parse = function (gpxstring) {
route.cmt = keepThis.getElementValue(rte, "cmt");
route.desc = keepThis.getElementValue(rte, "desc");
route.src = keepThis.getElementValue(rte, "src");
route.number = keepThis.getElementValue(rte, "number");
route.number= keepThis.getElementValue(rte, "number");
let type = keepThis.queryDirectSelector(rte, "type");
route.type = type != null ? type.innerHTML : null;
let link = {};
let linkElem = rte.querySelector('link');
let linkElem= rte.querySelector('link');
if(linkElem != null){
link.href = linkElem.getAttribute('href');
link.text = keepThis.getElementValue(linkElem, "text");
@@ -159,7 +160,7 @@ gpxParser.prototype.parse = function (gpxstring) {
track.cmt = keepThis.getElementValue(trk, "cmt");
track.desc = keepThis.getElementValue(trk, "desc");
track.src = keepThis.getElementValue(trk, "src");
track.number = keepThis.getElementValue(trk, "number");
track.number= keepThis.getElementValue(trk, "number");
track.color = keepThis.getElementValue(trk, "DisplayColor");
track.time = keepThis.metadata.time;
@@ -167,7 +168,7 @@ gpxParser.prototype.parse = function (gpxstring) {
track.type = type != null ? type.innerHTML : null;
let link = {};
let linkElem = trk.querySelector('link');
let linkElem= trk.querySelector('link');
if(linkElem != null){
link.href = linkElem.getAttribute('href');
link.text = keepThis.getElementValue(linkElem, "text");
@@ -305,17 +306,18 @@ class Gaia {
}
feedback(sType, sMsg) {
var sFormattedMsg = sType.charAt(0).toUpperCase()+sType.slice(1)+': '+sMsg+(sMsg.slice(-1)=='.'?'':'.');
let sColor = 'black';
let sIcon = '';
switch(sType) {
case 'error': sColor = 'red'; sIcon = '\u274C'; break;
case 'warning': sColor = 'orange'; sIcon = '\u26A0'; break;
case 'info': sColor = '#2D5E38'; sIcon = '\u2713'; break;
}
var sFormattedMsg = sIcon+' '+sMsg+(sMsg.slice(-1)=='.'?'':'.');
console.log(sFormattedMsg);
let sColor = 'black';
switch(sType) {
case 'error': sColor = 'red'; break;
case 'warning': sColor = 'orange'; break;
case 'info': sColor = '#2D5E38'; break;
}
this.$Feedback.append($('<p>', {'style': 'color: '+sColor+';'}).text(sFormattedMsg));
this.$Feedback.scrollTop(this.$Feedback.prop("scrollHeight"));
}
@@ -658,13 +660,15 @@ class Gaia {
iIndex++;
this.incProgress();
if(iIndex < this.aoWaypoints.length) this.uploadWayPoints(iIndex);
else this.assignElementsToFolders();
//else this.assignElementsToFolders();
else this.feedback('info', 'Done');
}).fail(() => {
this.feedback('error', 'Failed to upload waypoint #'+(iIndex + 1)+' "'+asWaypoint.properties.title+'" (Stage 2). Trying again...');
this.confirmWayPoint(iIndex, asWaypoint, sPostedData);
});
}
/*
assignElementsToFolders(iIndex) {
iIndex = iIndex || 0;
let asFolders = Object.keys(this.asFolders).map(key => this.asFolders[key]);
@@ -710,6 +714,7 @@ class Gaia {
this.assignElementsToFolders(iIndex);
});
}
*/
static getIconName(sGarminName) {
var asMapping = {
@@ -746,7 +751,7 @@ class Gaia {
}
}
console.log('Loading GaiaGps Uploader 3.1');
console.log('Loading GaiaGps Uploader 3.1.1');
let oGaia = new Gaia();
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
@@ -759,10 +764,6 @@ let observer = new MutationObserver((mutations, observer) => {
observer.disconnect();
$Import.parent('li').on('click', () => { setTimeout(() => { oGaia.setLayout(); }, 500)});
}
});
observer.observe(document, {
subtree: true,
attributes: true
});
observer.observe(document, { subtree: true, attributes: true});