summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/webserver
diff options
context:
space:
mode:
authorPekka Lampila <pekka.lampila@iki.fi>2014-03-05 18:13:55 +0200
committerPekka Lampila <pekka.lampila@iki.fi>2014-03-05 18:14:33 +0200
commit6333f0549cf29457f6886a5cb6279dd5f40dafe5 (patch)
tree88639143cb9f9328dea8e15c6bda3a0cee4838cb /crawl-ref/source/webserver
parentccfdd9ccddc22590e0a22d73adce1728a24086bd (diff)
downloadcrawl-ref-6333f0549cf29457f6886a5cb6279dd5f40dafe5.tar.gz
crawl-ref-6333f0549cf29457f6886a5cb6279dd5f40dafe5.zip
Clean out all document event handlers when changing game version.
Diffstat (limited to 'crawl-ref/source/webserver')
-rw-r--r--crawl-ref/source/webserver/static/scripts/client.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/crawl-ref/source/webserver/static/scripts/client.js b/crawl-ref/source/webserver/static/scripts/client.js
index 5bf13282ee..457240883a 100644
--- a/crawl-ref/source/webserver/static/scripts/client.js
+++ b/crawl-ref/source/webserver/static/scripts/client.js
@@ -1047,7 +1047,8 @@ function (exports, $, key_conversion, chat, comm) {
{
if (game_version == null || data["version"] != game_version)
{
- $(document).unbind("game_preinit game_init game_cleanup");
+ $(document).off();
+ bind_document_events();
for (var i in loaded_modules)
requirejs.undef(loaded_modules[i]);
loaded_modules = [];
@@ -1130,6 +1131,14 @@ function (exports, $, key_conversion, chat, comm) {
return true;
}
+ function bind_document_events()
+ {
+ $(document).on("keypress.client", handle_keypress);
+ $(document).on("keydown.client", handle_keydown);
+ $(document).on("game_keypress", stale_processes_keypress);
+ $(document).on("game_keypress", force_terminate_keypress);
+ }
+
// Global functions for backwards compatibility (HACK)
window.log = log;
window.set_layer = set_layer;
@@ -1174,9 +1183,7 @@ function (exports, $, key_conversion, chat, comm) {
});
$(document).ready(function () {
- // Key handler
- $(document).bind('keypress.client', handle_keypress);
- $(document).bind('keydown.client', handle_keydown);
+ bind_document_events();
$(window).resize(function (ev) {
do_layout();
@@ -1205,8 +1212,6 @@ function (exports, $, key_conversion, chat, comm) {
$("#force_terminate_no").click(force_terminate_no);
$("#force_terminate_yes").click(force_terminate_yes);
- $(document).on("game_keypress", stale_processes_keypress);
- $(document).on("game_keypress", force_terminate_keypress);
do_layout();