- Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.ts
31 lines (25 loc) · 1.17 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import{XtermPlayer}from'../src/Player'
constAUDIO_CAST=require('../assets/audio.cast')
typeBuiltinTheme='THEME_SOLARIZED_DARK'|'THEME_SOLARIZED_LIGHT'
function$id(id: string): HTMLElement{
constel=document.getElementById(id)
if(!el){thrownewError('Cannot find element '+id)}
returnel
}
constSAMPLE_CAST_URLS: {[key: string]: string}={
'sample cast with audio': AUDIO_CAST,
'asciinema-1': 'https://raw.githubusercontent.com/JavaCS3/xterm-player/master/assets/1.cast',
'asciinema-2': 'https://raw.githubusercontent.com/JavaCS3/xterm-player/master/assets/5.cast',
'asciinema-3': 'https://raw.githubusercontent.com/JavaCS3/xterm-player/master/assets/4.cast',
'terminalizer': 'https://raw.githubusercontent.com/faressoft/terminalizer-player/master/data.json',
}
constapp=$id('app')
constcastOption=<HTMLSelectElement>$id('cast-option')
constthemeOption=<HTMLSelectElement>$id('theme-option')
constplayer=newXtermPlayer(AUDIO_CAST,app)
castOption.onchange=()=>{
player.url=SAMPLE_CAST_URLS[castOption.value]||AUDIO_CAST
}
themeOption.onchange=()=>{
player.options={theme: XtermPlayer[<BuiltinTheme>themeOption.value]}
}