From aec2f81884c56bd4032332e47170a60fa7cd2b88 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 23 May 2020 06:37:04 -0400 Subject: [PATCH] Add ability to toggle god mode in popup panel Pressing spacebar will toggle god mode in popup panel. This capability shouldn't encourage people to misuse _allow_ rules as having to press the space bar act as an extra necessary step which purpose is to make the creation of _allow_ rules more mindful. --- src/js/popup-fenix.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/js/popup-fenix.js b/src/js/popup-fenix.js index 5d4afae0a..5570e83c1 100644 --- a/src/js/popup-fenix.js +++ b/src/js/popup-fenix.js @@ -310,8 +310,8 @@ const updateAllFirewallCells = function() { const buildAllFirewallRows = function() { // Do this before removing the rows if ( dfHotspots === null ) { - dfHotspots = - uDom('#actionSelector').on('click', 'span', setFirewallRuleHandler); + dfHotspots = uDom.nodeFromId('actionSelector'); + dfHotspots.addEventListener('click', setFirewallRuleHandler); } dfHotspots.remove(); @@ -846,10 +846,10 @@ uDom('#lessButton').on('click', ( ) => { toggleSections(false); }); /******************************************************************************/ -const mouseenterCellHandler = function() { - if ( uDom(this).hasClass('ownRule') === false ) { - dfHotspots.appendTo(this); - } +const mouseenterCellHandler = function(ev) { + const target = ev.target; + if ( target.classList.contains('ownRule') ) { return; } + target.appendChild(dfHotspots); }; const mouseleaveCellHandler = function() { @@ -901,7 +901,7 @@ const unsetFirewallRuleHandler = function(ev) { 0, ev.ctrlKey || ev.metaKey ); - dfHotspots.appendTo(cell); + cell.appendChild(dfHotspots); }; /******************************************************************************/ @@ -1110,6 +1110,20 @@ const toggleHostnameSwitch = async function(ev) { hashFromPopupData(); }; +/******************************************************************************* + + Space bar: toggle god mode + +*/ + +const keyboardHandler = function(ev) { + if ( ev.keyCode === 0x20 ) { + document.body.classList.toggle('godMode'); + } +}; + +document.addEventListener('keydown', keyboardHandler); + /******************************************************************************/ // Poll for changes.