removed a lot of workarounds and experiments
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
import { getModuleIndex, getModule } from './utils'
|
import { getModuleIndex, getModule } from './utils'
|
||||||
import DATA from './data'
|
import DATA from './data'
|
||||||
|
|
||||||
let video; let interval; let timeout; let firstUpdate;
|
let video; let interval; let timeout;
|
||||||
|
|
||||||
// TODO: load data from JSON or an API
|
// TODO: load data from JSON or an API
|
||||||
// TODO: validate the data: overlaps? gaps? (gaps should be ok).
|
// TODO: validate the data: overlaps? gaps? (gaps should be ok).
|
||||||
@@ -16,16 +16,12 @@
|
|||||||
// TODO: (depends on above) enable search
|
// TODO: (depends on above) enable search
|
||||||
|
|
||||||
const positionUpdater = () => {
|
const positionUpdater = () => {
|
||||||
if (firstUpdate) {
|
|
||||||
firstUpdate = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
interval = setInterval(() => {
|
interval = setInterval(() => {
|
||||||
const newModule = getModule($position)
|
|
||||||
const pos = video.position()
|
const pos = video.position()
|
||||||
|
const newModule = getModule(pos)
|
||||||
|
if (!pos) return console.log('no pos')
|
||||||
position.update(() => pos)
|
position.update(() => pos)
|
||||||
if (!newModule
|
if (newModule && !$currentModule
|
||||||
|| newModule && !$currentModule
|
|
||||||
|| newModule && $currentModule && newModule.name !== $currentModule.name)
|
|| newModule && $currentModule && newModule.name !== $currentModule.name)
|
||||||
{ currentModule.update(() => newModule) }
|
{ currentModule.update(() => newModule) }
|
||||||
}, 100)
|
}, 100)
|
||||||
@@ -39,8 +35,7 @@
|
|||||||
currentModule.update(() => module)
|
currentModule.update(() => module)
|
||||||
position.update(() => module.start)
|
position.update(() => module.start)
|
||||||
video.jumpTo(module.start)
|
video.jumpTo(module.start)
|
||||||
firstUpdate = true
|
positionUpdater()
|
||||||
timeout = setTimeout(positionUpdater, 500)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,12 +51,12 @@
|
|||||||
} else if ([32, "Space"].includes(code)) {
|
} else if ([32, "Space"].includes(code)) {
|
||||||
video.toggle()
|
video.toggle()
|
||||||
} else if (["l", "ArrowRight"].includes(key)) {
|
} else if (["l", "ArrowRight"].includes(key)) {
|
||||||
video.jumpTo($position + 5)
|
|
||||||
clearInterval(interval)
|
clearInterval(interval)
|
||||||
|
video.jumpTo($position + 5)
|
||||||
positionUpdater()
|
positionUpdater()
|
||||||
} else if (["h", "ArrowLeft"].includes(key)) {
|
} else if (["h", "ArrowLeft"].includes(key)) {
|
||||||
video.jumpTo($position - 5)
|
|
||||||
clearInterval(interval)
|
clearInterval(interval)
|
||||||
|
video.jumpTo($position - 5)
|
||||||
positionUpdater()
|
positionUpdater()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,6 +81,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keydown={handleKeyDown} />
|
<svelte:window on:keydown={handleKeyDown} />
|
||||||
|
|||||||
@@ -2,24 +2,29 @@
|
|||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
import { currentModule, position } from "./stores"
|
import { currentModule, position } from "./stores"
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
export let module
|
export let module
|
||||||
const duration = module.end - module.start
|
const duration = module.end - module.start
|
||||||
const getProgress = pos => (pos - module.start) / duration * 100
|
const getProgress = pos => (pos - module.start) / duration * 100
|
||||||
|
|
||||||
let styl; let selected; let progress;
|
let selected; let progress; let klass;
|
||||||
|
|
||||||
$: selected = $currentModule && $currentModule.name === module.name
|
$: selected = $currentModule && $currentModule.name === module.name
|
||||||
$: if (selected) {
|
$: if (selected) {
|
||||||
progress = getProgress($position)
|
progress = getProgress($position)
|
||||||
|
klass = "current"
|
||||||
|
} else {
|
||||||
|
progress = null;
|
||||||
|
klass = ""
|
||||||
}
|
}
|
||||||
// TODO: add checkboxes for 'want to watch'
|
// TODO: add checkboxes for 'want to watch'
|
||||||
// TODO: gray out watched modules
|
// TODO: gray out watched modules
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div on:click={() => dispatcher("selectModule", { module })} >
|
<div on:click={() => dispatch("selectModule", { module })} >
|
||||||
<span style="{styl}" >I want to {module.outcome}.</span>
|
<span class="{klass}">I want to {module.outcome}.</span>
|
||||||
{#if selected}
|
{#if progress}
|
||||||
<progress value={progress} max=100>Hi</progress>
|
<progress value={progress} max=100>Hi</progress>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -28,21 +33,12 @@
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
@media (prefers-color-scheme: light) {
|
@media (prefers-color-scheme: light) {
|
||||||
/* span.current { background-color: yellow;} */
|
span.current { background-color: yellow;}
|
||||||
span.current:hover { background-color: lightgrey; }
|
span.current:hover { background-color: lightgrey; }
|
||||||
:root {
|
|
||||||
--pending-bg: yellow;
|
|
||||||
--finished-bg: white;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
:root {
|
span.current { background-color: blue; }
|
||||||
--pending-bg: #222;
|
|
||||||
--finished-bg: blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* span.current { background-color: blue; } */
|
|
||||||
span:hover {
|
span:hover {
|
||||||
background-color: lavender;
|
background-color: lavender;
|
||||||
color: #222;
|
color: #222;
|
||||||
|
|||||||
Reference in New Issue
Block a user