moved inputbox logic to javascript file,

corrected error with second ENTER not being registered
This commit is contained in:
DennisSchiefer 2012-03-18 15:04:17 +01:00
parent 276b023b05
commit 4615b01fdf
2 changed files with 17 additions and 5 deletions

View File

@ -88,14 +88,14 @@ or see http://www.gnu.org/licenses/agpl.txt.
<table class="full">
<tr>
<td id="gui-search-source-label">Start:</td>
<td><input id="input-source-name" class="input-box" type="text" maxlength="200" value="" title="Startposition eingeben" onchange="if( OSRM.G.markers.hasSource() ) OSRM.G.markers.route[0].dirty_type = true;" onblur="callGeocoder(OSRM.C.SOURCE_LABEL, document.getElementById('input-source-name').value);" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.C.SOURCE_LABEL, document.getElementById('input-source-name').value);}" /></td>
<td class="right"><a class="button not-selectable" id="gui-search-source" onclick="centerMarker('source')">Zeigen</a></td>
<td><input id="input-source-name" class="input-box" type="text" maxlength="200" value="" title="Startposition eingeben" onchange="inputChanged(OSRM.C.SOURCE_LABEL);"/></td>
<td class="right"><a class="button not-selectable" id="gui-search-source" onclick="showMarker('source')">Zeigen</a></td>
</tr>
<tr>
<td id="gui-search-target-label">Ende:</td>
<td><input id="input-target-name" class="input-box" type="text" maxlength="200" value="" title="Zielposition eingeben" onchange="if( OSRM.G.markers.route.hasTarget() ) OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type = true;" onblur="callGeocoder(OSRM.C.TARGET_LABEL, document.getElementById('input-target-name').value);" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.C.TARGET_LABEL, document.getElementById('input-target-name').value);}" /></td>
<td class="right"><a class="button not-selectable" id="gui-search-target" onclick="centerMarker('target');">Zeigen</a></td>
<td><input id="input-target-name" class="input-box" type="text" maxlength="200" value="" title="Zielposition eingeben" onchange="inputChanged(OSRM.C.TARGET_LABEL);"/></td>
<td class="right"><a class="button not-selectable" id="gui-search-target" onclick="showMarker('target');">Zeigen</a></td>
</tr>
</table>

View File

@ -474,10 +474,22 @@ function reverseRouting() {
}
// click: button "show"
function centerMarker(marker_id) {
function showMarker(marker_id) {
if( marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource() && !OSRM.G.markers.route[0].dirty_type ) {
OSRM.G.markers.route[0].centerView();
} else if( marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() && !OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type) {
OSRM.G.markers.route[OSRM.G.markers.route.length-1].centerView();
}
}
// changed: any inputbox (is called when return is pressed [after] or focus is lost [before])
function inputChanged(marker_id) {
if( marker_id == OSRM.C.SOURCE_LABEL){
if( OSRM.G.markers.hasSource() ) OSRM.G.markers.route[0].dirty_type = true;
callGeocoder(OSRM.C.SOURCE_LABEL, document.getElementById('input-source-name').value);
} else if( marker_id == OSRM.C.TARGET_LABEL) {
if( OSRM.G.markers.hasTarget() ) OSRM.G.markers.route[OSRM.G.markers.route.length-1].dirty_type = true;
callGeocoder(OSRM.C.TARGET_LABEL, document.getElementById('input-target-name').value);
}
}