Add configurable columns to directory view
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run } from 'svelte/legacy';
|
|
||||||
import Chart from "util/Chart.svelte";
|
import Chart from "util/Chart.svelte";
|
||||||
import { formatDataVolume, formatDate, formatThousands } from "util/Formatting";
|
import { formatDataVolume, formatDate, formatThousands } from "util/Formatting";
|
||||||
import Modal from "util/Modal.svelte";
|
import Modal from "util/Modal.svelte";
|
||||||
@@ -19,12 +18,13 @@ let {
|
|||||||
|
|
||||||
export const toggle = () => visible = !visible
|
export const toggle = () => visible = !visible
|
||||||
|
|
||||||
const visibility_change = visible => {
|
$effect(() => {
|
||||||
|
// Only update the chart if the details modal is open. Else the chart is
|
||||||
|
// rendered for nothing
|
||||||
if (visible) {
|
if (visible) {
|
||||||
update_chart(nav.base, 0, 0)
|
update_chart($nav.base, chart_timespan, chart_interval)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
|
|
||||||
let chart: Chart = $state()
|
let chart: Chart = $state()
|
||||||
let chart_timespan = $state(0)
|
let chart_timespan = $state(0)
|
||||||
@@ -134,15 +134,9 @@ let update_chart = async (base: FSNode, timespan: number, interval: number) => {
|
|||||||
console.error("Failed to get time series data:", err)
|
console.error("Failed to get time series data:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
run(() => {
|
|
||||||
visibility_change(visible)
|
|
||||||
});
|
|
||||||
let direct_url = $derived($nav.base.path ? window.location.origin+fs_path_url($nav.base.path) : "")
|
let direct_url = $derived($nav.base.path ? window.location.origin+fs_path_url($nav.base.path) : "")
|
||||||
let share_url = $derived(fs_share_url($nav.path))
|
let share_url = $derived(fs_share_url($nav.path))
|
||||||
let direct_share_url = $derived(fs_share_hotlink_url($nav.path))
|
let direct_share_url = $derived(fs_share_hotlink_url($nav.path))
|
||||||
run(() => {
|
|
||||||
update_chart($nav.base, chart_timespan, chart_interval)
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:visible={visible} title="Details" width={($nav.base.type === "file" ? 1000 : 750) + "px"}>
|
<Modal bind:visible={visible} title="Details" width={($nav.base.type === "file" ? 1000 : 750) + "px"}>
|
||||||
@@ -172,13 +166,6 @@ run(() => {
|
|||||||
<td>Mode</td>
|
<td>Mode</td>
|
||||||
<td>{$nav.base.mode_string}</td>
|
<td>{$nav.base.mode_string}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>Node ID</td>
|
|
||||||
<td>
|
|
||||||
<CopyButton text={$nav.base.id}>Copy</CopyButton>
|
|
||||||
<a href="/d/{$nav.base.id}">{$nav.base.id}</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{#if $nav.base.type === "file"}
|
{#if $nav.base.type === "file"}
|
||||||
<tr>
|
<tr>
|
||||||
<td>File type</td>
|
<td>File type</td>
|
||||||
@@ -201,7 +188,23 @@ run(() => {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>SHA256 sum</td><td>{$nav.base.sha256_sum}</td></tr>
|
<tr><td>SHA256 sum</td><td>{$nav.base.sha256_sum}</td></tr>
|
||||||
|
{:else if $nav.base.type === "dir"}
|
||||||
|
<tr>
|
||||||
|
<td>Total directory size</td>
|
||||||
|
<td>{formatDataVolume($nav.base.recursive_size, 4)}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Total directory children</td>
|
||||||
|
<td>{formatThousands($nav.base.recursive_children)}</td>
|
||||||
|
</tr>
|
||||||
{/if}
|
{/if}
|
||||||
|
<tr>
|
||||||
|
<td>Node ID</td>
|
||||||
|
<td>
|
||||||
|
<CopyButton text={$nav.base.id}>Copy</CopyButton>
|
||||||
|
<a href="/d/{$nav.base.id}">{$nav.base.id}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Direct link</td>
|
<td>Direct link</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ onMount(() => {
|
|||||||
<p>
|
<p>
|
||||||
This content has been removed for breaking the law.
|
This content has been removed for breaking the law.
|
||||||
</p>
|
</p>
|
||||||
|
{:else if $nav.navigation_error === "out_of_transfer"}
|
||||||
|
<h1>Traffic limit exceeded</h1>
|
||||||
|
<p>
|
||||||
|
The host user has exceeded the traffic limit of their subscription.
|
||||||
|
They need to upgrade to a higher subscription tier.
|
||||||
|
</p>
|
||||||
{:else}
|
{:else}
|
||||||
<h1>Unknown error code</h1>
|
<h1>Unknown error code</h1>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -270,9 +270,14 @@ const sort_children = (children: FSNode[], field: string, asc: boolean) => {
|
|||||||
[a, b] = [b, a]
|
[a, b] = [b, a]
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the two values are equal then we force sort by name, since names
|
if (field === "size") {
|
||||||
// are always unique
|
// When doing a size comparison we also take the recursive directory
|
||||||
if (a[field] === b[field]) {
|
// size into account
|
||||||
|
return (a.type === "dir" ? a.recursive_size : a.file_size) -
|
||||||
|
(b.type === "dir" ? b.recursive_size : b.file_size)
|
||||||
|
} else if (a[field] === b[field]) {
|
||||||
|
// If the two values are equal then we force sort by name, since
|
||||||
|
// names are always unique
|
||||||
return a.name.localeCompare(b.name, undefined, { numeric: true })
|
return a.name.localeCompare(b.name, undefined, { numeric: true })
|
||||||
} else if (typeof (a[field]) === "number") {
|
} else if (typeof (a[field]) === "number") {
|
||||||
// Sort ints from high to low
|
// Sort ints from high to low
|
||||||
|
|||||||
@@ -86,6 +86,14 @@ const themes = [
|
|||||||
brand_background_color: "#1e1e2e",
|
brand_background_color: "#1e1e2e",
|
||||||
brand_body_color: "#181825",
|
brand_body_color: "#181825",
|
||||||
brand_card_color: "#313244",
|
brand_card_color: "#313244",
|
||||||
|
}, {
|
||||||
|
name: "Dracula",
|
||||||
|
brand_input_color: "#424450",
|
||||||
|
brand_highlight_color: "#50FA7B",
|
||||||
|
brand_danger_color: "#FF5555",
|
||||||
|
brand_background_color: "#191A21",
|
||||||
|
brand_body_color: "#21222C",
|
||||||
|
brand_card_color: "#343746",
|
||||||
}, {
|
}, {
|
||||||
name: "Nova",
|
name: "Nova",
|
||||||
brand_input_color: "#28033f",
|
brand_input_color: "#28033f",
|
||||||
|
|||||||
@@ -101,21 +101,6 @@ const navigate_back = () => {
|
|||||||
// Deletion function
|
// Deletion function
|
||||||
|
|
||||||
const delete_selected = async () => {
|
const delete_selected = async () => {
|
||||||
let count = nav.children.reduce((acc, cur) => {
|
|
||||||
if (cur.fm_selected) {
|
|
||||||
acc++
|
|
||||||
}
|
|
||||||
return acc
|
|
||||||
}, 0)
|
|
||||||
|
|
||||||
let confirmSingle = `Are you sure you want to delete this file? This action is irreversible.`
|
|
||||||
let confirmMulti = `Are you sure you want to delete these ${count} files? This action is irreversible.`
|
|
||||||
if (count === 0 ||
|
|
||||||
(count === 1 && !confirm(confirmSingle)) ||
|
|
||||||
(count > 1 && !confirm(confirmMulti))) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading_start()
|
loading_start()
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { formatDataVolume } from "util/Formatting";
|
import { formatDataVolume, formatDate, formatThousands } from "util/Formatting";
|
||||||
import { fs_encode_path, fs_node_icon } from "lib/FilesystemAPI.svelte"
|
import { fs_encode_path, fs_node_icon } from "lib/FilesystemAPI.svelte"
|
||||||
import type { FSNavigator } from "filesystem/FSNavigator";
|
import type { FSNavigator } from "filesystem/FSNavigator";
|
||||||
import SortButton from "layout/SortButton.svelte";
|
import SortButton from "layout/SortButton.svelte";
|
||||||
import { FileAction, type FileActionHandler } from "./FileManagerLib";
|
import { FileAction, type FileActionHandler } from "./FileManagerLib";
|
||||||
|
import Dialog from "layout/Dialog.svelte";
|
||||||
|
import Button from "layout/Button.svelte";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import CopyButton from "layout/CopyButton.svelte";
|
||||||
|
|
||||||
let {
|
let {
|
||||||
nav,
|
nav,
|
||||||
@@ -20,23 +24,70 @@ let {
|
|||||||
hide_edit?: boolean
|
hide_edit?: boolean
|
||||||
hide_branding?: boolean
|
hide_branding?: boolean
|
||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
|
let dialog: Dialog = $state()
|
||||||
|
const columns: {field: string, label: string}[] = [
|
||||||
|
{field: "modified", label: "Modified on"},
|
||||||
|
{field: "created", label: "Created on"},
|
||||||
|
{field: "created_by", label: "Created by"},
|
||||||
|
{field: "mode", label: "Mode"},
|
||||||
|
{field: "recursive_children", label: "Children"},
|
||||||
|
{field: "file_type", label: "File type"},
|
||||||
|
{field: "size", label: "Size"},
|
||||||
|
{field: "id", label: "Node ID"},
|
||||||
|
]
|
||||||
|
let config: {
|
||||||
|
modified?: boolean
|
||||||
|
created?: boolean
|
||||||
|
created_by?: boolean
|
||||||
|
mode?: boolean
|
||||||
|
recursive_children?: boolean
|
||||||
|
file_type?: boolean
|
||||||
|
size?: boolean
|
||||||
|
id?: boolean
|
||||||
|
} = $state({
|
||||||
|
size: true, // Only size is visible by default
|
||||||
|
})
|
||||||
|
|
||||||
|
const prevent = (e: MouseEvent) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
const submit_settings = (e: SubmitEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
dialog.close()
|
||||||
|
}
|
||||||
|
const save_settings = () => {
|
||||||
|
window.localStorage.setItem("list_view_columns", JSON.stringify(config))
|
||||||
|
}
|
||||||
|
const load_settings = () => {
|
||||||
|
let item = window.localStorage.getItem("list_view_columns")
|
||||||
|
if (item !== null) {
|
||||||
|
config = JSON.parse(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onMount(load_settings)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<table class="directory">
|
<table class="directory">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr class="header_row">
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<SortButton active_field={$nav.sort_last_field} asc={$nav.sort_asc} sort_func={nav.sort_children} field="name">
|
<SortButton active_field={$nav.sort_last_field} asc={$nav.sort_asc} sort_func={nav.sort_children} field="name">
|
||||||
Name
|
Name
|
||||||
</SortButton>
|
</SortButton>
|
||||||
</td>
|
</td>
|
||||||
<td class="hide_small">
|
{#each columns as col}
|
||||||
<SortButton active_field={$nav.sort_last_field} asc={$nav.sort_asc} sort_func={nav.sort_children} field="file_size">
|
<td class="hide_small" class:hidden={!config[col.field]}>
|
||||||
Size
|
<SortButton active_field={$nav.sort_last_field} asc={$nav.sort_asc} sort_func={nav.sort_children} field={col.field}>
|
||||||
</SortButton>
|
{col.label}
|
||||||
|
</SortButton>
|
||||||
|
</td>
|
||||||
|
{/each}
|
||||||
|
<td class="node_icons icons_wrap">
|
||||||
|
<Button flat icon="settings" click={e => dialog.open(e)} />
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -56,11 +107,35 @@ let {
|
|||||||
{child.name}
|
{child.name}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="node_size hide_small">
|
<td class="node_size hide_small" class:hidden={!config.modified}>
|
||||||
|
{formatDate(child.modified, true, true, false)}
|
||||||
|
</td>
|
||||||
|
<td class="node_size hide_small" class:hidden={!config.created}>
|
||||||
|
{formatDate(child.created, true, true, false)}
|
||||||
|
</td>
|
||||||
|
<td class="node_size hide_small" class:hidden={!config.created_by}>
|
||||||
|
{child.created_by}
|
||||||
|
</td>
|
||||||
|
<td class="node_size hide_small" class:hidden={!config.mode}>
|
||||||
|
{child.mode_string}
|
||||||
|
</td>
|
||||||
|
<td class="node_size hide_small" class:hidden={!config.recursive_children}>
|
||||||
|
{formatThousands(child.recursive_children)}
|
||||||
|
</td>
|
||||||
|
<td class="node_size hide_small" class:hidden={!config.file_type}>
|
||||||
|
{child.file_type}
|
||||||
|
</td>
|
||||||
|
<td class="node_size hide_small" class:hidden={!config.size}>
|
||||||
{#if child.type === "file"}
|
{#if child.type === "file"}
|
||||||
{formatDataVolume(child.file_size, 3)}
|
{formatDataVolume(child.file_size, 3)}
|
||||||
|
{:else if child.type === "dir"}
|
||||||
|
{formatDataVolume(child.recursive_size, 3)}
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
|
<td class="node_size hide_small" class:hidden={!config.id}>
|
||||||
|
<CopyButton text={$nav.base.id} onclick={prevent} />
|
||||||
|
<a href="/d/{child.id}" onclick={prevent}>{child.id}</a>
|
||||||
|
</td>
|
||||||
<td class="node_icons">
|
<td class="node_icons">
|
||||||
<div class="icons_wrap">
|
<div class="icons_wrap">
|
||||||
{#if child.abuse_type !== undefined}
|
{#if child.abuse_type !== undefined}
|
||||||
@@ -91,15 +166,39 @@ let {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<Dialog bind:this={dialog} onclose={save_settings}>
|
||||||
|
<form class="column_config" onsubmit={submit_settings}>
|
||||||
|
{#each columns as col}
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" id="show_{col.field}" name="show_{col.field}" bind:checked={config[col.field]}/>
|
||||||
|
<label for="show_{col.field}">{col.label}</label>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
<button type="submit">
|
||||||
|
<i class="icon">save</i>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.directory {
|
.directory {
|
||||||
background: var(--body_background);
|
background: var(--body_background);
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
/* backdrop-filter: blur(4px); */
|
backdrop-filter: blur(4px);
|
||||||
max-width: 1200px;
|
max-width: 1200px;
|
||||||
margin: auto; /* center */
|
margin: auto; /* center */
|
||||||
}
|
}
|
||||||
td {
|
td {
|
||||||
|
padding-top: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
.header_row {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.node_icons {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
.node {
|
.node {
|
||||||
@@ -151,6 +250,12 @@ td {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.column_config {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
/* Large icon mode only supported on wide screens */
|
/* Large icon mode only supported on wide screens */
|
||||||
@media (min-width: 500px) {
|
@media (min-width: 500px) {
|
||||||
.node_icon.large_icons {
|
.node_icon.large_icons {
|
||||||
|
|||||||
@@ -6,20 +6,22 @@ let {
|
|||||||
style = "",
|
style = "",
|
||||||
large_icon = false,
|
large_icon = false,
|
||||||
small_icon = false,
|
small_icon = false,
|
||||||
children
|
children,
|
||||||
|
onclick,
|
||||||
}: {
|
}: {
|
||||||
text?: string;
|
text?: string;
|
||||||
style?: string;
|
style?: string;
|
||||||
large_icon?: boolean;
|
large_icon?: boolean;
|
||||||
small_icon?: boolean;
|
small_icon?: boolean;
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet;
|
||||||
|
onclick?: (e: MouseEvent) => void;
|
||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
let failed = $state(false)
|
let failed = $state(false)
|
||||||
let success = $state(false)
|
let success = $state(false)
|
||||||
|
|
||||||
// Exported so it can be called manually
|
// Exported so it can be called manually
|
||||||
export const copy = () => {
|
export const copy = (e: MouseEvent) => {
|
||||||
try {
|
try {
|
||||||
copy_text(text)
|
copy_text(text)
|
||||||
success = true
|
success = true
|
||||||
@@ -32,6 +34,10 @@ export const copy = () => {
|
|||||||
success = false
|
success = false
|
||||||
failed = false
|
failed = false
|
||||||
}, 10000)
|
}, 10000)
|
||||||
|
|
||||||
|
if (onclick !== undefined) {
|
||||||
|
onclick(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
let { children }: {
|
let { children, onclose }: {
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet;
|
||||||
|
onclose?: () => void
|
||||||
} = $props();
|
} = $props();
|
||||||
let dialog: HTMLDialogElement = $state()
|
let dialog: HTMLDialogElement = $state()
|
||||||
|
|
||||||
@@ -8,12 +9,12 @@ export const open = (origin: DOMRect|MouseEvent) => {
|
|||||||
// Show the window so we can get the location
|
// Show the window so we can get the location
|
||||||
dialog.showModal()
|
dialog.showModal()
|
||||||
|
|
||||||
const edge_offset = 2
|
const edge_offset = 10
|
||||||
|
|
||||||
// Get the egdes of the screen, so the window does not spawn off-screen
|
// Get the egdes of the screen, so the window does not spawn off-screen
|
||||||
const dialog_rect = dialog.getBoundingClientRect()
|
const dialog_rect = dialog.getBoundingClientRect()
|
||||||
const max_left = window.innerWidth - dialog_rect.width - edge_offset
|
const max_left = document.documentElement.clientWidth - dialog_rect.width - edge_offset
|
||||||
const max_top = window.innerHeight - dialog_rect.height - edge_offset
|
const max_top = document.documentElement.clientHeight - dialog_rect.height - edge_offset
|
||||||
|
|
||||||
let min_left: number, min_top: number
|
let min_left: number, min_top: number
|
||||||
if (origin instanceof DOMRect) {
|
if (origin instanceof DOMRect) {
|
||||||
@@ -35,6 +36,9 @@ export const open = (origin: DOMRect|MouseEvent) => {
|
|||||||
|
|
||||||
export const close = () => {
|
export const close = () => {
|
||||||
dialog.close()
|
dialog.close()
|
||||||
|
if (onclose !== undefined) {
|
||||||
|
onclose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach a click handler so that the dialog is closed when the user clicks
|
// Attach a click handler so that the dialog is closed when the user clicks
|
||||||
@@ -44,7 +48,7 @@ export const close = () => {
|
|||||||
const click = (e: MouseEvent) => {
|
const click = (e: MouseEvent) => {
|
||||||
if (e.target === dialog) {
|
if (e.target === dialog) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
dialog.close()
|
close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ let {
|
|||||||
active_field = "",
|
active_field = "",
|
||||||
asc = true,
|
asc = true,
|
||||||
sort_func,
|
sort_func,
|
||||||
children
|
children,
|
||||||
}: {
|
}: {
|
||||||
field?: string;
|
field?: string;
|
||||||
active_field?: string;
|
active_field?: string;
|
||||||
@@ -14,7 +14,7 @@ let {
|
|||||||
} = $props();
|
} = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button onclick={() => sort_func(field)}>
|
<button onclick={() => sort_func(field)} class="button flat">
|
||||||
{#if active_field === field}
|
{#if active_field === field}
|
||||||
{#if asc}↓{:else}↑{/if}
|
{#if asc}↓{:else}↑{/if}
|
||||||
{/if}
|
{/if}
|
||||||
@@ -25,8 +25,6 @@ let {
|
|||||||
button {
|
button {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
line-height: 1em;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: initial;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ export class FSNode {
|
|||||||
mode_string: string
|
mode_string: string
|
||||||
mode_octal: string
|
mode_octal: string
|
||||||
created_by: string
|
created_by: string
|
||||||
|
recursive_size: number
|
||||||
|
recursive_children: number
|
||||||
|
|
||||||
abuse_type?: string
|
abuse_type?: string
|
||||||
abuse_report_time?: string
|
abuse_report_time?: string
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const min_card_size = 0
|
|||||||
const def_card_size = 1
|
const def_card_size = 1
|
||||||
const max_card_size = 3
|
const max_card_size = 3
|
||||||
|
|
||||||
const expand = i => {
|
const expand = (i: number) => {
|
||||||
if (cards[i].size === undefined) {
|
if (cards[i].size === undefined) {
|
||||||
cards[i].size = def_card_size
|
cards[i].size = def_card_size
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ const expand = i => {
|
|||||||
}
|
}
|
||||||
save()
|
save()
|
||||||
}
|
}
|
||||||
const shrink = i => {
|
const shrink = (i: number) => {
|
||||||
if (cards[i].size === undefined) {
|
if (cards[i].size === undefined) {
|
||||||
cards[i].size = def_card_size
|
cards[i].size = def_card_size
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ const shrink = i => {
|
|||||||
save()
|
save()
|
||||||
}
|
}
|
||||||
|
|
||||||
const swap_card = (idx1, idx2) => {
|
const swap_card = (idx1: number, idx2: number) => {
|
||||||
const card1 = cards[idx1]
|
const card1 = cards[idx1]
|
||||||
cards[idx1] = cards[idx2]
|
cards[idx1] = cards[idx2]
|
||||||
cards[idx2] = card1
|
cards[idx2] = card1
|
||||||
|
|||||||
Reference in New Issue
Block a user