Allow disabling of shortcuts
This commit is contained in:
parent
ebea657f8c
commit
b8a6e9e0b3
@ -180,6 +180,32 @@ var ActionList = {
|
|||||||
global: true,
|
global: true,
|
||||||
site: true,
|
site: true,
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'set-keyboard': {
|
||||||
|
name: 'Keyboard shortcuts',
|
||||||
|
args: [{
|
||||||
|
name: 'Enable',
|
||||||
|
arg: ExtensionMode.Enabled,
|
||||||
|
},{
|
||||||
|
name: 'On whitelisted only',
|
||||||
|
arg: ExtensionMode.Whitelist,
|
||||||
|
scopes: {
|
||||||
|
global: true,
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
name: 'Default',
|
||||||
|
arg: ExtensionMode.Default,
|
||||||
|
scopes: {
|
||||||
|
page: true,
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
name: 'Disable',
|
||||||
|
arg: ExtensionMode.Disabled
|
||||||
|
}],
|
||||||
|
scopes: {
|
||||||
|
global: true,
|
||||||
|
site: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@ var Debug = {
|
|||||||
init: true,
|
init: true,
|
||||||
debug: true,
|
debug: true,
|
||||||
// debug: false,
|
// debug: false,
|
||||||
// keyboard: true,
|
keyboard: true,
|
||||||
debugResizer: true,
|
// debugResizer: true,
|
||||||
debugArDetect: true,
|
// debugArDetect: true,
|
||||||
scaler: true,
|
// scaler: true,
|
||||||
// debugStorage: false,
|
// debugStorage: false,
|
||||||
// debugStorage: true,
|
// debugStorage: true,
|
||||||
// comms: false,
|
// comms: false,
|
||||||
@ -18,15 +18,15 @@ var Debug = {
|
|||||||
// showArDetectCanvas: true,
|
// showArDetectCanvas: true,
|
||||||
// flushStoredSettings: true,
|
// flushStoredSettings: true,
|
||||||
// flushStoredSettings: false,
|
// flushStoredSettings: false,
|
||||||
playerDetectDebug: true,
|
// playerDetectDebug: true,
|
||||||
periodic: true,
|
// periodic: true,
|
||||||
videoRescan: true,
|
// videoRescan: true,
|
||||||
// mousemove: true,
|
// mousemove: true,
|
||||||
arDetect: {
|
// arDetect: {
|
||||||
// edgeDetect: true
|
// edgeDetect: true
|
||||||
},
|
// },
|
||||||
canvas: {
|
canvas: {
|
||||||
debugDetection: true
|
// debugDetection: true
|
||||||
},
|
},
|
||||||
debugCanvas: {
|
debugCanvas: {
|
||||||
// enabled: true,
|
// enabled: true,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import Debug from '../conf/Debug';
|
import Debug from '../conf/Debug';
|
||||||
import PlayerData from './video-data/PlayerData';
|
import PlayerData from './video-data/PlayerData';
|
||||||
|
import ExtensionMode from '../../common/enums/extension-mode.enum';
|
||||||
|
|
||||||
class ActionHandler {
|
class ActionHandler {
|
||||||
|
|
||||||
@ -8,6 +9,7 @@ class ActionHandler {
|
|||||||
this.settings = pageInfo.settings;
|
this.settings = pageInfo.settings;
|
||||||
|
|
||||||
this.inputs = ['input', 'select', 'button', 'textarea'];
|
this.inputs = ['input', 'select', 'button', 'textarea'];
|
||||||
|
this.keyboardLocalDisabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -119,6 +121,15 @@ class ActionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setKeyboardLocal(state) {
|
||||||
|
if (state === ExtensionMode.Enabled) {
|
||||||
|
this.keyboardLocalDisabled = false;
|
||||||
|
} else if (state === ExtensionMode.Disabled) {
|
||||||
|
this.keyboardLocalDisabled = true;
|
||||||
|
}
|
||||||
|
// don't do shit on invalid value of state
|
||||||
|
}
|
||||||
|
|
||||||
preventAction() {
|
preventAction() {
|
||||||
var activeElement = document.activeElement;
|
var activeElement = document.activeElement;
|
||||||
|
|
||||||
@ -130,6 +141,8 @@ class ActionHandler {
|
|||||||
"\nis tag one of defined inputs? (yes->prevent):", this.inputs.indexOf(activeElement.tagName.toLocaleLowerCase()) !== -1,
|
"\nis tag one of defined inputs? (yes->prevent):", this.inputs.indexOf(activeElement.tagName.toLocaleLowerCase()) !== -1,
|
||||||
"\nis role = textbox? (yes -> prevent):", activeElement.getAttribute("role") === "textbox",
|
"\nis role = textbox? (yes -> prevent):", activeElement.getAttribute("role") === "textbox",
|
||||||
"\nis type === 'text'? (yes -> prevent):", activeElement.getAttribute("type") === "text",
|
"\nis type === 'text'? (yes -> prevent):", activeElement.getAttribute("type") === "text",
|
||||||
|
"\nis keyboard local disabled? (yes -> prevent):", this.keyboardLocalDisabled,
|
||||||
|
"\nis keyboard enabled in settings? (no -> prevent)", this.settings.keyboardShortcutsEnabled(window.location.hostname),
|
||||||
"\nwill the action be prevented? (yes -> prevent)", this.preventAction(),
|
"\nwill the action be prevented? (yes -> prevent)", this.preventAction(),
|
||||||
"\n-----------------{ extra debug info }-------------------",
|
"\n-----------------{ extra debug info }-------------------",
|
||||||
"\ntag name? (lowercase):", activeElement.tagName, activeElement.tagName.toLocaleLowerCase(),
|
"\ntag name? (lowercase):", activeElement.tagName, activeElement.tagName.toLocaleLowerCase(),
|
||||||
@ -146,6 +159,13 @@ class ActionHandler {
|
|||||||
// if (PlayerData.isFullScreen()) {
|
// if (PlayerData.isFullScreen()) {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
if (this.keyboardLocalDisabled) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!this.settings.keyboardShortcutsEnabled(window.location.hostname)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (this.inputs.indexOf(activeElement.tagName.toLocaleLowerCase()) !== -1) {
|
if (this.inputs.indexOf(activeElement.tagName.toLocaleLowerCase()) !== -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -193,27 +213,22 @@ class ActionHandler {
|
|||||||
if (videoData) {
|
if (videoData) {
|
||||||
videoData.panHandler(event, true);
|
videoData.panHandler(event, true);
|
||||||
}
|
}
|
||||||
|
} else if (cmd.action === 'set-keyboard') {
|
||||||
|
this.setKeyboardLocal(cmd.arg);
|
||||||
}
|
}
|
||||||
} else if (action.scope === 'site') {
|
} else {
|
||||||
|
let site = action.scope === 'site' ? window.location.host : '@global';
|
||||||
|
|
||||||
if (cmd.action === "set-stretch") {
|
if (cmd.action === "set-stretch") {
|
||||||
this.settings.active.sites[window.location.host].stretch = cmd.arg;
|
this.settings.active.sites[site].stretch = cmd.arg;
|
||||||
} else if (cmd.action === "set-alignment") {
|
} else if (cmd.action === "set-alignment") {
|
||||||
this.settings.active.sites[window.location.host].videoAlignment = cmd.arg;
|
this.settings.active.sites[site].videoAlignment = cmd.arg;
|
||||||
} else if (cmd.action === "set-extension-mode") {
|
} else if (cmd.action === "set-extension-mode") {
|
||||||
this.settings.active.sites[window.location.host].status = cmd.arg;
|
this.settings.active.sites[site].status = cmd.arg;
|
||||||
} else if (cmd.action === "set-autoar-mode") {
|
} else if (cmd.action === "set-autoar-mode") {
|
||||||
this.settings.active.sites[window.location.host].arStatus = cmd.arg;
|
this.settings.active.sites[site].arStatus = cmd.arg;
|
||||||
}
|
} else if (cmd.action === 'set-keyboard') {
|
||||||
this.settings.save();
|
this.settings.active.sites[site].keyboardShortcutsEnabled = cmd.arg;
|
||||||
} else if (action.scope === 'global') {
|
|
||||||
if (cmd.action === "set-stretch") {
|
|
||||||
this.settings.active.stretch.initialMode = cmd.arg;
|
|
||||||
} else if (cmd.action === "set-alignment") {
|
|
||||||
this.settings.active.miscSettings.videoAlignment = cmd.arg;
|
|
||||||
} else if (cmd.action === "set-extension-mode") {
|
|
||||||
this.settings.active.sites['@global'] = cmd.arg;
|
|
||||||
} else if (cmd.action === "set-autoar-mode") {
|
|
||||||
this.settings.active.arDetect.mode.arStatus = cmd.arg;
|
|
||||||
}
|
}
|
||||||
this.settings.save();
|
this.settings.save();
|
||||||
}
|
}
|
||||||
|
@ -297,6 +297,30 @@ class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keyboardShortcutsEnabled(site) {
|
||||||
|
if (!site) {
|
||||||
|
site = window.location.hostname;
|
||||||
|
}
|
||||||
|
if (!site) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!this.active.sites[site]
|
||||||
|
|| this.active.sites[site].keyboardShortcutsEnabled === undefined
|
||||||
|
|| this.active.sites[site].keyboardShortcutsEnabled === ExtensionMode.Default) {
|
||||||
|
return this.keyboardShortcutsEnabled('@global');
|
||||||
|
} else {
|
||||||
|
return this.active.sites[site].keyboardShortcutsEnabled === ExtensionMode.Enabled;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (Debug.debug) {
|
||||||
|
console.error("[Settings.js::keyboardDisabled] something went wrong:", e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extensionEnabled(){
|
extensionEnabled(){
|
||||||
return this.active.sites['@global'] !== ExtensionMode.Disabled
|
return this.active.sites['@global'] !== ExtensionMode.Disabled
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,8 @@ class CommsClient {
|
|||||||
this.pageInfo.restoreAr();
|
this.pageInfo.restoreAr();
|
||||||
} else if (message.cmd === "set-stretch") {
|
} else if (message.cmd === "set-stretch") {
|
||||||
this.pageInfo.setStretchMode(message.arg, message.playing);
|
this.pageInfo.setStretchMode(message.arg, message.playing);
|
||||||
|
} else if (message.cmd === 'set-keyboard') {
|
||||||
|
this.pageInfo.setKeyboardShortcutsEnabled(message.arg)
|
||||||
} else if (message.cmd === "autoar-start") {
|
} else if (message.cmd === "autoar-start") {
|
||||||
if (message.enabled !== false) {
|
if (message.enabled !== false) {
|
||||||
this.pageInfo.initArDetection(message.playing);
|
this.pageInfo.initArDetection(message.playing);
|
||||||
|
@ -479,6 +479,10 @@ class PageInfo {
|
|||||||
requestCurrentZoom() {
|
requestCurrentZoom() {
|
||||||
this.comms.announceZoom(this.currentZoomScale);
|
this.comms.announceZoom(this.currentZoomScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setKeyboardShortcutsEnabled(state) {
|
||||||
|
this.actionHandler.setKeybordLocal(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PageInfo;
|
export default PageInfo;
|
||||||
|
@ -46,7 +46,7 @@ class ExecAction {
|
|||||||
this.settings.active.sites[site].mode = cmd.arg;
|
this.settings.active.sites[site].mode = cmd.arg;
|
||||||
} else if (cmd.action === "set-autoar-mode") {
|
} else if (cmd.action === "set-autoar-mode") {
|
||||||
this.settings.active.sites[site].autoar = cmd.arg;
|
this.settings.active.sites[site].autoar = cmd.arg;
|
||||||
}
|
} else if (cmd.action === 'set-keyboard') {
|
||||||
this.settings.active.sites[site].keyboardShortcutsEnabled = cmd.arg;
|
this.settings.active.sites[site].keyboardShortcutsEnabled = cmd.arg;
|
||||||
}
|
}
|
||||||
this.settings.save();
|
this.settings.save();
|
||||||
|
@ -57,6 +57,19 @@
|
|||||||
</ShortcutButton>
|
</ShortcutButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="keyboardActions.length">
|
||||||
|
<div class="label experimental">Enable/disable keyboard shortcuts</div>
|
||||||
|
<div class="flex flex-row flex-wrap">
|
||||||
|
<ShortcutButton v-for="(action, index) of keyboardActions"
|
||||||
|
class="flex b3 flex-grow button"
|
||||||
|
:class="{'setting-selected': getCurrent('keyboardShortcutsEnabled') === action.cmd[0].arg}"
|
||||||
|
:key="index"
|
||||||
|
:label="(action.scopes[scope] && action.scopes[scope].label) ? action.scopes[scope].label : action.label"
|
||||||
|
:shortcut="parseShortcut(action)"
|
||||||
|
@click.native="execAction(action)"
|
||||||
|
>
|
||||||
|
</ShortcutButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -65,8 +65,21 @@
|
|||||||
</ShortcutButton>
|
</ShortcutButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- <div v-if="keyboardActions.length">
|
||||||
|
<div class="label">Keyboard shortcuts:</div>
|
||||||
|
<div class="flex flex-row flex-wrap">
|
||||||
|
<ShortcutButton v-for="(action, index) of keyboardActions"
|
||||||
|
class="flex b3 button"
|
||||||
|
:key="index"
|
||||||
|
:label="(action.scopes.page && action.scopes.page.label) ? action.scopes.page.label : action.label"
|
||||||
|
:shortcut="parseShortcut(action)"
|
||||||
|
@click.native="execAction(action)"
|
||||||
|
>
|
||||||
|
</ShortcutButton>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
<div v-if="true">
|
|
||||||
<div v-if="alignmentActions.length">
|
<div v-if="alignmentActions.length">
|
||||||
<div class="label">Video alignment:</div>
|
<div class="label">Video alignment:</div>
|
||||||
<div class="flex flex-row flex-wrap">
|
<div class="flex flex-row flex-wrap">
|
||||||
|
Loading…
Reference in New Issue
Block a user