-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfgmap_menu.js
More file actions
467 lines (383 loc) · 18 KB
/
fgmap_menu.js
File metadata and controls
467 lines (383 loc) · 18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
/*
* FGMapMenu
*
* Pigeon <pigeon at pigeond dot net>
*
* GPLv2, see LICENSE file for details
*/
/*
* @param id the FGMap object
*/
function FGMapMenu(fgmap) {
this.id = "FGMapMenu";
this.fgmap = fgmap;
this.div = fgmap.div;
this.init();
// Preload images
this.preload1 = new Image();
this.preload1.src = "images/link_active.gif";
}
FGMapMenu.prototype.init = function() {
var html;
var elem;
// FIXME
var menu_height = "160px";
/* The whole menu container */
elem = this.menu_container = element_create(this.div, "div");
elem.style.position = "absolute";
elem.style.bottom = "0px";
elem.style.width = "50%";
elem.style.color = "#fff";
//elem.style.backgroundColor = "transparent";
elem.style.overflow = "hidden";
element_opacity_set(elem, 0.8);
//element_event_bubble_cancel(elem);
html = "";
html += "<b class=\"mh\">";
html += "<b class=\"m1\"></b>";
html += "<b class=\"m2\"></b>";
html += "<b class=\"m3\"></b>";
html += "<b class=\"m4\"></b>";
html += "<b class=\"m5\"></b>";
html += "</b>";
elem.innerHTML = html;
/* menu title container */
elem = this.menu_title_container =
element_create(this.menu_container, "div");
elem.className = "fgmap_menu_title";
elem.style.textAlign = "center";
elem.style.paddingTop = "2px";
elem.style.paddingBottom = "4px";
elem.style.overflow = "hidden";
elem.style.fontWeight = "bold";
var span = this.menu_title_span = element_create(elem, "span");
span.className = "fgmap_menu_title";
span.style.cursor = "pointer";
span.style.padding = "0px";
span.style.margin = "0px";
span.title = "Click here to bring up the menu";
attach_event(span, "click", this.menu_visible_toggle.bind_event(this));
/* Just because stupid IE doesn't support CSS properly... */
attach_event(span, "mouseover",
this.menu_title_mouse_event_cb.bind_event(this));
attach_event(span, "mouseout",
this.menu_title_mouse_event_cb.bind_event(this));
elem = element_create(span, "span");
elem.className = "fgmap_title_label";
elem.innerHTML = "FGMap | ";
elem = this.menu_title_server =
element_create(span, "span");
elem.className = "fgmap_title_value";
elem.innerHTML = "(none)";
elem = element_create(span, "span");
elem.className = "fgmap_v_separator";
elem.innerHTML = " | ";
elem = element_create(span, "span");
elem.className = "fgmap_title_label";
elem.innerHTML = "pilots: ";
elem = this.menu_title_pilots =
element_create(span, "span");
elem.className = "fgmap_title_value";
elem.innerHTML = "-";
var anchor = this.linktomap =
element_create(this.menu_title_container, "a");
anchor.style.position = "absolute";
anchor.style.right = "0px";
anchor.style.top = "0px";
anchor.style.padding = "4px 8px 0px 0px";
anchor.style.cursor = "pointer";
anchor.title = "Link to this map";
var elem = element_create(anchor, "img");
elem.src = "images/link.gif";
elem.style.width = "16px";
elem.style.height = "16px";
elem.title = "Link to this map";
elem.alt = "Link to this map";
elem.style.border = "0px";
//img_ie_fix(elem);
attach_event(elem, "mouseover", function(e) {
var target = target_get(e || window.event);
target.src = "images/link_active.gif";
//img_ie_fix(target);
});
attach_event(elem, "mouseout", function(e) {
var target = target_get(e || window.event);
target.src = "images/link.gif";
//img_ie_fix(target);
});
/* menu body part */
elem = this.menu_body = element_create(this.menu_container, "div");
elem.className = "fgmap_menu";
elem.style.overflow = "hidden";
elem.style.width = "100%";
elem.style.height = menu_height;
elem.style.maxHeight = menu_height;
elem.style.display = "none"; // FIXME
elem.style.paddingTop = "2px";
elem.style.paddingBottom = "5px";
elem.style.borderTop = "1px dotted #fff";
this.tabdiv = new FGTabbedDiv(this.menu_body);
/* menu body content part */
/*
elem = this.menu_content = element_create(this.menu_body, "div");
elem.className = "fgmap_menu";
elem.style.position = "relative";
elem.style.overflow = "hidden";
elem.style.width = "100%";
elem.style.height = "90%";
*/
/* menu body tabs */
/*
elem = this.menu_tabs = element_create(this.menu_body, "div");
elem.setAttribute("id", "fgmap_menu_tabs");
elem.className = "fgmap_menu";
elem.style.position = "relative";
elem.style.height = "auto";
elem.style.width = "100%";
elem.style.textAlign = "left";
elem.style.whiteSpace = "nowrap";
elem.style.overflow = "hidden";
elem.style.paddingTop = "1px";
elem.style.paddingBottom = "6px";
*/
this.map_resize_cb();
this.fgmap.event_callback_add(FGMAP_EVENT_MAP_RESIZE,
this.map_resize_cb.bind_event(this), null);
// TODO
if(this.fgmap.fg_server_current != null) {
this.server_changed_cb(FGMAP_EVENT_SERVER_CHANGED, null,
this.fgmap.fg_server_current.name);
}
this.fgmap.event_callback_add(FGMAP_EVENT_SERVER_CHANGED,
this.server_changed_cb.bind_event(this), null);
this.fgmap.event_callback_add(FGMAP_EVENT_PILOTS_POS_UPDATE,
this.pilots_pos_update_cb.bind_event(this), null);
this.map_view_changed_cb(FGMAP_EVENT_MAP_VIEW_CHANGED, null);
this.fgmap.event_callback_add(FGMAP_EVENT_MAP_VIEW_CHANGED,
this.map_view_changed_cb.bind_event(this), null);
this.default_menu_add();
};
FGMapMenu.prototype.default_menu_add = function() {
this.about_tab_setup();
this.help_tab_setup();
if(typeof(FGMapMenuPilots) == "function") {
new FGMapMenuPilots(this.fgmap, this.tabdiv);
}
if(typeof(FGMapMenuNav) == "function") {
new FGMapMenuNav(this.fgmap, this.tabdiv);
}
if(typeof(FGMapMenuServer) == "function") {
new FGMapMenuServer(this.fgmap, this.tabdiv);
}
if(typeof(FGMapMenuSettings) == "function") {
new FGMapMenuSettings(this.fgmap, this.tabdiv);
}
}
FGMapMenu.prototype.menu_visible_toggle = function() {
if(!this.menu_body)
return;
if(this.menu_body.style.display == "block") {
this.menu_visible_set(false);
} else {
this.menu_visible_set(true);
}
};
FGMapMenu.prototype.menu_visible_set = function(visible) {
if(!this.menu_body)
return;
if(visible) {
element_show(this.menu_body);
this.menu_title_span.title = "Click here to minimize the menu";
} else {
element_hide(this.menu_body);
this.menu_title_span.title = "Click here to bring up the menu";
}
};
FGMapMenu.prototype.menu_title_mouse_event_cb = function(e) {
if(!e) e = window.event;
if(e.type == "mouseover") {
this.menu_title_span.className = "fgmap_menu_title_highlight";
} else if(e.type == "mouseout") {
this.menu_title_span.className = "fgmap_menu_title";
}
};
FGMapMenu.prototype.about_tab_setup = function() {
var elem = element_create(null, "div");
elem.style.textAlign = "center";
elem.style.padding = "8px 8px 8px 8px";
elem.style.margin = "0px 0px 0px 0px";
elem.style.lineHeight = "180%";
elem.innerHTML = "\
<a href=\"http://pigeond.net/flightgear/fgmap.html\" target=\"_blank\">FGMap</a> " + this.fgmap.version + " - <a href=\"http://www.flightgear.org/\">FlightGear</a> network server traffic map<br>\
Written by <a href=\"http://pigeond.net/\">Pigeon</a> <a href=\"https://github.com/pigeond/fgmap/issues\">FGMap bug tracker</a><br>\
Powered by <a href=\"https://developers.google.com/maps/\">Google Map API</a> v3<br>\
<a href=\"http://fgms.sf.net/\">FlightGear server</a> written by Oliver Schroeder<br>\
<div style=\"padding-top: 6px; line-height: 100%;\">Disclaimer: All navigation info are for flight simulation use only</div>\
";
this.tabdiv.tab_add("about", "about", elem, null, 1000, true);
};
FGMapMenu.prototype.help_tab_setup = function() {
var elem = element_create(null, "div");
elem.className = "fgmap_help";
elem.style.textAlign = "left";
elem.style.overflow = "auto";
elem.style.margin = "0px auto";
//elem.style.padding = "8px 16px 4px 16px";
elem.style.paddingLeft = '12px';
elem.style.height = "90%";
elem.innerHTML = "\
\
<p style=\"text-align: center; font-weight: bold;\">\
General help\
</p>\
\
<ul style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 8px;\">\
<li>You can minimize this menu dock by clicking on the title (where the \"FGMap - server name - pilots: n\" is). Click on it again to bring up this menu again.</li>\
<li>The <img src=\"images/link.gif\" alt=\"\" title=\"\" border=0 align=\"middle\"> icon at the top right hand corner of the menu box gives you a permanent link to current view of the map, which includes the current zoom level, map type, and pilots that map is following.</li>\
</ul>\
\
<p style=\"text-align: center; font-weight: bold;\">\
Pilots tab\
</p>\
\
<ul style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 8px;\">\
<li>You can pan to a pilot by clicking on the callsign/name.</li>\
<li>You can \"follow\" and track a pilot by ticking the checkbox of a pilot. This means that pilot will always be visible on the map. You can follow more than one pilot, and the map will pan and zoom automatically.</li>\
<li>You can define a filter by specifying a keyword that matches (or doesn\'t match) the callsign or aircraft name of a pilot. Click on the <img src=\"images/filter.gif\" alt=\"\" title=\"\" border=0 align=\"middle\"> button to toggle displaying of the filter panel.</li>\
</ul>\
\
<p style=\"text-align: center; font-weight: bold;\">\
Nav tab\
</p>\
\
<ul style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 8px;\">\
<li>You can search for navaids by string using the lookup input field. You could start the lookup by pressing Enter or clicking on the <img src=\"images/search.gif\" alt=\"\" title=\"\" border=0 align=\"middle\"> button after typing in the lookup string.</li>\
<li>Lookup results are shown in the lower part of the menu. You can view and pan to the navaid by clicking on each navaid result.</li>\
<li>You can search for all navaids visible in the current map view by clicking on the <img src=\"images/inview.gif\" alt=\"\" title=\"\" border=0 align=\"middle\"> button.</li>\
<li>For all the lookups, you can select the type of navaids to search for using the six checkboxes below the lookup input field.</li>\
<li>Both the string lookup and current map view lookup has a maximum number for returning navaids.</li>\
<li>You can toggle each type of shown navaid on or off by using the five checkboxes on the bottom right of the menu.</li>\
<li>You can clear all the navaids added from lookups by clicking on the <img src=\"images/trash.gif\" alt=\"\" title=\"\" border=0 align=\"middle\"> button.</li>\
</ul>\
\
<p style=\"text-align: center; font-weight: bold;\">\
Server tab\
</p>\
\
<ul style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 8px;\">\
<li>You can select which server the map will be showing from the server dropdown list.</li>\
<li>You can toggle updating of the map using the checkbox provided.</li>\
<li>You can change how often the map will update using the textbox provided.</li>\
</ul>\
\
<p style=\"text-align: center; font-weight: bold;\">\
Settings tab\
</p>\
\
<ul style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 8px;\">\
<li><a name=\"pilot_label\"></a>You can choose how the pilot label will be shown on the map. Currently there are 4 modes:<br>\
<ul style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 16px;\">\
<li style=\"line-height: 150%;\"><code>off</code> - labels are always off.</li>\
<li style=\"line-height: 150%;\"><code>always</code> - labels will be shown for all pilots at any time.</li>\
<li style=\"line-height: 150%;\"><code>follow always</code> - labels will only be shown for pilots which are selected for \"follow\" in the pilot tab.</li>\
<li style=\"line-height: 150%;\"><code>mouse over only</code> - labels will only be shown when you move your mouse over the icon of a pilot.</li>\
</ul>\
<li><a name=\"aircraft_icon_mode\"></a>You can choose how the icon is displayed for each pilot on the map. Currently there are 3 modes:<br>\
<ul style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 16px;\">\
<li style=\"line-height: 150%;\"><code>normal</code> - a normal red aircraft icon.</li>\
<li style=\"line-height: 150%;\"><code>photo</code> - a photographic icon, not available for all aircraft.</li>\
<li style=\"line-height: 150%;\"><code>dot</code> - a simple red dot, similiar to a ATC radar.</li>\
</ul>\
<li>You can turn on or off the trails of pilots with the \"Pilot trails\" checkbox.</li>\
<li>You can turn on or off the \"Zoom/Pan to all pilots\" mode with the corresponding checkbox. When this mode is enabled, all pilots will be \"followed\" automatically at all time. That also means any new pilots joining will be followed automatically too.</li>\
<li>You can turn on debug mode of the map with the \"Debug\" checkbox. When it is turned on a debug tab will be added, showing debugging messages of the map.</li>\
</ul>\
\
<p style=\"text-align: center; font-weight: bold;\">Startup parameters</p>\
You can specify certain startup parameters for the map. Parameters are passed using standard URL query string. Key and value pairs are appended to the URL like:<br><br>\
<code>http://blah.net/fgmap.html?key1=value1&key2=value2</code><br><br>\
Currently valid keys and values are:<br>\
<ul style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 16px;\">\
<li style=\"line-height: 150%;\">\
<code>fg_server</code> - FG server to use at startup.<br>\
value format: <i>server name,server host,admin port</i><br>\
<ul style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 16px;\">\
<li style=\"line-height: 150%;\"><i>server name</i>: the name of the server which would be shown in the server selection dropdown list.<br></li>\
<li style=\"line-height: 150%;\"><i>server host</i>: the host of the server, this could be the host name or the IP address of the server.<br></li>\
<li style=\"line-height: 150%;\"><i>admin port</i>: the admin port number of the server, this is usually the port you use for FlightGear --multiplay <b>plus one</b>.<br></li>\
</ul>\
example: <code>fg_server=os-devel,postrobot.de,5003</code>\
</li>\
<li style=\"line-height: 150%;\">\
<code>ll</code> - Latitude and Longitude (in that order) at startup.<br>\
example: <code>ll=37.613545,-122.357237</code>\
</li>\
<li style=\"line-height: 150%;\">\
<code>z</code> - map zoom level, range 0 - 17, being 0 is the highest zoom level.<br>\
example: <code>z=0</code>\
</li>\
<li style=\"line-height: 150%;\">\
<code>t</code> - map type, m for map, s for satellite, h for hybrid.<br>\
example: <code>t=s</code>\
</li>\
<li style=\"line-height: 150%;\">\
<code>follow</code> - Follow the pilot at startup given its callsign. Multiple follow is allowed.<br>\
example: <code>follow=pigeon&follow=ampere</code>\
</li>\
<li style=\"line-height: 150%;\">\
<code>pilot_label</code> - Set the startup pilot label mode. Valid values are <code>off</code>, <code>always</code>, <code>follows</code>, and <code>mouseover</code>. See the help of the settings tab more info.<br>\
example: <code>pilot_label=off</code>\
</li>\
<li style=\"line-height: 150%;\">\
<code>icon_mode</code> - Set the startup pilot aircraft icon mode. Valid values are <code>normal</code>, <code>photo</code>, and <code>dot</code>. See the help of the settings tab more info.<br>\
example: <code>icon_mode=dot</code>\
</li>\
<li style=\"line-height: 150%;\">\
<code>menu</code> - menu tab to display at startup.<br>\
example: <code>menu=nav</code>\
</li>\
<li style=\"line-height: 150%;\">\
<code>nomapcontrol</code> - Hide Google Map zoom and map mode controls.<br>\
</li>\
<li style=\"line-height: 150%;\">\
<code>nomenu</code> - Hide the menu, completely.<br>\
</li>\
<li style=\"line-height: 150%;\">\
<code>menuminimized</code> - Have the menu minimized on startup.<br>\
</li>\
<li style=\"line-height: 150%;\">\
<code>update_interval</code> - Set the startup map update interval, in seconds.<br>\
example: <code>update_interval=10</code>\
</li>\
<li style=\"line-height: 150%;\">\
<code>pilots_filter_callsign</code> - Set a keyword as the startup pilot callsign filter. Keyword that starts with a ! represents a not condition.<br>\
example: <code>pilots_filter_callsign=!mpdummy</code>\
</li>\
<li style=\"line-height: 150%;\">\
<code>pilots_filter_aircraft</code> - Set a keyword as the startup pilot aircraft filter. Keyword that starts with a ! represents a not condition.<br>\
example: <code>pilots_filter_aircraft=cp172</code>\
</li>\
</ul>\
<br><br><br>\
";
this.tabdiv.tab_add("help", "help", elem, null, 999, true);
};
/* FGMapMenu callbacks */
FGMapMenu.prototype.map_resize_cb = function(event, cb_data) {
this.menu_container.style.left =
((this.div.clientWidth - this.menu_container.clientWidth) / 2) + "px";
};
FGMapMenu.prototype.server_changed_cb = function(event, cb_data, name) {
this.menu_title_pilots.innerHTML = "-";
this.menu_title_server.innerHTML = name;
};
FGMapMenu.prototype.pilots_pos_update_cb = function(event, cb_data) {
this.menu_title_pilots.innerHTML = this.fgmap.pilots_cnt;
if(this.fgmap.filtered_pilots_cnt > 0) {
this.menu_title_pilots.innerHTML += ' + ' + this.fgmap.filtered_pilots_cnt;
}
};
FGMapMenu.prototype.map_view_changed_cb = function(event, cb_data) {
this.linktomap.href = this.fgmap.linktomap;
};
/* vim: set sw=4 sts=4 expandtab: */