Skip to content

Commit 23472c1

Browse files
committed
Various
1 parent 781dff2 commit 23472c1

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

scripts/storyteller/storyteller.ecs

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
div TopicText
1111
div ImageDiv
1212
div Mask
13-
pre Branch
1413
pre Resources
1514
img BigPic
1615
img TopImage
@@ -29,6 +28,8 @@
2928
variable CDNPath
3029
variable Args
3130
variable Arg
31+
variable Mode
32+
variable NClicks
3233
variable Stories
3334
variable Themes
3435
variable Theme
@@ -92,10 +93,7 @@
9293
if portrait set Mobile
9394
end
9495

95-
! attach Branch to `storyteller-branch`
96-
! put the content of Branch into Value
97-
! put `https://cdn.jsdelivr.net/gh/easycoder/storyteller@` cat Value into CDNPath
98-
put `https://cdn.jsdelivr.net/gh/easycoder/storyteller@master` into CDNPath
96+
put `https://cdn.jsdelivr.net/gh/easycoder/storyteller` into CDNPath
9997

10098
attach Resources to `storyteller-stories`
10199
put the content of Resources into Stories
@@ -123,6 +121,7 @@
123121

124122
create Content in Container
125123
set style `position` of Content to `absolute`
124+
set style `height` of Content to `100vh`
126125
if Mobile
127126
begin
128127
create ButtonBar in Content
@@ -135,6 +134,27 @@
135134
end
136135
create TopicText in Content
137136

137+
! Detect a triple click on the title
138+
get Mode from storage as `mode`
139+
put 0 into NClicks
140+
on click TitleDiv
141+
begin
142+
add 1 to NClicks
143+
if NClicks is 1
144+
begin
145+
if Mode is `admin`
146+
begin
147+
put empty into Mode
148+
put 0 into NClicks
149+
end
150+
end
151+
else if NClicks is 3
152+
begin
153+
put `admin` into Mode
154+
put 0 into NClicks
155+
end
156+
end
157+
138158
json parse url the location as Args
139159
put property `arg` of Args into Arg
140160
if Arg is empty
@@ -190,7 +210,6 @@
190210

191211
! View a record, given its Subject and Topic ids.
192212
ViewRecord:
193-
if not Mobile scroll TopicText to 0
194213
rest get Record from Stories cat SID cat `/content.txt?v=` cat now
195214
or begin
196215
put `home` into SID
@@ -405,12 +424,18 @@ ViewRecord:
405424
end
406425
end
407426
end
427+
428+
wait 20 ticks
429+
if Mode is `admin` alert `Scroll`
430+
if Mobile scroll to 0 else scroll TopicText to 0
431+
! scroll TopicText to 0 ! This doesn't work on mobile
432+
408433
stop
409434

410435
! Set up the theme
411436
SetupTheme:
412437
get Theme from storage as `theme`
413-
if Theme is empty rest get Theme from Stories cat `theme.txt`
438+
if Theme is empty rest get Theme from Stories cat `theme.txt?v=` cat now
414439
if left 1 of Theme is `/`
415440
begin
416441
put from 1 of Theme into Theme
@@ -436,11 +461,16 @@ SetupTheme:
436461
put property `border-t` of Layout into BorderT
437462
put property `border-b` of Layout into BorderB
438463
put property `font-scale` of Layout into FontScale
439-
if not Mobile
464+
if Mobile
440465
begin
441-
set attribute `src` of MidImage to CDNPath cat `/themes/` cat Theme cat `/mid.jpg`
442-
set attribute `src` of TopImage to CDNPath cat `/themes/` cat Theme cat `/top.jpg`
443-
set attribute `src` of BottomImage to CDNPath cat `/themes/` cat Theme cat `/bottom.jpg`
466+
multiply FontScale by 3
467+
divide FontScale by 2
468+
end
469+
else
470+
begin
471+
set attribute `src` of MidImage to Path cat `/themes/` cat Theme cat `/mid.jpg`
472+
set attribute `src` of TopImage to Path cat `/themes/` cat Theme cat `/top.jpg`
473+
set attribute `src` of BottomImage to Path cat `/themes/` cat Theme cat `/bottom.jpg`
444474
end
445475
return
446476

@@ -512,7 +542,6 @@ CreateButtons:
512542
put `content` into TID
513543
go to ViewAnotherRecord
514544
end
515-
516545
return
517546

518547
! View another record, given the Subject and Topic ids
@@ -730,8 +759,10 @@ ProcessImage:
730759
add 1 to N
731760
if Data is not empty
732761
begin
733-
if Class is not empty put Class cat ` ` into Class
734-
put Class cat from N of Data into Class
762+
! Redundant code removed, 27/7/21
763+
! if Class is not empty put Class cat ` ` into Class
764+
! put Class cat from N of Data into Class
765+
put from N of Data into Class
735766
end
736767
put the position of `!` in Class into N
737768
if N is not -1

0 commit comments

Comments
 (0)