PEE/src/App.svelte

185 lines
4.5 KiB
Svelte
Raw Normal View History

2022-01-02 13:12:19 +00:00
<script lang="ts">
2022-01-05 01:14:23 +00:00
import { hasContext, onDestroy } from 'svelte'
2022-01-04 15:36:43 +00:00
2022-01-02 14:37:19 +00:00
import { settings } from './stores'
2022-01-04 15:36:43 +00:00
2022-01-05 01:14:23 +00:00
let visible = false
2022-01-04 15:36:43 +00:00
let penisEvent = () => {
2022-01-05 01:14:23 +00:00
console.log('bepis')
visible = !visible
2022-01-04 15:36:43 +00:00
}
2022-01-05 01:14:23 +00:00
document.addEventListener('penis', penisEvent)
console.log('app loaded')
let sources = [
'gelbooru.com',
'yande.re',
'capi-v2.sankakucomplex.com',
'api.rule34.xxx',
'danbooru.donmai.us',
'lolibooru.moe',
]
let selectobj: HTMLSelectElement
let selectobj2: HTMLSelectElement
function toggleSelection() {
for (let i = 0; i < selectobj.selectedOptions.length; ++i) {
let item = selectobj.selectedOptions.item(i)
if (!item) continue
if ($settings.sources.includes(item.value))
$settings.sources = $settings.sources.filter(
(e: string) => e != item!.value,
)
else $settings.sources = [...$settings.sources, item.value]
}
}
function removeSelection() {
let s = new Set<string>();
for (let i = 0; i < selectobj2.selectedOptions.length; ++i) {
let obj = selectobj2.selectedOptions.item(i)
if (!obj) continue
s.add(obj.value)
$settings.blacklist = $settings.blacklist.filter((e: any) => !s.has(e))
}
}
2022-01-04 15:36:43 +00:00
onDestroy(() => {
2022-01-05 01:14:23 +00:00
document.removeEventListener('penis', penisEvent)
})
2022-01-02 13:12:19 +00:00
</script>
<div class="backpanel" class:enabled={visible} class:disabled={!visible}>
<div class="content">
<h1>PEE Settings</h1>
<hr />
2022-01-02 15:02:09 +00:00
<label>
<input type="checkbox" bind:checked={$settings.xpi} />
Autoexpand Images on opening.
</label>
<label>
<input type="checkbox" bind:checked={$settings.xpv} />
Autoexpand Videos on opening.
</label>
2022-01-04 20:26:05 +00:00
<label>
<input type="checkbox" bind:checked={$settings.loop} />
Loop media content.
</label>
2022-01-05 01:14:23 +00:00
<label>
<input type="checkbox" bind:checked={$settings.dh} />
Turn off hover preview.
</label>
2022-01-05 19:12:12 +00:00
<label>
<input type="checkbox" bind:checked={$settings.eye} />
Hide embedded content behind an eye.
</label>
2022-01-07 04:43:28 +00:00
<label>
<input type="checkbox" bind:checked={$settings.pre} />
Preload external files.
</label>
<label>
<input type="checkbox" bind:checked={$settings.prev} />
Preload external files when they are in view.
</label>
<label>
<input type="checkbox" bind:checked={$settings.ca} />
Control audio on videos with mouse wheel.
</label>
2022-01-07 06:45:30 +00:00
<label>
<input type="checkbox" bind:checked={$settings.sh} />
Show Minimap
</label>
<label>
<input type="checkbox" bind:checked={$settings.ep} />
<!-- svelte-ignore a11y-missing-attribute -->
Turn off embedded file preloading<a title="You might still want to enable 'preload external files'">?</a>
</label>
2022-01-05 01:14:23 +00:00
<label>
<input type="checkbox" bind:checked={$settings.te} />
Turn off third-eye.
</label>
{#if !$settings.te}
<h3>Booru sources</h3>
<select multiple bind:this={selectobj} size={sources.length}>
{#each sources as source, i}
<option
class="sourcedi"
class:sourceen={$settings.sources.includes(source)}
value={source}>{source}</option
>
{/each}
</select>
<button on:click={toggleSelection}>Toggle sources</button>
<hr />
<h3>Blacklisted tags</h3>
<select multiple bind:this={selectobj2} size={sources.length}>
{#each $settings.blacklist as source, i}
<option value={source}>{source}</option>
{/each}
</select>
<button on:click={removeSelection}>Remove</button>
<input
placeholder="Press enter after typing your tag"
on:keydown={ev => {
if (ev.key == 'Enter') {
$settings.blacklist = [
...$settings.blacklist,
ev.currentTarget.value,
]
ev.currentTarget.value = ''
}
}}
/>
{/if}
2022-01-02 13:12:19 +00:00
</div>
</div>
<style scoped>
2022-01-05 01:14:23 +00:00
select {
font-size: 1.2em;
}
2022-01-02 13:12:19 +00:00
.enabled {
display: block;
}
2022-01-05 01:14:23 +00:00
.sourcedi {
border-right: 10px solid lightcoral;
2022-01-02 13:12:19 +00:00
}
2022-01-05 01:14:23 +00:00
.sourceen {
border-right: 10px solid lightgreen;
2022-01-02 13:12:19 +00:00
}
2022-01-05 01:14:23 +00:00
.disabled {
display: none;
2022-01-02 13:12:19 +00:00
}
.content {
display: flex;
flex-direction: column;
}
hr {
width: 100%;
}
h1 {
text-align: center;
}
.backpanel {
position: absolute;
right: 32px;
padding: 10px;
2022-01-05 01:14:23 +00:00
width: 15%;
2022-01-02 13:12:19 +00:00
top: 32px;
border: 1px solid;
border-radius: 5px;
background-color: rgba(0, 0, 0, 0.2);
2022-01-04 16:17:22 +00:00
pointer-events: all;
2022-01-04 16:37:17 +00:00
backdrop-filter: blur(9px);
2022-01-02 13:12:19 +00:00
}
</style>