Add sorting to Quick Links
This commit is contained in:
parent
69949fb8f4
commit
2ffa3510ee
@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
import Island from '$lib/islands/island.svelte';
|
import Island from '$lib/islands/island.svelte';
|
||||||
import { ql } from '$lib/stores/quick-links.js';
|
import { ql } from '$lib/stores/quick-links';
|
||||||
export let variables = {
|
export let variables = {
|
||||||
title: 'Quick Links'
|
title: 'Quick Links'
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
import Island from '$lib/islands/island.svelte';
|
import Island from '$lib/islands/island.svelte';
|
||||||
import { ql } from '$lib/stores/quick-links.js';
|
import { ql } from '$lib/stores/quick-links';
|
||||||
export let variables = {
|
export let variables = {
|
||||||
title: 'Quick Links'
|
title: 'Quick Links'
|
||||||
};
|
};
|
||||||
|
|
||||||
let qlData = [];
|
let qlData: string[] = [];
|
||||||
$: {
|
$: {
|
||||||
qlData = $ql;
|
qlData = $ql;
|
||||||
console.log(qlData);
|
console.log(qlData);
|
||||||
@ -13,16 +13,16 @@
|
|||||||
|
|
||||||
let saveButton = 'Save';
|
let saveButton = 'Save';
|
||||||
|
|
||||||
async function timeout(ms) {
|
async function timeout(ms: number): Promise<any> {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveQl() {
|
async function saveQl() {
|
||||||
// Fetch the content of all text entries within the island then run ql.set([ARRAY OF INPUT CONTENT])
|
// Fetch the content of all text entries within the island then run ql.set([ARRAY OF INPUT CONTENT])
|
||||||
const inputs = document.getElementsByClassName('qlInput');
|
const inputs = document.getElementsByClassName('qlInput');
|
||||||
let inputLinks = [];
|
let inputLinks: string[] = [];
|
||||||
for (let item of inputs) {
|
for (let item of inputs) {
|
||||||
let text = item?.value;
|
let text = (<HTMLInputElement>item)?.value;
|
||||||
if (text !== '') {
|
if (text !== '') {
|
||||||
inputLinks.push(text);
|
inputLinks.push(text);
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@
|
|||||||
ql.set(updatedQl);
|
ql.set(updatedQl);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleClick(event) {
|
function handleClick(event: any) {
|
||||||
// Handle the click event here
|
// Handle the click event here
|
||||||
console.log('Island Clicked');
|
console.log('Island Clicked');
|
||||||
// You can access the `variables` passed to the Island component here if needed
|
// You can access the `variables` passed to the Island component here if needed
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
import { welcome } from '$lib/stores/welcome';
|
import { welcome } from '$lib/stores/welcome';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import { version } from '$lib/stores/version';
|
import { version } from '$lib/stores/version';
|
||||||
|
|
||||||
const variables = {
|
let pageNum: number = 0;
|
||||||
title: 'Welcome to OwlBoard'
|
|
||||||
};
|
|
||||||
let pageNum = 0;
|
|
||||||
|
|
||||||
function pageUp() {
|
function pageUp() {
|
||||||
pageNum++;
|
pageNum++;
|
||||||
@ -22,7 +19,7 @@
|
|||||||
welcome.set(version);
|
welcome.set(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageText = [
|
const pageText: string[] = [
|
||||||
'<h3>A brand new look</h3>' +
|
'<h3>A brand new look</h3>' +
|
||||||
"<p>OwlBoard has a brand new look, making it even faster for you to access the data - you won't have to register again.</p>" +
|
"<p>OwlBoard has a brand new look, making it even faster for you to access the data - you won't have to register again.</p>" +
|
||||||
"<p><strong>Live station data</strong> is still available right from the homepage. If you are signed up, you'll get improved data from the <strong>Staff board</strong>. Bus and Ferry services are still included</p>" +
|
"<p><strong>Live station data</strong> is still available right from the homepage. If you are signed up, you'll get improved data from the <strong>Staff board</strong>. Bus and Ferry services are still included</p>" +
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable, type Writable } from 'svelte/store';
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
export const ql = writable(fromLocalStorage('ql', []));
|
export const ql = writable(fromLocalStorage('ql', []));
|
||||||
toLocalStorage(ql, 'ql');
|
toLocalStorage(ql, 'ql');
|
||||||
|
|
||||||
function fromLocalStorage(storageKey, fallback) {
|
function fromLocalStorage(storageKey: string, fallback: string[]): string[] {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
const storedValue = localStorage.getItem(storageKey);
|
const storedValue = localStorage.getItem(storageKey);
|
||||||
if (storedValue !== 'undefined' && storedValue !== null) {
|
if (storedValue !== 'undefined' && storedValue !== null) {
|
||||||
@ -14,10 +14,10 @@ function fromLocalStorage(storageKey, fallback) {
|
|||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toLocalStorage(store, storageKey) {
|
function toLocalStorage(store: Writable<string[]>, storageKey: string) {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
store.subscribe((value) => {
|
store.subscribe((value) => {
|
||||||
let storageValue = typeof value === 'object' ? JSON.stringify(value) : value;
|
let storageValue = typeof value === 'object' ? JSON.stringify(value.sort()) : value;
|
||||||
|
|
||||||
localStorage.setItem(storageKey, storageValue);
|
localStorage.setItem(storageKey, storageValue);
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user