Skip to content

Commit 4713198

Browse files
authored
Merge pull request #105 from easycoder/dev
Start to code parent blocks
2 parents df03cb5 + b2bd28d commit 4713198

File tree

6 files changed

+91
-48
lines changed

6 files changed

+91
-48
lines changed

iwsy/iwsy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ const IWSY = (player, text) => {
752752
block.element = null;
753753
}
754754
}
755+
player.innerHTML = null;
755756
script.steps.forEach((step, index) => {
756757
step.index = index;
757758
if (typeof step.label !== `undefined`) {

iwsy/resources/ecs/blocks.txt

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
div Row
1111
div Cell
1212
div Empty
13-
input PropertyValue
13+
input PropertyInput
14+
select BlockSelect
1415
button EditButton
1516
button SaveButton
1617
img ShowBlock
@@ -21,14 +22,18 @@
2122
variable Blocks
2223
variable Block
2324
variable Block2
25+
variable BlockNames
26+
variable ParentBlock
2427
variable Defaults
2528
variable PropertyDefaults
2629
variable PropertyNames
2730
variable PropertyName
2831
variable SelectedBlock
2932
variable SavedIndex
33+
variable Parent
3034
variable Message
3135
variable N
36+
variable M
3237
variable NBlocks
3338

3439
put -1 into SelectedBlock
@@ -162,7 +167,7 @@ Restart:
162167
put element SelectedBlock of Blocks into Block
163168
put property `defaults` of Block into Defaults
164169
put the json count of PropertyNames into N
165-
set the elements of PropertyValue to N
170+
set the elements of PropertyInput to N
166171
put 0 into N
167172
while N is less than the json count of PropertyNames
168173
begin
@@ -172,10 +177,33 @@ Restart:
172177
create Cell in Row
173178
set the style of Cell to `width:8em;padding-left:0.5em`
174179
set the content of Cell to PropertyName
175-
index PropertyValue to N
176-
create PropertyValue in Row
177-
set the style of PropertyValue to `flex:1`
178-
set the text of PropertyValue to property PropertyName of Defaults
180+
if PropertyName is `parent`
181+
begin
182+
put property PropertyName of Defaults into Parent
183+
set BlockNames to array
184+
json add `` to BlockNames
185+
put 0 into M
186+
while M is less than the json count of Blocks
187+
begin
188+
if M is not SelectedBlock
189+
begin
190+
put element M of Blocks into ParentBlock
191+
put property `defaults` of ParentBlock into Defaults
192+
json add property `name` of Defaults to BlockNames
193+
end
194+
add 1 to M
195+
end
196+
create BlockSelect in Row
197+
set the style of BlockSelect to `flex:1;height:1.5em`
198+
set BlockSelect from BlockNames as Parent
199+
end
200+
else
201+
begin
202+
index PropertyInput to N
203+
create PropertyInput in Row
204+
set the style of PropertyInput to `flex:1;height:1.5em`
205+
set the text of PropertyInput to property PropertyName of Defaults
206+
end
179207
add 1 to N
180208
end
181209
create Row in Editor
@@ -221,9 +249,13 @@ SaveSelectedBlock:
221249
while N is less than the json count of PropertyNames
222250
begin
223251
put element N of PropertyNames into PropertyName
224-
index PropertyValue to N
225-
set property PropertyName of Defaults to the text of PropertyValue
226-
add 1 to N
252+
if PropertyName is `parent` set property PropertyName of Defaults to BlockSelect
253+
else
254+
begin
255+
index PropertyInput to N
256+
set property PropertyName of Defaults to the text of PropertyInput
257+
end
258+
add 1 to N
227259
end
228260
set the text of EditButton to property `name` of Defaults
229261
set property `defaults` of Block to Defaults

iwsy/resources/json/demo.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"background": "",
8787
"border": "",
8888
"borderRadius": "",
89-
"fontColor": "#ffffff",
89+
"fontColor": "#ccffff",
9090
"fontFamily": "",
9191
"fontSize": 40,
9292
"fontStyle": "",
@@ -188,7 +188,7 @@
188188
"title": "My demo presentation",
189189
"action": "init",
190190
"label": "",
191-
"aspect ratio": "16:9",
191+
"aspect ratio": "160:89",
192192
"background": "",
193193
"border": ""
194194
},

iwsy/resources/json/propertyDefaults.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "New block",
3+
"parent": "",
34
"left": 0,
45
"top": 0,
56
"width": "100%",

iwsy/resources/json/propertyNames.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
"name",
3+
"parent",
34
"left",
45
"top",
56
"width",

iwsy/resources/json/test.json

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"fontColor": "",
1818
"textAlign": "",
1919
"textMarginLeft": "",
20-
"textMarginTop": ""
20+
"textMarginTop": "",
21+
"parent": ""
2122
}
2223
},
2324
{
@@ -37,7 +38,8 @@
3738
"fontColor": "",
3839
"textAlign": "",
3940
"textMarginLeft": "",
40-
"textMarginTop": ""
41+
"textMarginTop": "",
42+
"parent": ""
4143
}
4244
},
4345
{
@@ -57,7 +59,8 @@
5759
"fontColor": "#dddd88",
5860
"textAlign": "center",
5961
"textMarginLeft": "",
60-
"textMarginTop": ""
62+
"textMarginTop": "",
63+
"parent": ""
6164
}
6265
},
6366
{
@@ -68,7 +71,7 @@
6871
"borderRadius": "",
6972
"fontColor": "#dddd88",
7073
"fontFamily": "",
71-
"fontSize": 80,
74+
"fontSize": 70,
7275
"fontStyle": "",
7376
"fontWeight": "",
7477
"height": 300,
@@ -77,7 +80,8 @@
7780
"textMarginLeft": "",
7881
"textMarginTop": "",
7982
"top": 300,
80-
"width": "100%"
83+
"width": "100%",
84+
"parent": ""
8185
}
8286
},
8387
{
@@ -86,43 +90,45 @@
8690
"background": "",
8791
"border": "",
8892
"borderRadius": "",
89-
"fontColor": "#ffffff",
93+
"fontColor": "#ccffff",
9094
"fontFamily": "",
91-
"fontSize": 50,
95+
"fontSize": 40,
9296
"fontStyle": "",
9397
"fontWeight": "",
9498
"height": 220,
9599
"left": 0,
96100
"textAlign": "center",
97101
"textMarginLeft": "",
98102
"textMarginTop": "",
99-
"top": 30,
100-
"width": "100%"
103+
"top": 20,
104+
"width": "100%",
105+
"parent": ""
101106
}
102107
},
103108
{
104109
"defaults": {
105110
"name": "main content",
106-
"left": 50,
107-
"top": 250,
108-
"width": 900,
109-
"height": 700,
110-
"background": "",
111-
"border": "",
111+
"background": "rgba(80,80,80,0.5)",
112+
"border": "1px solid white",
112113
"borderRadius": "",
114+
"fontColor": "yellow",
113115
"fontFamily": "",
114116
"fontSize": 50,
115-
"fontWeight": "",
116117
"fontStyle": "",
117-
"fontColor": "yellow",
118-
"textAlign": "",
118+
"fontWeight": "",
119+
"height": 700,
120+
"left": 50,
121+
"textAlign": "left",
119122
"textMarginLeft": 20,
120-
"textMarginTop": 20
123+
"textMarginTop": 20,
124+
"top": 250,
125+
"width": 900,
126+
"parent": ""
121127
}
122128
},
123129
{
124130
"defaults": {
125-
"name": "left",
131+
"name": "main content left",
126132
"background": "rgba(80,80,80,0.5)",
127133
"border": "1px solid white",
128134
"borderRadius": "",
@@ -133,16 +139,17 @@
133139
"fontWeight": "",
134140
"height": 700,
135141
"left": 50,
136-
"textAlign": "",
142+
"textAlign": "left",
137143
"textMarginLeft": 20,
138144
"textMarginTop": 20,
139145
"top": 250,
140-
"width": 400
146+
"width": 400,
147+
"parent": "main content"
141148
}
142149
},
143150
{
144151
"defaults": {
145-
"name": "right",
152+
"name": "main content right",
146153
"background": "rgba(80,80,80,0.5)",
147154
"border": "1px solid white",
148155
"borderRadius": "",
@@ -153,15 +160,20 @@
153160
"fontWeight": "",
154161
"height": 700,
155162
"left": 550,
156-
"textAlign": "",
163+
"textAlign": "left",
157164
"textMarginLeft": 20,
158165
"textMarginTop": 20,
159166
"top": 250,
160-
"width": 400
167+
"width": 400,
168+
"parent": "main content"
161169
}
162170
}
163171
],
164172
"content": [
173+
{
174+
"name": "blank",
175+
"content": ""
176+
},
165177
{
166178
"name": "a new dawn",
167179
"content": "# A new dawn is coming..."
@@ -172,23 +184,19 @@
172184
},
173185
{
174186
"name": "page 1 left",
175-
"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."
187+
"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 is tied to the desktop."
176188
},
177189
{
178190
"name": "page 1 right",
179191
"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."
180-
},
181-
{
182-
"name": "blank",
183-
"content": ""
184192
}
185193
],
186194
"steps": [
187195
{
188196
"title": "My demo presentation",
189197
"action": "init",
190198
"label": "",
191-
"aspect ratio": "16:9",
199+
"aspect ratio": "160:89",
192200
"background": "",
193201
"border": ""
194202
},
@@ -210,11 +218,11 @@
210218
"content": "a new dawn"
211219
},
212220
{
213-
"block": "left",
221+
"block": "main content left",
214222
"content": "page 1 left"
215223
},
216224
{
217-
"block": "right",
225+
"block": "main content right",
218226
"content": "page 1 right"
219227
}
220228
]
@@ -262,7 +270,7 @@
262270
"title": "Wait 3 seconds",
263271
"action": "pause",
264272
"label": "",
265-
"duration": 1
273+
"duration": 3
266274
},
267275
{
268276
"title": "Change title",
@@ -274,7 +282,7 @@
274282
},
275283
{
276284
"title": "Wait 1 second",
277-
"action": "hold",
285+
"action": "pause",
278286
"label": "",
279287
"duration": 1
280288
},
@@ -297,8 +305,8 @@
297305
"action": "fade up",
298306
"label": "",
299307
"blocks": [
300-
"left",
301-
"right"
308+
"main content left",
309+
"main content right"
302310
],
303311
"duration": 1
304312
}

0 commit comments

Comments
 (0)