forgot to commit new files
This commit is contained in:
parent
8cc1d4c19f
commit
bf5a51963b
21
js/lib/KeyboardShortcutParser.js
Normal file
21
js/lib/KeyboardShortcutParser.js
Normal file
@ -0,0 +1,21 @@
|
||||
class KeyboardShortcutParser {
|
||||
static parseShortcut(keypress) {
|
||||
var shortcutCombo = '';
|
||||
|
||||
if (keypress.ctrlKey) {
|
||||
shortcutCombo += 'Ctrl + ';
|
||||
}
|
||||
if (keypress.shiftKey) {
|
||||
shortcutCombo += 'Shift + ';
|
||||
}
|
||||
if (keypress.metaKey) {
|
||||
shortcutCombo += 'Meta + ';
|
||||
}
|
||||
if (keypress.altKey) {
|
||||
shortcutCombo += 'Alt + ';
|
||||
}
|
||||
shortcutCombo += keypress.key.toUpperCase();
|
||||
|
||||
return shortcutCombo;
|
||||
}
|
||||
}
|
39
js/lib/libghettoui/settings/ActionItem.js
Normal file
39
js/lib/libghettoui/settings/ActionItem.js
Normal file
@ -0,0 +1,39 @@
|
||||
class ActionItem extends BaseElement {
|
||||
constructor(id, action, onClick) {
|
||||
super(id, undefined, onClick);
|
||||
this.element.classList.add("action-list-item", "flex", "flex-row");
|
||||
|
||||
// action list item looks like this
|
||||
// [ action.label | shortcut | visibility checkboxes ]
|
||||
|
||||
var cmd = document.createElement('div')
|
||||
var label = document.createElement('div');
|
||||
var shortcut = document.createElement('div');
|
||||
var popupVideoCb = document.createElement('div');
|
||||
var popupSiteCb = document.createElement('div');
|
||||
var popupGlobalCb = document.createElement('div');
|
||||
var playerUi = document.createElement('div');
|
||||
|
||||
cmd.classList.add('cmd', 'flex');
|
||||
label.classList.add('label', 'flex');
|
||||
shortcut.classList.add('shortcut', 'flex');
|
||||
popupVideoCb.classList.add('checkbox', 'flex');
|
||||
popupSiteCb.classList.add('checkbox', 'flex');
|
||||
popupGlobalCb.classList.add('checkbox', 'flex');
|
||||
playerUi.classList.add('checkbox', 'flex');
|
||||
|
||||
for (var c in action.cmd) {
|
||||
cmd.textContent += `${c > 0 ? '; ' : ''}${action.cmd[0].action} ${action.cmd[0].arg}`
|
||||
}
|
||||
label.textContent = action.label;
|
||||
shortcut.textContent = action.parsedShortcut;
|
||||
|
||||
this.element.appendChild(label);
|
||||
this.element.appendChild(cmd);
|
||||
this.element.appendChild(shortcut);
|
||||
this.element.appendChild(popupVideoCb);
|
||||
this.element.appendChild(popupSiteCb);
|
||||
this.element.appendChild(popupGlobalCb);
|
||||
this.element.appendChild(playerUi);
|
||||
}
|
||||
}
|
65
res/settings/js/customization.js
Normal file
65
res/settings/js/customization.js
Normal file
@ -0,0 +1,65 @@
|
||||
if (Debug.debug) {
|
||||
console.log("[customization.js] loading script for customization tab")
|
||||
}
|
||||
|
||||
function loadActions() {
|
||||
if (Debug.debug) {
|
||||
console.log("[customization.js] loading actions\n", settings, "\n", settings.active.actions)
|
||||
}
|
||||
|
||||
// build actions list
|
||||
|
||||
const actions = settings.active.actions;
|
||||
|
||||
const cropActions = actions.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-ar');
|
||||
const stretchActions = actions.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-stretch');
|
||||
const alignActions = actions.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-alignment');
|
||||
const zoomPanActions = actions.filter(action => action.cmd.length === 1 && (
|
||||
action.cmd[0].action === 'set-zoom' ||
|
||||
action.cmd[0].action === 'set-pan' ||
|
||||
action.cmd[0].action === 'pan' ||
|
||||
action.cmd[0].action === 'set-pan')
|
||||
);
|
||||
|
||||
// this is shit on performance but it'll cut it for this job
|
||||
const otherActions = actions.filter(action => action.cmd.length > 1 || (
|
||||
action.cmd.length === 1 &&
|
||||
cropActions.indexOf(action) === -1 &&
|
||||
stretchActions.indexOf(action) === -1 &&
|
||||
alignActions.indexOf(action) === -1 &&
|
||||
zoomPanActions.indexOf(action) === -1 )
|
||||
);
|
||||
|
||||
loadActionSection(cropActions, ui.customization.actionList);
|
||||
loadActionSection(stretchActions, ui.customization.actionList);
|
||||
loadActionSection(alignActions, ui.customization.actionList);
|
||||
loadActionSection(zoomPanActions, ui.customization.actionList);
|
||||
loadActionSection(otherActions, ui.customization.actionList);
|
||||
|
||||
ui.customization.actionItems.push(cropActions);
|
||||
ui.customization.actionItems.push(stretchActions);
|
||||
ui.customization.actionItems.push(alignActions);
|
||||
ui.customization.actionItems.push(zoomPanActions);
|
||||
ui.customization.actionItems.push(otherActions);
|
||||
|
||||
console.log("ui.customization:", ui.customization)
|
||||
}
|
||||
|
||||
function loadActionSection(actions, container) {
|
||||
for(action of actions) {
|
||||
if (action.shortcut && action.shortcut[0].key) {
|
||||
action.parsedShortcut = KeyboardShortcutParser.parseShortcut(action.shortcut[0])
|
||||
}
|
||||
var actionIndex = settings.active.actions.indexOf(action);
|
||||
var newAction = new ActionItem(
|
||||
undefined,
|
||||
action,
|
||||
() => editShortcut(actionIndex)
|
||||
);
|
||||
newAction.appendTo(container);
|
||||
}
|
||||
}
|
||||
|
||||
function editShortcut(actionIndex) {
|
||||
alert(`customization.js/editShortcut: Implement me pls. ActionIndex: ${actionIndex}`);
|
||||
}
|
Loading…
Reference in New Issue
Block a user