1
|
|
|
/*jslint |
2
|
|
|
indent: 4 |
3
|
|
|
*/ |
4
|
|
|
|
5
|
|
|
/*global |
6
|
|
|
$, document, gapi, setTimeout, |
7
|
|
|
CDDA, Cookies, Coordinates, Freifunk, Hillshading, NPA, Okapi, Sidebar, |
8
|
|
|
showMulticoordinatesDialog, Markers, get_cookie_string |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
///* boundaries layer */ |
12
|
|
|
//function toggleBoundaries(t) |
13
|
|
|
//{ |
14
|
|
|
// Cookies.set('boundaries', t ? "1" : "0", {expires:30}); |
15
|
|
|
// |
16
|
|
|
// if ($('#boundaries').is(':checked') != t) |
17
|
|
|
// { |
18
|
|
|
// $('#boundaries').attr('checked', t); |
19
|
|
|
// } |
20
|
|
|
// |
21
|
|
|
// if( boundariesLayerShown == t ) return; |
22
|
|
|
// boundariesLayerShown = t; |
23
|
|
|
// |
24
|
|
|
// if (t) { |
25
|
|
|
// map.overlayMapTypes.push(boundariesLayer); |
26
|
|
|
// } else { |
27
|
|
|
// map.overlayMapTypes.removeAt(map.overlayMapTypes.indexOf(boundariesLayer)); |
28
|
|
|
// } |
29
|
|
|
//} |
30
|
|
|
// |
31
|
|
|
//function restoreBoundaries(defaultValue) |
32
|
|
|
//{ |
33
|
|
|
// var state = get_cookie_string("boundaries", "invalid"); |
34
|
|
|
// |
35
|
|
|
// if (state == "0") |
36
|
|
|
// { |
37
|
|
|
// toggleBoundaries(false); |
38
|
|
|
// } |
39
|
|
|
// else if (state == "1") |
40
|
|
|
// { |
41
|
|
|
// toggleBoundaries(true); |
42
|
|
|
// } |
43
|
|
|
// else |
44
|
|
|
// { |
45
|
|
|
// toggleBoundaries(defaultValue); |
46
|
|
|
// } |
47
|
|
|
//} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/* coordinate format */ |
51
|
|
|
function setCoordinatesFormat(t) { |
52
|
|
|
'use strict'; |
53
|
|
|
|
54
|
|
|
Cookies.set('coordinatesFormat', t, {expires: 30}); |
55
|
|
|
|
56
|
|
|
if ($('#coordinatesFormat').val() !== t) { |
57
|
|
|
$('#coordinatesFormat').val(t); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
Coordinates.setFormat(t); |
61
|
|
|
Markers.update(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
function restoreCoordinatesFormat(defaultValue) { |
66
|
|
|
'use strict'; |
67
|
|
|
|
68
|
|
|
var t = get_cookie_string("coordinatesFormat", "DM"); |
69
|
|
|
|
70
|
|
|
if (t === "DM" || t === "DMS" || t === "D") { |
71
|
|
|
setCoordinatesFormat(t); |
72
|
|
|
} else { |
73
|
|
|
setCoordinatesFormat(defaultValue); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
/* info dialog */ |
79
|
|
|
function showInfoDialog() { |
80
|
|
|
'use strict'; |
81
|
|
|
|
82
|
|
|
$('#dlgInfoAjax').modal({show : true, backdrop: "static", keyboard: true}); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
/* alert dialog */ |
87
|
|
|
function showAlert(title, msg) { |
88
|
|
|
'use strict'; |
89
|
|
|
|
90
|
|
|
$("#dlgAlertHeader").html(title); |
91
|
|
|
$("#dlgAlertMessage").html(msg); |
92
|
|
|
$("#dlgAlert").modal({show : true, backdrop: "static", keyboard: true}); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
/* projection dialog */ |
97
|
|
|
function showProjectionDialog(callback) { |
98
|
|
|
'use strict'; |
99
|
|
|
|
100
|
|
|
$('#projectionDialogOk').off('click'); |
101
|
|
|
$('#projectionDialogOk').click(function () { |
102
|
|
|
$('body').removeClass('modal-open'); |
103
|
|
|
$('.modal-backdrop').remove(); |
104
|
|
|
$('#projectionDialog').modal('hide'); |
105
|
|
|
if (callback) { |
106
|
|
|
setTimeout(function () { |
107
|
|
|
callback($("#projectionBearing").val(), $("#projectionDistance").val()); |
108
|
|
|
}, 10); |
109
|
|
|
} |
110
|
|
|
}); |
111
|
|
|
$("#projectionDialog").modal({show : true, backdrop: "static", keyboard: true}); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
/* permalink dialog */ |
116
|
|
|
function showLinkDialog(linkUrl) { |
117
|
|
|
'use strict'; |
118
|
|
|
|
119
|
|
|
$('#linkDialogLink').val(linkUrl); |
120
|
|
|
$('#linkDialog').modal({show : true, backdrop: "static", keyboard: true}); |
121
|
|
|
$('#linkDialogLink').select(); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
|
125
|
|
|
function linkDialogShortenLink() { |
126
|
|
|
'use strict'; |
127
|
|
|
|
128
|
|
|
var longUrl = $('#linkDialogLink').val(); |
129
|
|
|
gapi.client.setApiKey('AIzaSyC_KjqwiB6tKCcrq2aa8B3z-c7wNN8CTA0'); |
130
|
|
|
gapi.client.load('urlshortener', 'v1', function () { |
131
|
|
|
var request = gapi.client.urlshortener.url.insert({'resource': {'longUrl': longUrl}}); |
132
|
|
|
request.execute(function (resp) { |
133
|
|
|
if (resp.error) { |
134
|
|
|
$('#linkDialogError').html('Error: ' + resp.error.message); |
135
|
|
|
} else { |
136
|
|
|
$('#linkDialogLink').val(resp.id); |
137
|
|
|
$('#linkDialogLink').select(); |
138
|
|
|
} |
139
|
|
|
}); |
140
|
|
|
}); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
//function showHillshadingDialog() |
144
|
|
|
//{ |
145
|
|
|
// $('#dialogHillshading').modal({show : true, backdrop: "static", keyboard: true}); |
146
|
|
|
//} |
147
|
|
|
|
148
|
|
|
//function showBoundariesDialog() |
149
|
|
|
//{ |
150
|
|
|
// $('#dialogBoundaries').modal({show : true, backdrop: "static", keyboard: true}); |
151
|
|
|
//} |
152
|
|
|
|
153
|
|
|
|
154
|
|
|
/* setup button events */ |
155
|
|
|
$(document).ready(function () { |
156
|
|
|
'use strict'; |
157
|
|
|
|
158
|
|
|
$("#sidebartoggle").click(function () { if ($('#sidebar').is(':visible')) { Sidebar.hide(); } else { Sidebar.show(); } }); |
159
|
|
|
//$('#buttonWhereAmI').click(function () { Geolocation.whereAmI(); }); |
160
|
|
|
$("#hillshading").click(function () { Hillshading.toggle($('#hillshading').is(':checked')); }); |
161
|
|
|
//$("#boundaries").click(function () { toggleBoundaries($('#boundaries').is(':checked')); }); |
162
|
|
|
$("#npa").click(function () { NPA.toggle($('#npa').is(':checked')); }); |
163
|
|
|
$("#cdda").click(function () { CDDA.toggle($('#cdda').is(':checked')); }); |
164
|
|
|
$("#geocaches").click(function () { Okapi.toggle($('#geocaches').is(':checked')); }); |
165
|
|
|
$('#coordinatesFormat').change(function () { setCoordinatesFormat($('#coordinatesFormat').val()); }); |
166
|
|
|
$("#freifunk").click(function () { Freifunk.toggle($('#freifunk').is(':checked')); }); |
167
|
|
|
$("#buttonUploadGPX").click(function (e) { $("#buttonUploadGPXinput").click(); e.preventDefault(); }); |
168
|
|
|
$("#buttonExportGPX").click(function () { DownloadGPX.initiateDownload(); }); |
|
|
|
|
169
|
|
|
$("#buttonMulticoordinates").click(function () { showMulticoordinatesDialog(); }); |
170
|
|
|
}); |
171
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.