Skip to content

Commit ff57cf9

Browse files
committed
Quickstart tutorial
1 parent 9fe1075 commit ff57cf9

File tree

20 files changed

+275
-91
lines changed

20 files changed

+275
-91
lines changed

dist/easycoder-min.js

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/easycoder.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2317,7 +2317,7 @@ const EasyCoder_Core = {
23172317
radius_t
23182318
};
23192319
}
2320-
if ([`now`, `today`, `newline`, `break`, `empty`, `uuid`].includes(token)) {
2320+
if ([`now`, `today`, `newline`, `backtick`, `break`, `empty`, `uuid`].includes(token)) {
23212321
compiler.next();
23222322
return {
23232323
domain: `core`,
@@ -2750,6 +2750,12 @@ const EasyCoder_Core = {
27502750
numeric: false,
27512751
content: `\n`
27522752
};
2753+
case `backtick`:
2754+
return {
2755+
type: `constant`,
2756+
numeric: false,
2757+
content: `\``
2758+
};
27532759
case `break`:
27542760
return {
27552761
type: `constant`,

dist/plugins/iwsy.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ const EasyCoder_IWSY = {
141141
});
142142
return 0;
143143
case `load`:
144+
if (typeof EasyCoder.iwsyFunctions !== `undefined`) {
145+
throw Error(`IWSY has already been set up`);
146+
}
144147
const playerRecord = program.getSymbolRecord(command.player);
145148
const player = playerRecord.element[playerRecord.index];
146149
player.innerHTML = ``;

iwsy/iwsy.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ const IWSY = (player, text) => {
162162
element.style[`background-size`] = `cover`;
163163
element.style.border = defaults.border;
164164
element.style[`overflow`] = `hidden`;
165+
element.style[`display`] = `none`;
166+
element.style[`opacity`] = `0`;
165167
val = defaults.textMarginLeft;
166168
if (!isNaN(val)) {
167169
val *= w;
@@ -228,6 +230,7 @@ const IWSY = (player, text) => {
228230
for (const block of script.blocks) {
229231
if (block.defaults.name === name) {
230232
block.element.style.opacity = showHide ? `1.0` : `0.0`;
233+
block.element.style.display = showHide ? `block` : `none`;
231234
break;
232235
}
233236
}
@@ -265,27 +268,41 @@ const IWSY = (player, text) => {
265268
for (const block of stepBlocks)
266269
{
267270
block.element.style.opacity = upDown ? 1.0 : 0.0;
271+
block.element.style.display = upDown ? `block` : `none`;
268272
}
269273
step.next();
270274
} else {
271275
const animSteps = Math.round(step.duration * 25);
272276
const continueFlag = step.continue;
277+
for (const block of stepBlocks)
278+
{
279+
block.element.style.display = `block`;
280+
}
273281
let animStep = 0;
274282
const interval = setInterval(() => {
275-
if (animStep < animSteps) {
276-
const ratio = 0.5 - Math.cos(Math.PI * animStep / animSteps) / 2;
277-
let blocks = stepBlocks.length;
278-
for (const block of stepBlocks)
279-
{
280-
block.element.style.opacity = upDown ? ratio : 1.0 - ratio;
283+
try {
284+
if (animStep < animSteps) {
285+
const ratio = 0.5 - Math.cos(Math.PI * animStep / animSteps) / 2;
286+
for (const block of stepBlocks)
287+
{
288+
block.element.style.opacity = upDown ? ratio : 1.0 - ratio;
289+
}
290+
animStep++;
291+
} else {
292+
for (const block of stepBlocks)
293+
{
294+
block.element.style.opacity = upDown ? 1 : 0;
295+
block.element.style.display = upDown ? `block` :`none`;
296+
}
297+
script.stepping = false;
298+
clearInterval(interval);
299+
if (!continueFlag) {
300+
step.next();
301+
}
281302
}
282-
animStep++;
283-
} else {
284-
script.stepping = false;
303+
} catch(err) {
285304
clearInterval(interval);
286-
if (!continueFlag) {
287-
step.next();
288-
}
305+
throw Error(err);
289306
}
290307
}, 40);
291308
if (continueFlag) {
@@ -496,6 +513,11 @@ const IWSY = (player, text) => {
496513
}
497514
return true;
498515
});
516+
if (typeof block.element === `undefined`) {
517+
throw Error(`Block '${block.defaults.name}' has not been set up`);
518+
}
519+
block.element.style.opacity = 1;
520+
block.element.style.display = `block`;
499521
if (script.speed === `scan`) {
500522
doTransitionStep(block, target, 1.0);
501523
setFinalState(block,target);
@@ -674,7 +696,6 @@ const IWSY = (player, text) => {
674696
// Show a block
675697
const block = blockIndex => {
676698
player.innerHTML = ``;
677-
// player.style.background = null;
678699
const w = player.getBoundingClientRect().width / 1000;
679700
const h = player.getBoundingClientRect().height / 1000;
680701
script.blocks.forEach((block, index) => {
@@ -769,13 +790,13 @@ const IWSY = (player, text) => {
769790
} else {
770791
switch (item) {
771792
case `left`:
772-
styles.push(`float:left`);
793+
styles.push(`float:left;margin-right:1em`);
773794
break;
774795
case `center`:
775796
styles.push(`margin:0 auto`);
776797
break;
777798
case `right`:
778-
styles.push(`float:right`);
799+
styles.push(`float:right;margin-left:1em`);
779800
break;
780801
case `clear`:
781802
styles.push(`clear:both`);

iwsy/resources/ecs/blocks.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Restart:
105105
index DeleteBlock to N
106106
index Editor to N
107107
create Row in Table
108+
set the style of Row to `margin-bottom:0.2em`
108109
create Cell in Row
109110
set the style of Cell to `width:100%;display:flex`
110111
create Link in Cell
@@ -241,6 +242,7 @@ Restart:
241242
put the index of DeleteBlock into N
242243
json delete element N of Blocks
243244
set property `blocks` of Presentation to Blocks
245+
put -1 into SelectedBlock
244246
go to Restart
245247
end
246248
stop

iwsy/resources/ecs/content.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Restart:
7575
set property `content` of Item to empty
7676
json add Item to Items
7777
set property `content` of Presentation to Items
78+
put -1 into SelectedItem
7879
go to Restart
7980
end
8081

@@ -102,6 +103,7 @@ Restart:
102103
put element N of Items into Item
103104
put property `name` of Item into ItemName
104105
create Row in Table
106+
set the style of Row to `margin-bottom:0.2em`
105107
create Cell in Row
106108
set the style of Cell to `width:100%;display:flex`
107109
create EditButton in Cell
@@ -199,6 +201,7 @@ Restart:
199201
put property `content` of Presentation into Items
200202
json delete property ItemName of Items
201203
set property `content` of Presentation to Items
204+
put -1 into SelectedItem
202205
go to Restart
203206
end
204207
stop

iwsy/resources/ecs/fileman.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import div Container
66

7-
div Tracer
87
div Panel
98
div FileListing
109
div FileRow
@@ -51,9 +50,6 @@
5150
if Mobile set the style of Panel to `background:#ffe`
5251
else set the style of Panel to `width:100%;height:100%`
5352

54-
create Tracer in Panel
55-
set attribute `id` of Tracer to `easycoder-tracer`
56-
5753
create Uploader in Panel
5854
set the style of Uploader to `width:100%;padding:0.5em 0;font-size:80%;text-align:center`
5955
create UploadFile in Uploader
@@ -68,7 +64,7 @@
6864
set attribute `max` of UploadProgress to 100
6965

7066
create Buttons in Panel
71-
set the style of Buttons to `display:flex`
67+
set the style of Buttons to `display:flex;margin-bottom:0.5em`
7268
create UploadButton in Buttons
7369
set the style of UploadButton to `flex:1;width:150px;height:40px;font-family:sans;color:black`
7470
set the text of UploadButton to `Upload`
@@ -132,10 +128,12 @@ Show:
132128
put property `home` of UserRecord into Home
133129
put Home cat `/` cat property `id` of UserRecord into Home
134130
put `users/` cat Home cat `/images` into Home
135-
put Home into CurrentPath
131+
get CurrentPath from storage as `.filepath`
132+
if CurrentPath is empty put Home into CurrentPath
136133

137134
! Build the list
138135
Browser:
136+
put CurrentPath into storage as `.filepath`
139137
rest get Content from `ulist/` cat Email cat `/` cat Password cat `/` cat CurrentPath cat `?v=` cat now
140138
or begin
141139
alert `Failed to list files.`
@@ -148,7 +146,7 @@ Browser:
148146
set the elements of FileName to FileCount
149147

150148
! Add a row for each file
151-
set the content of Scroller to ``
149+
clear Scroller
152150
set Even
153151

154152
if CurrentPath is not Home
@@ -239,7 +237,6 @@ SelectFile:
239237
set attribute `src` of Image to `/resources/` cat FilePath cat `?v=` cat now
240238
on click CloseButton go to CloseMedia
241239
set the text of URL to `resources/` cat FilePath
242-
! highlight URL
243240
on click DeleteButton
244241
begin
245242
rest post to `udelete/` cat Email cat `/` cat Password cat `/` cat FilePath or

iwsy/resources/ecs/help.txt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
if mobile set Mobile else clear Mobile
2626
end
2727

28+
set style `position` of Container to `relative`
2829
set style `padding` of Container to `0 1em`
2930
set style `overflow-y` of Container to `scroll`
3031

@@ -70,23 +71,27 @@ GetPage:
7071
stop
7172

7273
!------------------------------------------------------------------------------
73-
! This is the Showndown extension.
74+
! This is the Showdown extension.
7475

7576
! Decorate is called for every occurrence of ~...~ in the topic data
7677
Decorate:
7778
put the payload of DecoratorCallback into Payload
78-
put the position of `:` in Payload into N
79-
if N is -1
80-
begin
81-
if Payload is `clear` put `<div style="height:1px;clear:both"></div>` into Payload
82-
end
79+
if Payload is `iwsy` put `<img src="resources/icon/iwsy.png" `
80+
cat `style="height:0.8em;position:relative;top:0.1em" />` into Payload
81+
else if Payload is `clear` put `<div style="height:1px;clear:both"></div>` into Payload
8382
else
8483
begin
85-
put left N of Payload into Function
86-
add 1 to N
87-
put from N of Payload into Data
88-
if Function is `img` gosub to ProcessImage
89-
else if Function is `page` gosub to ProcessPage
84+
put the position of `:` in Payload into N
85+
if N is greater than 0
86+
begin
87+
put left N of Payload into Function
88+
add 1 to N
89+
put from N of Payload into Data
90+
if Function is `m`
91+
put `<span style="font-family:monospace;color:darkred">` cat Data cat `</span>` into Payload
92+
else if Function is `img` gosub to ProcessImage
93+
else if Function is `page` gosub to ProcessPage
94+
end
9095
end
9196
set the payload of DecoratorCallback to Payload
9297
stop

iwsy/resources/ecs/iwsy.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ L2:
288288
set the content of NameEditor to empty
289289
put empty into CurrentScriptName
290290
gosub to CreateNewPresentation
291+
iwsy script Presentation
291292
put Presentation into LastSavedState
292293
gosub to UpdateCurrentSection
293294
end
@@ -439,6 +440,9 @@ L2:
439440
end
440441
else if Action is `block`
441442
begin
443+
set style `display` of FileManPanel to `none`
444+
set style `display` of HelpPanel to `none`
445+
set style `display` of Player to `block`
442446
put property `block` of Message into N
443447
iwsy block N
444448
end
@@ -484,7 +488,6 @@ CreateNewPresentation:
484488
set Item to array
485489
set property `blocks` of Presentation to Item
486490
set property `content` of Presentation to Item
487-
iwsy load Player Presentation
488491
return
489492

490493
SetupSteps:
@@ -653,14 +656,20 @@ SelectFile:
653656
put File into CurrentScriptName
654657
if UserRecord rest get Presentation from
655658
`/resources/users/` cat UserHome cat `/scripts/` cat File cat `?v=` cat now
656-
else get Presentation from storage as File
659+
! else get Presentation from storage as File
660+
send to StepsModule
661+
send to BlocksModule
662+
send to ContentModule
657663
put Presentation into LastSavedState
658664
gosub to UpdateCurrentSection
659665
gosub to SetStatusGreen
660666
set the content of Status to `Presentation '` cat File cat `' loaded`
661667
fork to ResetStatus
662668
set ShowRun
663-
iwsy load Player Presentation
669+
set style `display` of FileManPanel to `none`
670+
set style `display` of HelpPanel to `none`
671+
set style `display` of Player to `block`
672+
iwsy script Presentation
664673

665674
CloseBrowser:
666675
set style `background-color` of Overlay to `rgba(0,0,0,0.0)`
@@ -694,13 +703,8 @@ DoRunStop:
694703
set style `display` of Player to `block`
695704
put property `steps` of Presentation into Item
696705
if the json count of Item is 0 stop
697-
put element 0 of Item into Item
698-
if property `action` of Item is not `init`
699-
begin
700-
alert `The first step of a presentation must be an 'init' action.`
701-
stop
702-
end
703706
set Running
707+
set style `display` of FileManPanel to `none`
704708
gosub to ClearStepsButtons
705709
set attribute `src` of RunStop to `resources/icon/runstop.png`
706710

0 commit comments

Comments
 (0)