Update settings object, finalize-ish site settings panel
This commit is contained in:
parent
30b028d836
commit
cc0ae60c83
@ -357,11 +357,8 @@ export interface SiteSettingsInterface {
|
|||||||
|
|
||||||
type?: 'official' | 'community' | 'user-defined' | 'testing' | 'officially-disabled';
|
type?: 'official' | 'community' | 'user-defined' | 'testing' | 'officially-disabled';
|
||||||
|
|
||||||
persistOption?: { // must be defined in @global and @empty
|
// must be defined in @global and @empty
|
||||||
crop?: CropModePersistence,
|
persistCSA?: CropModePersistence, // CSA - crop, stretch, alignment
|
||||||
stretch?: CropModePersistence,
|
|
||||||
alignment?: CropModePersistence
|
|
||||||
},
|
|
||||||
|
|
||||||
defaults?: { // must be defined in @global and @empty
|
defaults?: { // must be defined in @global and @empty
|
||||||
crop?: {type: AspectRatioType, [x: string]: any},
|
crop?: {type: AspectRatioType, [x: string]: any},
|
||||||
|
@ -11,8 +11,8 @@ export function _cp(obj) {
|
|||||||
try {
|
try {
|
||||||
return JSON.parse(JSON.stringify(obj));
|
return JSON.parse(JSON.stringify(obj));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to parse json. This probably means that the data we received was not an object. Will return data as-is');
|
// console.error('Failed to parse json. This probably means that the data we received was not an object. Will return data as-is');
|
||||||
console.error('data in:', obj, 'error:', e);
|
// console.error('data in:', obj, 'error:', e);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,57 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-column w-100">
|
<div class="flex flex-column w-100">
|
||||||
|
|
||||||
<h2>Settings for {{site}}</h2>
|
|
||||||
<SiteExtensionSettings
|
<SiteExtensionSettings
|
||||||
|
v-if="settings"
|
||||||
:settings="settings"
|
:settings="settings"
|
||||||
:site="site"
|
:siteSettings="globalSettings"
|
||||||
|
:isDefaultConfiguration="true"
|
||||||
></SiteExtensionSettings>
|
></SiteExtensionSettings>
|
||||||
|
|
||||||
|
|
||||||
<h2>Default settings</h2>
|
|
||||||
<div class="field">
|
|
||||||
<div class="label">Default crop:</div>
|
|
||||||
<div class="select">
|
|
||||||
<select>
|
|
||||||
<!-- todo: load crop options -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="hint">'Auto' option will enable autodetection. 'Reset' will disable extension until manually activated.</div>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<div class="label">Default stretch:</div>
|
|
||||||
<div class="select">
|
|
||||||
<select>
|
|
||||||
<!-- todo: load stretch options -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<div class="label">Persist crop mode between videos</div>
|
|
||||||
<div class="select">
|
|
||||||
<select>
|
|
||||||
<!-- todo: load crop mode persistence -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<div class="label">Only enable extension in full screen</div>
|
|
||||||
<div class="select">
|
|
||||||
<select>
|
|
||||||
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<div class="label">Only enable autodetection in full screen</div>
|
|
||||||
<div class="select">
|
|
||||||
<select>
|
|
||||||
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- <SiteSettingsBasicTable
|
<!-- <SiteSettingsBasicTable
|
||||||
:settings="settings"
|
:settings="settings"
|
||||||
></SiteSettingsBasicTable> -->
|
></SiteSettingsBasicTable> -->
|
||||||
@ -65,7 +21,8 @@ import SiteExtensionSettings from './PanelComponents/ExtensionSettings/SiteExten
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
return {
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mixins: [
|
mixins: [
|
||||||
|
|
||||||
@ -78,6 +35,11 @@ export default {
|
|||||||
SiteExtensionSettings,
|
SiteExtensionSettings,
|
||||||
SiteSettingsBasicTable
|
SiteSettingsBasicTable
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
globalSettings() {
|
||||||
|
return this.settings?.getSiteSettings('@global') ?? null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,41 +1,144 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<h3>Extension settings</h3>
|
<!-- Enable extension -->
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
Enable extension under the following conditions:
|
Enable extension under the following conditions:
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<div class="select">
|
||||||
<li>while in full screen</li>
|
<select
|
||||||
<li>while in theater mode</li>
|
v-model="simpleExtensionSettings.enable"
|
||||||
<li>during normal playback</li>
|
@click="setExtensionMode('enable', $event)"
|
||||||
</ul>
|
>
|
||||||
|
<option
|
||||||
|
v-if="simpleExtensionSettings.enable === 'complex'"
|
||||||
|
value="complex"
|
||||||
|
>
|
||||||
|
(Site uses advanced settings)
|
||||||
|
</option>
|
||||||
|
<template v-if="isDefaultConfiguration">
|
||||||
|
<option value="disabled">
|
||||||
|
Disabled (unless enabled for specific site)
|
||||||
|
</option>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<option value="default">
|
||||||
|
Use default ()
|
||||||
|
</option>
|
||||||
|
<option value="disabled">
|
||||||
|
Never
|
||||||
|
</option>
|
||||||
|
</template>
|
||||||
|
<option value="fs">
|
||||||
|
Fullscreen only
|
||||||
|
</option>
|
||||||
|
<option value="theater">
|
||||||
|
Fullscreen and theater mode
|
||||||
|
</option>
|
||||||
|
<option value="enabled">
|
||||||
|
Always
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Enable AARD -->
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
Enable automatic aspect ratio detection under the following conditions:
|
Enable automatic aspect ratio detection under the following conditions:
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<div class="select">
|
||||||
<li>while in full screen</li>
|
<select
|
||||||
<li>while in theater mode</li>
|
v-model="simpleExtensionSettings.enableAard"
|
||||||
<li>during normal playback</li>
|
@click="setExtensionMode('enableAard', $event)"
|
||||||
</ul>
|
>
|
||||||
<div class=""></div>
|
<option
|
||||||
|
v-if="simpleExtensionSettings.enable === 'complex'"
|
||||||
|
value="complex"
|
||||||
|
>
|
||||||
|
(Site uses advanced settings)
|
||||||
|
</option>
|
||||||
|
<template v-if="isDefaultConfiguration">
|
||||||
|
<option value="disabled">
|
||||||
|
Disabled (unless enabled for specific site)
|
||||||
|
</option>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<option value="default">
|
||||||
|
Use default ()
|
||||||
|
</option>
|
||||||
|
<option value="disabled">
|
||||||
|
Never
|
||||||
|
</option>
|
||||||
|
</template>
|
||||||
|
<option value="fs">
|
||||||
|
Fullscreen only
|
||||||
|
</option>
|
||||||
|
<option value="theater">
|
||||||
|
Fullscreen and theater mode
|
||||||
|
</option>
|
||||||
|
<option value="enabled">
|
||||||
|
Always
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Enable keyboard -->
|
||||||
|
<div class="field">
|
||||||
|
<div class="label">
|
||||||
|
Enable keyboard shortcuts under the following conditions
|
||||||
|
</div>
|
||||||
|
<div class="select">
|
||||||
|
<select
|
||||||
|
v-model="simpleExtensionSettings.enableKeyboard"
|
||||||
|
@click="setExtensionMode('enableKeyboard', $event)"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-if="simpleExtensionSettings.enable === 'complex'"
|
||||||
|
value="complex"
|
||||||
|
>
|
||||||
|
(Site uses advanced settings)
|
||||||
|
</option>
|
||||||
|
<template v-if="isDefaultConfiguration">
|
||||||
|
<option value="disabled">
|
||||||
|
Disabled (unless enabled for specific site)
|
||||||
|
</option>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<option value="default">
|
||||||
|
Use default ()
|
||||||
|
</option>
|
||||||
|
<option value="disabled">
|
||||||
|
Never
|
||||||
|
</option>
|
||||||
|
</template>
|
||||||
|
<option value="fs">
|
||||||
|
Fullscreen only
|
||||||
|
</option>
|
||||||
|
<option value="theater">
|
||||||
|
Fullscreen and theater mode
|
||||||
|
</option>
|
||||||
|
<option value="enabled">
|
||||||
|
Always
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Default crop -->
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label">Default crop:</div>
|
<div class="label">Default crop:</div>
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select
|
<select
|
||||||
v-model="siteDefaultCrop"
|
v-model="siteDefaultCrop"
|
||||||
@click="setOption('defaultCrop', $event)"
|
@click="setOption('defaults.crop', $event)"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
v-if="site !== '@global'"
|
v-if="!isDefaultConfiguration"
|
||||||
:value="undefined"
|
:value="undefined"
|
||||||
>
|
>
|
||||||
Use default ({{defaultCrop}})
|
Use default ({{getCommandValue(settings?.active.commands.crop, siteSettings.data.defaults.crop)}})
|
||||||
</option>
|
</option>
|
||||||
<option
|
<option
|
||||||
v-for="(command, index) of settings?.active.commands.crop"
|
v-for="(command, index) of settings?.active.commands.crop"
|
||||||
@ -49,18 +152,19 @@
|
|||||||
<div class="hint">This is how extension will crop video if/when autodetection is disabled. Pick 'Reset' option to keep aspect ratio as-is by default.</div>
|
<div class="hint">This is how extension will crop video if/when autodetection is disabled. Pick 'Reset' option to keep aspect ratio as-is by default.</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Default stretch -->
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label">Default stretch:</div>
|
<div class="label">Default stretch:</div>
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select
|
<select
|
||||||
v-model="siteDefaultStretchMode"
|
v-model="siteDefaultStretch"
|
||||||
@click="setOption('defaultStretch', $event)"
|
@click="setOption('defaults.stretch', $event)"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
v-if="site !== '@global'"
|
v-if="!isDefaultConfiguration"
|
||||||
:value="undefined"
|
:value="undefined"
|
||||||
>
|
>
|
||||||
Use default ({{defaultStretch}})
|
Use default ({{getCommandValue(settings?.active.commands.stretch, siteSettings.data.defaults.stretch)}})
|
||||||
</option>
|
</option>
|
||||||
<option
|
<option
|
||||||
v-for="(command, index) of settings?.active.commands.stretch"
|
v-for="(command, index) of settings?.active.commands.stretch"
|
||||||
@ -73,18 +177,44 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Default alignment -->
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label">Persist crop mode between videos</div>
|
<div class="label">Default alignment:</div>
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select
|
<select
|
||||||
v-model="siteDefaultCropModePersistence"
|
v-model="siteDefaultAlignment"
|
||||||
@click="setOption('cropModePersistence')"
|
@click="setOption('defaults.alignment', $event)"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
v-if="site !== '@global'"
|
v-if="!isDefaultConfiguration"
|
||||||
|
:value="undefined"
|
||||||
|
>
|
||||||
|
Use default ({{getAlignmentLabel(siteSettings.data.defaults.alignment)}})
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="(command, index) of alignmentOptions"
|
||||||
|
:key="index"
|
||||||
|
:value="JSON.stringify(command.arguments)"
|
||||||
|
>
|
||||||
|
{{command.label}}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Crop, et. al. Persistence -->
|
||||||
|
<div class="field">
|
||||||
|
<div class="label">Persist crop, stretch, and alignment between videos</div>
|
||||||
|
<div class="select">
|
||||||
|
<select
|
||||||
|
v-model="siteDefaultCropPersistence"
|
||||||
|
@click="setOption('persistCSA', $event)"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-if="!isDefaultConfiguration"
|
||||||
:value="CropModePersistence.Default"
|
:value="CropModePersistence.Default"
|
||||||
>
|
>
|
||||||
Use default ({{defaultCropPersistence}})
|
Use default ({{defaultPersistanceLabel()}})
|
||||||
</option>
|
</option>
|
||||||
<option :value="CropModePersistence.Disabled">Disabled</option>
|
<option :value="CropModePersistence.Disabled">Disabled</option>
|
||||||
<option :value="CropModePersistence.UntilPageReload">Until page reload</option>
|
<option :value="CropModePersistence.UntilPageReload">Until page reload</option>
|
||||||
@ -93,44 +223,36 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<div class="label">Persist stretch mode between videos (TODO — this is not yet implemented)</div>
|
|
||||||
<div class="select">
|
|
||||||
<select
|
|
||||||
v-model="siteDefaultCropModePersistence"
|
|
||||||
@click="setOption('cropModePersistence')"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-if="site !== '@global'"
|
|
||||||
:value="CropModePersistence.Default"
|
|
||||||
>
|
|
||||||
Use default ({{defaultCropPersistence}})
|
|
||||||
</option>
|
|
||||||
<option :value="CropModePersistence.Disabled">Disabled</option>
|
|
||||||
<option :value="CropModePersistence.UntilPageReload">Until page reload</option>
|
|
||||||
<option :value="CropModePersistence.CurrentSession">Current session</option>
|
|
||||||
<option :value="CropModePersistence.Forever">Always persist</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import ExtensionMode from '../../../../../common/enums/ExtensionMode.enum';
|
||||||
|
import VideoAlignmentType from '../../../../../common/enums/VideoAlignmentType.enum';
|
||||||
import CropModePersistence from './../../../../../common/enums/CropModePersistence.enum';
|
import CropModePersistence from './../../../../../common/enums/CropModePersistence.enum';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
CropModePersistence: CropModePersistence,
|
CropModePersistence: CropModePersistence,
|
||||||
|
alignmentOptions: [
|
||||||
|
{label: 'Top left', arguments: {x: VideoAlignmentType.Left, y: VideoAlignmentType.Top}},
|
||||||
|
{label: 'Top center', arguments: {x: VideoAlignmentType.Center, y: VideoAlignmentType.Top}},
|
||||||
|
{label: 'Top right', arguments: {x: VideoAlignmentType.Right, y: VideoAlignmentType.Top}},
|
||||||
|
{label: 'Left', arguments: {x: VideoAlignmentType.Left, y: VideoAlignmentType.Center}},
|
||||||
|
{label: 'Center', arguments: {x: VideoAlignmentType.Center, y: VideoAlignmentType.Center}},
|
||||||
|
{label: 'Right', arguments: {x: VideoAlignmentType.Right, y: VideoAlignmentType.Center}},
|
||||||
|
{label: 'Bottom left', arguments: {x: VideoAlignmentType.Left, y: VideoAlignmentType.Bottom}},
|
||||||
|
{label: 'Bottom center', arguments: {x: VideoAlignmentType.Center, y: VideoAlignmentType.Bottom}},
|
||||||
|
{label: 'Bottom right', arguments: {x: VideoAlignmentType.Right, y: VideoAlignmentType.Bottom}}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mixins: [
|
mixins: [
|
||||||
|
|
||||||
],
|
],
|
||||||
props: [
|
props: [
|
||||||
|
'settings',
|
||||||
'siteSettings',
|
'siteSettings',
|
||||||
'isDefaultConfiguration'
|
'isDefaultConfiguration'
|
||||||
],
|
],
|
||||||
@ -138,45 +260,136 @@ export default {
|
|||||||
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
simpleExtensionSettings() {
|
||||||
|
return {
|
||||||
|
enable: this.compileSimpleSettings('enable'),
|
||||||
|
enableAard: this.compileSimpleSettings('enableAard'),
|
||||||
|
enableKeyboard: this.compileSimpleSettings('enableKeyboard'),
|
||||||
|
}
|
||||||
|
},
|
||||||
siteDefaultCrop() {
|
siteDefaultCrop() {
|
||||||
return JSON.stringify(
|
return this.siteSettings.raw?.defaults?.crop ? JSON.stringify(this.siteSettings.raw?.defaults?.crop) : undefined;
|
||||||
this.siteSettings.data.defaults.crop
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
siteDefaultStretch() {
|
siteDefaultStretch() {
|
||||||
return JSON.stringify(
|
return this.siteSettings.raw?.defaults?.stretch ? JSON.stringify(this.siteSettings.raw?.defaults?.stretch) : undefined;
|
||||||
this.siteSettings.data.defaults.stretch
|
},
|
||||||
);
|
siteDefaultAlignment() {
|
||||||
|
return this.siteSettings.raw?.defaults?.alignment ? JSON.stringify(this.siteSettings.raw?.defaults?.alignment) : undefined;
|
||||||
},
|
},
|
||||||
siteDefaultCropPersistence() {
|
siteDefaultCropPersistence() {
|
||||||
return CropModePersistence.Default;
|
return this.siteSettings.raw?.persistCSA ?? undefined;
|
||||||
// this.settings?.getDefaultCropPersistence(this.site) ?? {type: this.site === '@global' ? CropModePersistence.Disabled : CropModePersistence.Default}
|
|
||||||
},
|
},
|
||||||
siteDefaultFullScreenOnly() {
|
defaultPersistanceLabel() {
|
||||||
return undefined;
|
switch (this.siteSettings.defaultSettings.persistCSA) {
|
||||||
// return this.settings.getDefaultRestriction(this.site, 'onlyAllowInFullscreen');
|
case CropModePersistence.CurrentSession:
|
||||||
},
|
return 'current session';
|
||||||
siteDefaultAardFullScreenOnly() {
|
case CropModePersistence.Disabled:
|
||||||
return undefined;
|
return 'disabled';
|
||||||
// return this.settings.getDefaultRestriction(this.site, 'onlyAllowAutodetectionInFullscreen')
|
case CropModePersistence.UntilPageReload:
|
||||||
},
|
return 'until page reload';
|
||||||
defaultCrop() {
|
case CropModePersistence.Forever:
|
||||||
return 'parse me';
|
return 'Always persist';
|
||||||
},
|
}
|
||||||
defaultStretch() {
|
|
||||||
return 'parse me';
|
return '??';
|
||||||
},
|
|
||||||
defaultCropPersistence() {
|
|
||||||
return 'parse me';
|
|
||||||
},
|
|
||||||
defaultFullScreenOnly() {
|
|
||||||
return 'parse me';
|
|
||||||
},
|
|
||||||
defaultAardFullScreenOnly() {
|
|
||||||
return 'parse me';
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/**
|
||||||
|
* Compiles our extension settings into more user-friendly options
|
||||||
|
*/
|
||||||
|
compileSimpleSettings(component) {
|
||||||
|
try {
|
||||||
|
if (
|
||||||
|
this.siteSettings?.data?.[component]?.normal === ExtensionMode.Disabled
|
||||||
|
&& this.siteSettings?.data?.[component]?.theater === ExtensionMode.Disabled
|
||||||
|
&& this.siteSettings?.data?.[component]?.fullscreen === ExtensionMode.Disabled
|
||||||
|
) {
|
||||||
|
return 'disabled';
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
this.siteSettings?.data?.[component]?.normal === ExtensionMode.Default
|
||||||
|
&& this.siteSettings?.data?.[component]?.theater === ExtensionMode.Default
|
||||||
|
&& this.siteSettings?.data?.[component]?.fullscreen === ExtensionMode.Default
|
||||||
|
) {
|
||||||
|
return 'default';
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
this.siteSettings?.data?.[component]?.normal === ExtensionMode.Disabled
|
||||||
|
&& this.siteSettings?.data?.[component]?.theater === ExtensionMode.Disabled
|
||||||
|
&& this.siteSettings?.data?.[component]?.fullscreen === ExtensionMode.Enabled
|
||||||
|
) {
|
||||||
|
return 'fs';
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
this.siteSettings?.data?.[component]?.normal === ExtensionMode.Disabled
|
||||||
|
&& this.siteSettings?.data?.[component]?.theater === ExtensionMode.Enabled
|
||||||
|
&& this.siteSettings?.data?.[component]?.fullscreen === ExtensionMode.Enabled
|
||||||
|
) {
|
||||||
|
return 'theater';
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
this.siteSettings?.data?.[component]?.normal === ExtensionMode.Enabled
|
||||||
|
&& this.siteSettings?.data?.[component]?.theater === ExtensionMode.Enabled
|
||||||
|
&& this.siteSettings?.data?.[component]?.fullscreen === ExtensionMode.Enabled
|
||||||
|
) {
|
||||||
|
return 'enabled';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'complex';
|
||||||
|
} catch (e) {
|
||||||
|
return 'loading';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getCommandValue(availableCommands, command) {
|
||||||
|
console.log('command:', command, 'from available commands', availableCommands);
|
||||||
|
|
||||||
|
for (const cmd of availableCommands) {
|
||||||
|
console.log('——— processing command:', cmd)
|
||||||
|
console.log('comparing', JSON.stringify(command), 'to', JSON.stringify(cmd.arguments));
|
||||||
|
if (JSON.stringify(cmd.arguments) === JSON.stringify(command)) {
|
||||||
|
return cmd.label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Unknown command';
|
||||||
|
},
|
||||||
|
|
||||||
|
getAlignmentLabel(alignment) {
|
||||||
|
console.log('alignment for site. ----------------------------', alignment);
|
||||||
|
|
||||||
|
// in case default settings don't have this set
|
||||||
|
if (!alignment) {
|
||||||
|
return 'Center'
|
||||||
|
}
|
||||||
|
|
||||||
|
let x, y;
|
||||||
|
if (alignment.x === VideoAlignmentType.Center) {
|
||||||
|
x = 'center';
|
||||||
|
} else if (alignment.x === VideoAlignmentType.Left) {
|
||||||
|
x = 'left';
|
||||||
|
} else if (alignment.x === VideoAlignmentType.Right) {
|
||||||
|
x = 'right';
|
||||||
|
} else {
|
||||||
|
x = '??'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alignment.y === VideoAlignmentType.Center) {
|
||||||
|
y = 'center';
|
||||||
|
} else if (alignment.y === VideoAlignmentType.Bottom) {
|
||||||
|
y = 'bottom';
|
||||||
|
} else if (alignment.y === VideoAlignmentType.Top) {
|
||||||
|
y = 'top';
|
||||||
|
} else {
|
||||||
|
y = '???'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (x === y) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
return `${y} ${x}`;
|
||||||
|
},
|
||||||
getOption(option) {
|
getOption(option) {
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -191,6 +404,51 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.siteSettings.set(option, commandArguments);
|
this.siteSettings.set(option, commandArguments);
|
||||||
|
},
|
||||||
|
setExtensionMode(component, event) {
|
||||||
|
const option = event.target.value;
|
||||||
|
|
||||||
|
console.log('setting option', component, 'to', event.target.value);
|
||||||
|
|
||||||
|
if (option === 'complex') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option === 'default') {
|
||||||
|
return this.siteSettings.set(component, {
|
||||||
|
normal: ExtensionMode.Default,
|
||||||
|
theater: ExtensionMode.Default,
|
||||||
|
fullscreen: ExtensionMode.Default
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (option === 'disabled') {
|
||||||
|
return this.siteSettings.set(component, {
|
||||||
|
normal: ExtensionMode.Disabled,
|
||||||
|
theater: ExtensionMode.Disabled,
|
||||||
|
fullscreen: ExtensionMode.Disabled
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (option === 'enabled') {
|
||||||
|
return this.siteSettings.set(component, {
|
||||||
|
normal: ExtensionMode.Enabled,
|
||||||
|
theater: ExtensionMode.Enabled,
|
||||||
|
fullscreen: ExtensionMode.Enabled
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (option === 'theater') {
|
||||||
|
return this.siteSettings.set(component, {
|
||||||
|
normal: ExtensionMode.Disabled,
|
||||||
|
theater: ExtensionMode.Enabled,
|
||||||
|
fullscreen: ExtensionMode.Enabled
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (option === 'fs') {
|
||||||
|
return this.siteSettings.set(component, {
|
||||||
|
normal: ExtensionMode.Disabled,
|
||||||
|
theater: ExtensionMode.Disabled,
|
||||||
|
fullscreen: ExtensionMode.Enabled
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,24 +147,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<div class="label">Extension default:</div>
|
|
||||||
<div class="select">
|
|
||||||
<select
|
|
||||||
v-model="extensionDefaultStretchMode"
|
|
||||||
@click="setDefaultStretchingMode($event, 'global')"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-for="(command, index) of settings?.active.commands.stretch"
|
|
||||||
:key="index"
|
|
||||||
:value="JSON.stringify(command.arguments)"
|
|
||||||
>
|
|
||||||
{{command.label}}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import VideoAlignmentType from '../../common/enums/VideoAlignmentType.enum';
|
|||||||
import BrowserDetect from './BrowserDetect';
|
import BrowserDetect from './BrowserDetect';
|
||||||
import SettingsInterface from '../../common/interfaces/SettingsInterface';
|
import SettingsInterface from '../../common/interfaces/SettingsInterface';
|
||||||
import { _cp } from '../../common/js/utils';
|
import { _cp } from '../../common/js/utils';
|
||||||
|
import CropModePersistence from '../../common/enums/CropModePersistence.enum';
|
||||||
|
|
||||||
const ExtensionConfPatch = [
|
const ExtensionConfPatch = [
|
||||||
{
|
{
|
||||||
@ -201,6 +202,15 @@ const ExtensionConfPatch = [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
forVersion: '6.0.0-alpha3',
|
||||||
|
updateFn: (userOptions: SettingsInterface, defaultOptions) => {
|
||||||
|
delete (userOptions as any).sites['@global'].persistOption;
|
||||||
|
delete (userOptions as any).sites['@empty'].persistOption;
|
||||||
|
|
||||||
|
userOptions.sites['@global'].persistCSA = CropModePersistence.Disabled;
|
||||||
|
userOptions.sites['@empty'].persistCSA = CropModePersistence.Disabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1410,11 +1410,7 @@ const ExtensionConf: SettingsInterface = {
|
|||||||
normal: ExtensionMode.Disabled
|
normal: ExtensionMode.Disabled
|
||||||
},
|
},
|
||||||
|
|
||||||
persistOption: {
|
persistCSA: CropModePersistence.Disabled,
|
||||||
crop: CropModePersistence.Disabled,
|
|
||||||
stretch: CropModePersistence.Disabled,
|
|
||||||
alignment: CropModePersistence.Disabled,
|
|
||||||
},
|
|
||||||
|
|
||||||
defaults: {
|
defaults: {
|
||||||
crop: {type: AspectRatioType.Reset}, // does NOT override Aard
|
crop: {type: AspectRatioType.Reset}, // does NOT override Aard
|
||||||
@ -1439,11 +1435,7 @@ const ExtensionConf: SettingsInterface = {
|
|||||||
normal: ExtensionMode.Default
|
normal: ExtensionMode.Default
|
||||||
},
|
},
|
||||||
type: 'user-defined',
|
type: 'user-defined',
|
||||||
persistOption: {
|
persistCSA: CropModePersistence.Default,
|
||||||
crop: CropModePersistence.Default,
|
|
||||||
stretch: CropModePersistence.Default,
|
|
||||||
alignment: CropModePersistence.Default,
|
|
||||||
},
|
|
||||||
defaults: {
|
defaults: {
|
||||||
crop: null,
|
crop: null,
|
||||||
stretch: StretchType.Default,
|
stretch: StretchType.Default,
|
||||||
|
@ -7,19 +7,28 @@ import { browser } from 'webextension-polyfill-ts';
|
|||||||
import StretchType from '../../../common/enums/StretchType.enum';
|
import StretchType from '../../../common/enums/StretchType.enum';
|
||||||
import VideoAlignmentType from '../../../common/enums/VideoAlignmentType.enum';
|
import VideoAlignmentType from '../../../common/enums/VideoAlignmentType.enum';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains settings that are currently in effect for a given site. If a certain option
|
||||||
|
* doesn't have a value — or if it has 'default' option, SiteSettings.data will contain
|
||||||
|
* the value that "default" should stand for.
|
||||||
|
*
|
||||||
|
* SiteSettings.raw also contains settings object as it actually exist in the config.
|
||||||
|
*/
|
||||||
export class SiteSettings {
|
export class SiteSettings {
|
||||||
private settings: Settings;
|
private settings: Settings;
|
||||||
private site: string;
|
private site: string;
|
||||||
|
|
||||||
data: SiteSettingsInterface;
|
raw: SiteSettingsInterface; // actual settings
|
||||||
|
data: SiteSettingsInterface; // effective settings
|
||||||
temporaryData: SiteSettingsInterface;
|
temporaryData: SiteSettingsInterface;
|
||||||
sessionData: SiteSettingsInterface;
|
sessionData: SiteSettingsInterface;
|
||||||
private defaultSettings: SiteSettingsInterface;
|
readonly defaultSettings: SiteSettingsInterface;
|
||||||
|
|
||||||
//#region lifecycle
|
//#region lifecycle
|
||||||
constructor(settings: Settings, site: string) {
|
constructor(settings: Settings, site: string) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.data = settings.active.sites[site];
|
this.data = settings.active.sites[site];
|
||||||
|
this.site = site;
|
||||||
this.defaultSettings = settings.default.sites['@global'];
|
this.defaultSettings = settings.default.sites['@global'];
|
||||||
|
|
||||||
this.compileSettingsObject();
|
this.compileSettingsObject();
|
||||||
@ -42,12 +51,13 @@ export class SiteSettings {
|
|||||||
* Alan pls ensure default settings object follows the correct structure
|
* Alan pls ensure default settings object follows the correct structure
|
||||||
*/
|
*/
|
||||||
private compileSettingsObject() {
|
private compileSettingsObject() {
|
||||||
|
this.raw = _cp(this.settings.active.sites[this.site] ?? {})
|
||||||
|
|
||||||
if (!this.data) {
|
if (!this.data) {
|
||||||
this.data = _cp(this.defaultSettings);
|
this.data = _cp(this.defaultSettings);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!this.data.defaults) {
|
if (!this.data.defaults) {
|
||||||
this.data.defaults = _cp(this.defaultSettings.defaults);
|
this.data.defaults = _cp(this.defaultSettings.defaults);
|
||||||
} else {
|
} else {
|
||||||
@ -82,16 +92,9 @@ export class SiteSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure data.persistOption exists:
|
if (!this.data.persistCSA || this.data.persistCSA === CropModePersistence.Default) {
|
||||||
if (!this.data.persistOption) {
|
this.data.persistCSA = this.defaultSettings.persistCSA ?? CropModePersistence.Disabled;
|
||||||
this.data.persistOption = {} as any; // this will get populated correctly soon
|
|
||||||
}
|
}
|
||||||
for (const persistOption of ['crop', 'stretch', 'alignment']) {
|
|
||||||
if ( (this.data.persistOption[persistOption] ?? CropModePersistence.Default) === CropModePersistence.Default ) {
|
|
||||||
this.data.persistOption[persistOption] = this.defaultSettings.persistOption[persistOption];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (this.data.activeDOMConfig && this.data.DOMConfig) {
|
if (this.data.activeDOMConfig && this.data.DOMConfig) {
|
||||||
this.data.currentDOMConfig = this.data.DOMConfig[this.data.activeDOMConfig];
|
this.data.currentDOMConfig = this.data.DOMConfig[this.data.activeDOMConfig];
|
||||||
@ -113,7 +116,9 @@ export class SiteSettings {
|
|||||||
|
|
||||||
const parsedSettings = JSON.parse(changes.uwSettings.newValue);
|
const parsedSettings = JSON.parse(changes.uwSettings.newValue);
|
||||||
this.data = parsedSettings.active.sites[this.site];
|
this.data = parsedSettings.active.sites[this.site];
|
||||||
this.defaultSettings = parsedSettings.active.sites['@global'];
|
|
||||||
|
// we ignore 'readonly' property this once
|
||||||
|
(this as any).defaultSettings = parsedSettings.active.sites['@global'];
|
||||||
|
|
||||||
this.compileSettingsObject();
|
this.compileSettingsObject();
|
||||||
}
|
}
|
||||||
@ -142,7 +147,7 @@ export class SiteSettings {
|
|||||||
* Gets default crop mode for extension, while taking persistence settings into account
|
* Gets default crop mode for extension, while taking persistence settings into account
|
||||||
*/
|
*/
|
||||||
getDefaultOption(option: 'crop' | 'stretch' | 'alignment') {
|
getDefaultOption(option: 'crop' | 'stretch' | 'alignment') {
|
||||||
const persistenceLevel = this.data.persistOption[option];
|
const persistenceLevel = this.data.persistCSA;
|
||||||
|
|
||||||
switch (persistenceLevel) {
|
switch (persistenceLevel) {
|
||||||
case CropModePersistence.UntilPageReload:
|
case CropModePersistence.UntilPageReload:
|
||||||
@ -217,6 +222,9 @@ export class SiteSettings {
|
|||||||
|
|
||||||
const pathParts = optionPath.split('.');
|
const pathParts = optionPath.split('.');
|
||||||
|
|
||||||
|
if (pathParts.length === 1) {
|
||||||
|
this.settings.active.sites[this.site][optionPath] = optionValue;
|
||||||
|
} else {
|
||||||
let iterator = this.settings.active.sites[this.site];
|
let iterator = this.settings.active.sites[this.site];
|
||||||
let i;
|
let i;
|
||||||
for (i = 0; i < pathParts.length - 1; i++) {
|
for (i = 0; i < pathParts.length - 1; i++) {
|
||||||
@ -226,6 +234,7 @@ export class SiteSettings {
|
|||||||
iterator = iterator[pathParts[i]];
|
iterator = iterator[pathParts[i]];
|
||||||
}
|
}
|
||||||
iterator[pathParts[i]] = optionValue;
|
iterator[pathParts[i]] = optionValue;
|
||||||
|
}
|
||||||
|
|
||||||
if (reload) {
|
if (reload) {
|
||||||
this.settings.save();
|
this.settings.save();
|
||||||
@ -275,7 +284,7 @@ export class SiteSettings {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async updatePersistentOption(option: 'crop' | 'stretch' | 'alignment', value) {
|
async updatePersistentOption(option: 'crop' | 'stretch' | 'alignment', value) {
|
||||||
const persistenceLevel = this.data.persistOption[option];
|
const persistenceLevel = this.data.persistCSA;
|
||||||
switch (persistenceLevel) {
|
switch (persistenceLevel) {
|
||||||
case CropModePersistence.Disabled:
|
case CropModePersistence.Disabled:
|
||||||
return;
|
return;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Ultrawidify",
|
"name": "Ultrawidify",
|
||||||
"description": "Removes black bars on ultrawide videos and offers advanced options to fix aspect ratio.",
|
"description": "Removes black bars on ultrawide videos and offers advanced options to fix aspect ratio.",
|
||||||
"version": "6.0.0-alpha1",
|
"version": "6.0.0-alpha3",
|
||||||
"applications": {
|
"applications": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "{cf02b1a7-a01a-4e37-a609-516a283f1ed3}"
|
"id": "{cf02b1a7-a01a-4e37-a609-516a283f1ed3}"
|
||||||
|
Loading…
Reference in New Issue
Block a user