Skip to content

Commit bbccfb8

Browse files
committed
Deal with browser history
1 parent 7166582 commit bbccfb8

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

resources/ecs/codex.ecs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@
4747
variable PasswordRequested
4848
variable PasswordValid
4949
variable ReadOnly
50+
variable Args
51+
variable Arg
5052
variable Name
53+
variable CallStack
5154
variable CurrentName
5255
variable Content
5356
variable Current
@@ -92,6 +95,7 @@
9295

9396
load showdown
9497
rest get ECPayload from `/resources/fragment/ec.txt`
98+
json parse url the location as Args
9599

96100
! create Tracer
97101
! set attribute `id` of Tracer to `easycoder-tracer`
@@ -107,7 +111,19 @@
107111
end
108112
L2:
109113
clear PasswordRequested
110-
114+
put empty into CallStack
115+
history set
116+
on restore
117+
begin
118+
put the json count of CallStack into N
119+
if N is less than 2 stop
120+
take 1 from N
121+
json delete element N of CallStack
122+
take 1 from N
123+
put element N of CallStack into Step
124+
go to SHP2
125+
end
126+
111127
if portrait
112128
begin
113129
if mobile set Mobile else clear Mobile
@@ -487,6 +503,13 @@ L2:
487503
end
488504
end
489505
end
506+
507+
put property `arg` of Args into Arg
508+
if Arg is not empty
509+
begin
510+
put from 2 of Arg into Step
511+
gosub to SHP2
512+
end
490513

491514
set ready
492515
stop
@@ -651,6 +674,10 @@ ShowContents:
651674
stop
652675

653676
ShowHelpPage:
677+
append Step to CallStack
678+
SHP1:
679+
history push url `?s=` cat Step
680+
SHP2:
654681
put Step into storage as `.step`
655682
put `/resources/codex/code/` cat Step cat `.ecs` into Item
656683
rest get Fragment from Item or begin end

resources/ecs/main.ecs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
variable Script
3535
variable ButtonStyle
3636
variable Message
37+
variable Args
38+
variable Arg
3739

3840
! create Tracer
3941
! set attribute `id` of Tracer to `easycoder-tracer`
@@ -216,14 +218,7 @@ BuildPage:
216218
set the style of CodexButton to ButtonStyle
217219
set style `margin-top` of CodexButton to `0.25em`
218220
set the text of CodexButton to `Codex`
219-
on click CodexButton
220-
begin
221-
load plugin `codemirror`
222-
rest get Script from `/resources/ecs/codex.ecs`
223-
send `pause` to CurrentModule
224-
set style `display` of Body to `none`
225-
run Script
226-
end
221+
on click CodexButton go to RunCodex
227222

228223
create Notes in Main
229224
create ShowNotes in Notes
@@ -241,8 +236,20 @@ DoNotes:
241236
end
242237
end
243238

239+
json parse url the location as Args
240+
put property `arg` of Args into Arg
241+
if Arg is not empty go to RunCodex
244242
stop
245243

244+
RunCodex:
245+
load plugin `codemirror`
246+
rest get Script from `/resources/ecs/codex.ecs`
247+
send `pause` to CurrentModule
248+
set style `display` of Body to `none`
249+
run Script
250+
stop
251+
252+
246253
DeselectAllButtons:
247254
set style `background` of HomeButton to ``
248255
set style `background` of IntroButton to ``

0 commit comments

Comments
 (0)