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 // @namespace https://greasyfork.org/users/583371
// @description Allow the user to upload multiple files at once and more than 1000 waypoints // @description Allow the user to upload multiple files at once and more than 1000 waypoints
// @grant none // @grant none
// @version 3.1 // @version 3.1.1
// @author Franzz // @author Franzz
// @license GNU GPLv3
// @match https://www.gaiagps.com/map/* // @match https://www.gaiagps.com/map/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
// ==/UserScript== // ==/UserScript==
@@ -305,17 +306,18 @@ class Gaia {
} }
feedback(sType, sMsg) { 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); 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.append($('<p>', {'style': 'color: '+sColor+';'}).text(sFormattedMsg));
this.$Feedback.scrollTop(this.$Feedback.prop("scrollHeight")); this.$Feedback.scrollTop(this.$Feedback.prop("scrollHeight"));
} }
@@ -658,13 +660,15 @@ class Gaia {
iIndex++; iIndex++;
this.incProgress(); this.incProgress();
if(iIndex < this.aoWaypoints.length) this.uploadWayPoints(iIndex); if(iIndex < this.aoWaypoints.length) this.uploadWayPoints(iIndex);
else this.assignElementsToFolders(); //else this.assignElementsToFolders();
else this.feedback('info', 'Done');
}).fail(() => { }).fail(() => {
this.feedback('error', 'Failed to upload waypoint #'+(iIndex + 1)+' "'+asWaypoint.properties.title+'" (Stage 2). Trying again...'); this.feedback('error', 'Failed to upload waypoint #'+(iIndex + 1)+' "'+asWaypoint.properties.title+'" (Stage 2). Trying again...');
this.confirmWayPoint(iIndex, asWaypoint, sPostedData); this.confirmWayPoint(iIndex, asWaypoint, sPostedData);
}); });
} }
/*
assignElementsToFolders(iIndex) { assignElementsToFolders(iIndex) {
iIndex = iIndex || 0; iIndex = iIndex || 0;
let asFolders = Object.keys(this.asFolders).map(key => this.asFolders[key]); let asFolders = Object.keys(this.asFolders).map(key => this.asFolders[key]);
@@ -710,6 +714,7 @@ class Gaia {
this.assignElementsToFolders(iIndex); this.assignElementsToFolders(iIndex);
}); });
} }
*/
static getIconName(sGarminName) { static getIconName(sGarminName) {
var asMapping = { 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(); let oGaia = new Gaia();
MutationObserver = window.MutationObserver || window.WebKitMutationObserver; MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
@@ -759,10 +764,6 @@ let observer = new MutationObserver((mutations, observer) => {
observer.disconnect(); observer.disconnect();
$Import.parent('li').on('click', () => { setTimeout(() => { oGaia.setLayout(); }, 500)}); $Import.parent('li').on('click', () => { setTimeout(() => { oGaia.setLayout(); }, 500)});
} }
}); });
observer.observe(document, { observer.observe(document, { subtree: true, attributes: true});
subtree: true,
attributes: true
});