annotate www/search.js @ 2835:9405a18756c8 default tip

Add entry for Caz.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 18 Jun 2024 11:21:06 +0300
parents 1436eecc751f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 //
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 // Frontend map/location search JavaScript functionality
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 // Written by Matti 'ccr' Hamalainen <ccr@tnsp.org>
2112
11f0f408fd0f Bump copyright year.
Matti Hamalainen <ccr@tnsp.org>
parents: 2111
diff changeset
4 // (C) Copyright 2017-2019 Tecnic Software productions (TNSP)
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 //
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
1968
4044e50bd644 Adjust how the random search pattern button works.
Matti Hamalainen <ccr@tnsp.org>
parents: 1965
diff changeset
7 var fieldPattern, chosenPattern = 0;
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
8 var msgLog, mapWS, tmpWS, locWS, mapList = [];
2155
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
9 var mapItemToggles = new Array();
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
1937
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
11 var mapExamples =
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
12 [
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
13 "^^HHHHHHHH+HHHHHH^^^H\n"
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
14 ,
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
15 "~~~~~~~~~~~~hh^hhhhh\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
16 "~~~~~~~~~~~~~hhh~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
17 "~~~~~~~~~~~~~h~~~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
18 "~~~~~~~~~~~~~~~~~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
19 "~~~~~~~~~~~~~~~~~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
20 "~~h~~~~~~~~~~~~~~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
21 "~h^^f~~~~*~~~~~~~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
22 "~~h^fff~~~~~~~~~~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
23 "~~~ff^f~~~~~~~~~~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
24 "~~~~fff~~~~~~h~~~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
25 "~~~~~~~~~~~h~h~~~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
26 "~~~~~~~~~~h^^^hh~~~~\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
27 "~~~~~~~~~~h^^^^^hh~~\n"
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
28 ,
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
29
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
30 " lljjjjjjjjhhhhjjjjjjjjjjj \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
31 " llljjjjjjjjhhhhjjjjjjjjjj \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
32 " lllljjjjjjjhhhhjjjjjjjjjj \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
33 " jjllljjjjjjjjhhhhjjjjjjjj \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
34 "jjjllllljjjjj*jjjhjjjjjjjjj\n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
35 " jllllllljjjjjjjjjjjjjjjjj \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
36 " jlllllllljjjjjjjjjjjjjjjj \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
37 " jlllllllljjjjjjjjjjjjjjjj \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
38 " jjlljllllljjjjjjjjjjjjjjj \n"
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
39 ,
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
40 " S \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
41 " SSSSSSSSSS~ \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
42 " SSSSSSSSSSS~~ \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
43 " SSSSsyssSSSSSSS~~ \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
44 " SSSSsyyssssSSSSS~~~ \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
45 " SSSSssssysssSSSSS~~~~ \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
46 " SSSSysshsyyssSSSS~~~~ \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
47 " SSSSSysyhhssssSSSSS~~~~ \n"+
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
48 " SSSSSSysshhsssssSSSSS~~~~ \n"
1955
241ebec5b302 Add another search example.
Matti Hamalainen <ccr@tnsp.org>
parents: 1954
diff changeset
49 ,
241ebec5b302 Add another search example.
Matti Hamalainen <ccr@tnsp.org>
parents: 1954
diff changeset
50 "....|...|\n"+
241ebec5b302 Add another search example.
Matti Hamalainen <ccr@tnsp.org>
parents: 1954
diff changeset
51 "----*---+\n"+
241ebec5b302 Add another search example.
Matti Hamalainen <ccr@tnsp.org>
parents: 1954
diff changeset
52 "yy.y....|\n"
1937
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
53 ];
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
54
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
55
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56
2120
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
57 function mapCE(obname, obid)
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
58 {
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
59 var mob = document.createElement(obname);
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
60 if (obid)
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
61 mob.id = obid;
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
62 return mob;
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
63 }
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
64
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
65
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
66 function mapClearChildren(obnode)
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
67 {
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
68 if (obnode == null || typeof(obnode) == 'undefined')
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
69 return;
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
70
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
71 while (obnode.firstChild)
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
72 obnode.removeChild(obnode.firstChild);
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
73 }
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
74
1f1f07313eae Add helper functions mapCE() and mapClearChildren().
Matti Hamalainen <ccr@tnsp.org>
parents: 2119
diff changeset
75
1893
f9581f28d9f7 Add obname argument to mapAddEventOb() and adjust callers accordingly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1889
diff changeset
76 function mapAddEventOb(obname, evobj, evtype, evcallback)
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 {
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 if (evobj == null || typeof(evobj) == 'undefined')
1893
f9581f28d9f7 Add obname argument to mapAddEventOb() and adjust callers accordingly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1889
diff changeset
79 {
f9581f28d9f7 Add obname argument to mapAddEventOb() and adjust callers accordingly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1889
diff changeset
80 console.log("Event object '"+ obname +"' == null.");
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 return;
1893
f9581f28d9f7 Add obname argument to mapAddEventOb() and adjust callers accordingly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1889
diff changeset
82 }
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 if (evobj.addEventListener)
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 evobj.addEventListener(evtype, evcallback, false);
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 else
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 if (evobj.attachEvent)
1813
d7deea635463 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1807
diff changeset
88 evobj.attachEvent("on"+evtype, evcallback);
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 else
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 evobj["on"+evtype] = evcallback;
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 }
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 function mapAddEvent(obname, evtype, evcallback)
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 {
1893
f9581f28d9f7 Add obname argument to mapAddEventOb() and adjust callers accordingly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1889
diff changeset
96 mapAddEventOb(obname, document.getElementById(obname), evtype, evcallback);
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 }
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99
2155
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
100 function mapToggleView(id)
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
101 {
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
102 var elem = document.getElementById(id);
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
103 if (elem)
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
104 {
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
105 var val = true;
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
106 if (id in mapItemToggles)
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
107 val = mapItemToggles[id];
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
108
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
109 mapItemToggles[id] = !val;
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
110
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
111 elem.style.display = val ? "block" : "none";
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
112 }
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
113 }
fb4249e817d1 Hide mapsearch help by default, add button to toggle it.
Matti Hamalainen <ccr@tnsp.org>
parents: 2154
diff changeset
114
2483
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
115
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
116 function mapCapitalize(str)
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
117 {
1946
5d1b1462da7a Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1938
diff changeset
118 return str.substr(0, 1).toUpperCase() + str.substr(1);
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
119 }
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
120
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
121
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
122 function mapResult(msg)
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 {
1956
76ce2c75d028 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1955
diff changeset
124 var elem = document.getElementById("results");
76ce2c75d028 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1955
diff changeset
125 if (elem)
76ce2c75d028 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1955
diff changeset
126 elem.innerHTML = msg;
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 }
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129
1947
3333dd5e6043 Adjust front-end code the backend changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1946
diff changeset
130 function mapValidateJSON(edata, elen1, elen2)
1920
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
131 {
1921
2761364c9044 Handle JSON parser exceptions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1920
diff changeset
132 var results;
2761364c9044 Handle JSON parser exceptions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1920
diff changeset
133 try { results = JSON.parse(edata); }
2761364c9044 Handle JSON parser exceptions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1920
diff changeset
134 catch (err) { return "Failed to parse JSON: "+ err.message; }
2761364c9044 Handle JSON parser exceptions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1920
diff changeset
135
1920
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
136 if (results && Array.isArray(results))
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
137 {
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
138 for (var i = 0; i < results.length; i++)
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
139 {
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
140 var res = results[i];
1947
3333dd5e6043 Adjust front-end code the backend changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1946
diff changeset
141 if (!Array.isArray(res))
1920
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
142 return "Invalid data.";
1947
3333dd5e6043 Adjust front-end code the backend changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1946
diff changeset
143
3333dd5e6043 Adjust front-end code the backend changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1946
diff changeset
144 if (i == 0 && res.length != elen1)
3333dd5e6043 Adjust front-end code the backend changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1946
diff changeset
145 return "Invalid data. First element mismatch.";
3333dd5e6043 Adjust front-end code the backend changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1946
diff changeset
146 else
3333dd5e6043 Adjust front-end code the backend changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1946
diff changeset
147 if (i > 0 && res.length != elen2)
3333dd5e6043 Adjust front-end code the backend changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1946
diff changeset
148 return "Invalid data. Element mismatch.";
1920
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
149 }
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
150 return results;
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
151 }
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
152 else
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
153 return "Could not parse result dataset."
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
154 }
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
155
c058c135c33d Factorize result JSON parsing and validation into a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 1917
diff changeset
156
1932
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
157 function mapGetSelectedMaps()
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
158 {
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
159 // Check which maps are enabled, if any
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
160 var searchList = [];
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
161 for (var i = 0; i < mapList.length; i++)
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
162 {
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
163 var res = mapList[i];
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
164 var elem = document.getElementById("map_"+ res[0]);
1954
53256a78129d Improve front-end output.
Matti Hamalainen <ccr@tnsp.org>
parents: 1951
diff changeset
165 if (elem && elem.checked)
1932
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
166 searchList.push(res[0]);
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
167 }
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
168 return searchList;
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
169 }
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
170
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
171
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
172 function mapUpdateMapCount()
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
173 {
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
174 var elem = document.getElementById("mapInfo");
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
175 var l = mapGetSelectedMaps();
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
176 elem.innerHTML = (l.length == 0) ?
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
177 "No maps selected!" :
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
178 "<b>"+ l.length +"</b> map"+ (l.length > 1 ? "s" : "") +" selected.";
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
179 }
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
180
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
181
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
182 function mapSetupWebSocket()
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
183 {
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
184 if ("WebSocket" in window)
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
185 {
2484
71e565a46274 Change WebSocket port from TCP 444 to 5222 and also fix the WS connect
Matti Hamalainen <ccr@tnsp.org>
parents: 2483
diff changeset
186 var mapPort = "5222";
71e565a46274 Change WebSocket port from TCP 444 to 5222 and also fix the WS connect
Matti Hamalainen <ccr@tnsp.org>
parents: 2483
diff changeset
187 var tmpWS = new WebSocket("wss://tnsp.org:"+ mapPort);
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
188 if (!tmpWS)
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
189 {
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
190 mapResult("WebSocket error: Could not create WebSocket.");
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
191 return null;
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
192 }
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
193
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
194 tmpWS.onerror = function(mev)
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
195 {
2270
2ed0d91d410b Be more verbose about one type of WebSocket errors that may occur and offer
Matti Hamalainen <ccr@tnsp.org>
parents: 2157
diff changeset
196 mapResult("<b>WebSocket error occured!</b>"+
2ed0d91d410b Be more verbose about one type of WebSocket errors that may occur and offer
Matti Hamalainen <ccr@tnsp.org>
parents: 2157
diff changeset
197 "<p>If this problem persists for more than few hours AND this search HAS worked for you before, "+
2484
71e565a46274 Change WebSocket port from TCP 444 to 5222 and also fix the WS connect
Matti Hamalainen <ccr@tnsp.org>
parents: 2483
diff changeset
198 "you should check if your Internet provider and firewall allow connections to TCP port "+ mapPort +".</p>"
71e565a46274 Change WebSocket port from TCP 444 to 5222 and also fix the WS connect
Matti Hamalainen <ccr@tnsp.org>
parents: 2483
diff changeset
199 );
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
200 console.error("WebSocket error occured: ", mev);
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
201 };
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
202
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
203 return tmpWS;
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
204 }
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
205 else
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
206 {
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
207 mapResult("Your browser does not support WebSockets.");
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
208 return null;
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
209 }
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
210 }
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
211
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
212
2119
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
213 function mapHandleError(str)
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
214 {
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
215 if (str.substr(0, 6) == "ERROR:")
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
216 {
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
217 mapResult("ERROR! "+ str.substr(6).trim());
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
218 return false;
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
219 }
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
220 else
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
221 return true;
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
222 }
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
223
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
224
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
225 function mapGetData()
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
226 {
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
227 var dataWS = mapSetupWebSocket();
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
228 if (!dataWS)
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
229 return;
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
230
2153
b76df7f424b8 Improve status logging of first contact of MapSearch WS server when fetching map names.
Matti Hamalainen <ccr@tnsp.org>
parents: 2152
diff changeset
231 var mlobj = document.getElementById("mapList");
2151
d842540da233 Make maplist loading and first contact to search server more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 2149
diff changeset
232 if (mlobj)
d842540da233 Make maplist loading and first contact to search server more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 2149
diff changeset
233 mlobj.innerHTML = "Contacting server ...";
d842540da233 Make maplist loading and first contact to search server more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 2149
diff changeset
234
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
235 dataWS.onopen = function()
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
236 {
2151
d842540da233 Make maplist loading and first contact to search server more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 2149
diff changeset
237 if (mlobj)
d842540da233 Make maplist loading and first contact to search server more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 2149
diff changeset
238 mlobj.innerHTML = "Loading maplist ...";
d842540da233 Make maplist loading and first contact to search server more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 2149
diff changeset
239
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
240 dataWS.send("GETMAPS");
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
241 };
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
242
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
243 dataWS.onmessage = function(evt)
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
244 {
2119
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
245 if (mapHandleError(evt.data))
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
246 {
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
247 if (evt.data.substr(0, 5) == "MAPS:" && evt.data.length > 8)
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
248 {
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
249 var results = mapValidateJSON(evt.data.substr(5), 3, 3);
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
250 if (Array.isArray(results) && results.length > 0)
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
251 {
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
252 mapList = results;
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
253
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
254 // Create list of map selection buttons
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
255 var mobj = document.getElementById("mapList");
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
256 mapClearChildren(mobj);
2121
dd280de434b9 Create elements in javascript instead of using direct HTML.
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
257
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
258 for (var i = 0; i < results.length; i++)
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
259 {
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
260 var res = results[i];
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
261 var id = "map_"+ res[0];
2121
dd280de434b9 Create elements in javascript instead of using direct HTML.
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
262
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
263 // Checkbox input
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
264 var mbut = mapCE("input", id);
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
265 mbut.type = "checkbox";
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
266 mbut.checked = true;
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
267 mbut.className = "map";
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
268
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
269 mapAddEventOb(id, mbut, "change", mapUpdateMapCount);
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
270 mobj.appendChild(mbut);
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
271
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
272 // Label for button
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
273 var mlabel = mapCE("label");
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
274 mlabel.htmlFor = id;
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
275 mlabel.textContent = mapCapitalize(res[0]);
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
276 mobj.appendChild(mlabel);
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
277 }
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
278
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
279 mapUpdateMapCount();
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
280 }
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
281 else
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
282 mapResult("ERROR: "+ results);
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
283 }
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
284 else
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
285 mapResult("ERROR: Unknown reply from server.");
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
286 }
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
287 dataWS.close();
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
288 };
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
289 }
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
290
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
291
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
292 function mapGetLocType(flags)
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
293 {
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
294 switch (flags & 0xfffc)
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
295 {
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
296 case 0x0004: return "PCITY";
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
297 case 0x0008: return "CITY";
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
298 case 0x0010: return "SHRINE";
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
299 case 0x0020: return "GUILD";
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
300 case 0x0040: return "SS";
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
301 case 0x0080: return "MONSTER";
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
302 case 0x0100: return "TRAINER";
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
303 case 0x0200: return "FORT";
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
304 default: return null;
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
305 }
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
306 }
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
307
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
308
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
309 function mapGetLocPrefix(flags)
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
310 {
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
311 var str = mapGetLocType(flags);
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
312 return str != null ? "["+ str + "] " : "";
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
313 }
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
314
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
315
2111
793bb8848061 Unify GMap link generating in search frontend.
Matti Hamalainen <ccr@tnsp.org>
parents: 2100
diff changeset
316 function mapGetGMapLink(gx, gy)
793bb8848061 Unify GMap link generating in search frontend.
Matti Hamalainen <ccr@tnsp.org>
parents: 2100
diff changeset
317 {
793bb8848061 Unify GMap link generating in search frontend.
Matti Hamalainen <ccr@tnsp.org>
parents: 2100
diff changeset
318 return "[ <a class=\"glob\" target=\"_blank\" "+
793bb8848061 Unify GMap link generating in search frontend.
Matti Hamalainen <ccr@tnsp.org>
parents: 2100
diff changeset
319 "href=\"http://jeskko.pupunen.net/gmap2/?x="+ gx +"&y="+
793bb8848061 Unify GMap link generating in search frontend.
Matti Hamalainen <ccr@tnsp.org>
parents: 2100
diff changeset
320 gy +"&zoom=10\">"+ gx +", "+ gy +"</a> ]";
793bb8848061 Unify GMap link generating in search frontend.
Matti Hamalainen <ccr@tnsp.org>
parents: 2100
diff changeset
321 }
793bb8848061 Unify GMap link generating in search frontend.
Matti Hamalainen <ccr@tnsp.org>
parents: 2100
diff changeset
322
793bb8848061 Unify GMap link generating in search frontend.
Matti Hamalainen <ccr@tnsp.org>
parents: 2100
diff changeset
323
2126
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
324 function mapGetNearby(mx, my, mid)
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
325 {
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
326 var qtmpWS = mapSetupWebSocket();
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
327 if (!qtmpWS)
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
328 return;
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
329
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
330 qtmpWS.onopen = function(evt)
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
331 {
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
332 qtmpWS.send("LOCNEAR:"+ mx +":"+ my +":"+ 200 +":2:");
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
333 };
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
334
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
335 qtmpWS.onmessage = function(evt)
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
336 {
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
337 if (mapHandleError(evt.data))
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
338 {
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
339 if (evt.data.substr(0, 7) == "RESULT:" && evt.data.length >= 9)
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
340 {
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
341 var results = mapValidateJSON(evt.data.substr(7), 2, 9);
2126
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
342
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
343 if (Array.isArray(results) && results.length > 0 && mid)
2126
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
344 {
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
345 var str = "";
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
346
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
347 // Format results, if any
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
348 for (var i = 1; i < results.length; i++)
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
349 {
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
350 var res = results[i];
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
351 var flags = res[5];
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
352 var names = res[8];
2126
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
353
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
354 str += "<div class=\"nearby\" title=\""+ names.join(" | ") +"\">"+
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
355 "<a target=\"_blank\" href=\""+ res[0] +".html#loc"+
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
356 res[1] +"_"+ res[2] +"\">"+
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
357 mapGetLocPrefix(flags) + names[0] +"</a>" +
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
358 " "+ mapGetGMapLink(res[3], res[4]) +
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
359 " dist "+ res[7] +
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
360 "</div>";
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
361 }
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
362
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
363 mid.innerHTML += str;
2126
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
364 }
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
365 }
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
366 }
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
367 qtmpWS.close();
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
368 };
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
369 }
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
370
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
371
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
372 function mapDoMapSearch()
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373 {
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
374 // Check the search pattern for some sanity before
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
375 // submitting to the server .. though we do checks there also.
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
376 var tmp = fieldPattern.value.trim();
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
377 if (tmp == "")
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 {
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
379 mapResult("Nothing to search for.");
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 return;
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 }
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382
1889
4641b8cbf1fc Adjust max client-side check for map search pattern block size.
Matti Hamalainen <ccr@tnsp.org>
parents: 1818
diff changeset
383 if (tmp.length > 25*25)
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
384 {
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
385 mapResult("Search pattern too large!");
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
386 return;
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
387 }
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
388
1932
69294bfa48ca Add helper function mapGetSelectedMaps() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
389 var searchList = mapGetSelectedMaps();
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
390 if (searchList.length == 0 && mapList.length > 0)
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
391 {
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
392 mapResult("No maps selected!");
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
393 return;
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
394 }
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
395
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
396 // Are we running an old query?
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397 if (mapWS)
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398 {
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
399 mapResult("Old query not finished.");
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 return;
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 }
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
403 // Open a WebSocket connection ..
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
404 mapWS = mapSetupWebSocket();
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405 if (!mapWS)
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406 return;
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
408 btnMapSearch.disabled = true;
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 mapWS.onopen = function()
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 {
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 // Web Socket is connected, send data using send()
1807
d419124e284a More work on the front-end.
Matti Hamalainen <ccr@tnsp.org>
parents: 1805
diff changeset
413 mapWS.send("MAPSEARCH:"+ -1 +":"+ searchList.join(":") +"\n" + fieldPattern.value);
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414 };
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
416 mapWS.onclose = function()
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
417 {
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
418 mapWS = null;
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
419 btnMapSearch.disabled = false;
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
420 };
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
421
1802
649998a9b6d8 Handle empty result set.
Matti Hamalainen <ccr@tnsp.org>
parents: 1800
diff changeset
422 // Register events
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423 mapWS.onmessage = function(evt)
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
424 {
2119
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
425 if (mapHandleError(evt.data))
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426 {
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
427 if (evt.data.substr(0, 7) == "RESULT:" && evt.data.length >= 9)
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
428 {
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
429 var results = mapValidateJSON(evt.data.substr(7), 7, 5);
1947
3333dd5e6043 Adjust front-end code the backend changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1946
diff changeset
430
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
431 if (Array.isArray(results) && results.length > 0)
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
432 {
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
433 var glb = results[0];
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
434 var str =
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
435 "<div class=\"resultHead\">Search pattern size <b>"+ glb[5] +" x "+ glb[6] +"</b>"+
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
436 (glb[2] ? " (Centered at <b>"+ glb[3] +", "+ glb[4] +"</b>)" : " (Not centered)") +
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
437 "</div><div class=\"resultHead\"><b>"+ glb[0] +"</b> match"+
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
438 ((glb[0] > 1 || glb[0] == 0) ? "es" : "") +" found, match limit is "+ glb[1] +".</div>";
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
439
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
440 // First element is the global info
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
441 if (results.length <= 1)
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
442 str += "<div class=\"resultHead\">No matches found.</div>";
2124
f3b049beedce Add some CSS for results.
Matti Hamalainen <ccr@tnsp.org>
parents: 2123
diff changeset
443
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
444 var mobj = document.getElementById("results");
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
445 mobj.innerHTML = str;
2126
c4c556d6089c Show 2 nearest locations to the matched map location in map search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
446
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
447 // Format results, if any
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
448 for (var i = 1; i < results.length; i++)
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
449 {
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
450 var res = results[i];
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
451 var mid = mapCE("div");
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
452 mid.className = "resultData";
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
453 mid.innerHTML = "<span class=\"resultData\">"+ res[1] +", "+ res[2] +" at "+
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
454 mapCapitalize(res[0]) +" "+
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
455 mapGetGMapLink(res[3], res[4]) +
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
456 "</span>";
1807
d419124e284a More work on the front-end.
Matti Hamalainen <ccr@tnsp.org>
parents: 1805
diff changeset
457
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
458 mobj.appendChild(mid);
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
459 mapGetNearby(res[3], res[4], mid);
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
460 }
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
461 }
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
462 else
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
463 mapResult("ERROR: "+ results);
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464 }
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
465 else
2588
1436eecc751f Make some if () branches a bit clearer by using blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 2486
diff changeset
466 mapResult("ERROR: Unknown reply from server.");
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
467 }
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
468
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
469 mapWS.close();
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
470 };
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
471 }
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
472
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
473
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
474 function mapDoLocSearch()
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
475 {
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
476 locPID = -1;
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
477
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
478 // Check the search pattern for some sanity before
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
479 // submitting to the server .. though we do checks there also.
2114
2b9b9e0f89b3 Add maxMatches argument to nearby location search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2113
diff changeset
480 var nearby = false;
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
481 var tmp = fieldLocPattern.value.trim();
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
482 if (tmp == "")
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
483 {
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
484 mapResult("Nothing to search for.");
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
485 return;
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
486 }
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
487
2149
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
488 if (tmp.length > 30)
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
489 {
2100
9141edfb5647 Clean up the mapsearch front-end Javascript code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1981
diff changeset
490 mapResult("Search pattern too large!");
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
491 return;
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
492 }
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
493
2149
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
494 if (tmp.substr(0, 1) == "@")
2114
2b9b9e0f89b3 Add maxMatches argument to nearby location search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2113
diff changeset
495 {
2b9b9e0f89b3 Add maxMatches argument to nearby location search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2113
diff changeset
496 nearby = true;
2149
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
497 tmp = tmp.substr(1).trim().replace(",", ":") + ":";
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
498 }
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
499 else
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
500 {
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
501 // Allow exact matches
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
502 if (tmp.substr(0, 1) == "^")
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
503 tmp = tmp.substr(1);
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
504 else
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
505 tmp = "*"+ tmp;
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
506
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
507 if (tmp.substr(-1) == "$")
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
508 tmp = tmp.substr(-1);
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
509 else
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
510 tmp = tmp +"*";
2114
2b9b9e0f89b3 Add maxMatches argument to nearby location search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2113
diff changeset
511 }
2b9b9e0f89b3 Add maxMatches argument to nearby location search.
Matti Hamalainen <ccr@tnsp.org>
parents: 2113
diff changeset
512
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
513 // Are we running an old query?
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
514 if (locWS)
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
515 return;
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
516
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
517 // Open a WebSocket connection ..
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
518 locWS = mapSetupWebSocket();
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
519 if (!locWS)
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
520 return;
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
521
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
522 locWS.onopen = function()
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
523 {
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
524 // Web Socket is connected, send data using send()
2149
c34839d51fbf Cleanups in search frontend JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 2137
diff changeset
525 locWS.send((nearby ? "LOCNEAR:" : "LOCSEARCH:") + tmp);
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
526 };
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
527
2118
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
528 locWS.onclose = function()
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
529 {
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
530 locWS = null;
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
531 };
995c45c244ed Improve WebSocket handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 2117
diff changeset
532
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
533 // Register events
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
534 locWS.onmessage = function(evt)
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
535 {
2119
5b0fd5ee79a4 Unify some error handling in the mapsearch front-end javascript code.
Matti Hamalainen <ccr@tnsp.org>
parents: 2118
diff changeset
536 if (mapHandleError(evt.data))
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
537 if (evt.data.substr(0, 7) == "RESULT:" && evt.data.length >= 9)
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
538 {
2113
282f84c10f97 Adjust location search results parsing to match changes in the server end.
Matti Hamalainen <ccr@tnsp.org>
parents: 2112
diff changeset
539 var results = mapValidateJSON(evt.data.substr(7), 2, 9);
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
540
1951
732cbbc3efba Implement search result count and server-side returning limit on matches to be shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1948
diff changeset
541 if (Array.isArray(results) && results.length > 0)
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
542 {
1951
732cbbc3efba Implement search result count and server-side returning limit on matches to be shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1948
diff changeset
543 var glb = results[0];
2123
6ba7aae53296 Change a variable to be more local to a block.
Matti Hamalainen <ccr@tnsp.org>
parents: 2122
diff changeset
544 var str =
2124
f3b049beedce Add some CSS for results.
Matti Hamalainen <ccr@tnsp.org>
parents: 2123
diff changeset
545 "<div class=\"resultHead\"><b>"+ glb[0] +"</b> match"+
1959
1f19b0bb2009 Improve results.
Matti Hamalainen <ccr@tnsp.org>
parents: 1958
diff changeset
546 ((glb[0] > 1 || glb[0] == 0) ? "es" : "") +" found, match limit is "+ glb[1] +".</div>";
1951
732cbbc3efba Implement search result count and server-side returning limit on matches to be shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1948
diff changeset
547
2124
f3b049beedce Add some CSS for results.
Matti Hamalainen <ccr@tnsp.org>
parents: 2123
diff changeset
548 if (results.length <= 1)
f3b049beedce Add some CSS for results.
Matti Hamalainen <ccr@tnsp.org>
parents: 2123
diff changeset
549 str += "<div class=\"resultHead\">No matches found.</div>";
f3b049beedce Add some CSS for results.
Matti Hamalainen <ccr@tnsp.org>
parents: 2123
diff changeset
550
1951
732cbbc3efba Implement search result count and server-side returning limit on matches to be shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1948
diff changeset
551 // Format results, if any
732cbbc3efba Implement search result count and server-side returning limit on matches to be shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1948
diff changeset
552 for (var i = 1; i < results.length; i++)
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
553 {
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
554 var res = results[i];
1958
fe4a65855a09 Use location flags to add type prefix to results.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
555 var flags = res[5];
fe4a65855a09 Use location flags to add type prefix to results.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
556 var nname = res[6];
2113
282f84c10f97 Adjust location search results parsing to match changes in the server end.
Matti Hamalainen <ccr@tnsp.org>
parents: 2112
diff changeset
557 var names = res[8];
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
558
2124
f3b049beedce Add some CSS for results.
Matti Hamalainen <ccr@tnsp.org>
parents: 2123
diff changeset
559 str += "<div class=\"resultData\" title=\""+ names.join(" | ") +"\">"+
1970
392a8807d2cc Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1969
diff changeset
560 "<a target=\"_blank\" href=\""+ res[0] +".html#loc"+
392a8807d2cc Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1969
diff changeset
561 res[1] +"_"+ res[2] +"\">"+
2125
ddd0c9f85f5e Show also the matched alternative name for location name search instead of only the main name.
Matti Hamalainen <ccr@tnsp.org>
parents: 2124
diff changeset
562 mapGetLocPrefix(flags) + names[0] +"</a>" +
ddd0c9f85f5e Show also the matched alternative name for location name search instead of only the main name.
Matti Hamalainen <ccr@tnsp.org>
parents: 2124
diff changeset
563 (nname > 0 ? " ["+ names[nname] +"]" : "") +
ddd0c9f85f5e Show also the matched alternative name for location name search instead of only the main name.
Matti Hamalainen <ccr@tnsp.org>
parents: 2124
diff changeset
564 " at "+ res[1] +", "+ res[2] +" on "+ mapCapitalize(res[0]) +
2117
eb05d61f969c Show distance value in results.
Matti Hamalainen <ccr@tnsp.org>
parents: 2114
diff changeset
565 " "+ mapGetGMapLink(res[3], res[4]) +
eb05d61f969c Show distance value in results.
Matti Hamalainen <ccr@tnsp.org>
parents: 2114
diff changeset
566 (nearby ? " dist "+ res[7] : "")+
eb05d61f969c Show distance value in results.
Matti Hamalainen <ccr@tnsp.org>
parents: 2114
diff changeset
567 "</div>";
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
568 }
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
569
2123
6ba7aae53296 Change a variable to be more local to a block.
Matti Hamalainen <ccr@tnsp.org>
parents: 2122
diff changeset
570 mapResult(str);
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
571 }
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
572 else
2123
6ba7aae53296 Change a variable to be more local to a block.
Matti Hamalainen <ccr@tnsp.org>
parents: 2122
diff changeset
573 mapResult("ERROR: "+ results);
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
574 }
2122
66a54bef0d7e Check for unknown replies from mapsearch server.
Matti Hamalainen <ccr@tnsp.org>
parents: 2121
diff changeset
575 else
66a54bef0d7e Check for unknown replies from mapsearch server.
Matti Hamalainen <ccr@tnsp.org>
parents: 2121
diff changeset
576 mapResult("ERROR: Unknown reply from server.");
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
577
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
578 locWS.close();
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
579 };
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
580 }
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
581
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
582
1916
d6b3e3beeece Fix Javascript initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 1915
diff changeset
583 function mapInitSearch()
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
584 {
2131
146780d2d276 Improve checking of disabled Javascript.
Matti Hamalainen <ccr@tnsp.org>
parents: 2130
diff changeset
585 // Check for disabled Javascript
146780d2d276 Improve checking of disabled Javascript.
Matti Hamalainen <ccr@tnsp.org>
parents: 2130
diff changeset
586 var verr = document.getElementById("noscript");
146780d2d276 Improve checking of disabled Javascript.
Matti Hamalainen <ccr@tnsp.org>
parents: 2130
diff changeset
587 if (verr)
146780d2d276 Improve checking of disabled Javascript.
Matti Hamalainen <ccr@tnsp.org>
parents: 2130
diff changeset
588 verr.parentNode.removeChild(verr);
146780d2d276 Improve checking of disabled Javascript.
Matti Hamalainen <ccr@tnsp.org>
parents: 2130
diff changeset
589
2483
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
590 var mlhelp1 = document.getElementById("help1");
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
591 if (mlhelp1)
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
592 mlhelp1.style.display = "none";
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
593
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
594 var mlhelp2 = document.getElementById("help2");
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
595 if (mlhelp2)
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
596 mlhelp2.style.display = "none";
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
597
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
598 if (!("WebSocket" in window))
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
599 {
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
600 mapResult("Your browser does not support WebSockets!");
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
601 return;
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
602 }
1790
24e23feca10a Add server functionality to provide list of maps available for searching,
Matti Hamalainen <ccr@tnsp.org>
parents: 1787
diff changeset
603
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
604 fieldPattern = document.getElementById("mapPattern");
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
605 btnMapSearch = document.getElementById("btnMapSearch");
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
606
1968
4044e50bd644 Adjust how the random search pattern button works.
Matti Hamalainen <ccr@tnsp.org>
parents: 1965
diff changeset
607 // Show example search pattern
4044e50bd644 Adjust how the random search pattern button works.
Matti Hamalainen <ccr@tnsp.org>
parents: 1965
diff changeset
608 chosenPattern = Math.floor(Math.random() * mapExamples.length);
1937
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
609 mapAddEvent("btnExample", "click",
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
610 function ()
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
611 {
1970
392a8807d2cc Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1969
diff changeset
612 mapResult("Example search pattern <b>#"+ (chosenPattern + 1) +
392a8807d2cc Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1969
diff changeset
613 "/"+ mapExamples.length +"</b> selected. Try clicking 'Search' now.");
392a8807d2cc Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1969
diff changeset
614
1968
4044e50bd644 Adjust how the random search pattern button works.
Matti Hamalainen <ccr@tnsp.org>
parents: 1965
diff changeset
615 fieldPattern.value = mapExamples[chosenPattern];
4044e50bd644 Adjust how the random search pattern button works.
Matti Hamalainen <ccr@tnsp.org>
parents: 1965
diff changeset
616 chosenPattern = (chosenPattern + 1) % mapExamples.length;
1937
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
617 });
f0311e3a9b44 Add button for showing a random example search pattern.
Matti Hamalainen <ccr@tnsp.org>
parents: 1936
diff changeset
618
1933
fe08d358382f Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1932
diff changeset
619 // Map search button
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
620 mapAddEventOb("btnMapSearch", btnMapSearch, "click", mapDoMapSearch);
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
621
1933
fe08d358382f Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1932
diff changeset
622 // Clear search button
1818
Matti Hamalainen <ccr@tnsp.org>
parents: 1813
diff changeset
623 mapAddEvent("btnClear", "click",
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
624 function ()
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
625 {
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
626 fieldPattern.value = "";
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
627 mapResult("Cleared search pattern and results.");
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
628 });
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
629
2483
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
630 mapGetData();
4541c68e1ebf Improve WebSocket failure mode handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2281
diff changeset
631
1933
fe08d358382f Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1932
diff changeset
632 // Reset or clear map list button
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
633 mapAddEvent("btnMaps", "click",
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
634 function ()
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
635 {
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
636 var same = true, first = true;
1933
fe08d358382f Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1932
diff changeset
637 // Get current state of map list
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
638 for (var i = 0; i < mapList.length; i++)
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
639 {
1938
ab7fd6ed8587 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1937
diff changeset
640 var elem = document.getElementById("map_"+ mapList[i][0]);
1894
45bc99d21e1a Don't check for existence of DOM objects via if (elem) in order to catch
Matti Hamalainen <ccr@tnsp.org>
parents: 1893
diff changeset
641 if (first)
45bc99d21e1a Don't check for existence of DOM objects via if (elem) in order to catch
Matti Hamalainen <ccr@tnsp.org>
parents: 1893
diff changeset
642 same = elem.checked;
45bc99d21e1a Don't check for existence of DOM objects via if (elem) in order to catch
Matti Hamalainen <ccr@tnsp.org>
parents: 1893
diff changeset
643 else
45bc99d21e1a Don't check for existence of DOM objects via if (elem) in order to catch
Matti Hamalainen <ccr@tnsp.org>
parents: 1893
diff changeset
644 if (elem.checked != same)
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
645 {
1894
45bc99d21e1a Don't check for existence of DOM objects via if (elem) in order to catch
Matti Hamalainen <ccr@tnsp.org>
parents: 1893
diff changeset
646 same = false;
45bc99d21e1a Don't check for existence of DOM objects via if (elem) in order to catch
Matti Hamalainen <ccr@tnsp.org>
parents: 1893
diff changeset
647 break;
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
648 }
1894
45bc99d21e1a Don't check for existence of DOM objects via if (elem) in order to catch
Matti Hamalainen <ccr@tnsp.org>
parents: 1893
diff changeset
649 first = false;
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
650 }
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
651
1933
fe08d358382f Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1932
diff changeset
652 // Invert it
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
653 same = !same;
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
654
1933
fe08d358382f Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1932
diff changeset
655 // Set it! Bop it!
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
656 for (var i = 0; i < mapList.length; i++)
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
657 {
1938
ab7fd6ed8587 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1937
diff changeset
658 var elem = document.getElementById("map_"+ mapList[i][0]);
1894
45bc99d21e1a Don't check for existence of DOM objects via if (elem) in order to catch
Matti Hamalainen <ccr@tnsp.org>
parents: 1893
diff changeset
659 elem.checked = same;
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
660 }
1936
fe32111858f6 Show number of currently selected target maps in the search.
Matti Hamalainen <ccr@tnsp.org>
parents: 1933
diff changeset
661
fe32111858f6 Show number of currently selected target maps in the search.
Matti Hamalainen <ccr@tnsp.org>
parents: 1933
diff changeset
662 mapUpdateMapCount();
1793
e65dde84a6a8 Various improvements to the front-end code.
Matti Hamalainen <ccr@tnsp.org>
parents: 1790
diff changeset
663 });
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
664
1933
fe08d358382f Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1932
diff changeset
665 // Listener for location name search
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
666 fieldLocPattern = document.getElementById("locPattern");
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
667 if (fieldLocPattern)
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
668 {
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
669 locPID = -1;
1914
f19f887ec328 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1913
diff changeset
670 mapAddEventOb("locPattern", fieldLocPattern, "input",
1912
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
671 function ()
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
672 {
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
673 if (locPID != -1)
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
674 clearTimeout(locPID);
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
675
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
676 locPID = setTimeout(mapDoLocSearch, 500);
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
677 });
fd642a09c8db Implement location search. Also get rid of the END message.
Matti Hamalainen <ccr@tnsp.org>
parents: 1894
diff changeset
678 }
1787
ccf488dac4c2 Some prototyping/initial code for the map search client-side stuff, JavaScript part.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
679 }