From abba49a44e3e3ae69cec3163223c1ba6edbf5193 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Tue, 3 Apr 2012 21:13:44 +0200 Subject: [PATCH 01/12] - added GUI support for language switching - first tests for support of printing --- WebContent/OSRM.GUI.js | 6 +- WebContent/images/printer.pdf | Bin 0 -> 4623 bytes WebContent/images/printer.png | Bin 0 -> 347 bytes WebContent/images/printer_active.png | Bin 0 -> 349 bytes WebContent/images/printer_hover.png | Bin 0 -> 350 bytes WebContent/images/printer_inactive.png | Bin 0 -> 322 bytes WebContent/localization/OSRM.Locale.de.js | 64 ++++++++++++++ WebContent/localization/OSRM.Locale.en.js | 64 ++++++++++++++ WebContent/localization/OSRM.Localization.js | 74 +++++++++++++++++ WebContent/main.css | 31 ++++++- WebContent/main.html | 18 ++-- WebContent/main.js | 7 +- WebContent/printing/OSRM.Printing.js | 60 ++++++++++++++ WebContent/printing/printing.html | 83 +++++++++++++++++++ 14 files changed, 395 insertions(+), 12 deletions(-) create mode 100644 WebContent/images/printer.pdf create mode 100644 WebContent/images/printer.png create mode 100644 WebContent/images/printer_active.png create mode 100644 WebContent/images/printer_hover.png create mode 100644 WebContent/images/printer_inactive.png create mode 100644 WebContent/localization/OSRM.Locale.de.js create mode 100644 WebContent/localization/OSRM.Locale.en.js create mode 100644 WebContent/localization/OSRM.Localization.js create mode 100644 WebContent/printing/OSRM.Printing.js create mode 100644 WebContent/printing/printing.html diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index b1ede611b..223c2a914 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -29,8 +29,10 @@ width: null, init: function() { OSRM.GUI.visible = true; OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth; - - // translate +}, + +// set language dependent labels +setLanguage: function() { document.getElementById("open-josm").innerHTML = OSRM.loc("OPEN_JOSM"); document.getElementById("open-osmbugs").innerHTML = OSRM.loc("OPEN_OSMBUGS"); document.getElementById("gui-reset").innerHTML = OSRM.loc("GUI_RESET"); diff --git a/WebContent/images/printer.pdf b/WebContent/images/printer.pdf new file mode 100644 index 0000000000000000000000000000000000000000..91928b90f9f740f0166bdd5e3d21720bbc00524c GIT binary patch literal 4623 zcmds5dpuNm8z*mMLKd-6>yScX&Y6oD*E z-4Yh;1f+PxHr|=XuWW_WZuj^ZPyDvxRJJ zs}C7qQCI*3*uFu)jvXj8l^GI9g+LHQGyqMq1RwxSqay!iW+*c=fX?zmTB2}Edbk}5 zp#x|#6^7{?7HUxtSs|gyV8J28t=a z5WpZV*fN;N@{lK!3e&CWG`1gII2IS?(5b%XOFF3Px@18dju@4S#6tNtVUUSh*OfgXo9l4YVH>#Z?Y<9*(n( zAtp2fEzyn{`^yV&#WQlN6))(~(mXStN873wk$bc%93`1iHpVx20lFM7OnY9aIxn3? zd%Rt9Ik3bfYhDC4fQ~|w*esaNg1LauDa7NYp@;&Ipy#k@u5=g)VlMBCY$3LLZ#6~Sw$wf0$z)W0-&wwVGJ6bVrS(o3`yazZ*mC`?!2(S zDCp^a4C=dt!6PsbaTp}XNgQ^F$c`fb1Uv*75db0xAulXB@QQXam4o;MU_^tzOKBrS zUkvU=+#uYCaXXR>330P|kv-BaM>*j<%Gdn)5K4&KjC0`4ksF#5;|_lG>SQlhtPG1j03AR8Mqr*JhU4WYtk&2 zexSUStk}6dcWc823tgO|eC<(y1+LzPB}in7`F%v-z6J3T{MQR%z3tMCbYGxIE*sc|@ zT&YTU?^uQ2oRA;&xw%z47k2K}T zxi*&?zB?Q&u;{OH{#v2_^u$%~sw?#*KJ`|*|S5iwJ`_9>X(=%HX zTRNSNm`|BjeRJB)s;h303Z9!)1P4-Bo)ro+pL%!I?T>7VjGk|ABOaq|Jfx%IRO8!K z@g@Fft8$kJ(+K9Z~kmo@7PQ${AC35yNt`@mo}Ze=segFcEHEDx@kZ!Z$Yv9SH-6V z)E(LmDwNaX8N(5G8P#3nq7$wclzi^y7sT7ERe6S|W}O_qo^vC!l$I98d@5k%a7kRE zQqbrtQg_1M-`vYrrHmgm!p}QM)~I}zqk=N&wYhln>K@C)2%npY$5?;udtA|Lc3aJ< zBCCY^YSXlhY~g{3jcw_3JWL)M-Q<(29IjTR<|s&VTsJ8_XsLe6$|KY6>T$RGfncNd zc@sHxJw=KH|BR!+!>gF1*;^&i!XitnuUgpX+H(A;hRzM0$)}Cuxq`5miE&@;*1h^Y z-^2}B88)9XNG&P!ElBWmLRn7SJF!a2UydgEFALN57>>bbN!9yytm=~G_VeA6DCs(l z`uEd5Kf?Q}eA0#WOCIyo7c+V5LS(ubN<>2^ImsQ#BMUx_SK=HtFs^Bp<(NiT3Zyy+ zA$MngMxR;#;*XSDo}0WM;T~B!Il9DRq%k&Xy0UpRuisrF`=#A8%Ni;KUd8_YmQiO+ z6|>!2zh)G6Q}AmuO2RYc354&vLdH*FK-q|k zTyFe>46fcwPua+fC;T#r7cH$vHe8*5)yBS}O1vLBWN4D+@?v9Qw=#cP?3x+zPo&8u zh5T*Sbg)KwHRpPHN|wp}$K?3eDpMV<34-jh4X05DU(VOpEKF+b-QKvSyK77{rb)*G zz}~%;1r_saf=ep(7P#!Z?Y>f+3}vvY;;!PgJVRSI71KKgQjrbpL9v*vSe6WAD3~)iyvy3 zMm2`R90>h3Z+f3ptm*OC}(=)*5S&w%98t4%O z6&`qAT%B4ufs7;ARGc{dTIZf^^7L5^LZCTjV&}x4cD!G$=JX{7Pe%IPkvb^Y%zLnV z;=<^_vq+eiAb8QlD>=Fl_8i?R{WNO%<+XAh!WD9YP^5ZBc&QV^kBe0PLhe982<)4O zsHz5#x>;!SUP6nY<>Zk>g{e$-fRIQ9Anf){K`v50r~1;FBEE}u2@Mv`BBbMJGN1$L znwddwWeg%?-pW`+#=ezth%BNK?}~e9DTyN?oEK(u03GBa0tg160R-wIi{P;RLTLy` ze%~x=%wV&ug@i`O+86^u7!U_yFc2P(!6E&e*?#}&-Mjh2Idp#%Lh}hI)(&fgTjm=MBrKT&=1>_-ItL~Ee&fnGOc(Am qn!;wofGFyaV%dS^&jv(6Af)QZXAdd|7GZ+JfLPR)EjBxCQU3?NMQuIzVMm_(QryG{l40fjgV zJR*x37`TN%nDNrxx<5ccmUKs7M+SzC{oH>NS%G}Ek|4ieh8hM}2KC1KALM}|H#}V& zLn>}1uPF>oS70@mxMY?LuTH_WTEoe+&GVB&Q&Lh?%Kj_tYGdb@i`iYqyP7RAG0{+B z_Q#)}p9?hK-&gzl_xJoYQa5hgXlZF_;L+99Z9Cd6ZY;=amUF|Qak;g%_0%a-HfZfC zdg_&&tQ^9utgLKo{CR)<|2J>nnui`wy80l*Qg#K;3l)Kv&z_Zid2w;d6p=rACr_Vd z*4n&rW8zGaT<#~{H(efHS5Q}H-zfjEz4-Y##?NMQuIzVMm_)c#w3FmLfI^%F z9+AZi4BSE>%y{W;-5;PJOS+@4BLl<6e(pbstUx|nNswPKLk)u~gL>or5Ar~fTb?eC zAr-fh*A#}PE3g_&Trx|BSEpcF>yDSVXPa--nq**PRr8)Vzm$<|RFyoE{rADl3l2SeIp?NMQuIzVMm_#^a-2%TJ0t#^! zctjR6FmMZjFyp1Wb$@_@Ea{HEjtmSN`?>!lvI6;RB|(0{3^fd{4C;;dKga_`ZhN{o zhE&{2UQ-yFuE1(Aamg$hUY&xl;>MTzx0`RAt(6#ZyOtsL@P7X9lK0|{u6iiHTwu=G zAOBBtx0Ne2|F5k-{NcNKS-HVx!$PiR38h;)|K;AK-H`LY@bbUHl>b&-HfIyAA5>Y; zbN7dNxMZK{0TTlwBLgGjKmU)bJP(l;?+tbSJV)}sM8l~W4PB8lL~JD%_5a;%!@l2p zh7Xs7iIN0MNJQ4(wT*v{wPpN~`uEY}`thR+emy)Ix!~%J(EWQDN(8%>&zw^G&(`k1 shgUXbpCu({Jdu%?NMQuIzVMm_#_0Uh2Hu2NdEg z@Q5sCVBi)4Va7{$>;3=*S<)SS9T^xl_H+M9WCilsN`m}?8EP0@8Ppr^e~<@??DuqW z45_%4yrwWTU4hkL;*wc1ygCJ8uja(s*Zn!Ls-wF*J8cs8uD1F1^^YzcIMfty?8oct z`U`>-UZ02`Q-S<@&En39H#PsIP8=c-bD~Gyoi literal 0 HcmV?d00001 diff --git a/WebContent/localization/OSRM.Locale.de.js b/WebContent/localization/OSRM.Locale.de.js new file mode 100644 index 000000000..20094d1d6 --- /dev/null +++ b/WebContent/localization/OSRM.Locale.de.js @@ -0,0 +1,64 @@ +/* +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU AFFERO General Public License as published by +the Free Software Foundation; either version 3 of the License, or +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +or see http://www.gnu.org/licenses/agpl.txt. +*/ + +// OSRM localization +// [German language support] + + +OSRM.Localization["de"] = { +//gui +"OPEN_JOSM": "JOSM", +"OPEN_OSMBUGS": "OSM Bugs", +"GUI_START": "Start", +"GUI_END": "Ziel", +"GUI_RESET": "Reset", +"GUI_SEARCH": "Zeigen", +"GUI_REVERSE": "Umdrehen", +"GUI_OPTIONS": "Kartenwerkzeuge", +"GUI_HIGHLIGHT_UNNAMED_ROADS": "Unbenannte Straßen hervorheben", +"GUI_START_TOOLTIP": "Startposition eingeben", +"GUI_END_TOOLTIP": "Zielposition eingeben", +"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by KIT - Geocoder by OSM", +// geocoder +"SEARCH_RESULTS": "Suchergebnisse", +"TIMED_OUT": "Zeitüberschreitung", +"NO_RESULTS_FOUND": "Keine Ergebnisse gefunden", +"NO_RESULTS_FOUND_SOURCE": "Keine Ergebnisse gefunden für Start", +"NO_RESULTS_FOUND_TARGET": "Keine Ergebnisse gefunden für Ziel", +// routing +"ROUTE_DESCRIPTION": "Routenbeschreibung", +"GET_LINK_TO_ROUTE": "Generiere Link", +"GENERATE_LINK_TO_ROUTE": "Warte auf Antwort", +"LINK_TO_ROUTE_TIMEOUT": "nicht möglich", +"GPX_FILE": "GPX Datei", +"DISTANCE": "Distanz", +"DURATION": "Dauer", +"YOUR_ROUTE_IS_BEING_COMPUTED": "Ihre Route wird berechnet", +"NO_ROUTE_FOUND": "Keine Route hierher möglich", +// directions +"N": "Norden", +"O": "Ost", +"S": "Süden", +"W": "Westen", +"NO": "Nordost", +"SO": "Südost", +"SW": "Südwest", +"NW": "Nordwest" +}; + +// set GUI language on load +OSRM.GUI.setLanguage(); \ No newline at end of file diff --git a/WebContent/localization/OSRM.Locale.en.js b/WebContent/localization/OSRM.Locale.en.js new file mode 100644 index 000000000..686eb30bb --- /dev/null +++ b/WebContent/localization/OSRM.Locale.en.js @@ -0,0 +1,64 @@ +/* +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU AFFERO General Public License as published by +the Free Software Foundation; either version 3 of the License, or +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +or see http://www.gnu.org/licenses/agpl.txt. +*/ + +// OSRM localization +// [English language support] + + +OSRM.Localization["en"] = { +//gui +"OPEN_JOSM": "JOSM", +"OPEN_OSMBUGS": "OSM Bugs", +"GUI_START": "Start", +"GUI_END": "End", +"GUI_RESET": "  Reset  ", +"GUI_SEARCH": "  Show  ", +"GUI_REVERSE": "Reverse", +"GUI_OPTIONS": "Mapping Tools", +"GUI_HIGHLIGHT_UNNAMED_ROADS": "Highlight unnamed streets", +"GUI_START_TOOLTIP": "Enter start", +"GUI_END_TOOLTIP": "Enter destination", +"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by KIT - Geocoder by OSM", +// geocoder +"SEARCH_RESULTS": "Search Results", +"TIMED_OUT": "Timed Out", +"NO_RESULTS_FOUND": "No results found", +"NO_RESULTS_FOUND_SOURCE": "No results found for start", +"NO_RESULTS_FOUND_TARGET": "No results found for end", +//routing +"ROUTE_DESCRIPTION": "Route Description", +"GET_LINK_TO_ROUTE": "Generate Link", +"GENERATE_LINK_TO_ROUTE": "waiting for link", +"LINK_TO_ROUTE_TIMEOUT": "not available", +"GPX_FILE": "GPX File", +"DISTANCE": "Distance", +"DURATION": "Duration", +"YOUR_ROUTE_IS_BEING_COMPUTED": "Your route is being computed", +"NO_ROUTE_FOUND": "No route possible", +// directions +"N": "north", +"E": "east", +"S": "south", +"W": "west", +"NE": "northeast", +"SE": "southeast", +"SW": "southwest", +"NW": "northwest" +}; + +//set GUI language on load +OSRM.GUI.setLanguage(); \ No newline at end of file diff --git a/WebContent/localization/OSRM.Localization.js b/WebContent/localization/OSRM.Localization.js new file mode 100644 index 000000000..597e939b0 --- /dev/null +++ b/WebContent/localization/OSRM.Localization.js @@ -0,0 +1,74 @@ +/* +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU AFFERO General Public License as published by +the Free Software Foundation; either version 3 of the License, or +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +or see http://www.gnu.org/licenses/agpl.txt. +*/ + +// OSRM localization +// [basic localization options] + + +OSRM.Localization = { + +supported_languages: ["en", "de"], + +// initialize localization +init: function() { + // create dropdown menu + var select = document.createElement('select'); + select.id = "language-toggle"; + select.onchange = function() { OSRM.Localization.change(this.value); }; + + // fill dropdown menu + for(var i=0, size=OSRM.Localization.supported_languages.length; i English string -> input string +translate: function(text) { + if( OSRM.Localization[OSRM.DEFAULTS.LANGUAGE] && OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text] ) + return OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text]; + else if( OSRM.Localization["en"] && OSRM.Localization["en"][text] ) + return OSRM.Localization["en"][text]; + else + return text; +} +}; + +// shorter call to translate function +OSRM.loc = OSRM.Localization.translate; \ No newline at end of file diff --git a/WebContent/main.css b/WebContent/main.css index 31c9ec175..bbd4e86f8 100644 --- a/WebContent/main.css +++ b/WebContent/main.css @@ -112,9 +112,9 @@ html, body, #map { .main-toggle-out { cursor:pointer; - position:absolute; +/* position:absolute; right:5px; - top:5px; + top:5px;*/ width:16px; height:16px; background-image:url("images/cancel.png"); @@ -322,7 +322,6 @@ html, body, #map { user-select: text; } - /* buttons */ .button { @@ -348,7 +347,7 @@ html, body, #map { color:#FF0000; } - +/* delete marker */ .delete-marker { cursor:pointer; @@ -367,4 +366,28 @@ html, body, #map { .delete-marker:active { background-image:url("images/cancel_active.png"); +} + +/* printer button */ +.printer-inactive +{ + cursor:pointer; + width:16px; + height:16px; + background-image:url("images/printer_inactive.png"); +} +.printer +{ + cursor:pointer; + width:16px; + height:16px; + background-image:url("images/printer.png"); +} +.printer:hover +{ + background-image:url("images/printer_hover.png"); +} +.printer:active +{ + background-image:url("images/printer_active.png"); } \ No newline at end of file diff --git a/WebContent/main.html b/WebContent/main.html index 5d6787d60..939df3ea5 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -64,7 +64,8 @@ or see http://www.gnu.org/licenses/agpl.txt. - + + @@ -78,16 +79,23 @@ or see http://www.gnu.org/licenses/agpl.txt.
-
+
-
+
-
-
+
+
+
+
+
+
+ + + diff --git a/WebContent/main.js b/WebContent/main.js index 76471caa7..1dc16984d 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -27,6 +27,7 @@ OSRM.init = function() { OSRM.prefetchImages(); OSRM.prefetchIcons(); + OSRM.Localization.init(); OSRM.GUI.init(); OSRM.Map.init(); OSRM.Routing.init(); @@ -53,7 +54,11 @@ OSRM.prefetchImages = function() { 'images/cancel_hover.png', 'images/restore.png', 'images/restore_active.png', - 'images/restore_hover.png' + 'images/restore_hover.png', + 'images/printer.png', + 'images/printer_active.png', + 'images/printer_hover.png', + 'images/printer_inactive.png' ]; for(var i=0; ia
b
"); + OSRM.printwindow.focus(); + + OSRM.printwindow.addEventListener("DOMContentLoaded", OSRM.Printing.x, false); +} + +}; \ No newline at end of file diff --git a/WebContent/printing/printing.html b/WebContent/printing/printing.html new file mode 100644 index 000000000..01382ab0b --- /dev/null +++ b/WebContent/printing/printing.html @@ -0,0 +1,83 @@ + + + + + + + + + + + + +OSRM Website + + + + + + + + + + + + + + + + + + + + + +
+
+ + + From 28a241c3716a9544cd038ee7b23c6aef639aad57 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Wed, 4 Apr 2012 13:08:25 +0200 Subject: [PATCH 02/12] more testing on printing --- WebContent/OSRM.JSONP.js | 10 +-- WebContent/OSRM.Map.js | 8 +- WebContent/main.html | 2 +- WebContent/printing/OSRM.Printing.js | 92 +++++++++++++++-------- WebContent/printing/printing.css | 105 +++++++++++++++++++++++++++ WebContent/printing/printing.html | 28 ++++--- WebContent/routing/OSRM.Routing.js | 1 + 7 files changed, 198 insertions(+), 48 deletions(-) create mode 100644 WebContent/printing/printing.css diff --git a/WebContent/OSRM.JSONP.js b/WebContent/OSRM.JSONP.js index c29e634e6..f62ed470d 100644 --- a/WebContent/OSRM.JSONP.js +++ b/WebContent/OSRM.JSONP.js @@ -66,8 +66,8 @@ OSRM.JSONP = { OSRM.JSONP.fences[id] = undefined; // clean fence } -// OSRM.JSONP.sum[id] += new Number( new Date() - OSRM.JSONP.durations[id] ); -// OSRM.debug.log("[jsonp] response handling: "+id+" "+ (OSRM.JSONP.sum[id]/OSRM.JSONP.counter[id]).toFixed(2) ); + OSRM.JSONP.sum[id] += new Number( new Date() - OSRM.JSONP.durations[id] ); + OSRM.debug.log("[jsonp] response handling: "+id+" "+ (OSRM.JSONP.sum[id]/OSRM.JSONP.counter[id]).toFixed(2) ); }; // clean DOM (unfortunately, script elements cannot be reused by all browsers) @@ -85,9 +85,9 @@ OSRM.JSONP = { // start timeout timer OSRM.JSONP.timers[id] = setTimeout(OSRM.JSONP.timeouts[id], timeout); -// if(!OSRM.JSONP.durations) { OSRM.JSONP.durations = {}; OSRM.JSONP.counter = {}; OSRM.JSONP.sum = {}; } -// if(OSRM.JSONP.counter[id]) OSRM.JSONP.counter[id]++; else {OSRM.JSONP.counter[id] = 1;OSRM.JSONP.sum[id] = 0;} -// OSRM.JSONP.durations[id] = new Date(); + if(!OSRM.JSONP.durations) { OSRM.JSONP.durations = {}; OSRM.JSONP.counter = {}; OSRM.JSONP.sum = {}; } + if(OSRM.JSONP.counter[id]) OSRM.JSONP.counter[id]++; else {OSRM.JSONP.counter[id] = 1;OSRM.JSONP.sum[id] = 0;} + OSRM.JSONP.durations[id] = new Date(); // OSRM.debug.log("[jsonp] init: "+id); return true; diff --git a/WebContent/OSRM.Map.js b/WebContent/OSRM.Map.js index 1031f3f0a..f53874d59 100644 --- a/WebContent/OSRM.Map.js +++ b/WebContent/OSRM.Map.js @@ -121,6 +121,8 @@ init: function() { // initial map position and zoom var position = new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE); OSRM.G.map.setViewUI( position, OSRM.DEFAULTS.ZOOM_LEVEL); + if (navigator.geolocation && document.URL.indexOf("file://") == -1) + navigator.geolocation.getCurrentPosition(OSRM.Map.geolocationResponse); // map events OSRM.G.map.on('zoomend', OSRM.Map.zoomed ); @@ -146,6 +148,10 @@ click: function(e) { OSRM.G.markers.route[index].show(); OSRM.G.markers.route[index].centerView( OSRM.G.map.getZoom() ); OSRM.Routing.getRoute(); - } + } +}, +geolocationResponse: function(response) { + var latlng = new L.LatLng(response.coords.latitude, response.coords.longitude); + OSRM.G.map.setViewUI(latlng, OSRM.DEFAULTS.ZOOM_LEVEL ); } }; \ No newline at end of file diff --git a/WebContent/main.html b/WebContent/main.html index 939df3ea5..a561bd4e0 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -46,7 +46,7 @@ or see http://www.gnu.org/licenses/agpl.txt. - + diff --git a/WebContent/printing/OSRM.Printing.js b/WebContent/printing/OSRM.Printing.js index 03df8d4ca..e1f19a8e9 100644 --- a/WebContent/printing/OSRM.Printing.js +++ b/WebContent/printing/OSRM.Printing.js @@ -18,43 +18,73 @@ or see http://www.gnu.org/licenses/agpl.txt. // OSRM printer // [printing support] - OSRM.Printing = { -x: function(){ - OSRM.printwindow.test(); -// var pos1 = OSRM.printwindow.document.getElementById('map1'); -// var pos2 = OSRM.printwindow.document.getElementById('map2'); -// // setup map -// var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', -// osmorgOptions = {maxZoom: 18}; -// var osmorg = new L.TileLayer(osmorgURL, osmorgOptions); -// var temp1 = new OSRM.MapView(pos1, { -// center: new L.LatLng(51.505, -0.09), -// zoom: 13, -// zoomAnimation: false, // false: removes animations and hiding of routes during zoom -// fadeAnimation: false, -// layers: [osmorg] -// }); -// var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', -// osmorgOptions = {maxZoom: 18}; -// var osmorg = new L.TileLayer(osmorgURL, osmorgOptions); -// var temp2 = new OSRM.MapView(pos2, { -// center: new L.LatLng(51.505, -0.09), -// zoom: 13, -// zoomAnimation: false, // false: removes animations and hiding of routes during zoom -// fadeAnimation: false, -// layers: [osmorg] -// }); +windowLoaded: function(){ + OSRM.printwindow.initialize(); + OSRM.Printing.show( OSRM.G.response ); + OSRM.printwindow.focus(); +}, + +show: function(response) { + // create route description + var route_desc = ""; + route_desc += ''; + + for(var i=0; i < response.route_instructions.length; i++){ + //odd or even ? + var rowstyle='results-odd'; + if(i%2==0) { rowstyle='results-even'; } + + route_desc += ''; + + route_desc += '"; + + route_desc += '"; + + route_desc += '"; + + route_desc += ""; + } + + route_desc += '
'; + route_desc += ''; + route_desc += "'; + route_desc += ''; + route_desc += response.route_instructions[i][0]; + if( i == 0 ) + route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] ); + if( response.route_instructions[i][1] != "" ) { + route_desc += ' on '; + route_desc += '' + response.route_instructions[i][1] + ''; + } + //route_desc += ' for '; + route_desc += ''; + route_desc += "'; + if( i != response.route_instructions.length-1 ) + route_desc += ''+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+''; + route_desc += "
'; + headline = ""; + headline += OSRM.loc("ROUTE_DESCRIPTION")+":
"; + headline += '
'; + headline += "" + + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + + "
" + + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + + "
"; + headline += '
'; + + var output = ""; + output += route_desc; + + OSRM.printwindow.document.getElementById('description-headline').innerHTML = headline; + OSRM.printwindow.document.getElementById('description').innerHTML = output; }, // react to click print: function() { - OSRM.printwindow = window.open("printing.html", "Popupfenster", "width=400,height=300,resizable=yes"); -// fenster.document.write("
a
b
"); - OSRM.printwindow.focus(); - - OSRM.printwindow.addEventListener("DOMContentLoaded", OSRM.Printing.x, false); + OSRM.printwindow = window.open("printing/printing.html","","width=400,height=300,left=100,top=100,dependent=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes"); + OSRM.printwindow.addEventListener("DOMContentLoaded", OSRM.Printing.windowLoaded, false); } }; \ No newline at end of file diff --git a/WebContent/printing/printing.css b/WebContent/printing/printing.css new file mode 100644 index 000000000..a1ae513f0 --- /dev/null +++ b/WebContent/printing/printing.css @@ -0,0 +1,105 @@ +/* +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU AFFERO General Public License as published by +the Free Software Foundation; either version 3 of the License, or +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +or see http://www.gnu.org/licenses/agpl.txt. +*/ + +/* OSRM CSS styles for printing*/ + + +/* printer button */ +.printer-inactive +{ + cursor:pointer; + width:16px; + height:16px; + background-image:url("../images/printer_inactive.png"); +} +.printer +{ + cursor:pointer; + width:16px; + height:16px; + background-image:url("../images/printer.png"); +} +.printer:hover +{ + background-image:url("../images/printer_hover.png"); +} +.printer:active +{ + background-image:url("../images/printer_active.png"); +} + +/* route summary */ +.route-summary +{ + font-size: 12px; +} + +/* route description box */ +#description +{ + position:absolute; + bottom:15px; + top:60px; + width:380px; + font-size:12px; + margin:5px; +} +.results-table +{ + border-spacing:0px; +} +.results-odd +{ + background-color: #FAF3E9; //#ffffff; +} +.results-even +{ + background-color: #F2DE9C; //#ffffe0; +} +.result-items +{ + text-align:left; + vertical-align: middle; + width:100%; + padding-left:1px; + padding-right:1px; + padding-top:1px; + padding-bottom:1px; +} +.result-direction +{ + width:30px; + padding-left:1px; + padding-right:1px; + padding-top:1px; + padding-bottom:1px; +} +.result-distance +{ + text-align:right; + vertical-align: middle; + width:30px; + padding-left:1px; + padding-right:1px; + padding-top:1px; + padding-bottom:1px; +} +.result-item +{ + cursor:pointer; + color:#000000 +} diff --git a/WebContent/printing/printing.html b/WebContent/printing/printing.html index 01382ab0b..5580e15da 100644 --- a/WebContent/printing/printing.html +++ b/WebContent/printing/printing.html @@ -30,17 +30,18 @@ or see http://www.gnu.org/licenses/agpl.txt. - + - - + + + - + @@ -74,10 +79,13 @@ function test() { - +
-
-
+ + +
+
diff --git a/WebContent/routing/OSRM.Routing.js b/WebContent/routing/OSRM.Routing.js index 2796d187d..b05704acd 100644 --- a/WebContent/routing/OSRM.Routing.js +++ b/WebContent/routing/OSRM.Routing.js @@ -71,6 +71,7 @@ showRoute: function(response) { if(!response) return; + OSRM.G.response = response; OSRM.G.via_points = response.via_points.slice(0); if(response.status == 207) { OSRM.RoutingGeometry.showNA(); From dc192d47a8ae19b4d21ddcb20d618ff045e73b65 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Thu, 5 Apr 2012 01:12:15 +0200 Subject: [PATCH 03/12] input boxes are no longer deleted on language change --- WebContent/OSRM.GUI.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index 223c2a914..f6ffe6203 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -29,6 +29,9 @@ width: null, init: function() { OSRM.GUI.visible = true; OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth; + + document.getElementById('input-source-name').value = OSRM.DEFAULTS.ONLOAD_SOURCE; + document.getElementById('input-target-name').value = OSRM.DEFAULTS.ONLOAD_TARGET; }, // set language dependent labels @@ -46,9 +49,6 @@ setLanguage: function() { document.getElementById("input-source-name").title = OSRM.loc("GUI_START_TOOLTIP"); document.getElementById("input-target-name").title = OSRM.loc("GUI_END_TOOLTIP"); document.getElementById("legal-notice").innerHTML = OSRM.loc("GUI_LEGAL_NOTICE"); - - document.getElementById('input-source-name').value = OSRM.DEFAULTS.ONLOAD_SOURCE; - document.getElementById('input-target-name').value = OSRM.DEFAULTS.ONLOAD_TARGET; }, // show/hide main-gui From 3141d3ba48d8a9864d9ec161e84a0d4b77155379 Mon Sep 17 00:00:00 2001 From: shiin Date: Fri, 6 Apr 2012 12:27:23 +0200 Subject: [PATCH 04/12] prepared localization / route description module to use description ids instead of description strings --- WebContent/localization/OSRM.Locale.de.js | 26 +++++++++++++++++-- WebContent/localization/OSRM.Locale.en.js | 26 +++++++++++++++++-- WebContent/localization/OSRM.Localization.js | 2 ++ WebContent/routing/OSRM.RoutingDescription.js | 9 +++++++ 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/WebContent/localization/OSRM.Locale.de.js b/WebContent/localization/OSRM.Locale.de.js index 20094d1d6..b0029cab0 100644 --- a/WebContent/localization/OSRM.Locale.de.js +++ b/WebContent/localization/OSRM.Locale.de.js @@ -57,8 +57,30 @@ OSRM.Localization["de"] = { "NO": "Nordost", "SO": "Südost", "SW": "Südwest", -"NW": "Nordwest" +"NW": "Nordwest", +// driving directions +"DIRECTION_1":"Links abbiegen[ auf %s]", +"DIRECTION_2":"Rechts abbiegen[ auf %s]", +"DIRECTION_3":"Umkehren[ auf %s]", +"DIRECTION_4":"Fahren Sie Richtung %s", +"DIRECTION_5":"Weiterfahren[ auf %s]", +"DIRECTION_6":"Leicht links abbiegen[ auf %s]", +"DIRECTION_7":"Leicht rechts abbiegen[ auf %s]", +"DIRECTION_8":"Scharf links abbiegen[ auf %s]", +"DIRECTION_9":"Scharf rechts abbiegen[ auf %s]", +"DIRECTION_10":"In den Kreisverkehr einfahren und bei erster Möglichkeit verlassen[ auf %s]", +"DIRECTION_11":"In den Kreisverkehr einfahren und bei zweiter Möglichkeit verlassen[ auf %s]", +"DIRECTION_12":"In den Kreisverkehr einfahren und bei dritter Möglichkeit verlassen[ auf %s]", +"DIRECTION_13":"In den Kreisverkehr einfahren und bei vierter Möglichkeit verlassen[ auf %s]", +"DIRECTION_14":"In den Kreisverkehr einfahren und bei f�nfter Möglichkeit verlassen[ auf %s]", +"DIRECTION_15":"In den Kreisverkehr einfahren und bei sechster Möglichkeit verlassen[ auf %s]", +"DIRECTION_16":"In den Kreisverkehr einfahren und bei siebter Möglichkeit verlassen[ auf %s]", +"DIRECTION_17":"In den Kreisverkehr einfahren und bei achter Möglichkeit verlassen[ auf %s]", +"DIRECTION_18":"In den Kreisverkehr einfahren und bei neunter Möglichkeit verlassen[ auf %s]", +"DIRECTION_19":"In den Kreisverkehr einfahren und bei zehnter Möglichkeit verlassen[ auf %s]", +"DIRECTION_20":"In den Kreisverkehr einfahren und bei einer der vielen Möglichkeiten verlassen[ auf %s]", +"DIRECTION_21":"Sie haben Ihr Ziel erreicht" }; // set GUI language on load -OSRM.GUI.setLanguage(); \ No newline at end of file +OSRM.Localization.change("de"); \ No newline at end of file diff --git a/WebContent/localization/OSRM.Locale.en.js b/WebContent/localization/OSRM.Locale.en.js index 686eb30bb..a063d9fa5 100644 --- a/WebContent/localization/OSRM.Locale.en.js +++ b/WebContent/localization/OSRM.Locale.en.js @@ -57,8 +57,30 @@ OSRM.Localization["en"] = { "NE": "northeast", "SE": "southeast", "SW": "southwest", -"NW": "northwest" +"NW": "northwest", +// driving directions +"DIRECTION_1":"Turn left[ on %s]", +"DIRECTION_2":"Turn right[ on %s]", +"DIRECTION_3":"U-Turn[ on %s]", +"DIRECTION_4":"Head %s", +"DIRECTION_5":"Continue[ on %s]", +"DIRECTION_6":"Turn slight left[ on %s]", +"DIRECTION_7":"Turn slight right[ on %s]", +"DIRECTION_8":"Turn sharp left[ on %s]", +"DIRECTION_9":"Turn sharp right[ on %s]", +"DIRECTION_10":"Enter roundabout and leave at first exit[ on %s]", +"DIRECTION_11":"Enter roundabout and leave at second exit[ on %s]", +"DIRECTION_12":"Enter roundabout and leave at third exit[ on %s]", +"DIRECTION_13":"Enter roundabout and leave at fourth exit[ on %s]", +"DIRECTION_14":"Enter roundabout and leave at fifth exit[ on %s]", +"DIRECTION_15":"Enter roundabout and leave at sixth exit[ on %s]", +"DIRECTION_16":"Enter roundabout and leave at seventh exit[ on %s]", +"DIRECTION_17":"Enter roundabout and leave at eighth exit[ on %s]", +"DIRECTION_18":"Enter roundabout and leave at nineth exit[ on %s]", +"DIRECTION_19":"Enter roundabout and leave at tenth exit[ on %s]", +"DIRECTION_20":"Enter roundabout and leave at one of the too many exits[ on %s]", +"DIRECTION_21":"You have reached your destination" }; //set GUI language on load -OSRM.GUI.setLanguage(); \ No newline at end of file +OSRM.Localization.change("en"); \ No newline at end of file diff --git a/WebContent/localization/OSRM.Localization.js b/WebContent/localization/OSRM.Localization.js index 597e939b0..2e5ce7415 100644 --- a/WebContent/localization/OSRM.Localization.js +++ b/WebContent/localization/OSRM.Localization.js @@ -51,6 +51,8 @@ change: function(language) { OSRM.DEFAULTS.LANGUAGE = language; if( OSRM.Localization[language]) { OSRM.GUI.setLanguage(); + if( document.getElementById('information-box').innerHTML != "" ) + OSRM.RoutingDescription.show( OSRM.G.response ); } else { var script = document.createElement('script'); script.type = 'text/javascript'; diff --git a/WebContent/routing/OSRM.RoutingDescription.js b/WebContent/routing/OSRM.RoutingDescription.js index 19911efb1..5d236fb4e 100644 --- a/WebContent/routing/OSRM.RoutingDescription.js +++ b/WebContent/routing/OSRM.RoutingDescription.js @@ -72,6 +72,15 @@ show: function(response) { route_desc += ''; route_desc += ''; + +// // build route description +// if( i == 0 ) +// route_desc += OSRM.loc("DIRECTION_"+response.route_instructions[i][0]).replace(/%s/, response.route_instructions[i][6]); +// else if( response.route_instructions[i][1] != "" ) +// route_desc += OSRM.loc("DIRECTION_"+response.route_instructions[i][0]).replace(/\[(.*)\]/,""); +// else +// route_desc += OSRM.loc("DIRECTION_"+response.route_instructions[i][0]).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][6]); + route_desc += response.route_instructions[i][0]; if( i == 0 ) route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] ); From 13f0a3fb6bf643fa5bf71da23fdc73d4747ab3c9 Mon Sep 17 00:00:00 2001 From: shiin Date: Sun, 8 Apr 2012 12:02:36 +0200 Subject: [PATCH 05/12] redid html and css, switched to sans-serif font --- WebContent/OSRM.Geocoder.js | 24 +- WebContent/OSRM.JSONP.js | 10 +- WebContent/OSRM.Localization.js | 122 ----- WebContent/OSRM.Markers.js | 4 +- WebContent/localization/OSRM.Localization.js | 4 +- WebContent/main.css | 426 ++++++++++-------- WebContent/main.html | 106 +++-- WebContent/printing/OSRM.Printing.js | 4 +- WebContent/routing/OSRM.RoutingDescription.js | 101 +++-- WebContent/routing/OSRM.RoutingGUI.js | 4 +- 10 files changed, 375 insertions(+), 430 deletions(-) delete mode 100644 WebContent/OSRM.Localization.js diff --git a/WebContent/OSRM.Geocoder.js b/WebContent/OSRM.Geocoder.js index 6896d702c..76378f43f 100644 --- a/WebContent/OSRM.Geocoder.js +++ b/WebContent/OSRM.Geocoder.js @@ -78,7 +78,7 @@ _showResults: function(response, parameters) { // show possible results for input var html = ""; - html += ''; + html += '
'; for(var i=0; i < response.length; i++){ var result = response[i]; @@ -91,29 +91,35 @@ _showResults: function(response, parameters) { html += '"; } html += '
'; if(result.display_name){ - html += '
'+result.display_name+'
'; + html += '
'+result.display_name+'
'; } html += "
'; - document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":"; + document.getElementById('information-box-header').innerHTML = + "
"+OSRM.loc("SEARCH_RESULTS")+"
" + + "
(found "+response.length+" results)"+"
"; document.getElementById('information-box').innerHTML = html; OSRM.Geocoder._onclickResult(parameters.marker_id, response[0].lat, response[0].lon); }, _showResults_Empty: function(parameters) { - document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":"; + document.getElementById('information-box-header').innerHTML = + "
"+OSRM.loc("SEARCH_RESULTS")+"
" + + "
(found 0 results)"+"
"; if(parameters.marker_id == OSRM.C.SOURCE_LABEL) - document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND_SOURCE")+": "+parameters.query +".

"; + document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND_SOURCE")+": "+parameters.query +"
"; else if(parameters.marker_id == OSRM.C.TARGET_LABEL) - document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+": "+parameters.query +".

"; + document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+": "+parameters.query +"
"; else - document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND")+": "+parameters.query +".

"; + document.getElementById('information-box').innerHTML = "

"+OSRM.loc("NO_RESULTS_FOUND")+": "+parameters.query +"
"; }, _showResults_Timeout: function() { - document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":"; - document.getElementById('information-box').innerHTML = "

"+OSRM.loc("TIMED_OUT")+".

"; + document.getElementById('information-box-header').innerHTML = + "

"+OSRM.loc("SEARCH_RESULTS")+"
" + + "
(found 0 results)"+"
"; + document.getElementById('information-box').innerHTML = "
"+OSRM.loc("TIMED_OUT")+"
"; }, diff --git a/WebContent/OSRM.JSONP.js b/WebContent/OSRM.JSONP.js index f62ed470d..c29e634e6 100644 --- a/WebContent/OSRM.JSONP.js +++ b/WebContent/OSRM.JSONP.js @@ -66,8 +66,8 @@ OSRM.JSONP = { OSRM.JSONP.fences[id] = undefined; // clean fence } - OSRM.JSONP.sum[id] += new Number( new Date() - OSRM.JSONP.durations[id] ); - OSRM.debug.log("[jsonp] response handling: "+id+" "+ (OSRM.JSONP.sum[id]/OSRM.JSONP.counter[id]).toFixed(2) ); +// OSRM.JSONP.sum[id] += new Number( new Date() - OSRM.JSONP.durations[id] ); +// OSRM.debug.log("[jsonp] response handling: "+id+" "+ (OSRM.JSONP.sum[id]/OSRM.JSONP.counter[id]).toFixed(2) ); }; // clean DOM (unfortunately, script elements cannot be reused by all browsers) @@ -85,9 +85,9 @@ OSRM.JSONP = { // start timeout timer OSRM.JSONP.timers[id] = setTimeout(OSRM.JSONP.timeouts[id], timeout); - if(!OSRM.JSONP.durations) { OSRM.JSONP.durations = {}; OSRM.JSONP.counter = {}; OSRM.JSONP.sum = {}; } - if(OSRM.JSONP.counter[id]) OSRM.JSONP.counter[id]++; else {OSRM.JSONP.counter[id] = 1;OSRM.JSONP.sum[id] = 0;} - OSRM.JSONP.durations[id] = new Date(); +// if(!OSRM.JSONP.durations) { OSRM.JSONP.durations = {}; OSRM.JSONP.counter = {}; OSRM.JSONP.sum = {}; } +// if(OSRM.JSONP.counter[id]) OSRM.JSONP.counter[id]++; else {OSRM.JSONP.counter[id] = 1;OSRM.JSONP.sum[id] = 0;} +// OSRM.JSONP.durations[id] = new Date(); // OSRM.debug.log("[jsonp] init: "+id); return true; diff --git a/WebContent/OSRM.Localization.js b/WebContent/OSRM.Localization.js deleted file mode 100644 index ffe7ec9ec..000000000 --- a/WebContent/OSRM.Localization.js +++ /dev/null @@ -1,122 +0,0 @@ -/* -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU AFFERO General Public License as published by -the Free Software Foundation; either version 3 of the License, or -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -or see http://www.gnu.org/licenses/agpl.txt. -*/ - -// OSRM localization -// [basic localization options] - - -OSRM.Localization = { - -// if existing, return localized string -> English string -> input string -translate: function(text) { - if( OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text] ) - return OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text]; - else if( OSRM.Localization["en"][text] ) - return OSRM.Localization["en"][text]; - else - return text; -} -}; - -// shorter call to translate function -OSRM.loc = OSRM.Localization.translate; - - -// German language support -OSRM.Localization["de"] = { -//gui -"OPEN_JOSM": "JOSM", -"OPEN_OSMBUGS": "OSM Bugs", -"GUI_START": "Start", -"GUI_END": "Ziel", -"GUI_RESET": "Reset", -"GUI_SEARCH": "Zeigen", -"GUI_REVERSE": "Umdrehen", -"GUI_OPTIONS": "Kartenwerkzeuge", -"GUI_HIGHLIGHT_UNNAMED_ROADS": "Unbenannte Straßen hervorheben", -"GUI_START_TOOLTIP": "Startposition eingeben", -"GUI_END_TOOLTIP": "Zielposition eingeben", -"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by KIT - Geocoder by OSM", -// geocoder -"SEARCH_RESULTS": "Suchergebnisse", -"TIMED_OUT": "Zeitüberschreitung", -"NO_RESULTS_FOUND": "Keine Ergebnisse gefunden", -"NO_RESULTS_FOUND_SOURCE": "Keine Ergebnisse gefunden für Start", -"NO_RESULTS_FOUND_TARGET": "Keine Ergebnisse gefunden für Ziel", -// routing -"ROUTE_DESCRIPTION": "Routenbeschreibung", -"GET_LINK_TO_ROUTE": "Generiere Link", -"GENERATE_LINK_TO_ROUTE": "Warte auf Antwort", -"LINK_TO_ROUTE_TIMEOUT": "nicht möglich", -"GPX_FILE": "GPX Datei", -"DISTANCE": "Distanz", -"DURATION": "Dauer", -"YOUR_ROUTE_IS_BEING_COMPUTED": "Ihre Route wird berechnet", -"NO_ROUTE_FOUND": "Keine Route hierher möglich", -// directions -"N": "Norden", -"O": "Ost", -"S": "Süden", -"W": "Westen", -"NO": "Nordost", -"SO": "Südost", -"SW": "Südwest", -"NW": "Nordwest" -}; - - -// English language support -OSRM.Localization["en"] = { -//gui -"OPEN_JOSM": "JOSM", -"OPEN_OSMBUGS": "OSM Bugs", -"GUI_START": "Start", -"GUI_END": "End", -"GUI_RESET": "  Reset  ", -"GUI_SEARCH": "  Show  ", -"GUI_REVERSE": "Reverse", -"GUI_OPTIONS": "Mapping Tools", -"GUI_HIGHLIGHT_UNNAMED_ROADS": "Highlight unnamed streets", -"GUI_START_TOOLTIP": "Enter start", -"GUI_END_TOOLTIP": "Enter destination", -"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by KIT - Geocoder by OSM", -// geocoder -"SEARCH_RESULTS": "Search Results", -"TIMED_OUT": "Timed Out", -"NO_RESULTS_FOUND": "No results found", -"NO_RESULTS_FOUND_SOURCE": "No results found for start", -"NO_RESULTS_FOUND_TARGET": "No results found for end", -//routing -"ROUTE_DESCRIPTION": "Route Description", -"GET_LINK_TO_ROUTE": "Generate Link", -"GENERATE_LINK_TO_ROUTE": "waiting for link", -"LINK_TO_ROUTE_TIMEOUT": "not available", -"GPX_FILE": "GPX File", -"DISTANCE": "Distance", -"DURATION": "Duration", -"YOUR_ROUTE_IS_BEING_COMPUTED": "Your route is being computed", -"NO_ROUTE_FOUND": "No route possible", -// directions -"N": "north", -"E": "east", -"S": "south", -"W": "west", -"NE": "northeast", -"SE": "southeast", -"SW": "southwest", -"NW": "northwest" -}; \ No newline at end of file diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js index bc8ff1bd8..ad649bc7c 100644 --- a/WebContent/OSRM.Markers.js +++ b/WebContent/OSRM.Markers.js @@ -218,14 +218,14 @@ removeMarker: function(id) { this.removeVias(); document.getElementById('input-source-name').value = ""; document.getElementById('information-box').innerHTML = ""; - document.getElementById('information-box-headline').innerHTML = ""; + document.getElementById('information-box-header').innerHTML = ""; document.getElementById('delete-source-marker').style.visibility = "hidden"; } else if( id == this.route.length-1 && this.route[ this.route.length-1 ].label == OSRM.C.TARGET_LABEL ) { this.removeVias(); id = this.route.length-1; document.getElementById('input-target-name').value = ""; document.getElementById('information-box').innerHTML = ""; - document.getElementById('information-box-headline').innerHTML = ""; + document.getElementById('information-box-header').innerHTML = ""; document.getElementById('delete-target-marker').style.visibility = "hidden"; } diff --git a/WebContent/localization/OSRM.Localization.js b/WebContent/localization/OSRM.Localization.js index 2e5ce7415..fe9ad8215 100644 --- a/WebContent/localization/OSRM.Localization.js +++ b/WebContent/localization/OSRM.Localization.js @@ -39,8 +39,8 @@ init: function() { } // add element to DOM - var main_input_header = document.getElementById('main-input-header'); - main_input_header.insertBefore(select,main_input_header.firstChild); + var input_mask_header = document.getElementById('input-mask-header'); + input_mask_header.insertBefore(select,input_mask_header.firstChild); // initialize default language OSRM.Localization.change( OSRM.DEFAULTS.LANGUAGE ); diff --git a/WebContent/main.css b/WebContent/main.css index bbd4e86f8..d6f287df5 100644 --- a/WebContent/main.css +++ b/WebContent/main.css @@ -18,25 +18,19 @@ or see http://www.gnu.org/licenses/agpl.txt. /* OSRM CSS styles */ -/* map -> fullscreen */ -body { +/* fullscreen map */ +html, body { padding: 0; margin: 0; -} -html, body, #map { height: 100%; } #map { + height: 100%; z-index: 0; } -/* styles for gui */ -.vquad -{ - height:10px; -} - +/* general styles for gui boxes */ .gui-wrapper { position:absolute; @@ -63,11 +57,13 @@ html, body, #map { padding:5px; } + +/* styles for specific gui boxes */ #main-wrapper { width:410px; - height:95%; top:5px; + bottom:25px; left:5px; } #main-input @@ -78,10 +74,9 @@ html, body, #map { #main-output { width:390px; - top:220px; + top:220px; /* main-input.height+2*gui-box.margin+2*gui-box.padding */ bottom:0px; } - #blob-wrapper { left:-5px; @@ -96,73 +91,69 @@ html, body, #map { -webkit-border-bottom-left-radius:0px; visibility:hidden; } -#blob-input +#blob-content { - width:26px; - height:26px; + width:16px; + height:16px; border-top-left-radius:0px; border-bottom-left-radius:0px; -moz-border-radius-topleft:0px; -moz-border-radius-bottomleft:0px; -webkit-border-top-left-radius:0px; -webkit-border-bottom-left-radius:0px; - padding:0px; } -.main-toggle-out -{ - cursor:pointer; -/* position:absolute; - right:5px; - top:5px;*/ - width:16px; - height:16px; - background-image:url("images/cancel.png"); -} -.main-toggle-out:hover -{ - background-image:url("images/cancel_hover.png"); -} -.main-toggle-out:active -{ - background-image:url("images/cancel_active.png"); -} -.main-toggle-in -{ - cursor:pointer; - position:absolute; - right:5px; - top:5px; - width:16px; - height:16px; - background-image:url("images/restore.png"); -} -.main-toggle-in:hover -{ - background-image:url("images/restore_hover.png"); -} -.main-toggle-in:active -{ - background-image:url("images/restore_active.png"); -} -.main-options +/* styles for main-input areas */ +#input-mask-header { - position:relative; - font-size:10px; -} -.main-options-left-box -{ - position:absolute; - left:5px; + left:0px; + right:0px; top:0px; + height:50px; + background-repeat:no-repeat; + background-position:center; + background-image:url("images/osrm-logo.png"); } -.main-options-right-box +#input-mask { - position:absolute; - right:5px; - top:5px; + margin:3px; } +#input-mask-options +{ + margin:3px; +} + + +/* styles for main-input input-mask-header */ +#language-toggle +{ + border: 0px; + text-decoration:none; +} +.top-right-button +{ + float:right; +} + + +/* styles for main-input input-mask */ +.input-marker +{ + display:table-row; +} +.input-marker > div +{ + padding-bottom:4px; +} +.input-box +{ + width: 250px; + padding-right: 2px; +} + + +/* styles for main-input input-mask-options */ #options-toggle { cursor:pointer; @@ -177,111 +168,92 @@ html, body, #map { visibility:hidden; } -#osrm-logo -{ - display: block; - margin-left: auto; - margin-right: auto; - width: 192px; - height: 50px; - text-align:center; - vertical-align: middle; -} -.input-box +/* styles for main-output areas */ +#information-box-header { - width: 250px; + margin:5px; + height:60px; } - - -.full -{ - width:100%; -} -.right -{ - text-align:right; -} -.center -{ - text-align:center; -} - #information-box { position:absolute; - bottom:15px; - top:60px; + bottom:20px; + top:65px; width:380px; - font-size:12px; overflow:auto; margin:5px; } - -.route-summary +#legal-notice { - font-size: 12px; + position:absolute; + right:0px; + bottom:0px; + margin:5px; } -#gpx-link + + +/* styles for information-box-header */ +.header-title +{ + font-weight:bold; + margin-bottom:10px; +} +.header-content +{ + font-weight:normal; +} +.result-link { color:#0000ff; text-decoration:none; cursor:pointer; } -#gpx-link:hover +.result-link:hover { color:#ff0000; } + + +/* style for information-box table (search results, driving directions) */ .results-table { border-spacing:0px; + width:100%; } .results-odd { - background-color: #FAF3E9; //#ffffff; + background-color: #FFFDE3; } .results-even { - background-color: #F2DE9C; //#ffffe0; + background-color: #FFF9BB; } .result-counter { text-align:right; - vertical-align: top; - width:30px; + vertical-align:top; font-weight:bold; - padding-left:5px; - padding-right:5px; - padding-top:1px; - padding-bottom:1px; + padding:1px 5px 1px 5px; } .result-items { text-align:left; vertical-align: middle; width:100%; - padding-left:1px; - padding-right:1px; - padding-top:1px; - padding-bottom:1px; + padding:1px; } -.result-direction +.result-directions { - width:30px; - padding-left:1px; - padding-right:1px; - padding-top:1px; - padding-bottom:1px; + text-align:left; + vertical-align: middle; + padding:1px 5px 1px 5px; } .result-distance { text-align:right; - vertical-align: middle; - width:30px; - padding-left:1px; - padding-right:1px; - padding-top:1px; - padding-bottom:1px; + vertical-align: middle; + padding:1px 1px 1px 5px; } .result-item { @@ -292,18 +264,135 @@ html, body, #map { { color:#ff0000 } - -#legal-notice +.no-results { - position:absolute; - right:0px; - bottom:0px; - padding:5px; - font-size:10px; + text-align:center; + margin:28px; +} + + +/* buttons */ +.button +{ + cursor:pointer; + padding:2px 10px 2px 10px; + border-radius:5px; + -moz-border-radius:5px; + -webkit-border-radius:5px; + background-color:#EEEEEE; + border:1px solid #999999; + color:#333333; + text-decoration:none; + font-size:9px; + outline-style:none; + vertical-align:1px; +} +.button:hover +{ + background-color:#F9F9F9; + color:#000000; +} +.button:active +{ + background-color:#F4F4F4; + color:#FF0000; +} + + +/* iconic buttons */ +.iconic-button +{ + cursor:pointer; + width:16px; + height:16px; + background-repeat:no-repeat; + background-position:center; +} + +#gui-toggle-out +{ + background-image:url("images/cancel.png"); +} +#gui-toggle-out:hover +{ + background-image:url("images/cancel_hover.png"); +} +#gui-toggle-out:active +{ + background-image:url("images/cancel_active.png"); +} + +#gui-toggle-in +{ + background-image:url("images/restore.png"); +} +#gui-toggle-in:hover +{ + background-image:url("images/restore_hover.png"); +} +#gui-toggle-in:active +{ + background-image:url("images/restore_active.png"); +} + +#printer +{ + background-image:url("images/printer.png"); +} +#printer:hover +{ + background-image:url("images/printer_hover.png"); +} +#printer:active +{ + background-image:url("images/printer_active.png"); +} + +.delete-marker +{ + background-image:url("images/cancel.png"); + visibility:hidden; +} +.delete-marker:hover +{ + background-image:url("images/cancel_hover.png"); +} +.delete-marker:active +{ + background-image:url("images/cancel_active.png"); +} + + +/* fonts */ +.base-font { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 12px; + font-weight: normal; +} +.big-font { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + font-weight: bold; +} +.medium-font { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10.5px; + font-weight: normal; +} +.small-font { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 9px; + font-weight: normal; } /* utility styles (defined above buttons, so that buttons retain cursor:pointer)*/ +.quad +{ + min-width:10px; + min-height:10px; +} + .not-selectable { cursor:default; @@ -322,72 +411,31 @@ html, body, #map { user-select: text; } -/* buttons */ -.button +.checkbox-label { - cursor:pointer; - padding:2px 10px 2px 10px; - border-radius:5px; - -moz-border-radius:5px; - background-color:#EEEEEE; - border:1px solid #999999; - color:#333333; - text-decoration:none; - font-size:11px; - outline-style:none; -} -.button:hover -{ - background-color:#F9F9F9; - color:#000000; -} -.button:active -{ - background-color:#F4F4F4; - color:#FF0000; + vertical-align:2px; } -/* delete marker */ -.delete-marker +.full { - cursor:pointer; - position:absolute; - right:5px; - top:3px; - width:16px; - height:16px; - background-image:url("images/cancel.png"); - visibility:hidden; + display:table; + width:100%; } -.delete-marker:hover +.left { - background-image:url("images/cancel_hover.png"); + display:table-cell; + text-align:left; + vertical-align:middle; } -.delete-marker:active +.right { - background-image:url("images/cancel_active.png"); + display:table-cell; + text-align:right; + vertical-align:middle; } - -/* printer button */ -.printer-inactive +.center { - cursor:pointer; - width:16px; - height:16px; - background-image:url("images/printer_inactive.png"); -} -.printer -{ - cursor:pointer; - width:16px; - height:16px; - background-image:url("images/printer.png"); -} -.printer:hover -{ - background-image:url("images/printer_hover.png"); -} -.printer:active -{ - background-image:url("images/printer_active.png"); + display:table-cell; + text-align:center; + vertical-align:middle; } \ No newline at end of file diff --git a/WebContent/main.html b/WebContent/main.html index a561bd4e0..4a69533ec 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -46,7 +46,7 @@ or see http://www.gnu.org/licenses/agpl.txt. - + @@ -71,15 +71,15 @@ or see http://www.gnu.org/licenses/agpl.txt. - +
-
-
+
+
@@ -87,63 +87,69 @@ or see http://www.gnu.org/licenses/agpl.txt.
-
-
-
-
-
+
+ +
+
+
+
- + +
- - - - - - - - - - - - - - -
Start:
- -
Zeigen
Ende:
- -
Zeigen
- +
+
+
Start:
+
+
+ +
+
+
Ende:
+
+
+ +
+
+ +
+ -
- - - - - -
Reset Umdrehen
- +
+ + +
+
+ +
+ - Kartenwerkzeuge -
- - Unbenannte Straßen hervorheben - - - JOSM - OSM Bugs - +
+ + + Kartenwerkzeuge + + +
+
+ + Unbenannte Straßen hervorheben +
+
+ JOSM + OSM Bugs +
+
-
-
+
+
- +
diff --git a/WebContent/printing/OSRM.Printing.js b/WebContent/printing/OSRM.Printing.js index e1f19a8e9..11a692370 100644 --- a/WebContent/printing/OSRM.Printing.js +++ b/WebContent/printing/OSRM.Printing.js @@ -65,11 +65,11 @@ show: function(response) { route_desc += ''; headline = ""; - headline += OSRM.loc("ROUTE_DESCRIPTION")+":
"; + headline += OSRM.loc("ROUTE_DESCRIPTION")+":
"; headline += '
'; headline += "" + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) - + "
" + + "
" + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + "
"; headline += '
'; diff --git a/WebContent/routing/OSRM.RoutingDescription.js b/WebContent/routing/OSRM.RoutingDescription.js index 5d236fb4e..1e4e6300e 100644 --- a/WebContent/routing/OSRM.RoutingDescription.js +++ b/WebContent/routing/OSRM.RoutingDescription.js @@ -30,16 +30,15 @@ onClickRouteDescription: function(geometry_index) { OSRM.G.markers.highlight.centerView(OSRM.DEFAULTS.HIGHLIGHT_ZOOM_LEVEL); }, onClickCreateShortcut: function(src){ - src += '&z='+ OSRM.G.map.getZoom() + '¢er=' + OSRM.G.map.getCenter().lat + ',' + OSRM.G.map.getCenter().lng; + src += '&z='+ OSRM.G.map.getZoom() + '¢er=' + OSRM.G.map.getCenter().lat.toFixed(6) + ',' + OSRM.G.map.getCenter().lng.toFixed(6); OSRM.JSONP.call(OSRM.DEFAULTS.HOST_SHORTENER_URL+src, OSRM.RoutingDescription.showRouteLink, OSRM.RoutingDescription.showRouteLink_TimeOut, OSRM.DEFAULTS.JSONP_TIMEOUT, 'shortener'); - document.getElementById('route-prelink').innerHTML = '['+OSRM.loc("GENERATE_LINK_TO_ROUTE")+']'; + document.getElementById('route-link').innerHTML = '['+OSRM.loc("GENERATE_LINK_TO_ROUTE")+']'; }, showRouteLink: function(response){ - document.getElementById('route-prelink').innerHTML = '['+response.ShortURL+']'; -// document.getElementById('route-prelink').innerHTML = '[]'; + document.getElementById('route-link').innerHTML = '['+response.ShortURL+']'; }, showRouteLink_TimeOut: function(){ - document.getElementById('route-prelink').innerHTML = '['+OSRM.loc("LINK_TO_ROUTE_TIMEOUT")+']'; + document.getElementById('route-link').innerHTML = '['+OSRM.loc("LINK_TO_ROUTE_TIMEOUT")+']'; }, // handling of routing description @@ -47,17 +46,17 @@ show: function(response) { // compute query string var query_string = '?rebuild=1'; for(var i=0; i'+OSRM.loc("GET_LINK_TO_ROUTE")+']'; + var route_link ='['+OSRM.loc("GET_LINK_TO_ROUTE")+']'; // create GPX link - var gpx_link = '['+OSRM.loc("GPX_FILE")+']'; + var gpx_link = '['+OSRM.loc("GPX_FILE")+']'; // create route description var route_desc = ""; - route_desc += ''; + route_desc += '
'; for(var i=0; i < response.route_instructions.length; i++){ //odd or even ? @@ -71,7 +70,7 @@ show: function(response) { route_desc += ""; route_desc += '"; route_desc += '"; } - - route_desc += '
'; - route_desc += ''; + route_desc += '
'; // // build route description // if( i == 0 ) @@ -88,8 +87,7 @@ show: function(response) { route_desc += ' on '; route_desc += '' + response.route_instructions[i][1] + ''; } - //route_desc += ' for '; - route_desc += ''; + route_desc += '
'; route_desc += "
'; @@ -99,52 +97,61 @@ show: function(response) { route_desc += "
'; - headline = ""; - headline += OSRM.loc("ROUTE_DESCRIPTION")+":
"; - headline += '
'; - headline += "" - + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) - + "
" - + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) - + "
"; - headline += '
'; - headline += '
'+route_link+'
'+gpx_link+'
'; + route_desc += ''; + + // create header + header = + '
' + OSRM.loc("ROUTE_DESCRIPTION") + '
' + + '
' + + '
' + + '
' + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '
' + + '
' + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '
' + + '
' + + '
' + + '' + + '
' + gpx_link + '
' + + '
' + + '
'; - var output = ""; - output += route_desc; - - document.getElementById('information-box-headline').innerHTML = headline; - document.getElementById('information-box').innerHTML = output; + // update DOM + document.getElementById('information-box-header').innerHTML = header; + document.getElementById('information-box').innerHTML = route_desc; }, // simple description showSimple: function(response) { - headline = OSRM.loc("ROUTE_DESCRIPTION")+":
"; - headline += "" - + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) - + "
" - + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) - + "
"; - headline += '

'; + header = + '
' + OSRM.loc("ROUTE_DESCRIPTION") + '
' + + '
' + + '
' + + '
' + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '
' + + '
' + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '
' + + '
' + + '
' + + '
' + + '
'; - document.getElementById('information-box-headline').innerHTML = headline; - document.getElementById('information-box').innerHTML = "

"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+".

"; + // update DOM + document.getElementById('information-box-header').innerHTML = header; + document.getElementById('information-box').innerHTML = "

"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+"
"; }, // no description showNA: function( display_text ) { - headline = OSRM.loc("ROUTE_DESCRIPTION")+":
"; - headline += "" - + OSRM.loc("DISTANCE")+": N/A" - + "
" - + OSRM.loc("DURATION")+": N/A" - + "
"; - headline += '

'; + header = + '
' + OSRM.loc("ROUTE_DESCRIPTION") + '
' + + '
' + + '
' + + '
' + OSRM.loc("DISTANCE")+": N/A" + '
' + + '
' + OSRM.loc("DURATION")+": N/A" + '
' + + '
' + + '
' + + '
' + + '
'; - document.getElementById('information-box-headline').innerHTML = headline; - document.getElementById('information-box').innerHTML = "

"+display_text+".

"; + // update DOM + document.getElementById('information-box-header').innerHTML = header; + document.getElementById('information-box').innerHTML = "

"+display_text+"
"; }, // map driving instructions to icons diff --git a/WebContent/routing/OSRM.RoutingGUI.js b/WebContent/routing/OSRM.RoutingGUI.js index da0f20289..cd47d1e35 100644 --- a/WebContent/routing/OSRM.RoutingGUI.js +++ b/WebContent/routing/OSRM.RoutingGUI.js @@ -31,7 +31,7 @@ resetRouting: function() { OSRM.G.markers.highlight.hide(); document.getElementById('information-box').innerHTML = ""; - document.getElementById('information-box-headline').innerHTML = ""; + document.getElementById('information-box-header').innerHTML = ""; OSRM.JSONP.reset(); }, @@ -67,7 +67,7 @@ reverseRouting: function() { OSRM.G.markers.highlight.hide(); } else { document.getElementById('information-box').innerHTML = ""; - document.getElementById('information-box-headline').innerHTML = ""; + document.getElementById('information-box-header').innerHTML = ""; } }, From 0fd8d4d8cf48ddbec2c10593e1eaaa626eae41b9 Mon Sep 17 00:00:00 2001 From: shiin Date: Sun, 8 Apr 2012 19:50:30 +0200 Subject: [PATCH 06/12] all visible lat/lng coordinates are truncated after 6 digits (this includes inputboxes, osmbugs link, route link, gpx link), moved all events from html to javascript --- WebContent/OSRM.GUI.js | 48 ++++++++++++++------ WebContent/OSRM.Geocoder.js | 10 ++-- WebContent/OSRM.Markers.js | 16 +++---- WebContent/OSRM.debug.js | 5 +- WebContent/localization/OSRM.Localization.js | 2 +- WebContent/main.css | 12 ++--- WebContent/main.html | 30 ++++++------ WebContent/main.js | 14 ++++-- WebContent/routing/OSRM.RoutingGUI.js | 14 +++--- 9 files changed, 90 insertions(+), 61 deletions(-) diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index 223c2a914..f47b548ad 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -29,6 +29,34 @@ width: null, init: function() { OSRM.GUI.visible = true; OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth; + + // init events + // [TODO: switch to new event model] + document.getElementById("gui-toggle-in").onclick = OSRM.GUI.toggleMain; + document.getElementById("gui-toggle-out").onclick = OSRM.GUI.toggleMain; + document.getElementById("gui-printer").onclick = OSRM.Printing.print; + + document.getElementById("gui-input-source").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.SOURCE_LABEL);}; + document.getElementById("gui-delete-source").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.SOURCE_LABEL);}; + document.getElementById("gui-search-source").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.SOURCE_LABEL);}; + + document.getElementById("gui-input-target").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.TARGET_LABEL);}; + document.getElementById("gui-delete-target").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.TARGET_LABEL);}; + document.getElementById("gui-search-target").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.TARGET_LABEL);}; + + document.getElementById("gui-reset").onclick = OSRM.RoutingGUI.resetRouting; + document.getElementById("gui-reverse").onclick = OSRM.RoutingGUI.reverseRouting; + document.getElementById("gui-options-toggle").onclick = OSRM.GUI.toggleOptions; + document.getElementById("open-josm").onclick = OSRM.RoutingGUI.openJOSM; + document.getElementById("open-osmbugs").onclick = OSRM.RoutingGUI.openOSMBugs; + + // gui after transition events + if( OSRM.Browser.FF3==-1 && OSRM.Browser.IE6_9==-1 ) { + document.getElementById('main-wrapper').addEventListener("transitionend", OSRM.GUI.onMainTransitionEnd, false); + document.getElementById('main-wrapper').addEventListener("webkitTransitionEnd", OSRM.GUI.onMainTransitionEnd, false); + document.getElementById('main-wrapper').addEventListener("oTransitionEnd", OSRM.GUI.onMainTransitionEnd, false); + document.getElementById('main-wrapper').addEventListener("MSTransitionEnd", OSRM.GUI.onMainTransitionEnd, false); + } }, // set language dependent labels @@ -38,17 +66,17 @@ setLanguage: function() { document.getElementById("gui-reset").innerHTML = OSRM.loc("GUI_RESET"); document.getElementById("gui-reverse").innerHTML = OSRM.loc("GUI_REVERSE"); document.getElementById("gui-option-highlight-nonames-label").innerHTML = OSRM.loc("GUI_HIGHLIGHT_UNNAMED_ROADS"); - document.getElementById("options-toggle").innerHTML = OSRM.loc("GUI_OPTIONS"); + document.getElementById("gui-options-toggle").innerHTML = OSRM.loc("GUI_OPTIONS"); document.getElementById("gui-search-source").innerHTML = OSRM.loc("GUI_SEARCH"); document.getElementById("gui-search-target").innerHTML = OSRM.loc("GUI_SEARCH"); document.getElementById("gui-search-source-label").innerHTML = OSRM.loc("GUI_START")+":"; document.getElementById("gui-search-target-label").innerHTML = OSRM.loc("GUI_END")+":"; - document.getElementById("input-source-name").title = OSRM.loc("GUI_START_TOOLTIP"); - document.getElementById("input-target-name").title = OSRM.loc("GUI_END_TOOLTIP"); + document.getElementById("gui-input-source").title = OSRM.loc("GUI_START_TOOLTIP"); + document.getElementById("gui-input-target").title = OSRM.loc("GUI_END_TOOLTIP"); document.getElementById("legal-notice").innerHTML = OSRM.loc("GUI_LEGAL_NOTICE"); - document.getElementById('input-source-name').value = OSRM.DEFAULTS.ONLOAD_SOURCE; - document.getElementById('input-target-name').value = OSRM.DEFAULTS.ONLOAD_TARGET; + document.getElementById('gui-input-source').value = OSRM.DEFAULTS.ONLOAD_SOURCE; + document.getElementById('gui-input-target').value = OSRM.DEFAULTS.ONLOAD_TARGET; }, // show/hide main-gui @@ -68,15 +96,9 @@ toggleMain: function() { document.getElementById('main-wrapper').style.left=-OSRM.GUI.width+"px"; } - // execute after animation - if( OSRM.Browser.FF3==-1 && OSRM.Browser.IE6_9==-1 ) { - document.getElementById('main-wrapper').addEventListener("transitionend", OSRM.GUI.onMainTransitionEnd, false); - document.getElementById('main-wrapper').addEventListener("webkitTransitionEnd", OSRM.GUI.onMainTransitionEnd, false); - document.getElementById('main-wrapper').addEventListener("oTransitionEnd", OSRM.GUI.onMainTransitionEnd, false); - document.getElementById('main-wrapper').addEventListener("MSTransitionEnd", OSRM.GUI.onMainTransitionEnd, false); - } else { + // execute after animation (old browser support) + if( OSRM.Browser.FF3!=-1 || OSRM.Browser.IE6_9!=-1 ) OSRM.GUI.onMainTransitionEnd(); - } }, // do stuff after main-gui animation finished diff --git a/WebContent/OSRM.Geocoder.js b/WebContent/OSRM.Geocoder.js index 76378f43f..80f302995 100644 --- a/WebContent/OSRM.Geocoder.js +++ b/WebContent/OSRM.Geocoder.js @@ -91,7 +91,7 @@ _showResults: function(response, parameters) { html += ''; if(result.display_name){ - html += '
'+result.display_name+'
'; + html += '
'+result.display_name+'
'; } html += ""; } @@ -128,9 +128,9 @@ _showResults_Timeout: function() { //update geo coordinates in input boxes updateLocation: function(marker_id) { if (marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource()) { - document.getElementById("input-source-name").value = OSRM.G.markers.route[0].getLat().toFixed(6) + ", " + OSRM.G.markers.route[0].getLng().toFixed(6); + document.getElementById("gui-input-source").value = OSRM.G.markers.route[0].getLat().toFixed(6) + ", " + OSRM.G.markers.route[0].getLng().toFixed(6); } else if (marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget()) { - document.getElementById("input-target-name").value = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLat().toFixed(6) + ", " + OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLng().toFixed(6); + document.getElementById("gui-input-target").value = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLat().toFixed(6) + ", " + OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLng().toFixed(6); } }, @@ -198,9 +198,9 @@ _showReverseResults: function(response, parameters) { // add result to DOM if(parameters.marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource() ) - document.getElementById("input-source-name").value = address; + document.getElementById("gui-input-source").value = address; else if(parameters.marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() ) - document.getElementById("input-target-name").value = address; + document.getElementById("gui-input-target").value = address; }, _showReverseResults_Timeout: function(response, parameters) { if(!parameters.do_fallback) diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js index ad649bc7c..8858a8ba1 100644 --- a/WebContent/OSRM.Markers.js +++ b/WebContent/OSRM.Markers.js @@ -174,8 +174,8 @@ removeAll: function() { for(var i=0; i - +
@@ -79,7 +79,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
-
+
@@ -90,9 +90,9 @@ or see http://www.gnu.org/licenses/agpl.txt.
-
+
-
+
@@ -102,15 +102,15 @@ or see http://www.gnu.org/licenses/agpl.txt.
Start:
-
-
- +
+
+
Ende:
-
-
- +
+
+
@@ -118,8 +118,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
@@ -129,7 +129,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
- Kartenwerkzeuge + Kartenwerkzeuge
@@ -138,8 +138,8 @@ or see http://www.gnu.org/licenses/agpl.txt. Unbenannte Straßen hervorheben
diff --git a/WebContent/main.js b/WebContent/main.js index 1dc16984d..a93203567 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -18,9 +18,6 @@ or see http://www.gnu.org/licenses/agpl.txt. // OSRM initialization // [initialization, image prefetching] -// will hold the Leaflet map object -OSRM.GLOBALS.map = null; - // onload initialization routine OSRM.init = function() { @@ -152,7 +149,7 @@ OSRM.checkURL = function(){ if( destination_name == null ) OSRM.Geocoder.updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG ); else - document.getElementById("input-target-name").value = destination_name; + document.getElementById("gui-input-target").value = destination_name; OSRM.G.markers.route[index].show(); OSRM.G.markers.route[index].centerView(); return; @@ -185,4 +182,11 @@ OSRM.checkURL = function(){ // compute route OSRM.Routing.getRoute(); } -}; \ No newline at end of file +}; + + +// onload event +if(document.addEventListener) // FF, CH + document.addEventListener("DOMContentLoaded", OSRM.init, false); +else // old IE + document.onreadystatechange = function(){if(document.readyState == "interactive" || document.readyState == "complete") OSRM.init();}; diff --git a/WebContent/routing/OSRM.RoutingGUI.js b/WebContent/routing/OSRM.RoutingGUI.js index cd47d1e35..a7fa509cb 100644 --- a/WebContent/routing/OSRM.RoutingGUI.js +++ b/WebContent/routing/OSRM.RoutingGUI.js @@ -23,8 +23,8 @@ OSRM.RoutingGUI = { // click: button "reset" resetRouting: function() { - document.getElementById('input-source-name').value = ""; - document.getElementById('input-target-name').value = ""; + document.getElementById('gui-input-source').value = ""; + document.getElementById('gui-input-target').value = ""; OSRM.G.route.hideAll(); OSRM.G.markers.removeAll(); @@ -39,9 +39,9 @@ resetRouting: function() { // click: button "reverse" reverseRouting: function() { // invert input boxes - var tmp = document.getElementById("input-source-name").value; - document.getElementById("input-source-name").value = document.getElementById("input-target-name").value; - document.getElementById("input-target-name").value = tmp; + var tmp = document.getElementById("gui-input-source").value; + document.getElementById("gui-input-source").value = document.getElementById("gui-input-target").value; + document.getElementById("gui-input-target").value = tmp; // invert route OSRM.G.markers.route.reverse(); @@ -86,9 +86,9 @@ showMarker: function(marker_id) { // changed: any inputbox (is called when return is pressed [after] or focus is lost [before]) inputChanged: function(marker_id) { if( marker_id == OSRM.C.SOURCE_LABEL) - OSRM.Geocoder.call(OSRM.C.SOURCE_LABEL, document.getElementById('input-source-name').value); + OSRM.Geocoder.call(OSRM.C.SOURCE_LABEL, document.getElementById('gui-input-source').value); else if( marker_id == OSRM.C.TARGET_LABEL) - OSRM.Geocoder.call(OSRM.C.TARGET_LABEL, document.getElementById('input-target-name').value); + OSRM.Geocoder.call(OSRM.C.TARGET_LABEL, document.getElementById('gui-input-target').value); }, // click: button "open JOSM" From 213bb71b35bbfb6b83ab4ba64984f69e27a919ec Mon Sep 17 00:00:00 2001 From: shiin Date: Mon, 9 Apr 2012 11:59:32 +0200 Subject: [PATCH 07/12] changed behaviour of geocoder (return always triggers geocoder, moving a single marker clears search results) --- WebContent/OSRM.GUI.js | 3 +++ WebContent/OSRM.Geocoder.js | 10 +++++++--- WebContent/OSRM.Markers.js | 9 +++++---- WebContent/main.html | 6 +++--- WebContent/routing/OSRM.RoutingGUI.js | 11 ++++++++++- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index f47b548ad..bd367daf0 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -37,10 +37,12 @@ init: function() { document.getElementById("gui-printer").onclick = OSRM.Printing.print; document.getElementById("gui-input-source").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.SOURCE_LABEL);}; + document.getElementById("gui-input-source").onkeyup = function(e) {OSRM.RoutingGUI.keyUp(e,OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-delete-source").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-search-source").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-input-target").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.TARGET_LABEL);}; + document.getElementById("gui-input-target").onkeyup = function(e) {OSRM.RoutingGUI.keyUp(e,OSRM.C.TARGET_LABEL);}; document.getElementById("gui-delete-target").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.TARGET_LABEL);}; document.getElementById("gui-search-target").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.TARGET_LABEL);}; @@ -49,6 +51,7 @@ init: function() { document.getElementById("gui-options-toggle").onclick = OSRM.GUI.toggleOptions; document.getElementById("open-josm").onclick = OSRM.RoutingGUI.openJOSM; document.getElementById("open-osmbugs").onclick = OSRM.RoutingGUI.openOSMBugs; + document.getElementById("option-highlight-nonames").onclick = OSRM.Routing.getRoute; // gui after transition events if( OSRM.Browser.FF3==-1 && OSRM.Browser.IE6_9==-1 ) { diff --git a/WebContent/OSRM.Geocoder.js b/WebContent/OSRM.Geocoder.js index 80f302995..4331b3e9a 100644 --- a/WebContent/OSRM.Geocoder.js +++ b/WebContent/OSRM.Geocoder.js @@ -60,7 +60,8 @@ _onclickResult: function(marker_id, lat, lon) { OSRM.G.markers.route[index].show(); OSRM.G.markers.route[index].centerView(); - OSRM.Routing.getRoute(); + if( OSRM.G.markers.route.length > 1 ) + OSRM.Routing.getRoute(); }, @@ -76,6 +77,11 @@ _showResults: function(response, parameters) { return; } + // show first result + OSRM.Geocoder._onclickResult(parameters.marker_id, response[0].lat, response[0].lon); + if( OSRM.G.markers.route.length > 1 ) + return; + // show possible results for input var html = ""; html += ''; @@ -101,8 +107,6 @@ _showResults: function(response, parameters) { "
"+OSRM.loc("SEARCH_RESULTS")+"
" + "
(found "+response.length+" results)"+"
"; document.getElementById('information-box').innerHTML = html; - - OSRM.Geocoder._onclickResult(parameters.marker_id, response[0].lat, response[0].lon); }, _showResults_Empty: function(parameters) { document.getElementById('information-box-header').innerHTML = diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js index 8858a8ba1..a86e4853f 100644 --- a/WebContent/OSRM.Markers.js +++ b/WebContent/OSRM.Markers.js @@ -118,14 +118,15 @@ onDragEnd: function(e) { this.switchIcon(this.options.baseicon); this.parent.setPosition( e.target.getLatLng() ); - OSRM.Routing.getRoute(); if (OSRM.G.route.isShown()) { + OSRM.Routing.getRoute(); OSRM.G.route.hideOldRoute(); OSRM.G.route.hideUnnamedRoute(); - } - - if(OSRM.G.route.isShown()==false) + } else { OSRM.Geocoder.updateAddress(this.parent.label); + document.getElementById('information-box').innerHTML = ""; // do we want this? + document.getElementById('information-box-header').innerHTML = ""; + } }, toString: function() { return "OSRM.RouteMarker: \""+this.label+"\", "+this.position+")"; diff --git a/WebContent/main.html b/WebContent/main.html index 20a9d6e3e..171fc9da3 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -109,7 +109,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
Ende:
-
+
@@ -129,12 +129,12 @@ or see http://www.gnu.org/licenses/agpl.txt.
- Kartenwerkzeuge + Kartenwerkzeuge
- + Unbenannte Straßen hervorheben
diff --git a/WebContent/routing/OSRM.RoutingGUI.js b/WebContent/routing/OSRM.RoutingGUI.js index a7fa509cb..e549b1a0a 100644 --- a/WebContent/routing/OSRM.RoutingGUI.js +++ b/WebContent/routing/OSRM.RoutingGUI.js @@ -83,7 +83,16 @@ showMarker: function(marker_id) { }, -// changed: any inputbox (is called when return is pressed [after] or focus is lost [before]) +// keyup: force geocoder when enter is pressed +// (change event can be triggered, too; second call to geocoder gets fenced by JSONP) +// (alternative: track changes manually and only permit keyup event, if there was no change) +// do we want this? +keyUp: function(e, marker_id) { + if(e.keyCode==13) + OSRM.RoutingGUI.inputChanged(marker_id); +}, + +// changed: any inputbox (is called when enter is pressed [after] or focus is lost [before]) inputChanged: function(marker_id) { if( marker_id == OSRM.C.SOURCE_LABEL) OSRM.Geocoder.call(OSRM.C.SOURCE_LABEL, document.getElementById('gui-input-source').value); From ea207cef6e6634a06f88532fd84dce8ef02b3b50 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Tue, 10 Apr 2012 21:47:30 +0200 Subject: [PATCH 08/12] improved language support: geocoding uses language settings, geocoding results & locations are also translated if possible --- WebContent/OSRM.GUI.js | 7 ++++--- WebContent/OSRM.Geocoder.js | 4 ++-- WebContent/localization/OSRM.Localization.js | 21 +++++++++++++++----- WebContent/main.html | 2 +- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index 797b482eb..f60b44913 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -30,6 +30,10 @@ init: function() { OSRM.GUI.visible = true; OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth; + // init starting source/target + document.getElementById('gui-input-source').value = OSRM.DEFAULTS.ONLOAD_SOURCE; + document.getElementById('gui-input-target').value = OSRM.DEFAULTS.ONLOAD_TARGET; + // init events // [TODO: switch to new event model] document.getElementById("gui-toggle-in").onclick = OSRM.GUI.toggleMain; @@ -77,9 +81,6 @@ setLanguage: function() { document.getElementById("gui-input-source").title = OSRM.loc("GUI_START_TOOLTIP"); document.getElementById("gui-input-target").title = OSRM.loc("GUI_END_TOOLTIP"); document.getElementById("legal-notice").innerHTML = OSRM.loc("GUI_LEGAL_NOTICE"); - - document.getElementById('gui-input-source').value = OSRM.DEFAULTS.ONLOAD_SOURCE; - document.getElementById('gui-input-target').value = OSRM.DEFAULTS.ONLOAD_TARGET; }, // show/hide main-gui diff --git a/WebContent/OSRM.Geocoder.js b/WebContent/OSRM.Geocoder.js index 4331b3e9a..d02029e51 100644 --- a/WebContent/OSRM.Geocoder.js +++ b/WebContent/OSRM.Geocoder.js @@ -43,7 +43,7 @@ call: function(marker_id, query) { } //build request for geocoder - var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&q=" + query; + var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&accept-language="+OSRM.DEFAULTS.LANGUAGE+"&q=" + query; OSRM.JSONP.call( call, OSRM.Geocoder._showResults, OSRM.Geocoder._showResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_"+marker_id, {marker_id:marker_id,query:query} ); }, @@ -154,7 +154,7 @@ updateAddress: function(marker_id, do_fallback_to_lat_lng) { } else return; - var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&lat=" + lat + "&lon=" + lng; + var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&accept-language="+OSRM.DEFAULTS.LANGUAGE + "&lat=" + lat + "&lon=" + lng; OSRM.JSONP.call( call, OSRM.Geocoder._showReverseResults, OSRM.Geocoder._showReverseResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "reverse_geocoder_"+marker_id, {marker_id:marker_id, do_fallback: do_fallback_to_lat_lng} ); }, diff --git a/WebContent/localization/OSRM.Localization.js b/WebContent/localization/OSRM.Localization.js index ec3278771..4063a619b 100644 --- a/WebContent/localization/OSRM.Localization.js +++ b/WebContent/localization/OSRM.Localization.js @@ -21,7 +21,9 @@ or see http://www.gnu.org/licenses/agpl.txt. OSRM.Localization = { -supported_languages: ["en", "de"], +supported_languages: [ {display_name:"en", encoding:"en"}, + {display_name:"de", encoding:"de"} +], // initialize localization init: function() { @@ -33,8 +35,8 @@ init: function() { // fill dropdown menu for(var i=0, size=OSRM.Localization.supported_languages.length; i 1) + OSRM.Routing.getRoute(); + else if(OSRM.G.markers.route.length > 0 && document.getElementById('information-box').innerHTML != "" ) { + OSRM.Geocoder.call( OSRM.C.SOURCE_LABEL, document.getElementById("gui-input-source").value ); + OSRM.Geocoder.call( OSRM.C.TARGET_LABEL, document.getElementById("gui-input-target").value ); + } else { + OSRM.Geocoder.updateAddress(OSRM.C.SOURCE_LABEL, false); + OSRM.Geocoder.updateAddress(OSRM.C.TARGET_LABEL, false); + document.getElementById('information-box').innerHTML = ""; + document.getElementById('information-box-header').innerHTML = ""; + } } else { var script = document.createElement('script'); script.type = 'text/javascript'; diff --git a/WebContent/main.html b/WebContent/main.html index 171fc9da3..271f73d46 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -71,7 +71,7 @@ or see http://www.gnu.org/licenses/agpl.txt. - +
From ffd5e2de997f861f962af6a3f07171f8a2fe37d9 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Tue, 10 Apr 2012 23:50:04 +0200 Subject: [PATCH 09/12] all images are now loaded in main.js --- WebContent/OSRM.GUI.js | 3 + WebContent/main.html | 2 +- WebContent/main.js | 76 +++++++++++-------- WebContent/routing/OSRM.RoutingDescription.js | 46 +++++------ WebContent/routing/OSRM.RoutingGUI.js | 8 +- 5 files changed, 76 insertions(+), 59 deletions(-) diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index f60b44913..6d4c3841d 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -30,6 +30,9 @@ init: function() { OSRM.GUI.visible = true; OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth; + // init favicon + document.getElementById('favicon').href=OSRM.G.images["favicon"].src; + // init starting source/target document.getElementById('gui-input-source').value = OSRM.DEFAULTS.ONLOAD_SOURCE; document.getElementById('gui-input-target').value = OSRM.DEFAULTS.ONLOAD_TARGET; diff --git a/WebContent/main.html b/WebContent/main.html index 271f73d46..e6be48e39 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -30,7 +30,7 @@ or see http://www.gnu.org/licenses/agpl.txt. - + diff --git a/WebContent/main.js b/WebContent/main.js index a93203567..b848d95e8 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -27,7 +27,7 @@ OSRM.init = function() { OSRM.Localization.init(); OSRM.GUI.init(); OSRM.Map.init(); - OSRM.Routing.init(); + OSRM.Routing.init(); // check if the URL contains some GET parameter, e.g. for showing a route OSRM.checkURL(); @@ -35,40 +35,54 @@ OSRM.init = function() { // prefetch images -OSRM.GLOBALS.images = Array(); +OSRM.GLOBALS.images = {}; OSRM.prefetchImages = function() { - var images = [ 'images/marker-source.png', - 'images/marker-target.png', - 'images/marker-via.png', - 'images/marker-highlight.png', - 'images/marker-source-drag.png', - 'images/marker-target-drag.png', - 'images/marker-via-drag.png', - 'images/marker-highlight-drag.png', - 'images/marker-drag.png', - 'images/cancel.png', - 'images/cancel_active.png', - 'images/cancel_hover.png', - 'images/restore.png', - 'images/restore_active.png', - 'images/restore_hover.png', - 'images/printer.png', - 'images/printer_active.png', - 'images/printer_hover.png', - 'images/printer_inactive.png' - ]; - - for(var i=0; i'; route_desc += '
"; route_desc += '"; @@ -181,6 +182,38 @@ getDirectionIcon: function(name) { "You have reached your destination":"target" }; + if( directions[name] ) + return directions[name]; + else + return "default"; +}, + +//map driving instructions to ids +getDirectionId: function(name) { + var directions = { + "Turn left":1, + "Turn right":2, + "U-Turn":3, + "Head":4, + "Continue":5, + "Turn slight left":6, + "Turn slight right":7, + "Turn sharp left":8, + "Turn sharp right":9, + "Enter roundabout and leave at first exit":10, + "Enter roundabout and leave at second exit":11, + "Enter roundabout and leave at third exit":12, + "Enter roundabout and leave at fourth exit":13, + "Enter roundabout and leave at fifth exit":14, + "Enter roundabout and leave at sixth exit":15, + "Enter roundabout and leave at seventh exit":16, + "Enter roundabout and leave at eighth exit":17, + "Enter roundabout and leave at nineth exit":18, + "Enter roundabout and leave at tenth exit":19, + "Enter roundabout and leave at one of the too many exit":20, + "You have reached your destination":21 + }; + if( directions[name] ) return directions[name]; else diff --git a/WebContent/routing/OSRM.RoutingGUI.js b/WebContent/routing/OSRM.RoutingGUI.js index b276ad1f3..f687fb49e 100644 --- a/WebContent/routing/OSRM.RoutingGUI.js +++ b/WebContent/routing/OSRM.RoutingGUI.js @@ -82,16 +82,6 @@ showMarker: function(marker_id) { OSRM.G.markers.route[OSRM.G.markers.route.length-1].centerView(); }, - -// keyup: force geocoder when enter is pressed -// (change event can be triggered, too; second call to geocoder gets fenced by JSONP) -// (alternative: track changes manually and only permit keyup event, if there was no change) -// do we want this? -keyUp: function(e, marker_id) { - if(e.keyCode==13) - OSRM.RoutingGUI.inputChanged(marker_id); -}, - // changed: any inputbox (is called when enter is pressed [after] or focus is lost [before]) inputChanged: function(marker_id) { if( marker_id == OSRM.C.SOURCE_LABEL) From 888a5d04c8241430c1d118fa57579eb9cd995c34 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Wed, 11 Apr 2012 22:00:19 +0200 Subject: [PATCH 11/12] removal of dragger marker more consistent, changed printing initialization to be more easily removable from GUI, localization bug fixes, added option to give language as get parameter (hl=), --- WebContent/OSRM.GUI.js | 1 - WebContent/OSRM.Markers.js | 1 + WebContent/localization/OSRM.Locale.de.js | 30 +++++----- WebContent/localization/OSRM.Localization.js | 1 + WebContent/main.html | 2 - WebContent/main.js | 19 +++++-- WebContent/printing/OSRM.Printing.js | 15 +++++ WebContent/routing/OSRM.RoutingDescription.js | 55 +++---------------- 8 files changed, 54 insertions(+), 70 deletions(-) diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index a1f780dec..675b7f743 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -41,7 +41,6 @@ init: function() { // [TODO: switch to new event model] document.getElementById("gui-toggle-in").onclick = OSRM.GUI.toggleMain; document.getElementById("gui-toggle-out").onclick = OSRM.GUI.toggleMain; - document.getElementById("gui-printer").onclick = OSRM.Printing.print; document.getElementById("gui-input-source").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-delete-source").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.SOURCE_LABEL);}; diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js index cdc30e2f5..aa4fc325a 100644 --- a/WebContent/OSRM.Markers.js +++ b/WebContent/OSRM.Markers.js @@ -90,6 +90,7 @@ onClick: function(e) { OSRM.Routing.getRoute(); OSRM.G.markers.highlight.hide(); + OSRM.G.markers.dragger.hide(); }, onDrag: function(e) { this.parent.setPosition( e.target.getLatLng() ); diff --git a/WebContent/localization/OSRM.Locale.de.js b/WebContent/localization/OSRM.Locale.de.js index 7ba28b514..d7243a753 100644 --- a/WebContent/localization/OSRM.Locale.de.js +++ b/WebContent/localization/OSRM.Locale.de.js @@ -54,32 +54,32 @@ OSRM.Localization["de"] = { "O": "Ost", "S": "Süden", "W": "Westen", -"NO": "Nordost", -"SO": "Südost", +"NE": "Nordost", +"SE": "Südost", "SW": "Südwest", "NW": "Nordwest", // driving directions "DIRECTION_0":"Unbekannte Anweisung[ auf %s]", "DIRECTION_1":"Links abbiegen[ auf %s]", "DIRECTION_2":"Rechts abbiegen[ auf %s]", -"DIRECTION_3":"Umkehren[ auf %s]", +"DIRECTION_3":"Wenden[ auf %s]", "DIRECTION_4":"Fahren Sie Richtung %s", -"DIRECTION_5":"Weiterfahren[ auf %s]", +"DIRECTION_5":"Geradeaus weiterfahren[ auf %s]", "DIRECTION_6":"Leicht links abbiegen[ auf %s]", "DIRECTION_7":"Leicht rechts abbiegen[ auf %s]", "DIRECTION_8":"Scharf links abbiegen[ auf %s]", "DIRECTION_9":"Scharf rechts abbiegen[ auf %s]", -"DIRECTION_10":"In den Kreisverkehr einfahren und bei erster Möglichkeit verlassen[ auf %s]", -"DIRECTION_11":"In den Kreisverkehr einfahren und bei zweiter Möglichkeit verlassen[ auf %s]", -"DIRECTION_12":"In den Kreisverkehr einfahren und bei dritter Möglichkeit verlassen[ auf %s]", -"DIRECTION_13":"In den Kreisverkehr einfahren und bei vierter Möglichkeit verlassen[ auf %s]", -"DIRECTION_14":"In den Kreisverkehr einfahren und bei fünfter Möglichkeit verlassen[ auf %s]", -"DIRECTION_15":"In den Kreisverkehr einfahren und bei sechster Möglichkeit verlassen[ auf %s]", -"DIRECTION_16":"In den Kreisverkehr einfahren und bei siebter Möglichkeit verlassen[ auf %s]", -"DIRECTION_17":"In den Kreisverkehr einfahren und bei achter Möglichkeit verlassen[ auf %s]", -"DIRECTION_18":"In den Kreisverkehr einfahren und bei neunter Möglichkeit verlassen[ auf %s]", -"DIRECTION_19":"In den Kreisverkehr einfahren und bei zehnter Möglichkeit verlassen[ auf %s]", -"DIRECTION_20":"In den Kreisverkehr einfahren und bei einer der vielen Möglichkeiten verlassen[ auf %s]", +"DIRECTION_10":"In den Kreisverkehr einfahren und bei erster Möglichkeit[ in Richtung %s] verlassen", +"DIRECTION_11":"In den Kreisverkehr einfahren und bei zweiter Möglichkeit[ in Richtung %s] verlassen", +"DIRECTION_12":"In den Kreisverkehr einfahren und bei dritter Möglichkeit[ in Richtung %s] verlassen", +"DIRECTION_13":"In den Kreisverkehr einfahren und bei vierter Möglichkeit[ in Richtung %s] verlassen", +"DIRECTION_14":"In den Kreisverkehr einfahren und bei fünfter Möglichkeit[ in Richtung %s] verlassen", +"DIRECTION_15":"In den Kreisverkehr einfahren und bei sechster Möglichkeit[ in Richtung %s] verlassen", +"DIRECTION_16":"In den Kreisverkehr einfahren und bei siebter Möglichkeit[ in Richtung %s] verlassen", +"DIRECTION_17":"In den Kreisverkehr einfahren und bei achter Möglichkeit[ in Richtung %s] verlassen", +"DIRECTION_18":"In den Kreisverkehr einfahren und bei neunter Möglichkeit[ in Richtung %s] verlassen", +"DIRECTION_19":"In den Kreisverkehr einfahren und bei zehnter Möglichkeit[ in Richtung %s] verlassen", +"DIRECTION_20":"In den Kreisverkehr einfahren und bei einer der vielen Möglichkeiten[ in Richtung %s] verlassen", "DIRECTION_21":"Sie haben Ihr Ziel erreicht" }; diff --git a/WebContent/localization/OSRM.Localization.js b/WebContent/localization/OSRM.Localization.js index cc121b29f..af6021a43 100644 --- a/WebContent/localization/OSRM.Localization.js +++ b/WebContent/localization/OSRM.Localization.js @@ -52,6 +52,7 @@ init: function() { // perform language change change: function(language) { OSRM.DEFAULTS.LANGUAGE = language; + document.getElementById('gui-language-toggle').value = language; if( OSRM.Localization[language]) { OSRM.GUI.setLanguage(); if( OSRM.G.markers.route.length > 1) diff --git a/WebContent/main.html b/WebContent/main.html index b7af1bbc4..97c631324 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -91,8 +91,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
-
-
diff --git a/WebContent/main.js b/WebContent/main.js index b848d95e8..ad5ed0b98 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -27,6 +27,7 @@ OSRM.init = function() { OSRM.Localization.init(); OSRM.GUI.init(); OSRM.Map.init(); + OSRM.Printing.init(); OSRM.Routing.init(); // check if the URL contains some GET parameter, e.g. for showing a route @@ -128,8 +129,16 @@ OSRM.checkURL = function(){ var name_val = splitted_url[i].split('='); if(name_val.length!=2) continue; - - if(name_val[0] == 'loc') { + + if(name_val[0] == 'hl') { + for(var i=0, size=OSRM.Localization.supported_languages.length; i 0) { // draw via points if( positions.length > 0) { OSRM.G.markers.setSource( positions[0] ); @@ -196,6 +205,8 @@ OSRM.checkURL = function(){ // compute route OSRM.Routing.getRoute(); } + + // default case: do nothing }; diff --git a/WebContent/printing/OSRM.Printing.js b/WebContent/printing/OSRM.Printing.js index 11a692370..30a7f798c 100644 --- a/WebContent/printing/OSRM.Printing.js +++ b/WebContent/printing/OSRM.Printing.js @@ -20,6 +20,21 @@ or see http://www.gnu.org/licenses/agpl.txt. OSRM.Printing = { +init: function() { + var icon = document.createElement('div'); + icon.id = "gui-printer"; + icon.className = "iconic-button top-right-button"; + + var spacer = document.createElement('div'); + spacer.className = "quad top-right-button"; + + var input_mask_header = document.getElementById('input-mask-header'); + input_mask_header.appendChild(spacer,input_mask_header.lastChild); + input_mask_header.appendChild(icon,input_mask_header.lastChild); + + document.getElementById("gui-printer").onclick = OSRM.Printing.print; +}, + windowLoaded: function(){ OSRM.printwindow.initialize(); OSRM.Printing.show( OSRM.G.response ); diff --git a/WebContent/routing/OSRM.RoutingDescription.js b/WebContent/routing/OSRM.RoutingDescription.js index 0fde40312..0ec55e785 100644 --- a/WebContent/routing/OSRM.RoutingDescription.js +++ b/WebContent/routing/OSRM.RoutingDescription.js @@ -74,20 +74,12 @@ show: function(response) { // build route description if( i == 0 ) - route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(response.route_instructions[i][0])).replace(/%s/, OSRM.loc(response.route_instructions[i][6]) ); + route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.mapDirectionId(response.route_instructions[i][0])).replace(/%s/, OSRM.loc(response.route_instructions[i][6]) ); else if( response.route_instructions[i][1] != "" ) - route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]); + route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.mapDirectionId(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]); else - route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(response.route_instructions[i][0])).replace(/\[(.*)\]/,""); - - -// route_desc += response.route_instructions[i][0]; -// if( i == 0 ) -// route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] ); -// if( response.route_instructions[i][1] != "" ) { -// route_desc += ' on '; -// route_desc += '' + response.route_instructions[i][1] + ''; -// } + route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.mapDirectionId(response.route_instructions[i][0])).replace(/\[(.*)\]/,""); + route_desc += ''; route_desc += ""; @@ -155,41 +147,8 @@ showNA: function( display_text ) { document.getElementById('information-box').innerHTML = "
"+display_text+"
"; }, -// map driving instructions to icons -// [TODO: language-safe implementation] -getDirectionIcon: function(name) { - var directions = { - "Turn left":"turn-left", - "Turn right":"turn-right", - "U-Turn":"u-turn", - "Head":"continue", - "Continue":"continue", - "Turn slight left":"slight-left", - "Turn slight right":"slight-right", - "Turn sharp left":"sharp-left", - "Turn sharp right":"sharp-right", - "Enter roundabout and leave at first exit":"round-about", - "Enter roundabout and leave at second exit":"round-about", - "Enter roundabout and leave at third exit":"round-about", - "Enter roundabout and leave at fourth exit":"round-about", - "Enter roundabout and leave at fifth exit":"round-about", - "Enter roundabout and leave at sixth exit":"round-about", - "Enter roundabout and leave at seventh exit":"round-about", - "Enter roundabout and leave at eighth exit":"round-about", - "Enter roundabout and leave at nineth exit":"round-about", - "Enter roundabout and leave at tenth exit":"round-about", - "Enter roundabout and leave at one of the too many exit":"round-about", - "You have reached your destination":"target" - }; - - if( directions[name] ) - return directions[name]; - else - return "default"; -}, - -//map driving instructions to ids -getDirectionId: function(name) { +//map driving instruction ids to internal ids +mapDirectionId: function(name) { var directions = { "Turn left":1, "Turn right":2, @@ -217,7 +176,7 @@ getDirectionId: function(name) { if( directions[name] ) return directions[name]; else - return "default"; + return 0; } }; \ No newline at end of file From 252c23422153859e2a90c2f63900286b403e636e Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Wed, 11 Apr 2012 22:59:41 +0200 Subject: [PATCH 12/12] made parsing of get parameters more robust --- WebContent/main.js | 57 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/WebContent/main.js b/WebContent/main.js index ad5ed0b98..3f2565ecd 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -31,7 +31,7 @@ OSRM.init = function() { OSRM.Routing.init(); // check if the URL contains some GET parameter, e.g. for showing a route - OSRM.checkURL(); + OSRM.parseParameters(); }; @@ -108,8 +108,8 @@ OSRM.prefetchIcons = function() { }; -// parse URL GET parameters if any exist -OSRM.checkURL = function(){ +//parse URL GET parameters +OSRM.parseParameters = function(){ var called_url = document.location.search.substr(1,document.location.search.length); // reject messages that are clearly too long or too small @@ -117,11 +117,7 @@ OSRM.checkURL = function(){ return; // storage for parameter values - var positions = []; - var zoom = null; - var center = null; - var destination = null; - var destination_name = null; + var params = {}; // parse input var splitted_url = called_url.split('&'); @@ -142,68 +138,71 @@ OSRM.checkURL = function(){ var coordinates = unescape(name_val[1]).split(','); if(coordinates.length!=2 || !OSRM.Utils.isLatitude(coordinates[0]) || !OSRM.Utils.isLongitude(coordinates[1]) ) return; - positions.push ( new L.LatLng( coordinates[0], coordinates[1]) ); + params.positions = params.positions || []; + params.positions.push ( new L.LatLng( coordinates[0], coordinates[1]) ); } else if(name_val[0] == 'dest') { var coordinates = unescape(name_val[1]).split(','); if(coordinates.length!=2 || !OSRM.Utils.isLatitude(coordinates[0]) || !OSRM.Utils.isLongitude(coordinates[1]) ) return; - destination = new L.LatLng( coordinates[0], coordinates[1]); + params.destination = new L.LatLng( coordinates[0], coordinates[1]); } else if(name_val[0] == 'destname') { - destination_name = decodeURI(name_val[1]).replace(/<\/?[^>]+(>|$)/g ,""); // discard tags + params.destination_name = decodeURI(name_val[1]).replace(/<\/?[^>]+(>|$)/g ,""); // discard tags } else if(name_val[0] == 'z') { - zoom = name_val[1]; - if( zoom<0 || zoom > 18) + var zoom_level = Number(name_val[1]); + if( zoom_level<0 || zoom_level > 18) return; + params.zoom = zoom; } else if(name_val[0] == 'center') { var coordinates = unescape(name_val[1]).split(','); if(coordinates.length!=2 || !OSRM.Utils.isLatitude(coordinates[0]) || !OSRM.Utils.isLongitude(coordinates[1]) ) return; - center = new L.LatLng( coordinates[0], coordinates[1]); + params.center = new L.LatLng( coordinates[0], coordinates[1]); } } // case 1: destination given - if( destination != undefined ) { - var index = OSRM.G.markers.setTarget( destination.latlng ); - if( destination_name == null ) - OSRM.Geocoder.updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG ); + if( params.destination ) { + var index = OSRM.G.markers.setTarget( params.destination.latlng ); + if( params.destination_name ) + document.getElementById("gui-input-target").value = params.destination_name; else - document.getElementById("gui-input-target").value = destination_name; + OSRM.Geocoder.updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG ); OSRM.G.markers.route[index].show(); OSRM.G.markers.route[index].centerView(); return; } // case 2: locations given - if( positions.length > 0) { + if( params.positions ) { // draw via points - if( positions.length > 0) { - OSRM.G.markers.setSource( positions[0] ); + if( params.positions.length > 0 ) { + OSRM.G.markers.setSource( params.positions[0] ); OSRM.Geocoder.updateAddress( OSRM.C.SOURCE_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG ); } - if(positions.length > 1) { - OSRM.G.markers.setTarget( positions[positions.length-1] ); + if( params.positions.length > 1 ) { + OSRM.G.markers.setTarget( params.positions[params.positions.length-1] ); OSRM.Geocoder.updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG ); } - for(var i=1; i
'; - route_desc += ''; + route_desc += ''; route_desc += "'; @@ -158,33 +158,33 @@ showNA: function( display_text ) { // [TODO: language-safe implementation] getDirectionIcon: function(name) { var directions = { - "Turn left":"turn-left.png", - "Turn right":"turn-right.png", - "U-Turn":"u-turn.png", - "Head":"continue.png", - "Continue":"continue.png", - "Turn slight left":"slight-left.png", - "Turn slight right":"slight-right.png", - "Turn sharp left":"sharp-left.png", - "Turn sharp right":"sharp-right.png", - "Enter roundabout and leave at first exit":"round-about.png", - "Enter roundabout and leave at second exit":"round-about.png", - "Enter roundabout and leave at third exit":"round-about.png", - "Enter roundabout and leave at fourth exit":"round-about.png", - "Enter roundabout and leave at fifth exit":"round-about.png", - "Enter roundabout and leave at sixth exit":"round-about.png", - "Enter roundabout and leave at seventh exit":"round-about.png", - "Enter roundabout and leave at eighth exit":"round-about.png", - "Enter roundabout and leave at nineth exit":"round-about.png", - "Enter roundabout and leave at tenth exit":"round-about.png", - "Enter roundabout and leave at one of the too many exit":"round-about.png", - "You have reached your destination":"target.png" + "Turn left":"turn-left", + "Turn right":"turn-right", + "U-Turn":"u-turn", + "Head":"continue", + "Continue":"continue", + "Turn slight left":"slight-left", + "Turn slight right":"slight-right", + "Turn sharp left":"sharp-left", + "Turn sharp right":"sharp-right", + "Enter roundabout and leave at first exit":"round-about", + "Enter roundabout and leave at second exit":"round-about", + "Enter roundabout and leave at third exit":"round-about", + "Enter roundabout and leave at fourth exit":"round-about", + "Enter roundabout and leave at fifth exit":"round-about", + "Enter roundabout and leave at sixth exit":"round-about", + "Enter roundabout and leave at seventh exit":"round-about", + "Enter roundabout and leave at eighth exit":"round-about", + "Enter roundabout and leave at nineth exit":"round-about", + "Enter roundabout and leave at tenth exit":"round-about", + "Enter roundabout and leave at one of the too many exit":"round-about", + "You have reached your destination":"target" }; if( directions[name] ) return directions[name]; else - return "default.png"; + return "default"; } }; \ No newline at end of file diff --git a/WebContent/routing/OSRM.RoutingGUI.js b/WebContent/routing/OSRM.RoutingGUI.js index e549b1a0a..b276ad1f3 100644 --- a/WebContent/routing/OSRM.RoutingGUI.js +++ b/WebContent/routing/OSRM.RoutingGUI.js @@ -48,17 +48,17 @@ reverseRouting: function() { if(OSRM.G.markers.route.length == 1) { if(OSRM.G.markers.route[0].label == OSRM.C.TARGET_LABEL) { OSRM.G.markers.route[0].label = OSRM.C.SOURCE_LABEL; - OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') ); + OSRM.G.markers.route[0].marker.setIcon( OSRM.G.icons['marker-source'] ); } else if(OSRM.G.markers.route[0].label == OSRM.C.SOURCE_LABEL) { OSRM.G.markers.route[0].label = OSRM.C.TARGET_LABEL; - OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-target.png') ); + OSRM.G.markers.route[0].marker.setIcon( OSRM.G.icons['marker-target'] ); } } else if(OSRM.G.markers.route.length > 1){ OSRM.G.markers.route[0].label = OSRM.C.SOURCE_LABEL; - OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') ); + OSRM.G.markers.route[0].marker.setIcon( OSRM.G.icons['marker-source'] ); OSRM.G.markers.route[OSRM.G.markers.route.length-1].label = OSRM.C.TARGET_LABEL; - OSRM.G.markers.route[OSRM.G.markers.route.length-1].marker.setIcon( new L.Icon('images/marker-target.png') ); + OSRM.G.markers.route[OSRM.G.markers.route.length-1].marker.setIcon( OSRM.G.icons['marker-target'] ); } // recompute route From b1631eff7728da8484f3448d7db0cf1c1b65d4a4 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Wed, 11 Apr 2012 17:31:02 +0100 Subject: [PATCH 10/12] more localization, fixed bugs with FF3 --- WebContent/OSRM.GUI.js | 8 ++- WebContent/OSRM.Geocoder.js | 2 +- WebContent/OSRM.Markers.js | 7 ++- WebContent/localization/OSRM.Locale.de.js | 5 +- WebContent/localization/OSRM.Locale.en.js | 3 +- WebContent/localization/OSRM.Localization.js | 3 +- WebContent/main.css | 4 ++ WebContent/main.html | 4 +- WebContent/routing/OSRM.RoutingDescription.js | 61 ++++++++++++++----- WebContent/routing/OSRM.RoutingGUI.js | 10 --- 10 files changed, 71 insertions(+), 36 deletions(-) diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index 6d4c3841d..a1f780dec 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -44,12 +44,10 @@ init: function() { document.getElementById("gui-printer").onclick = OSRM.Printing.print; document.getElementById("gui-input-source").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.SOURCE_LABEL);}; - document.getElementById("gui-input-source").onkeyup = function(e) {OSRM.RoutingGUI.keyUp(e,OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-delete-source").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-search-source").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-input-target").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.TARGET_LABEL);}; - document.getElementById("gui-input-target").onkeyup = function(e) {OSRM.RoutingGUI.keyUp(e,OSRM.C.TARGET_LABEL);}; document.getElementById("gui-delete-target").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.TARGET_LABEL);}; document.getElementById("gui-search-target").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.TARGET_LABEL);}; @@ -129,6 +127,12 @@ toggleOptions: function() { } else { document.getElementById('options-box').style.visibility="visible"; } +}, + +// clear output area +clearResults: function() { + document.getElementById('information-box').innerHTML = ""; + document.getElementById('information-box-header').innerHTML = ""; } }; diff --git a/WebContent/OSRM.Geocoder.js b/WebContent/OSRM.Geocoder.js index d02029e51..b81f2ef20 100644 --- a/WebContent/OSRM.Geocoder.js +++ b/WebContent/OSRM.Geocoder.js @@ -79,7 +79,7 @@ _showResults: function(response, parameters) { // show first result OSRM.Geocoder._onclickResult(parameters.marker_id, response[0].lat, response[0].lon); - if( OSRM.G.markers.route.length > 1 ) + if( OSRM.G.markers.route.length > 1 ) // if a route is displayed, we don't need to show other possible geocoding results return; // show possible results for input diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js index a86e4853f..cdc30e2f5 100644 --- a/WebContent/OSRM.Markers.js +++ b/WebContent/OSRM.Markers.js @@ -109,7 +109,9 @@ onDragStart: function(e) { } if( this.parent != OSRM.G.markers.highlight) - OSRM.G.markers.highlight.hide(); + OSRM.G.markers.highlight.hide(); + if( this.parent != OSRM.G.markers.dragger) + OSRM.G.markers.dragger.hide(); if (OSRM.G.route.isShown()) OSRM.G.route.showOldRoute(); }, @@ -124,8 +126,7 @@ onDragEnd: function(e) { OSRM.G.route.hideUnnamedRoute(); } else { OSRM.Geocoder.updateAddress(this.parent.label); - document.getElementById('information-box').innerHTML = ""; // do we want this? - document.getElementById('information-box-header').innerHTML = ""; + OSRM.GUI.clearResults(); } }, toString: function() { diff --git a/WebContent/localization/OSRM.Locale.de.js b/WebContent/localization/OSRM.Locale.de.js index b0029cab0..7ba28b514 100644 --- a/WebContent/localization/OSRM.Locale.de.js +++ b/WebContent/localization/OSRM.Locale.de.js @@ -59,10 +59,11 @@ OSRM.Localization["de"] = { "SW": "Südwest", "NW": "Nordwest", // driving directions +"DIRECTION_0":"Unbekannte Anweisung[ auf %s]", "DIRECTION_1":"Links abbiegen[ auf %s]", "DIRECTION_2":"Rechts abbiegen[ auf %s]", "DIRECTION_3":"Umkehren[ auf %s]", -"DIRECTION_4":"Fahren Sie Richtung %s", +"DIRECTION_4":"Fahren Sie Richtung %s", "DIRECTION_5":"Weiterfahren[ auf %s]", "DIRECTION_6":"Leicht links abbiegen[ auf %s]", "DIRECTION_7":"Leicht rechts abbiegen[ auf %s]", @@ -72,7 +73,7 @@ OSRM.Localization["de"] = { "DIRECTION_11":"In den Kreisverkehr einfahren und bei zweiter Möglichkeit verlassen[ auf %s]", "DIRECTION_12":"In den Kreisverkehr einfahren und bei dritter Möglichkeit verlassen[ auf %s]", "DIRECTION_13":"In den Kreisverkehr einfahren und bei vierter Möglichkeit verlassen[ auf %s]", -"DIRECTION_14":"In den Kreisverkehr einfahren und bei f�nfter Möglichkeit verlassen[ auf %s]", +"DIRECTION_14":"In den Kreisverkehr einfahren und bei fünfter Möglichkeit verlassen[ auf %s]", "DIRECTION_15":"In den Kreisverkehr einfahren und bei sechster Möglichkeit verlassen[ auf %s]", "DIRECTION_16":"In den Kreisverkehr einfahren und bei siebter Möglichkeit verlassen[ auf %s]", "DIRECTION_17":"In den Kreisverkehr einfahren und bei achter Möglichkeit verlassen[ auf %s]", diff --git a/WebContent/localization/OSRM.Locale.en.js b/WebContent/localization/OSRM.Locale.en.js index a063d9fa5..86331ad33 100644 --- a/WebContent/localization/OSRM.Locale.en.js +++ b/WebContent/localization/OSRM.Locale.en.js @@ -59,10 +59,11 @@ OSRM.Localization["en"] = { "SW": "southwest", "NW": "northwest", // driving directions +"DIRECTION_0":"Unknown instruction[ on %s]", "DIRECTION_1":"Turn left[ on %s]", "DIRECTION_2":"Turn right[ on %s]", "DIRECTION_3":"U-Turn[ on %s]", -"DIRECTION_4":"Head %s", +"DIRECTION_4":"Head %s", "DIRECTION_5":"Continue[ on %s]", "DIRECTION_6":"Turn slight left[ on %s]", "DIRECTION_7":"Turn slight right[ on %s]", diff --git a/WebContent/localization/OSRM.Localization.js b/WebContent/localization/OSRM.Localization.js index 4063a619b..cc121b29f 100644 --- a/WebContent/localization/OSRM.Localization.js +++ b/WebContent/localization/OSRM.Localization.js @@ -30,6 +30,7 @@ init: function() { // create dropdown menu var select = document.createElement('select'); select.id = "gui-language-toggle"; + select.className = "top-left-button"; select.onchange = function() { OSRM.Localization.change(this.value); }; // fill dropdown menu @@ -67,7 +68,7 @@ change: function(language) { } else { var script = document.createElement('script'); script.type = 'text/javascript'; - script.src = "Localization/OSRM.Locale."+language+".js"; + script.src = "localization/OSRM.Locale."+language+".js"; document.head.appendChild(script); } }, diff --git a/WebContent/main.css b/WebContent/main.css index 3116951fe..02f695a1c 100644 --- a/WebContent/main.css +++ b/WebContent/main.css @@ -131,6 +131,10 @@ html, body { border: 0px; text-decoration:none; } +.top-left-button +{ + float:left; +} .top-right-button { float:right; diff --git a/WebContent/main.html b/WebContent/main.html index e6be48e39..b7af1bbc4 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -64,8 +64,8 @@ or see http://www.gnu.org/licenses/agpl.txt. - - + + diff --git a/WebContent/routing/OSRM.RoutingDescription.js b/WebContent/routing/OSRM.RoutingDescription.js index d632efca0..0fde40312 100644 --- a/WebContent/routing/OSRM.RoutingDescription.js +++ b/WebContent/routing/OSRM.RoutingDescription.js @@ -72,21 +72,22 @@ show: function(response) { route_desc += ''; route_desc += '
'; -// // build route description -// if( i == 0 ) -// route_desc += OSRM.loc("DIRECTION_"+response.route_instructions[i][0]).replace(/%s/, response.route_instructions[i][6]); -// else if( response.route_instructions[i][1] != "" ) -// route_desc += OSRM.loc("DIRECTION_"+response.route_instructions[i][0]).replace(/\[(.*)\]/,""); -// else -// route_desc += OSRM.loc("DIRECTION_"+response.route_instructions[i][0]).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][6]); - - route_desc += response.route_instructions[i][0]; + // build route description if( i == 0 ) - route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] ); - if( response.route_instructions[i][1] != "" ) { - route_desc += ' on '; - route_desc += '' + response.route_instructions[i][1] + ''; - } + route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(response.route_instructions[i][0])).replace(/%s/, OSRM.loc(response.route_instructions[i][6]) ); + else if( response.route_instructions[i][1] != "" ) + route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]); + else + route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(response.route_instructions[i][0])).replace(/\[(.*)\]/,""); + + +// route_desc += response.route_instructions[i][0]; +// if( i == 0 ) +// route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] ); +// if( response.route_instructions[i][1] != "" ) { +// route_desc += ' on '; +// route_desc += '' + response.route_instructions[i][1] + ''; +// } route_desc += '
'; route_desc += "