Skip to content

Commit 85ec411

Browse files
authored
Merge pull request #99 from easycoder/dev
Various bug fixes and mods
2 parents 504425f + 50a0942 commit 85ec411

File tree

8 files changed

+226
-233
lines changed

8 files changed

+226
-233
lines changed

dist/plugins/iwsy.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,20 @@ const EasyCoder_IWSY = {
137137
script = program.getValue(command.script);
138138
try {
139139
script = JSON.parse(script);
140-
EasyCoder.iwsyFunctions = IWSY(player, script);
141140
} catch (err) {
142-
alert(`Badly formatted script`);
141+
alert(`iwsy load: Badly formatted script`);
143142
}
143+
EasyCoder.iwsyFunctions = IWSY(player, script);
144144
break;
145145
case `script`:
146146
script = program.getValue(command.script);
147147
try {
148148
script = JSON.parse(script);
149-
if (EasyCoder.iwsyFunctions) {
150-
EasyCoder.iwsyFunctions.setScript(script);
151-
}
152149
} catch (err) {
153-
alert(`Badly formatted script`);
150+
alert(`iwsy script: Badly formatted script`);
151+
}
152+
if (EasyCoder.iwsyFunctions) {
153+
EasyCoder.iwsyFunctions.setScript(script);
154154
}
155155
break;
156156
case `goto`:
@@ -159,6 +159,9 @@ const EasyCoder_IWSY = {
159159
}
160160
break;
161161
case `block`:
162+
if (EasyCoder.iwsyFunctions) {
163+
EasyCoder.iwsyFunctions.block(program.getValue(command.block));
164+
}
162165
break;
163166
case `run`:
164167
if (EasyCoder.iwsyFunctions) {

iwsy/iwsy.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,9 @@ const IWSY = (container, text) => {
744744
initScript();
745745
IWSY.plugins = {};
746746
preloadImages();
747-
doStep(script.steps[0]);
747+
if (script.steps.length > 0) {
748+
doStep(script.steps[0]);
749+
}
748750
return {
749751
setScript,
750752
gotoStep,

iwsy/resources/ecs/iwsy.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
img Save
2525
img RunStop
2626
img Delete
27-
img Cycle
2827
a Link
2928
module StepsModule
3029
module BlocksModule
@@ -138,11 +137,6 @@ L2:
138137
set the style of RunStop to `width:40px;margin-right:1.5em`
139138
set attribute `src` of RunStop to `resources/icon/run.png`
140139
set attribute `title` of RunStop to `Run`
141-
create Link in Buttons
142-
create Cycle in Link
143-
set the style of Cycle to `width:40px`
144-
set attribute `src` of Cycle to `resources/icon/cycle.png`
145-
set attribute `title` of Cycle to `Cycle screens`
146140

147141
create Status in Buttons
148142
if Mobile set the style of Status to `height:1em`
@@ -321,6 +315,7 @@ L2:
321315
put 0 into N
322316
gosub to SelectSection
323317
clear Running
318+
iwsy load Player Presentation
324319

325320
on message
326321
begin
@@ -351,33 +346,32 @@ L2:
351346

352347
CreateNewPresentation:
353348
set Presentation to object
354-
set Item to object
355-
set property `content` of Presentation to Item
356349
set Item to array
357350
set property `steps` of Presentation to Item
358351
set property `blocks` of Presentation to Item
352+
set property `content` of Presentation to Item
359353
return
360354

361355
SetupSteps:
362356
if StepsModule is not running
363357
begin
364-
rest get Script from `/resources/ecs/steps.txt`
358+
rest get Script from `/resources/ecs/steps.txt?v=` cat now
365359
run Script with StepsPanel and Presentation as StepsModule
366360
end
367361
return
368362

369363
SetupBlocks:
370364
if BlocksModule is not running
371365
begin
372-
rest get Script from `/resources/ecs/blocks.txt`
366+
rest get Script from `/resources/ecs/blocks.txt?v=` cat now
373367
run Script with BlocksPanel and Presentation as BlocksModule
374368
end
375369
return
376370

377371
SetupContent:
378372
if ContentModule is not running
379373
begin
380-
rest get Script from `/resources/ecs/content.txt`
374+
rest get Script from `/resources/ecs/content.txt?v=` cat now
381375
run Script with ContentPanel and Presentation as ContentModule
382376
end
383377
return
@@ -521,7 +515,7 @@ SelectFile:
521515
index File to the index of FileName
522516
set the content of NameEditor to File
523517
put File into CurrentScriptName
524-
if PasswordValid rest get Presentation from `/resources/json/` cat File
518+
if PasswordValid rest get Presentation from `/resources/json/` cat File cat `?v=` cat now
525519
else get Presentation from storage as File
526520
put Presentation into LastSavedState
527521
gosub to UpdateCurrentSection
@@ -559,10 +553,16 @@ DoRunStop:
559553
end
560554
else
561555
begin
556+
put property `steps` of Presentation into Item
557+
if the json count of Item is 0 stop
558+
put element 0 of Item into Item
559+
if property `action` of Item is not `init`
560+
begin
561+
alert `The first step of a presentation must be an 'init' action.`
562+
stop
563+
end
562564
set Running
563565
gosub to ClearStepsButtons
564-
put property `steps` of Presentation into Item
565-
if the json count of Item is 0 stop
566566
set attribute `src` of RunStop to `resources/icon/runstop.png`
567567

568568
put 0 into N
@@ -578,8 +578,8 @@ DoRunStop:
578578
set property `action` of Message to `running`
579579
send Message to StepsModule
580580
end
581-
582-
iwsy run then
581+
582+
iwsy run then
583583
begin
584584
gosub to ClearStepsButtons
585585
set attribute `src` of RunStop to `resources/icon/run.png`

iwsy/resources/ecs/steps.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
variable Response
6262
variable Message
6363
variable Running
64+
variable SavedIndex
6465
variable N
6566
variable B
6667

@@ -170,9 +171,10 @@ Restart:
170171
end
171172
on click StepButton
172173
begin
174+
put the index of StepButton into SavedIndex
173175
gosub to SaveCurrentStep
174176
put SelectedStep into N
175-
put the index of StepButton into SelectedStep
177+
put SavedIndex into SelectedStep
176178
if SelectedStep is N
177179
begin
178180
index Editor to N
@@ -246,7 +248,6 @@ Restart:
246248
json add `goto` to ActionNames
247249
json add `load` to ActionNames
248250
set InitProperties to array
249-
json add `title` to InitProperties
250251
json add `aspect ratio` to InitProperties
251252
json add `background` to InitProperties
252253
json add `border` to InitProperties
@@ -380,7 +381,8 @@ ReloadStepEditor:
380381
if Response
381382
begin
382383
index StepButton to SelectedStep
383-
set property `title` of CurrentStep to TitleInput
384+
index TitleInput to SelectedStep
385+
set property `title` of CurrentStep to the text of TitleInput
384386
put the selected item in ActionSelect into Action
385387
gosub to CreateNewAction
386388
clear Table
@@ -702,7 +704,7 @@ CreateNewAction:
702704
while N is less than the json count of InitProperties
703705
begin
704706
put element N of InitProperties into InitProperty
705-
set property InitProperty of CurrentStep to empty
707+
set property InitProperty of CurrentStep to empty
706708
add 1 to N
707709
end
708710
set property `aspect ratio` of CurrentStep to `WW:HH`

iwsy/resources/json/demo.json

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
{
2+
"blocks": [
3+
{
4+
"name": "center title",
5+
"background": "",
6+
"border": "",
7+
"borderRadius": "",
8+
"fontColor": "#dddd88",
9+
"fontFamily": "",
10+
"fontSize": 80,
11+
"fontStyle": "",
12+
"fontWeight": "",
13+
"height": 300,
14+
"left": 0,
15+
"textAlign": "center",
16+
"textMarginLeft": "",
17+
"textMarginTop": "",
18+
"top": 300,
19+
"width": "100%"
20+
},
21+
{
22+
"name": "top title",
23+
"background": "",
24+
"border": "",
25+
"borderRadius": "",
26+
"fontColor": "#ffffff",
27+
"fontFamily": "",
28+
"fontSize": 50,
29+
"fontStyle": "",
30+
"fontWeight": "",
31+
"height": 300,
32+
"left": 0,
33+
"textAlign": "center",
34+
"textMarginLeft": "",
35+
"textMarginTop": "",
36+
"top": 30,
37+
"width": "100%"
38+
},
39+
{
40+
"name": "left",
41+
"background": "rgba(80,80,80,0.5)",
42+
"border": "1px solid gray",
43+
"borderRadius": "",
44+
"fontColor": "yellow",
45+
"fontFamily": "",
46+
"fontSize": 50,
47+
"fontStyle": "",
48+
"fontWeight": "",
49+
"height": 700,
50+
"left": 50,
51+
"textAlign": "",
52+
"textMarginLeft": 20,
53+
"textMarginTop": 20,
54+
"top": 250,
55+
"width": 400
56+
},
57+
{
58+
"name": "right",
59+
"background": "rgba(80,80,80,0.5)",
60+
"border": "1px solid gray",
61+
"borderRadius": "",
62+
"fontColor": "yellow",
63+
"fontFamily": "",
64+
"fontSize": 50,
65+
"fontStyle": "",
66+
"fontWeight": "",
67+
"height": 700,
68+
"left": 550,
69+
"textAlign": "",
70+
"textMarginLeft": 20,
71+
"textMarginTop": 20,
72+
"top": 250,
73+
"width": 400
74+
},
75+
{
76+
"name": "main content",
77+
"background": "",
78+
"border": "",
79+
"borderRadius": "",
80+
"fontColor": "yellow",
81+
"fontFamily": "",
82+
"fontSize": 50,
83+
"fontStyle": "",
84+
"fontWeight": "",
85+
"height": 800,
86+
"left": 50,
87+
"textAlign": "",
88+
"textMarginLeft": 10,
89+
"textMarginTop": "",
90+
"top": 300,
91+
"width": "100%"
92+
}
93+
],
94+
"content": [
95+
{
96+
"name": "iwannashowyou",
97+
"content": "# I Wanna Show You%0a%0a### _knockout web-based presentations_"
98+
},
99+
{
100+
"name": "page 1 left",
101+
"content": "### PowerPoint%0a%0a - is slide-based%0a - is a PC application%0a - is hard to embed%0a%0aPowerPoint is organized mainly around static text blocks and tied to the desktop."
102+
},
103+
{
104+
"name": "page 1 right",
105+
"content": "### I Wanna Show You%0a - is step based%0a - runs in your browser%0a - is fully embeddable%0a%0aIWannaShowYou is built to handle color, movement and the online environment."
106+
}
107+
],
108+
"steps": [
109+
{
110+
"title": "My demo presentation",
111+
"action": "init",
112+
"label": "",
113+
"aspect ratio": "16:9",
114+
"background": "url('resources/img/SemoigoDawn.jpg')",
115+
"border": "1px solid gray"
116+
},
117+
{
118+
"title": "Pause before starting",
119+
"action": "pause",
120+
"label": "",
121+
"duration": 1
122+
},
123+
{
124+
"title": "Setup main title and initial content",
125+
"action": "set content",
126+
"label": "",
127+
"blocks": [
128+
{
129+
"block": "center title",
130+
"content": "iwannashowyou"
131+
},
132+
{
133+
"block": "left",
134+
"content": "page 1 left"
135+
},
136+
{
137+
"block": "right",
138+
"content": "page 1 right"
139+
}
140+
]
141+
},
142+
{
143+
"title": "Fade up title",
144+
"action": "fade up",
145+
"label": "",
146+
"blocks": [
147+
"center title"
148+
],
149+
"duration": 1
150+
},
151+
{
152+
"title": "Wait 3 seconds",
153+
"action": "hold",
154+
"label": "",
155+
"duration": 3
156+
},
157+
{
158+
"title": "Move the title to the top",
159+
"action": "transition",
160+
"label": "",
161+
"target": "top title",
162+
"duration": 2,
163+
"block": "center title"
164+
},
165+
{
166+
"title": "Wait 1 second",
167+
"action": "hold",
168+
"label": "",
169+
"duration": 1
170+
},
171+
{
172+
"title": "Fade up first page",
173+
"action": "fade up",
174+
"label": "",
175+
"blocks": [
176+
"left",
177+
"right"
178+
],
179+
"duration": 1
180+
}
181+
]
182+
}

0 commit comments

Comments
 (0)