more localization,

fixed bugs with FF3
This commit is contained in:
DennisSchiefer 2012-04-11 17:31:02 +01:00
parent ffd5e2de99
commit b1631eff77
10 changed files with 71 additions and 36 deletions

View File

@ -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 = "";
}
};

View File

@ -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

View File

@ -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() {

View File

@ -59,10 +59,11 @@ OSRM.Localization["de"] = {
"SW": "Südwest",
"NW": "Nordwest",
// driving directions
"DIRECTION_0":"Unbekannte Anweisung[ auf <b>%s</b>]",
"DIRECTION_1":"Links abbiegen[ auf <b>%s</b>]",
"DIRECTION_2":"Rechts abbiegen[ auf <b>%s</b>]",
"DIRECTION_3":"Umkehren[ auf <b>%s</b>]",
"DIRECTION_4":"Fahren Sie Richtung %s",
"DIRECTION_4":"Fahren Sie Richtung <b>%s</b>",
"DIRECTION_5":"Weiterfahren[ auf <b>%s</b>]",
"DIRECTION_6":"Leicht links abbiegen[ auf <b>%s</b>]",
"DIRECTION_7":"Leicht rechts abbiegen[ auf <b>%s</b>]",
@ -72,7 +73,7 @@ OSRM.Localization["de"] = {
"DIRECTION_11":"In den Kreisverkehr einfahren und bei zweiter Möglichkeit verlassen[ auf <b>%s</b>]",
"DIRECTION_12":"In den Kreisverkehr einfahren und bei dritter Möglichkeit verlassen[ auf <b>%s</b>]",
"DIRECTION_13":"In den Kreisverkehr einfahren und bei vierter Möglichkeit verlassen[ auf <b>%s</b>]",
"DIRECTION_14":"In den Kreisverkehr einfahren und bei f<EFBFBD>nfter Möglichkeit verlassen[ auf <b>%s</b>]",
"DIRECTION_14":"In den Kreisverkehr einfahren und bei fünfter Möglichkeit verlassen[ auf <b>%s</b>]",
"DIRECTION_15":"In den Kreisverkehr einfahren und bei sechster Möglichkeit verlassen[ auf <b>%s</b>]",
"DIRECTION_16":"In den Kreisverkehr einfahren und bei siebter Möglichkeit verlassen[ auf <b>%s</b>]",
"DIRECTION_17":"In den Kreisverkehr einfahren und bei achter Möglichkeit verlassen[ auf <b>%s</b>]",

View File

@ -59,10 +59,11 @@ OSRM.Localization["en"] = {
"SW": "southwest",
"NW": "northwest",
// driving directions
"DIRECTION_0":"Unknown instruction[ on <b>%s</b>]",
"DIRECTION_1":"Turn left[ on <b>%s</b>]",
"DIRECTION_2":"Turn right[ on <b>%s</b>]",
"DIRECTION_3":"U-Turn[ on <b>%s</b>]",
"DIRECTION_4":"Head %s",
"DIRECTION_4":"Head <b>%s</b>",
"DIRECTION_5":"Continue[ on <b>%s</b>]",
"DIRECTION_6":"Turn slight left[ on <b>%s</b>]",
"DIRECTION_7":"Turn slight right[ on <b>%s</b>]",

View File

@ -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);
}
},

View File

@ -131,6 +131,10 @@ html, body {
border: 0px;
text-decoration:none;
}
.top-left-button
{
float:left;
}
.top-right-button
{
float:right;

View File

@ -64,8 +64,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
<script src="OSRM.Browser.js" type="text/javascript"></script>
<script src="OSRM.JSONP.js" type="text/javascript"></script>
<script src="Localization/OSRM.Localization.js" type="text/javascript"></script>
<script src="Printing/OSRM.Printing.js" type="text/javascript"></script>
<script src="localization/OSRM.Localization.js" type="text/javascript"></script>
<script src="printing/OSRM.Printing.js" type="text/javascript"></script>
<script src="OSRM.Utils.js" type="text/javascript"></script>
</head>

View File

@ -72,21 +72,22 @@ show: function(response) {
route_desc += '<td class="result-items">';
route_desc += '<div class="result-item" onclick="OSRM.RoutingDescription.onClickRouteDescription('+response.route_instructions[i][3]+')">';
// // 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 += '<b>' + response.route_instructions[i][1] + '</b>';
}
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 += '<b>' + response.route_instructions[i][1] + '</b>';
// }
route_desc += '</div>';
route_desc += "</td>";
@ -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

View File

@ -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)