Convert multiple pages into SPA
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { domain_url } from "util/Util.svelte";
|
||||
import CopyButton from "layout/CopyButton.svelte";
|
||||
import { formatDate } from "util/Formatting";
|
||||
import type { FSNode, NodeOptions } from "filesystem/FilesystemAPI";
|
||||
import { node_is_shared, type FSNode, type NodeOptions } from "lib/FilesystemAPI";
|
||||
import AccessControl from "./AccessControl.svelte";
|
||||
|
||||
let dispatch = createEventDispatcher()
|
||||
export let file: FSNode = {} as FSNode
|
||||
export let options: NodeOptions
|
||||
|
||||
@@ -14,8 +13,8 @@ let preview_area: HTMLDivElement
|
||||
|
||||
$: share_link = window.location.protocol+"//"+window.location.host+"/d/"+file.id
|
||||
$: embed_iframe(file, options)
|
||||
let embed_iframe = (file: FSNode, options: NodeOptions) => {
|
||||
if (!options.shared) {
|
||||
const embed_iframe = (file: FSNode, options: NodeOptions) => {
|
||||
if (!node_is_shared(file)) {
|
||||
example = false
|
||||
embed_html = "File is not shared, can't generate embed code"
|
||||
return
|
||||
@@ -24,14 +23,14 @@ let embed_iframe = (file: FSNode, options: NodeOptions) => {
|
||||
let url = domain_url()+"/d/"+file.id
|
||||
embed_html = `<iframe ` +
|
||||
`src="${url}" ` +
|
||||
`style="border: none; width: 100%; max-width 90vw; height: 800px; max-height: 75vh; border-radius: 6px; "` +
|
||||
`style="border: none; width: 100%; max-width 90vw; height: 800px; max-height: 75vh; border-radius: 6px;" ` +
|
||||
`allowfullscreen` +
|
||||
`></iframe>`
|
||||
}
|
||||
|
||||
let example = false
|
||||
const toggle_example = () => {
|
||||
if (options.shared) {
|
||||
if (node_is_shared(file)) {
|
||||
example = !example
|
||||
if (example) {
|
||||
preview_area.innerHTML = embed_html
|
||||
@@ -41,15 +40,6 @@ const toggle_example = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const update_shared = () => {
|
||||
// If sharing is enabled we automatically save the file so the user can copy
|
||||
// the sharing link. But if the user disables sharing we don't automatically
|
||||
// save so that the user can't accidentally discard a sharing link that's in
|
||||
// use
|
||||
if (options.shared && !file.id) {
|
||||
dispatch("save")
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<fieldset>
|
||||
@@ -64,34 +54,14 @@ const update_shared = () => {
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div>
|
||||
<input
|
||||
form="edit_form"
|
||||
bind:checked={options.shared}
|
||||
on:change={update_shared}
|
||||
id="shared"
|
||||
type="checkbox"
|
||||
class="form_input"
|
||||
/>
|
||||
<label for="shared">Share this file or directory</label>
|
||||
</div>
|
||||
<div class="link_grid">
|
||||
{#if options.shared}
|
||||
<span>Public link: <a href={share_link}>{share_link}</a></span>
|
||||
<a href={share_link}>{share_link}</a>
|
||||
<CopyButton text={share_link}>Copy</CopyButton>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<p>
|
||||
When a file or directory is shared it can be accessed through a
|
||||
unique link. You can get the URL with the 'Copy link' button on
|
||||
the toolbar, or share the link with the 'Share' button. If you
|
||||
share a directory all the files within the directory are also
|
||||
accessible from the link.
|
||||
</p>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<AccessControl options={options}/>
|
||||
|
||||
<fieldset>
|
||||
<legend>Embedding</legend>
|
||||
<p>
|
||||
@@ -108,7 +78,7 @@ const update_shared = () => {
|
||||
<textarea bind:value={embed_html} style="width: 100%; height: 4em;"></textarea>
|
||||
<br/>
|
||||
<CopyButton text={embed_html}>Copy HTML</CopyButton>
|
||||
<button on:click={toggle_example} class:button_highlight={example} disabled={!options.shared}>
|
||||
<button on:click={toggle_example} class:button_highlight={example} disabled={!node_is_shared(file)}>
|
||||
<i class="icon">visibility</i> Show example
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user