mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-13 14:20:01 -04:00
add settings, history, and search engine to frontend
This commit is contained in:
parent
ec58ef0e37
commit
8bd24c107f
1 changed files with 64 additions and 41 deletions
|
@ -1,22 +1,25 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { BareClient } from "bare-client-custom";
|
import { BareClient } from "bare-client-custom";
|
||||||
import {
|
|
||||||
Card,
|
|
||||||
SegmentedButtonContainer,
|
|
||||||
SegmentedButtonItem,
|
|
||||||
} from "m3-svelte";
|
|
||||||
import { Win, openWindow } from "../../corium";
|
import { Win, openWindow } from "../../corium";
|
||||||
import Icon from "@iconify/svelte";
|
import Icon from "@iconify/svelte";
|
||||||
|
|
||||||
let selectedProxy = "ultraviolet";
|
let selectedProxy = "ultraviolet";
|
||||||
|
|
||||||
let url: string = "http://google.com";
|
let url: string = "http://google.com";
|
||||||
|
|
||||||
import iconBack from "@iconify-icons/ic/outline-arrowback";
|
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
SegmentedButtonContainer,
|
||||||
|
SegmentedButtonItem,
|
||||||
|
TextField,
|
||||||
|
} from "m3-svelte";
|
||||||
|
|
||||||
let proxyIframe: HTMLIFrameElement;
|
let proxyIframe: HTMLIFrameElement;
|
||||||
|
|
||||||
|
let settingsenabled: boolean = false;
|
||||||
|
|
||||||
|
let searchengine = "https://google.com/search?q=";
|
||||||
|
|
||||||
function frameLoad() {
|
function frameLoad() {
|
||||||
if (!import.meta.env.VITE_ADRIFT_SINGLEFILE) {
|
if (!import.meta.env.VITE_ADRIFT_SINGLEFILE) {
|
||||||
const location = proxyIframe.contentDocument?.location.href;
|
const location = proxyIframe.contentDocument?.location.href;
|
||||||
|
@ -29,6 +32,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function visitURL(url: string) {
|
function visitURL(url: string) {
|
||||||
|
if (!url.includes("://")) {
|
||||||
|
url = searchengine + url;
|
||||||
|
}
|
||||||
|
|
||||||
if (!import.meta.env.VITE_ADRIFT_SINGLEFILE) {
|
if (!import.meta.env.VITE_ADRIFT_SINGLEFILE) {
|
||||||
let path =
|
let path =
|
||||||
selectedProxy == "dynamic"
|
selectedProxy == "dynamic"
|
||||||
|
@ -55,32 +62,43 @@
|
||||||
<div class="h-full w-full flex flex-col">
|
<div class="h-full w-full flex flex-col">
|
||||||
<div class="flex p-2">
|
<div class="flex p-2">
|
||||||
<div class="flex text-xl items-center w-full">
|
<div class="flex text-xl items-center w-full">
|
||||||
<button>
|
<button
|
||||||
|
on:click={() => {
|
||||||
|
proxyIframe.contentWindow?.history.back();
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Icon icon="fluent-mdl2:back" />
|
<Icon icon="fluent-mdl2:back" />
|
||||||
</button>
|
</button>
|
||||||
<div class="p-2" />
|
<div class="p-2" />
|
||||||
<button>
|
<button
|
||||||
|
on:click={() => {
|
||||||
|
proxyIframe.contentWindow?.history.forward();
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Icon icon="fluent-mdl2:forward" />
|
<Icon icon="fluent-mdl2:forward" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="text-2xl px-4"
|
class="text-2xl px-4"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
console.log("a");
|
|
||||||
visitURL(url);
|
visitURL(url);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon icon="tabler:reload" />
|
<Icon icon="tabler:reload" />
|
||||||
</button>
|
</button>
|
||||||
<div id="urlbar" class="flex items-center flex-1">
|
<div class="urlbar flex items-center flex-1">
|
||||||
<div class="text-2xl px-2">
|
<button
|
||||||
|
class="text-2xl px-2"
|
||||||
|
on:click={() => {
|
||||||
|
visitURL(url);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Icon icon="ic:round-search" />
|
<Icon icon="ic:round-search" />
|
||||||
</div>
|
</button>
|
||||||
<input
|
<input
|
||||||
bind:value={url}
|
bind:value={url}
|
||||||
type="text"
|
type="text"
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
on:keydown={(e) => {
|
on:keydown={(e) => {
|
||||||
console.log(e);
|
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
visitURL(url);
|
visitURL(url);
|
||||||
}
|
}
|
||||||
|
@ -88,42 +106,47 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="text-2xl pl-3">
|
<button class="text-2xl pl-3" on:click={() => (settingsenabled = true)}>
|
||||||
<Icon icon="ic:round-settings" />
|
<Icon icon="ic:round-settings" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<!-- {#if !import.meta.env.VITE_ADRIFT_SINGLEFILE}
|
<Dialog bind:open={settingsenabled} headline="Proxy Settings">
|
||||||
<div>
|
{#if !import.meta.env.VITE_ADRIFT_SINGLEFILE}
|
||||||
<SegmentedButtonContainer>
|
<div>
|
||||||
<input
|
<SegmentedButtonContainer>
|
||||||
type="radio"
|
<input
|
||||||
name="selectedProxy"
|
type="radio"
|
||||||
bind:group={selectedProxy}
|
name="selectedProxy"
|
||||||
value="ultraviolet"
|
bind:group={selectedProxy}
|
||||||
id="ultraviolet"
|
value="ultraviolet"
|
||||||
/>
|
id="ultraviolet"
|
||||||
<SegmentedButtonItem input="ultraviolet"
|
/>
|
||||||
>Ultraviolet</SegmentedButtonItem
|
<SegmentedButtonItem input="ultraviolet"
|
||||||
>
|
>Ultraviolet</SegmentedButtonItem
|
||||||
<input
|
>
|
||||||
type="radio"
|
<input
|
||||||
name="selectedProxy"
|
type="radio"
|
||||||
bind:group={selectedProxy}
|
name="selectedProxy"
|
||||||
value="dynamic"
|
bind:group={selectedProxy}
|
||||||
id="dynamic"
|
value="dynamic"
|
||||||
/>
|
id="dynamic"
|
||||||
<SegmentedButtonItem input="dynamic">Dynamic</SegmentedButtonItem>
|
/>
|
||||||
</SegmentedButtonContainer>
|
<SegmentedButtonItem input="dynamic">Dynamic</SegmentedButtonItem>
|
||||||
</div>
|
</SegmentedButtonContainer>
|
||||||
{/if} -->
|
</div>
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<TextField name="Default Search Engine" bind:value={searchengine} />
|
||||||
|
{/if}
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
<iframe class="flex-1" bind:this={proxyIframe} on:load={frameLoad} />
|
<iframe class="flex-1" bind:this={proxyIframe} on:load={frameLoad} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#urlbar {
|
.urlbar {
|
||||||
border: solid 0.0625rem rgb(var(--m3-scheme-outline));
|
border: solid 0.0625rem rgb(var(--m3-scheme-outline));
|
||||||
padding: 0.5rem;
|
padding: 0.25rem;
|
||||||
border-radius: 0.75rem;
|
border-radius: 0.75rem;
|
||||||
}
|
}
|
||||||
input {
|
input {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue