@@ -16,6 +16,35 @@ const hot_keys = {
16
16
description : "back" ,
17
17
action : one_step_back ,
18
18
} ,
19
+ f : {
20
+ description : "toggle full screen" ,
21
+ action : ( ) => {
22
+ if ( document . fullscreenElement ) {
23
+ document . exitFullscreen ( ) ;
24
+ return ;
25
+ }
26
+ const element = document . body ;
27
+ const requestMethod =
28
+ element . requestFullScreen ||
29
+ element . webkitRequestFullScreen ||
30
+ element . mozRequestFullScreen ||
31
+ element . msRequestFullScreen ;
32
+ if ( requestMethod ) {
33
+ // Native full screen.
34
+ requestMethod . call ( element ) ;
35
+ }
36
+ } ,
37
+ } ,
38
+ h : {
39
+ description : "toggle hide text" ,
40
+ action : ( ) => {
41
+ if ( story_container . classList . contains ( "d-none" ) ) {
42
+ story_container . classList . remove ( "d-none" ) ;
43
+ } else {
44
+ story_container . classList . add ( "d-none" ) ;
45
+ }
46
+ } ,
47
+ } ,
19
48
} ;
20
49
21
50
let current_viewer_state = viewer_states . MENU ;
@@ -146,7 +175,7 @@ function load_section(id, add_current_section_to_history = true) {
146
175
execute_actions ( section . script ) ;
147
176
}
148
177
149
- const text = get_text_from_section ( section , story . state ?. variables )
178
+ const text = get_text_from_section ( section , story . state ?. variables ) ;
150
179
151
180
if ( ! text ) {
152
181
toast_alert ( "This section has no text" ) ;
@@ -216,7 +245,8 @@ function read_query_params() {
216
245
function handle_global_click ( ) {
217
246
if (
218
247
document . activeElement . nodeName === "INPUT" ||
219
- document . activeElement . nodeName === "BUTTON"
248
+ document . activeElement . nodeName === "BUTTON" ||
249
+ ! story ?. state ?. current_section
220
250
) {
221
251
return ;
222
252
}
@@ -262,13 +292,7 @@ function overwrite_actions() {
262
292
return ;
263
293
}
264
294
const user_input = prompt ( parameters [ 1 ] ) ;
265
- if ( ! story . state ) {
266
- story . state = { } ;
267
- }
268
- if ( ! story . state . variables ) {
269
- story . state . variables = { } ;
270
- }
271
- story . state . variables [ parameters [ 0 ] ] = user_input ;
295
+ supported_actions [ "SET" ] . action ( st , [ parameters [ 0 ] , user_input ] ) ;
272
296
} ;
273
297
}
274
298
0 commit comments