From 47e540f401b21e6fc22db73b72d4005df37fb8c3 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Sat, 4 Jul 2015 14:08:22 -0500 Subject: [PATCH] Minor refactor to global click handler --- js/client.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/client.js b/js/client.js index 1d764f063..fea92d88b 100644 --- a/js/client.js +++ b/js/client.js @@ -4,8 +4,10 @@ window.gui = require('nw.gui'); window.nwWindow = gui.Window.get(); } - $(document).on('click', 'a', function(e) { - if (this.href && this.className !== 'closebutton' && (this.href.substr(0, 32) === 'http://play.pokemonshowdown.com/' || this.href.substr(0, 33) === 'https://play.pokemonshowdown.com/')) { + $(window).on('click', 'a', function(e) { + if (this.className === 'closebutton') return; // handled elsewhere + if (!this.href) return; // should never happen + if (this.href.substr(0, 32) === 'http://play.pokemonshowdown.com/' || this.href.substr(0, 33) === 'https://play.pokemonshowdown.com/') { var target; if (this.href.charAt(4) === ':') { target = this.href.substr(32);