From 3e787be6846aa40113457d683212a9ea547c825c Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Thu, 31 May 2018 23:15:47 +0200 Subject: [PATCH] Fixed the bug where extension didn't ignore binds when writing comments --- js/conf/Keybinds.js | 15 +++++++++++---- js/lib/PlayerData.js | 10 ++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/js/conf/Keybinds.js b/js/conf/Keybinds.js index 36d49e0..fbb344c 100644 --- a/js/conf/Keybinds.js +++ b/js/conf/Keybinds.js @@ -4,6 +4,7 @@ if(Debug.debug) class Keybinds { constructor(pageInfo){ this.pageInfo = pageInfo; + this.inputs = ['input','select','button','textarea']; } setup(){ @@ -20,10 +21,16 @@ class Keybinds { // Tipke upoštevamo samo, če smo v celozaslonskem načinu oz. če ne pišemo komentarja // v nasprotnem primeru ne naredimo nič. // We only take actions if we're in full screen or not writing a comment - if( !(PlayerData.isFullScreen() || ( - (document.activeElement.getAttribute("role") != "textbox") && - (document.activeElement.getAttribute("type") != "text") - ))){ + var activeElement = document.activeElement; + + console.log("[Keybinds::_kbd_process]\n\n\n\n", PlayerData.isFullScreen(), this.inputs.indexOf(activeElement.tagName.toLocaleLowerCase()) !== -1, PlayerData.isFullScreen() && this.inputs.indexOf(activeElement.tagName.toLocaleLowerCase()) !== -1 ); + + + if( (! PlayerData.isFullScreen()) && ( + (this.inputs.indexOf(activeElement.tagName.toLocaleLowerCase()) !== -1) || + (activeElement.getAttribute("role") === "textbox") || + (activeElement.getAttribute("type") === "text") + )){ if(Debug.debug && Debug.keyboard) console.log("[Keybinds::_kbd_process] We're writing a comment or something. Doing nothing"); return; diff --git a/js/lib/PlayerData.js b/js/lib/PlayerData.js index 85b6874..d8353a9 100644 --- a/js/lib/PlayerData.js +++ b/js/lib/PlayerData.js @@ -83,8 +83,14 @@ class PlayerData { this.watchTimeout = setTimeout(function(){ ths.watchTimeout = null; try{ - ths.ghettoWatcher(); - }catch(e){console.log("[PlayerData::scheduleGhettoWatcher] Scheduling failed. Error:",e)} + ths.ghettoWatcher(); + } catch(e) { + if (Debug.debug) { + console.log("[PlayerData::scheduleGhettoWatcher] Scheduling failed. Error:",e) + } + + ths.scheduleGhettoWatcher(1000); + } ths = null; }, timeout