File tree Expand file tree Collapse file tree 6 files changed +18
-1
lines changed Expand file tree Collapse file tree 6 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 6
6
</ head >
7
7
< body >
8
8
< div id ="screen "> </ div >
9
+
10
+ < button id ="save "> Save state</ button >
9
11
</ body >
10
12
</ html >
Original file line number Diff line number Diff line change @@ -6,9 +6,13 @@ const shell = new LinuxBrowserShell(
6
6
wasm : "./v86/v86.wasm" ,
7
7
bios : "./v86/seabios.bin" ,
8
8
vga_bios : "./v86/vgabios.bin" ,
9
- cdrom : "./v86/image.iso.zst " ,
9
+ cdrom : "./v86/image.iso" ,
10
10
initial_state : "./v86/initial-state.bin.zst" ,
11
11
} ,
12
12
screenDiv ,
13
13
)
14
14
shell . boot ( )
15
+
16
+ document . getElementById ( "save" ) . onclick = async function ( ) {
17
+ shell . downloadState ( )
18
+ }
Original file line number Diff line number Diff line change @@ -247,6 +247,17 @@ class LinuxBrowserShell {
247
247
setKeyboardActive ( active : boolean ) : void {
248
248
this . emulator . keyboard_set_status ( active )
249
249
}
250
+
251
+ downloadState ( filename : string = "linux-browser-shell-state.bin" ) : void {
252
+ this . emulator . save_state ( ) . then ( ( state : any ) => {
253
+ var a = document . createElement ( "a" )
254
+ a . download = filename
255
+ a . href = window . URL . createObjectURL ( new Blob ( [ state ] ) )
256
+ a . dataset . downloadurl =
257
+ "application/octet-stream:" + a . download + ":" + a . href
258
+ a . click ( )
259
+ } )
260
+ }
250
261
}
251
262
252
263
export default LinuxBrowserShell
You can’t perform that action at this time.
0 commit comments