Re-added all buttons to popup. Not working: selection
This commit is contained in:
parent
6b9c0274b7
commit
98250ee2f2
@ -191,7 +191,9 @@ var ExtensionConf = {
|
||||
actions: [{
|
||||
cmd: [{
|
||||
action: 'set-ar',
|
||||
arg: 'auto'
|
||||
arg: 'auto',
|
||||
persistent: false, // optional, false by default. If true, change doesn't take effect immediately.
|
||||
// Instead, this action saves stuff to settings
|
||||
}],
|
||||
shortcut: [{
|
||||
key: 'a',
|
||||
@ -438,6 +440,16 @@ var ExtensionConf = {
|
||||
popup_global: true,
|
||||
ui: true,
|
||||
label: 'Thin borders'
|
||||
},{
|
||||
cmd: [{
|
||||
action: 'set-stretch',
|
||||
arg: -1,
|
||||
}],
|
||||
popup: false,
|
||||
popup_site: true,
|
||||
popup_global: false,
|
||||
ui: false,
|
||||
label: 'Default'
|
||||
},
|
||||
//
|
||||
// A L I G N M E N T
|
||||
@ -472,7 +484,159 @@ var ExtensionConf = {
|
||||
popup_global: true,
|
||||
ui: true,
|
||||
label: 'Right',
|
||||
}],
|
||||
},{
|
||||
cmd: [{
|
||||
action: 'set-alignment',
|
||||
arg: 'default'
|
||||
}],
|
||||
popup: false,
|
||||
popup_site: true,
|
||||
popup_global: false,
|
||||
ui: false,
|
||||
label: 'Default',
|
||||
},
|
||||
//
|
||||
// E N A B L E E X T E N S I O N / A U T O A R
|
||||
// (for sites/extension tab in the popup)
|
||||
//
|
||||
{ // extension options:
|
||||
// global
|
||||
cmd: [{
|
||||
action: 'set-extension-mode',
|
||||
arg: 'blacklist',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: true,
|
||||
popup_site: false,
|
||||
ui: true,
|
||||
label: 'Enable'
|
||||
},{
|
||||
cmd: [{
|
||||
action: 'set-extension-mode',
|
||||
arg: 'whitelist',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: true,
|
||||
popup_site: false,
|
||||
ui: true,
|
||||
label: 'On whitelisted only'
|
||||
},{
|
||||
cmd: [{
|
||||
action: 'set-extension-mode',
|
||||
arg: 'disabled',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: true,
|
||||
popup_site: false,
|
||||
ui: true,
|
||||
label: 'Disabled'
|
||||
},{
|
||||
// site-only
|
||||
cmd: [{
|
||||
action: 'set-extension-mode',
|
||||
arg: 'whitelist',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: false,
|
||||
popup_site: true,
|
||||
ui: true,
|
||||
label: 'Enable'
|
||||
},{
|
||||
cmd: [{
|
||||
action: 'set-extension-mode',
|
||||
arg: 'default',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: false,
|
||||
popup_site: true,
|
||||
ui: true,
|
||||
label: 'Use default option'
|
||||
},{
|
||||
cmd: [{
|
||||
action: 'set-extension-mode',
|
||||
arg: 'disabled',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: false,
|
||||
popup_site: true,
|
||||
ui: true,
|
||||
label: 'Disable'
|
||||
},{ // extension options:
|
||||
// global
|
||||
cmd: [{
|
||||
action: 'set-autoar-mode',
|
||||
arg: 'blacklist',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: true,
|
||||
popup_site: false,
|
||||
ui: true,
|
||||
label: 'Enable'
|
||||
},{
|
||||
cmd: [{
|
||||
action: 'set-autoar-mode',
|
||||
arg: 'whitelist',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: true,
|
||||
popup_site: false,
|
||||
ui: true,
|
||||
label: 'On whitelisted only'
|
||||
},{
|
||||
cmd: [{
|
||||
action: 'set-autoar-mode',
|
||||
arg: 'disabled',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: true,
|
||||
popup_site: false,
|
||||
ui: true,
|
||||
label: 'Disabled'
|
||||
},{
|
||||
// site-only
|
||||
cmd: [{
|
||||
action: 'set-autoar-mode',
|
||||
arg: 'whitelist',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: false,
|
||||
popup_site: true,
|
||||
ui: true,
|
||||
label: 'Enable'
|
||||
},{
|
||||
|
||||
cmd: [{
|
||||
action: 'set-autoar-mode',
|
||||
arg: 'default',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: false,
|
||||
popup_site: true,
|
||||
ui: true,
|
||||
label: 'Use default option'
|
||||
},{
|
||||
cmd: [{
|
||||
action: 'set-autoar-mode',
|
||||
arg: 'disabled',
|
||||
persistent: true,
|
||||
}],
|
||||
popup: false,
|
||||
popup_global: false,
|
||||
popup_site: true,
|
||||
ui: true,
|
||||
label: 'Disable'
|
||||
},],
|
||||
// -----------------------------------------
|
||||
// ::: SITE CONFIGURATION :::
|
||||
// -----------------------------------------
|
||||
|
@ -275,29 +275,44 @@ function selectButton(action, arg, buttons) {
|
||||
function configureGlobalTab() {
|
||||
const popupButtons = settings.getActionsForSite(site).filter(action => action.popup_global === true);
|
||||
|
||||
const extensionButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-extension-mode');
|
||||
const autoarButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-autoar-mode');
|
||||
const stretchButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-stretch');
|
||||
const alignButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-alignment');
|
||||
|
||||
processButtonsForPopupCategory(GlobalPanel.elements.extensionSettings, extensionButtons, 'site');
|
||||
processButtonsForPopupCategory(GlobalPanel.elements.autoarSettings, autoarButtons, 'site');
|
||||
processButtonsForPopupCategory(GlobalPanel.elements.stretchSettings, stretchButtons);
|
||||
processButtonsForPopupCategory(GlobalPanel.elements.alignmentSettings, alignButtons);
|
||||
|
||||
selectButton('set-stretch', settings.active.stretch.initialMode, GlobalPanel.elements.stretchSettings.buttons);
|
||||
selectButton('set-alignment', settings.active.miscFullscreenSettings.videoFloat, GlobalPanel.elements.alignmentSettings.buttons);
|
||||
|
||||
return; // todo: revisit
|
||||
ExtPanel.extOptions[settings.active.extensionMode].classList.add("selected");
|
||||
ExtPanel.arOptions[settings.active.arDetect.mode].classList.add("selected");
|
||||
selectButton('set-extension-mode', settings.active.extensionMode, GlobalPanel.elements.extensionSettings.buttons);
|
||||
selectButton('set-extension-mode', settings.active.arDetect.mode, GlobalPanel.elements.autoarSettings.buttons);
|
||||
}
|
||||
|
||||
function configureSitesTab(site) {
|
||||
const popupButtons = settings.getActionsForSite(site).filter(action => action.popup_site === true);
|
||||
|
||||
const extensionButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-extension-mode');
|
||||
const autoarButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-autoar-mode');
|
||||
const stretchButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-stretch');
|
||||
const alignButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-alignment');
|
||||
|
||||
processButtonsForPopupCategory(SitePanel.elements.extensionSettings, extensionButtons, 'site');
|
||||
processButtonsForPopupCategory(SitePanel.elements.autoarSettings, autoarButtons, 'site');
|
||||
processButtonsForPopupCategory(SitePanel.elements.stretchSettings, stretchButtons, 'site');
|
||||
processButtonsForPopupCategory(SitePanel.elements.alignmentSettings, alignButtons, 'site');
|
||||
|
||||
if (settings.active.sites[site.host] && settings.active.sites[site.host]) {
|
||||
selectButton('set-extension-mode', settings.active.sites[site.host].status, SitePanel.elements.extensionSettings.buttons);
|
||||
selectButton('set-autoar-mode', settings.active.sites[site.host].arStatus, SitePanel.elements.extensionSettings.buttons);
|
||||
} else {
|
||||
selectButton('set-extension-mode', 'default', SitePanel.elements.extensionSettings.buttons);
|
||||
selectButton('set-autoar-mode', 'default', SitePanel.elements.extensionSettings.buttons);
|
||||
}
|
||||
|
||||
// optional settings:
|
||||
if(settings.active.sites[site.host] && settings.active.sites[site.host].stretch !== undefined) { // can be 0
|
||||
selectButton('set-stretch', settings.active.sites[site.host].stretch, SitePanel.elements.stretchSettings.buttons)
|
||||
@ -310,32 +325,6 @@ function configureSitesTab(site) {
|
||||
} else {
|
||||
selectButton('set-alignment', 'default', SitePanel.elements.alignmentSettings.buttons);
|
||||
}
|
||||
|
||||
return; // todo: revisit
|
||||
|
||||
for(const button in SitePanel.extOptions) {
|
||||
SitePanel.extOptions[button].classList.remove("selected");
|
||||
}
|
||||
for(const button in SitePanel.arOptions) {
|
||||
SitePanel.arOptions[button].classList.remove("selected");
|
||||
}
|
||||
for(const button in SitePanel.alignment) {
|
||||
SitePanel.alignment[button].classList.remove("selected");
|
||||
}
|
||||
for(const button in SitePanel.stretch) {
|
||||
SitePanel.stretch[button].classList.remove("selected");
|
||||
}
|
||||
|
||||
if (settings.active.sites[site.host] && settings.active.sites[site.host]) {
|
||||
console.log("settings for", site, "exist!")
|
||||
SitePanel.extOptions[settings.active.sites[site.host].status].classList.add("selected");
|
||||
SitePanel.arOptions[settings.active.sites[site.host].arStatus].classList.add("selected");
|
||||
} else {
|
||||
SitePanel.extOptions.default.classList.add("selected");
|
||||
SitePanel.arOptions.default.classList.add("selected");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function configureVideoTab(site) {
|
||||
@ -528,198 +517,6 @@ document.addEventListener("click", (e) => {
|
||||
command.sender = "popup";
|
||||
command.receiver = "uwbg";
|
||||
|
||||
if(e.target.classList.contains("disabled"))
|
||||
return;
|
||||
|
||||
// if(e.target.classList.contains("menu-item")){
|
||||
|
||||
// if(Debug.debug) {
|
||||
// console.log("[popup.js::eventListener] clicked on a tab. Class list:", e.target.classList);
|
||||
// }
|
||||
|
||||
// if(e.target.classList.contains("_menu_tab_settings_ext")){
|
||||
// openMenu("extensionSettings");
|
||||
// } else if(e.target.classList.contains("_menu_tab_settings_site")){
|
||||
// openMenu("siteSettings");
|
||||
// } else if(e.target.classList.contains("_menu_tab_settings_video")){
|
||||
// openMenu("videoSettings");
|
||||
// } else if(e.target.classList.contains("_menu_tab_about")){
|
||||
// openMenu("about");
|
||||
// }
|
||||
|
||||
// // don't send commands
|
||||
// return;
|
||||
// }
|
||||
if(e.target.classList.contains("_ext")) {
|
||||
var command = {};
|
||||
if(e.target.classList.contains("_ext_global_options")){
|
||||
if (e.target.classList.contains("_blacklist")) {
|
||||
settings.active.extensionMode = "blacklist";
|
||||
} else if (e.target.classList.contains("_whitelist")) {
|
||||
settings.active.extensionMode = "whitelist";
|
||||
} else {
|
||||
settings.active.extensionMode = "disabled";
|
||||
}
|
||||
settings.save();
|
||||
return;
|
||||
} else if (e.target.classList.contains("_ext_site_options")) {
|
||||
var mode;
|
||||
if(e.target.classList.contains("_blacklist")){
|
||||
mode = "disabled";
|
||||
} else if(e.target.classList.contains("_whitelist")) {
|
||||
mode = "enabled";
|
||||
} else {
|
||||
mode = "default";
|
||||
}
|
||||
|
||||
if(settings.active.sites[site.host]) {
|
||||
settings.active.sites[site.host].status = mode;
|
||||
settings.active.sites[site.host].statusEmbedded = mode;
|
||||
} else {
|
||||
settings.active.sites[site.host] = {
|
||||
status: mode,
|
||||
statusEmbedded: mode,
|
||||
arStatus: 'default',
|
||||
type: 'user-defined'
|
||||
}
|
||||
}
|
||||
settings.save();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(e.target.classList.contains("_changeAr")){
|
||||
if(e.target.classList.contains("_ar_auto")){
|
||||
command.cmd = "autoar-start";
|
||||
command.enabled = true;
|
||||
return command;
|
||||
}
|
||||
|
||||
}
|
||||
if(e.target.classList.contains("_stretch")){
|
||||
// stretch, global
|
||||
if (e.target.classList.contains("_ar_stretch_global")) {
|
||||
if (e.target.classList.contains("_none")) {
|
||||
settings.active.stretch.initialMode = 0;
|
||||
} else if (e.target.classList.contains("_basic")) {
|
||||
settings.active.stretch.initialMode = 1;
|
||||
} else if (e.target.classList.contains("_hybrid")) {
|
||||
settings.active.stretch.initialMode = 2;
|
||||
} else if (e.target.classList.contains("_conditional")) {
|
||||
settings.active.stretch.initialMode = 3;
|
||||
}
|
||||
settings.save();
|
||||
return;
|
||||
}
|
||||
|
||||
// stretch, site
|
||||
if (e.target.classList.contains("_ar_stretch_site")) {
|
||||
if (e.target.classList.contains("_none")) {
|
||||
settings.active.sites[site.host].stretch = 0;
|
||||
} else if (e.target.classList.contains("_basic")) {
|
||||
settings.active.sites[site.host].stretch = 1;
|
||||
} else if (e.target.classList.contains("_hybrid")) {
|
||||
settings.active.sites[site.host].stretch = 2;
|
||||
} else if (e.target.classList.contains("_conditional")) {
|
||||
settings.active.sites[site.host].stretch = 3;
|
||||
} else {
|
||||
delete(settings.active.sites[site.host].stretch);
|
||||
}
|
||||
settings.save();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(e.target.classList.contains("_autoAr")){
|
||||
if(e.target.classList.contains("_ar_global_options")){
|
||||
if (e.target.classList.contains("_blacklist")) {
|
||||
settings.active.arDetect.mode = "blacklist";
|
||||
} else if (e.target.classList.contains("_whitelist")) {
|
||||
settings.active.arDetect.mode = "whitelist";
|
||||
} else {
|
||||
settings.active.arDetect.mode = "disabled";
|
||||
}
|
||||
settings.save();
|
||||
return;
|
||||
} else if (e.target.classList.contains("_save_autoAr_timer")) {
|
||||
var value = parseInt(document.getElementById("_input_autoAr_timer").value.trim());
|
||||
|
||||
if(! isNaN(value)){
|
||||
var timeout = parseInt(value);
|
||||
settings.active.arDetect.timer_playing = timeout;
|
||||
settings.save();
|
||||
}
|
||||
return;
|
||||
} else if (e.target.classList.contains("_ar_site_options")) {
|
||||
var mode;
|
||||
if(e.target.classList.contains("_disabled")){
|
||||
mode = "disabled";
|
||||
} else if(e.target.classList.contains("_enabled")) {
|
||||
mode = "enabled";
|
||||
} else {
|
||||
mode = "default";
|
||||
}
|
||||
|
||||
if(settings.active.sites[site.host]) {
|
||||
settings.active.sites[site.host].arStatus = mode;
|
||||
} else {
|
||||
settings.active.sites[site.host] = {
|
||||
status: settings.active.extensionMode,
|
||||
statusEmbedded: settings.active.extensionMode,
|
||||
arStatus: mode,
|
||||
type: 'user-defined'
|
||||
}
|
||||
}
|
||||
settings.save();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (e.target.classList.contains("_align_ext")) {
|
||||
if (e.target.classList.contains("_align_ext_left")) {
|
||||
settings.active.miscFullscreenSettings.videoFloat = 'left';
|
||||
} else if (e.target.classList.contains("_align_ext_center")) {
|
||||
settings.active.miscFullscreenSettings.videoFloat = 'center';
|
||||
} else if (e.target.classList.contains("_align_ext_right")) {
|
||||
settings.active.miscFullscreenSettings.videoFloat = 'right';
|
||||
}
|
||||
|
||||
settings.save();
|
||||
return;
|
||||
}
|
||||
if (e.target.classList.contains("_align_site")) {
|
||||
if (!site) {
|
||||
return;
|
||||
}
|
||||
if (e.target.classList.contains("_align_site_left")) {
|
||||
settings.active.sites[site.host].videoAlignment = 'left';
|
||||
} else if (e.target.classList.contains("_align_site_center")) {
|
||||
settings.active.sites[site.host].videoAlignment = 'center';
|
||||
} else if (e.target.classList.contains("_align_site_right")) {
|
||||
settings.active.sites[site.host].videoAlignment = 'right';
|
||||
} else {
|
||||
// default case — remove this object
|
||||
delete(settings.active.sites[site.host].videoAlignment);
|
||||
}
|
||||
|
||||
settings.save();
|
||||
return;
|
||||
}
|
||||
if (e.target.classList.contains("_align")) {
|
||||
command.cmd = "set-alignment";
|
||||
|
||||
if (e.target.classList.contains("_align_video_left")) {
|
||||
command.mode = 'left';
|
||||
} else if (e.target.classList.contains("_align_video_center")) {
|
||||
command.mode = 'center';
|
||||
} else if (e.target.classList.contains("_align_video_right")) {
|
||||
command.mode = 'right';
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
//#region zoom buttons
|
||||
if (e.target.classList.contains("_zoom_show_shortcuts")) {
|
||||
VideoPanel.misc.zoomShortcuts.classList.remove("hidden");
|
||||
|
@ -28,13 +28,13 @@
|
||||
<p>These settings can be overriden on per-site basis.</p>
|
||||
<div class="row">
|
||||
<div id="_menu_settings_global_status" class="row">
|
||||
<span class="label experimental">Extension status</span>
|
||||
<span class="label">Extension status</span>
|
||||
<div id="_menu_settings_global_status_buttons" class="button-row">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="_menu_settings_global_autoar" class="row">
|
||||
<span class="label experimental">Automatic detection</span>
|
||||
<span class="label">Automatic detection</span>
|
||||
<div id="_menu_settings_global_autoar_buttons" class="button-row">
|
||||
</div>
|
||||
</div>
|
||||
@ -58,23 +58,14 @@
|
||||
|
||||
<!-- SITE SETTINGS -->
|
||||
<div id="_menu_settings_site" class="suboption hidden">
|
||||
<div class="row">
|
||||
<span class="label">Options for this site:</span>
|
||||
<div class="button-row">
|
||||
<a id="_ext_site_options_whitelist" class="button _ext _ext_site_options _whitelist">Whitelist</a>
|
||||
<a id="_ext_site_options_default" class="button _ext _ext_site_options _default" >Default</a>
|
||||
<a id="_ext_site_options_blacklist" class="button _ext _ext_site_options _blacklist">Blacklist</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="_menu_settings_site_status" class="row">
|
||||
<span class="label experimental">Extension status for this site</span>
|
||||
<span class="label">Options for this site</span>
|
||||
<div id="_menu_settings_site_status_buttons" class="button-row">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="_menu_settings_site_autoar" class="row">
|
||||
<span class="label experimental">Automatic detection</span>
|
||||
<span class="label">Automatic detection</span>
|
||||
<div id="_menu_settings_site_autoar_buttons" class="button-row">
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user