From: Darren Date: Sun, 30 Oct 2011 11:44:32 +0000 (+0000) Subject: Disabled page refresh keyboard shortcuts causing accidental page refreshes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=32a2d88bba869930eb4ff50c472a13ef64b9d40b;p=KiwiIRC.git Disabled page refresh keyboard shortcuts causing accidental page refreshes --- diff --git a/client/js/front.events.js b/client/js/front.events.js index 54499d8..bc24356 100644 --- a/client/js/front.events.js +++ b/client/js/front.events.js @@ -215,13 +215,7 @@ kiwi.front.events = { } // Now that we're connected, warn the user if they really want to quit - // TODO: disable page refreshing or at least just f5 - // This brakes the socket.io connection currently :( - /* - window.onbeforeunload = function() { - return "Are you sure you leave Kiwi IRC?"; - }; - */ + kiwi.front.ui.preventRefresh(); }, /** * Handles the connectFail event diff --git a/client/js/front.ui.js b/client/js/front.ui.js index f7159c4..37dbbf6 100644 --- a/client/js/front.ui.js +++ b/client/js/front.ui.js @@ -256,6 +256,21 @@ kiwi.front.ui = { }, + preventRefresh: function () { + $(document).keydown(function (e) { + // meta + r || F5 + if ((e.metaKey && e.which == 82) || e.which == 116) { + e.preventDefault(); + e.stopPropagation(); + + // Reset IE keyCode + event.keyCode = 0; + + return false; + } + }); + }, + /** * Prompts user for a new nick */