X-Git-Url: https://git-public.kairo.at/?p=lantea.git;a=blobdiff_plain;f=js%2Fui.js;h=187a84d6663b674619ab7a710ea562990dbc7aff;hp=74ea52115a812755d228aa88cd1f70a5ca5854ba;hb=99631a7543656fb58fe3c7f7913773d49630db03;hpb=23cd2dcceff47d3ff6156c6c4fba913f2ee2f9b9 diff --git a/js/ui.js b/js/ui.js index 74ea521..187a84d 100644 --- a/js/ui.js +++ b/js/ui.js @@ -35,4 +35,65 @@ * * ***** END LICENSE BLOCK ***** */ +window.onload = function() { + var mSel = document.getElementById("mapSelector"); + for (var mapStyle in gMapStyles) { + var opt = document.createElement("option"); + opt.value = mapStyle; + opt.text = gMapStyles[mapStyle].name; + mSel.add(opt, null); + } + initMap(); + resizeAndDraw(); + startTracking(); +} + +window.onresize = function() { + resizeAndDraw(); +} + +function toggleSettings() { + var fs = document.getElementById("settings"); + if (fs.style.display != "block") { + fs.style.display = "block"; + } + else { + fs.style.display = "none"; + } +} + +function makeISOString(aTimestamp) { + // ISO time format is YYYY-MM-DDTHH:mm:ssZ + var tsDate = new Date(aTimestamp); + return tsDate.getUTCFullYear() + "-" + + (tsDate.getUTCMonth() < 10 ? "0" : "") + tsDate.getUTCMonth() + "-" + + (tsDate.getUTCDate() < 10 ? "0" : "") + tsDate.getUTCDate() + "T" + + (tsDate.getUTCHours() < 10 ? "0" : "") + tsDate.getUTCHours() + ":" + + (tsDate.getUTCMinutes() < 10 ? "0" : "") + tsDate.getUTCMinutes() + ":" + + (tsDate.getUTCSeconds() < 10 ? "0" : "") + tsDate.getUTCSeconds() + "Z"; +} + +function saveTrack() { + if (gTrack.length) { + var out = '' + "\n\n"; + out += '' + "\n"; + out += ' ' + "\n"; + out += ' ' + "\n"; + for (var i = 0; i < gTrack.length; i++) { + out += ' ' + "\n"; + if (gTrack[i].coords.altitude) { + out += ' ' + gTrack[i].coords.altitude + '' + "\n"; + } + out += ' ' + "\n"; + out += ' ' + "\n"; + gTrack[i].coords.latitude, gTrack[i].coords.longitude; + } + out += ' ' + "\n"; + out += ' ' + "\n"; + out += '' + "\n"; + var outDataURI = "data:application/octet-stream," + encodeURIComponent(out); + window.open(outDataURI, 'GPX Track'); + } +}