|
1
|
|
|
/*jslint |
|
2
|
|
|
indent: 4 |
|
3
|
|
|
*/ |
|
4
|
|
|
|
|
5
|
|
|
/*global |
|
6
|
|
|
$, document, gapi, setTimeout, |
|
7
|
|
|
CDDA, Coordinates, Freifunk, Hillshading, NPA, Okapi, Sidebar, Storage, |
|
8
|
|
|
DownloadGPX, Geolocation, |
|
9
|
|
|
showMulticoordinatesDialog, Markers |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
/* coordinate format */ |
|
14
|
|
|
function setCoordinatesFormat(t) { |
|
15
|
|
|
'use strict'; |
|
16
|
|
|
|
|
17
|
|
|
Storage.set('coordinatesFormat', t); |
|
18
|
|
|
|
|
19
|
|
|
if ($('#coordinatesFormat').val() !== t) { |
|
20
|
|
|
$('#coordinatesFormat').val(t); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
Coordinates.setFormat(t); |
|
24
|
|
|
Markers.update(); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
function restoreCoordinatesFormat(defaultValue) { |
|
29
|
|
|
'use strict'; |
|
30
|
|
|
|
|
31
|
|
|
var t = Storage.getString("coordinatesFormat", "DM"); |
|
32
|
|
|
|
|
33
|
|
|
if (t === "DM" || t === "DMS" || t === "D") { |
|
34
|
|
|
setCoordinatesFormat(t); |
|
35
|
|
|
} else { |
|
36
|
|
|
setCoordinatesFormat(defaultValue); |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/* info dialog */ |
|
42
|
|
|
function showInfoDialog() { |
|
43
|
|
|
'use strict'; |
|
44
|
|
|
|
|
45
|
|
|
$('#dlgInfo').modal({show: true, backdrop: "static", keyboard: true}); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
function showWhatsnewDialog() { |
|
50
|
|
|
'use strict'; |
|
51
|
|
|
|
|
52
|
|
|
$.getJSON("whatsnew.json", function (json) { |
|
53
|
|
|
var i, |
|
54
|
|
|
obj; |
|
55
|
|
|
$('#dlgWhatsnewList').empty(); |
|
56
|
|
|
for (i = 0; i < json.length; i += 1) { |
|
57
|
|
|
obj = json[i]; |
|
58
|
|
|
$('#dlgWhatsnewList').append("<li>" + obj.date + ": " + obj.text + "</li>"); |
|
59
|
|
|
} |
|
60
|
|
|
$('#dlgWhatsnew').modal({show: true, backdrop: "static", keyboard: true}); |
|
61
|
|
|
}); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
/* alert dialog */ |
|
66
|
|
|
function showAlert(title, msg) { |
|
67
|
|
|
'use strict'; |
|
68
|
|
|
|
|
69
|
|
|
$("#dlgAlertHeader").html(title); |
|
70
|
|
|
$("#dlgAlertMessage").html(msg); |
|
71
|
|
|
$("#dlgAlert").modal({show: true, backdrop: "static", keyboard: true}); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
/* projection dialog */ |
|
76
|
|
|
function showProjectionDialog(callback) { |
|
77
|
|
|
'use strict'; |
|
78
|
|
|
|
|
79
|
|
|
$('#projectionDialogOk').off('click'); |
|
80
|
|
|
$('#projectionDialogOk').click(function () { |
|
81
|
|
|
$('body').removeClass('modal-open'); |
|
82
|
|
|
$('.modal-backdrop').remove(); |
|
83
|
|
|
$('#projectionDialog').modal('hide'); |
|
84
|
|
|
if (callback) { |
|
85
|
|
|
setTimeout(function () { |
|
86
|
|
|
callback($("#projectionBearing").val(), $("#projectionDistance").val()); |
|
87
|
|
|
}, 10); |
|
88
|
|
|
} |
|
89
|
|
|
}); |
|
90
|
|
|
$("#projectionDialog").modal({show: true, backdrop: "static", keyboard: true}); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
/* permalink dialog */ |
|
95
|
|
|
function showLinkDialog(linkUrl) { |
|
96
|
|
|
'use strict'; |
|
97
|
|
|
|
|
98
|
|
|
$('#linkDialogLink').val(linkUrl); |
|
99
|
|
|
$('#linkDialog').modal({show: true, backdrop: "static", keyboard: true}); |
|
100
|
|
|
$('#linkDialogLink').select(); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
|
|
104
|
|
|
function linkDialogShortenLink() { |
|
105
|
|
|
'use strict'; |
|
106
|
|
|
|
|
107
|
|
|
var longUrl = $('#linkDialogLink').val(); |
|
108
|
|
|
gapi.client.setApiKey('AIzaSyC_KjqwiB6tKCcrq2aa8B3z-c7wNN8CTA0'); |
|
109
|
|
|
gapi.client.load('urlshortener', 'v1', function () { |
|
110
|
|
|
var request = gapi.client.urlshortener.url.insert({resource: {longUrl: longUrl}}); |
|
111
|
|
|
request.execute(function (resp) { |
|
112
|
|
|
if (resp.error) { |
|
113
|
|
|
$('#linkDialogError').html('Error: ' + resp.error.message); |
|
114
|
|
|
} else { |
|
115
|
|
|
$('#linkDialogLink').val(resp.id); |
|
116
|
|
|
$('#linkDialogLink').select(); |
|
117
|
|
|
} |
|
118
|
|
|
}); |
|
119
|
|
|
}); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
|
|
123
|
|
|
/* setup button events */ |
|
124
|
|
|
$(document).ready(function () { |
|
125
|
|
|
'use strict'; |
|
126
|
|
|
|
|
127
|
|
|
$("#sidebartoggle").click(function () { |
|
128
|
|
|
if ($('#sidebar').is(':visible')) { |
|
129
|
|
|
Sidebar.hide(); |
|
130
|
|
|
} else { |
|
131
|
|
|
Sidebar.show(); |
|
132
|
|
|
} |
|
133
|
|
|
}); |
|
134
|
|
|
$('#buttonWhereAmI').click(function () { |
|
135
|
|
|
Geolocation.whereAmI(); |
|
136
|
|
|
}); |
|
137
|
|
|
$("#hillshading").click(function () { |
|
138
|
|
|
Hillshading.toggle($('#hillshading').is(':checked')); |
|
139
|
|
|
}); |
|
140
|
|
|
$("#npa").click(function () { |
|
141
|
|
|
NPA.toggle($('#npa').is(':checked')); |
|
142
|
|
|
}); |
|
143
|
|
|
$("#cdda").click(function () { |
|
144
|
|
|
CDDA.toggle($('#cdda').is(':checked')); |
|
145
|
|
|
}); |
|
146
|
|
|
$("#geocaches").click(function () { |
|
147
|
|
|
Okapi.toggle($('#geocaches').is(':checked')); |
|
148
|
|
|
}); |
|
149
|
|
|
$('#coordinatesFormat').change(function () { |
|
150
|
|
|
setCoordinatesFormat($('#coordinatesFormat').val()); |
|
151
|
|
|
}); |
|
152
|
|
|
$("#freifunk").click(function () { |
|
153
|
|
|
Freifunk.toggle($('#freifunk').is(':checked')); |
|
154
|
|
|
}); |
|
155
|
|
|
$("#buttonUploadGPX").click(function (e) { |
|
156
|
|
|
$("#buttonUploadGPXinput").click(); |
|
157
|
|
|
e.preventDefault(); |
|
158
|
|
|
}); |
|
159
|
|
|
$("#buttonExportGPX").click(function () { |
|
160
|
|
|
DownloadGPX.initiateDownload(); |
|
161
|
|
|
}); |
|
162
|
|
|
$("#buttonMulticoordinates").click(function () { |
|
163
|
|
|
showMulticoordinatesDialog(); |
|
164
|
|
|
}); |
|
165
|
|
|
}); |
|
166
|
|
|
|