Fixed a firefox-incompatability bug in the webclient. Resolves issue143.

This commit is contained in:
Griatch 2011-03-17 23:18:44 +00:00
parent de28b2d575
commit 8288534cf6
2 changed files with 11 additions and 5 deletions

View file

@ -192,7 +192,8 @@ function history_add(input) {
// Catching keyboard shortcuts // Catching keyboard shortcuts
$(document).keypress( function(event) { $(document).keypress( function(event) {
var code = event.keyCode ? event.keyCode : event.which; var code = event.keyCode ? event.keyCode : event.which;
wresult = event.which;
// always focus input field // always focus input field
$("#inputfield")[0].focus(); $("#inputfield")[0].focus();
@ -202,12 +203,17 @@ $(document).keypress( function(event) {
return false; return false;
} }
else { else {
if (code == 38) { // arrow up if (wresult == 38 || wresult == 40) {
$("#inputfield").val(function(index, value){ // this fixes a bug in firefox, those are on ASCII format
return false;
}
if (code == 38) { // arrow up 38
$("#inputfield").val(function(index, value){
return history_step_back(); return history_step_back();
}); });
} }
else if (code == 40) { // arrow down else if (code == 40) { // arrow down 40
$("#inputfield").val(function(index, value){ $("#inputfield").val(function(index, value){
return history_step_fwd(); return history_step_fwd();
}); });

View file

@ -38,7 +38,7 @@
</div> </div>
<form id="inputform"> <form id="inputform">
<div id="playercount">Logged in Players: {{num_players_connected}}</div> <div id="playercount">Logged in Players: {{num_players_connected}}</div>
<div id="inputcontrol"><input type="text" id="inputfield" autocomplete="off"><input id="inputsend" type="button" value="send" onClick="sendMsg()" /></div> <div id="inputcontrol"><input type="text" id="inputfield" autocomplete="off"><input id="inputsend" type="button" value="send" onClick="webclient_input()" /></div>
</form> </form>
</div> </div>