mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 01:17:22 +00:00
Add instant game launch
This commit is contained in:
parent
90f630f277
commit
97cd8aca9e
4 changed files with 24 additions and 31 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import { h } from 'preact'
|
||||
|
||||
export default function ({ setTargetName, setTargetUrl }) {
|
||||
export default function ({ theme, setLocation, buildLink }) {
|
||||
const fileInputHandler = ({ target }) => {
|
||||
const file = target.files[0]
|
||||
setTargetName(file.name)
|
||||
setTargetUrl(`${URL.createObjectURL(file)}#${file.name}`)
|
||||
target.value = null
|
||||
const url = `${URL.createObjectURL(file)}#${file.name}`
|
||||
|
||||
setLocation(buildLink({ url, theme }))
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
import { h } from 'preact'
|
||||
|
||||
export default function ({ setTargetName, setTargetUrl }) {
|
||||
export default function ({ theme, setLocation, buildLink }) {
|
||||
const urlRE = /^(http|https):\/\/[^ "]+$/
|
||||
|
||||
const emit = url => {
|
||||
setTargetName(url)
|
||||
setTargetUrl(url)
|
||||
}
|
||||
const onKeyPress = ({ keyCode, target }) => {
|
||||
if (keyCode !== 13) return
|
||||
|
||||
const urlInputHandler = ({ target }) => {
|
||||
const url = target.value
|
||||
emit(urlRE.test(url)
|
||||
? url
|
||||
: null)
|
||||
|
||||
if (urlRE.test(url)) {
|
||||
setLocation(buildLink({ url, theme }))
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<input
|
||||
type='text'
|
||||
placeholder='https://...'
|
||||
onInput={urlInputHandler} />)
|
||||
onKeyPress={onKeyPress} />)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue