Rewrite index page in svelte, rewrite language picker in Svelte, fix #1612
This commit is contained in:
parent
303d3a0337
commit
d638237e38
16 changed files with 265 additions and 333 deletions
|
@ -1,14 +1,31 @@
|
|||
<script lang="ts">
|
||||
import { UIEventSource } from "../../Logic/UIEventSource.js"
|
||||
import { UIEventSource } from "../../Logic/UIEventSource.js";
|
||||
|
||||
/**
|
||||
* For some stupid reason, it is very hard to bind inputs
|
||||
*/
|
||||
export let value: UIEventSource<number>
|
||||
let i: number = value.data
|
||||
$: value.setData(i)
|
||||
export let value: UIEventSource<any>
|
||||
let i: any = value.data
|
||||
let htmlElement : HTMLSelectElement
|
||||
function selectAppropriateValue(){
|
||||
if(!htmlElement){
|
||||
return;
|
||||
}
|
||||
const v = value.data
|
||||
for (let option of htmlElement.getElementsByTagName("option")) {
|
||||
if(option.value === v){
|
||||
option.selected = true
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
value.addCallbackD(() => selectAppropriateValue())
|
||||
$: {
|
||||
if(htmlElement){
|
||||
selectAppropriateValue()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<select bind:value={i}>
|
||||
<select bind:this={htmlElement} on:change={(e) => {value.setData(e.srcElement.value)}}>
|
||||
<slot />
|
||||
</select>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue