PEE/src/App.svelte

263 lines
6.6 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-12 04:18:50 +00:00
import Dialog from './Dialog.svelte';
2022-01-04 15:36:43 +00:00
2022-01-02 14:37:19 +00:00
import { settings } from './stores'
2022-01-09 14:29:51 +00:00
import Tag from './Tag.svelte'
2022-01-12 04:18:50 +00:00
import type { Booru } from './thirdeye';
2022-01-09 14:29:51 +00:00
let newbooru: Partial<Omit<Booru, 'quirks'> & {view: string}> = {};
let dial: Dialog;
function appendBooru() {
$settings.rsources = [...$settings.rsources, newbooru as any];
dial.toggle();
newbooru = {}
}
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')
2022-01-09 14:29:51 +00:00
function removeTag(t: string) {
$settings.blacklist = $settings.blacklist.filter((e: any) => e != t)
2022-01-05 01:14:23 +00:00
}
2022-01-09 14:29:51 +00:00
function removeBooru(t: string) {
const idx = $settings.rsources.findIndex(e => e.domain == t)
const rep = prompt("You DO know what you're doing, right? (type 'y')")
if (!rep || rep != 'y') return
if (idx >= 0) $settings.rsources.splice(idx, 1)
$settings.rsources = $settings.rsources
}
function toggleBooru(t: string) {
const elem = $settings.rsources.find(e => e.domain == t)
if (elem)
elem.disabled = !elem.disabled;
$settings.rsources = $settings.rsources
2022-01-05 01:14:23 +00:00
}
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-13 07:38:50 +00:00
<label>
<input type="checkbox" bind:checked={$settings.vercheck} />
Check for new versions at startup.
</label>
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} />
2022-01-12 04:18:50 +00:00
Disable hover preview.
2022-01-05 01:14:23 +00:00
</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-09 19:41:04 +00:00
{#if $settings.eye}
<label>
<input type="checkbox" bind:checked={$settings.ho} />
Hide original content when hidden content is visible.
</label>
{/if}
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>
2022-01-12 08:09:30 +00:00
<label>
<input type="checkbox" bind:checked={$settings.hotlink} />
Hotlink content.
</label>
2022-01-07 04:43:28 +00:00
<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 -->
2022-01-12 04:18:50 +00:00
Disable embedded file preloading<a
2022-01-09 14:29:51 +00:00
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} />
2022-01-12 04:18:50 +00:00
Disable third-eye.
2022-01-05 01:14:23 +00:00
</label>
{#if !$settings.te}
2022-01-12 04:18:50 +00:00
<label>
<input type="checkbox" bind:checked={$settings.expte} />
<!-- svelte-ignore a11y-missing-attribute -->
Use Experimental Query API<a title="Can be up to 30% faster, reduces strain on boorus, may break">?</a
>
</label>
2022-01-05 01:14:23 +00:00
<h3>Booru sources</h3>
2022-01-09 14:29:51 +00:00
<div class="tagcont">
{#each $settings.rsources as source, i}
<Tag
tag={source.name}
on:remove={() => removeBooru(source.domain)}
on:toggle={() => toggleBooru(source.domain)}
toggleable={true}
toggled={!$settings.rsources.find(e => e.domain == source.domain)
?.disabled}
/>
2022-01-05 01:14:23 +00:00
{/each}
2022-01-09 14:29:51 +00:00
</div>
<button
on:click={ev => {
dial.setPos([ev.clientX, ev.clientY])
dial.toggle()
}}>Add a source</button
>
<Dialog bind:this={dial}>
<div class="form">
<label>
Name
<input
type="text"
placeholder="Gelbooru"
bind:value={newbooru.name}
/>
</label>
<label>
Domain
<input
type="text"
placeholder="gelbooru.com"
bind:value={newbooru.domain}
/>
</label>
<label>
API Endpoint
<input
type="text"
placeholder="/post.json?tags=md5:"
bind:value={newbooru.endpoint}
/>
</label>
<label>
Post page prefix (for sources)
<input
type="text"
placeholder="https://yande.re/post/show/"
bind:value={newbooru.view}
/>
</label>
<button on:click={appendBooru}>Add</button>
</div>
</Dialog>
2022-01-05 01:14:23 +00:00
<hr />
<h3>Blacklisted tags</h3>
2022-01-09 14:29:51 +00:00
<div class="tagcont">
{#each $settings.blacklist as tag, i}
<Tag {tag} on:toggle={() => removeTag(tag)} />
2022-01-05 01:14:23 +00:00
{/each}
2022-01-09 14:29:51 +00:00
</div>
2022-01-05 01:14:23 +00:00
<input
2022-01-09 14:29:51 +00:00
placeholder="Press enter after typing your tag"
2022-01-05 01:14:23 +00:00
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-09 14:29:51 +00:00
.tagcont {
display: flex;
gap: 5px;
margin-bottom: 10px;
flex-wrap: wrap;
}
2022-01-02 13:12:19 +00:00
.enabled {
display: block;
}
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;
}
2022-01-09 14:29:51 +00:00
.form {
display: flex;
flex-direction: column;
gap: 20px;
position: absolute;
padding: 15px;
border: 1px solid white;
background-color: inherit;
border-radius: 10px;
}
.form > label {
display: flex;
flex-direction: column;
gap: 10px;
}
2022-01-02 13:12:19 +00:00
.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-09 14:29:51 +00:00
max-height: 80vh;
min-width: 321px;
2022-01-02 13:12:19 +00:00
}
</style>