Skip to content

Commit 1e332c9

Browse files
committed
how it works
1 parent 0f66f9e commit 1e332c9

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

resources/ecs/examples.ecs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ Start:
9090
on click ShowLifeDoc send `life` to parent
9191

9292
attach HowItWorks to `how-it-works`
93-
on click HowItWorks
94-
begin
95-
alert `How it works`
96-
send `howitworks` to parent
97-
end
93+
on click HowItWorks send `howitworks` to parent
9894

9995
stop
10096

resources/ecs/howitworks.ecs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99

1010
rest get Script from `/resources/md/howitworks.md`
1111

12-
on message
13-
begin
14-
put the message into Message
15-
if Message is `restore` send `show` to parent
16-
else if Message is `pause` begin end
17-
else go to Start
18-
end
12+
on message go to Start
1913

2014
set ready
2115
stop

resources/ecs/wordpress.ecs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99

1010
rest get Script from `/resources/md/wordpress.md`
1111

12-
on message
13-
begin
14-
put the message into Message
15-
if Message is `restore` send `show` to parent
16-
else if Message is `pause` begin end
17-
else go to Start
18-
end
12+
on message go to Start
1913

2014
set ready
2115
stop

resources/md/howitworks.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
# How It Works
22

3-
This is a description of the interaction between the ~ec~ and the Markdown scripts to power this website.
3+
This is a description of the interaction between the ~ec~ and the Markdown scripts to power this website. You should be able to follow the flow as I name the files involved.
4+
5+
Before I start I should explain that ~ec~ uses the ~code:Showdown~ Markdown library to add custom features to the regular `Markdown` set. I may refer to ~code:Showdown~ and `Markdown` interchangeably.
6+
7+
In `index.html` the boot script loads and runs `main.ecs`, whose main role is to control the menu panel on the home page. It sets up button variables and module handlers, each of which is initialized with a script for the functions it performs. Not all of the module handlers have a corresponding button; some are called from regular hyperlinks in the text. The code loads the script for each module then runs it, which initializes the module then waits for a message.
8+
9+
Let's start with one of the simplest possible cases, where the user clicks the `Wordpress` button. This will cause a message to be sent to the `wordpress.ecs` module. The module only ever expects to receive one kind of message, so the content is empty. The module will already have loaded the `wordpress.md` Markdown file, so all it needs to do on receiving the message is to call the ~code:Showdown~ module, passing it the page script. This is formatted by ~code:Showdown~ and placed in the main viewing panel.
10+
11+
Interactions between the ~ec~ and ~code:Showdown~ scripts occur in 2 ways:
12+
13+
1 `Markdown`/~code:Showdown~ can include HTML sections according to your needs. If a hyperlink element with an id is placed in the `.md` script, ~ec~ can attach one of its own variables to the hyperlink and detect when it is clicked.
14+
15+
1 In the same way, any element with an id can have its content altered at will by ~ec~. This allows the page to change dynamically under script control.
16+
17+
There's a fair amount of detail that I've glossed over by picking the simplest example, but this should at least provide an indication of where to start gaining an understanding of the code.

0 commit comments

Comments
 (0)