Skip to content

Commit 6a8f145

Browse files
authored
Merge pull request #97 from easycoder/dev
Prepare for 'show block'
2 parents 84a2515 + a022d3b commit 6a8f145

File tree

7 files changed

+124
-22
lines changed

7 files changed

+124
-22
lines changed

dist/plugins/iwsy.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ const EasyCoder_IWSY = {
5959
target
6060
});
6161
return true;
62+
case `block`:
63+
const block = compiler.getNextValue();
64+
compiler.addCommand({
65+
domain: `iwsy`,
66+
keyword: `iwsy`,
67+
lino,
68+
action,
69+
block
70+
});
71+
return true;
6272
case `run`:
6373
const pc = compiler.getPc();
6474
compiler.next();
@@ -148,6 +158,8 @@ const EasyCoder_IWSY = {
148158
EasyCoder.iwsyFunctions.gotoStep(program.getValue(command.target));
149159
}
150160
break;
161+
case `block`:
162+
break;
151163
case `run`:
152164
if (EasyCoder.iwsyFunctions) {
153165
EasyCoder.iwsyFunctions.run(function() {

iwsy/resources/ecs/blocks.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
div Table
1010
div Row
1111
div Cell
12+
div Empty
1213
input PropertyValue
1314
button EditButton
1415
button SaveButton
16+
img ShowBlock
1517
img AddBlock
18+
img Up
1619
img DeleteBlock
1720
a Link
1821
variable Blocks
1922
variable Block
23+
variable Block2
2024
variable PropertyDefaults
2125
variable PropertyNames
2226
variable PropertyName
@@ -73,25 +77,45 @@ Restart:
7377
end
7478

7579
put the json count of Blocks into NBlocks
80+
set the elements of ShowBlock to NBlocks
7681
set the elements of EditButton to NBlocks
7782
set the elements of SaveButton to NBlocks
7883
set the elements of Editor to NBlocks
84+
set the elements of Up to NBlocks
7985
set the elements of DeleteBlock to NBlocks
8086
create Table in Panel
8187
set the style of Table to `width:100%`
8288
put 0 into N
8389
while N is less than NBlocks
8490
begin
8591
index EditButton to N
92+
index Up to N
8693
index DeleteBlock to N
8794
index Editor to N
8895
create Row in Table
8996
create Cell in Row
9097
set the style of Cell to `width:100%;display:flex`
98+
create Link in Cell
99+
index ShowBlock to N
100+
create ShowBlock in Link
101+
set the style of ShowBlock to `width:1em;margin:0.1em 0.2em 0 0`
102+
set attribute `src` of ShowBlock to `resources/icon/binoculars.png`
91103
create EditButton in Cell
92104
set the style of EditButton to `flex:1`
93105
put element N of Blocks into Block
94106
set the text of EditButton to property `name` of Block
107+
if N is 0
108+
begin
109+
create Empty in Cell
110+
set the style of Empty to `width:1em;margin:0.2em 0 0 0.2em`
111+
end
112+
else
113+
begin
114+
create Link in Cell
115+
create Up in Link
116+
set the style of Up to `width:1em;margin:0.2em 0 0 0.2em`
117+
set attribute `src` of Up to `/resources/icon/up.png`
118+
end
95119
create Link in Cell
96120
create DeleteBlock in Link
97121
set the style of DeleteBlock to `width:1em;margin:0.2em 0 0 0.2em`
@@ -100,6 +124,13 @@ Restart:
100124
set the style of Editor to `margin:0.5em;border:1px solid black;padding:0.2em;display:none`
101125
add 1 to N
102126
end
127+
on click ShowBlock
128+
begin
129+
set Message to object
130+
set property `action` of Message to `block`
131+
set property `block` of Message to the index of ShowBlock
132+
send Message to parent
133+
end
103134
on click EditButton
104135
begin
105136
put the index of EditButton into SavedIndex
@@ -155,6 +186,18 @@ Restart:
155186
set style `display` of Editor to `none`
156187
end
157188
end
189+
on click Up
190+
begin
191+
put the index of Up into N
192+
put element N of Blocks into Block
193+
take 1 from N
194+
put element N of Blocks into Block2
195+
set element N of Blocks to Block
196+
add 1 to N
197+
set element N of Blocks to Block2
198+
set property `blocks` of Presentation to Blocks
199+
go to Restart
200+
end
158201
on click DeleteBlock
159202
begin
160203
put the index of DeleteBlock into N

iwsy/resources/ecs/content.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
div Table
1010
div Row
1111
div Cell
12+
div Empty
1213
input ItemNameInput
1314
textarea TextArea
1415
button EditButton
1516
button SaveButton
1617
img AddItem
18+
img Up
1719
img DeleteItem
1820
a Link
1921
variable Items
2022
variable Item
23+
variable Item2
2124
variable ItemNames
2225
variable ItemName
2326
variable SelectedItem
@@ -77,6 +80,7 @@ Restart:
7780
set the elements of EditButton to NumItems
7881
set the elements of Editor to NumItems
7982
set the elements of SaveButton to NumItems
83+
set the elements of Up to NumItems
8084
set the elements of DeleteItem to NumItems
8185
set the elements of ItemNameInput to NumItems
8286
set the elements of TextArea to NumItems
@@ -86,6 +90,7 @@ Restart:
8690
while N is less than the elements of EditButton
8791
begin
8892
index EditButton to N
93+
index Up to N
8994
index DeleteItem to N
9095
index Editor to N
9196
index ItemNameInput to N
@@ -97,6 +102,18 @@ Restart:
97102
create EditButton in Cell
98103
set the style of EditButton to `flex:1`
99104
set the text of EditButton to ItemName
105+
if N is 0
106+
begin
107+
create Empty in Cell
108+
set the style of Empty to `width:1em;margin:0.2em 0 0 0.2em`
109+
end
110+
else
111+
begin
112+
create Link in Cell
113+
create Up in Link
114+
set the style of Up to `width:1em;margin:0.2em 0 0 0.2em`
115+
set attribute `src` of Up to `/resources/icon/up.png`
116+
end
100117
create Link in Cell
101118
create DeleteItem in Link
102119
set the style of DeleteItem to `width:1em;margin:0.2em 0 0 0.2em`
@@ -157,6 +174,18 @@ Restart:
157174
set style `display` of Editor to `none`
158175
end
159176
end
177+
on click Up
178+
begin
179+
put the index of Up into N
180+
put element N of Items into Item
181+
take 1 from N
182+
put element N of Items into Item2
183+
set element N of Items to Item
184+
add 1 to N
185+
set element N of Items to Item2
186+
set property `content` of Presentation to Items
187+
go to Restart
188+
end
160189
on click DeleteItem
161190
begin
162191
put the index of DeleteItem into N

iwsy/resources/ecs/iwsy.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@ L2:
340340
else if Section is 1 set style `display` of BlocksPanel to `block`
341341
else if Section is 2 set style `display` of ContentPanel to `block`
342342
end
343+
else if Action is `block`
344+
begin
345+
put property `block` of Message into N
346+
alert `Show block ` cat N
347+
iwsy block N
348+
end
343349
end
344350
stop
345351

iwsy/resources/icon/up.png

7.89 KB
Loading

iwsy/resources/json/test.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,25 @@
3737
"width": "100%"
3838
},
3939
{
40-
"name": "main content",
41-
"background": "",
42-
"border": "",
40+
"name": "left",
41+
"background": "rgba(80,80,80,0.5)",
42+
"border": "1px solid gray",
4343
"borderRadius": "",
4444
"fontColor": "yellow",
4545
"fontFamily": "",
4646
"fontSize": 50,
4747
"fontStyle": "",
4848
"fontWeight": "",
49-
"height": 800,
49+
"height": 700,
5050
"left": 50,
5151
"textAlign": "",
52-
"textMarginLeft": 10,
53-
"textMarginTop": "",
54-
"top": 300,
55-
"width": "100%"
52+
"textMarginLeft": 20,
53+
"textMarginTop": 20,
54+
"top": 250,
55+
"width": 400
5656
},
5757
{
58-
"name": "left",
58+
"name": "right",
5959
"background": "rgba(80,80,80,0.5)",
6060
"border": "1px solid gray",
6161
"borderRadius": "",
@@ -64,31 +64,31 @@
6464
"fontSize": 50,
6565
"fontStyle": "",
6666
"fontWeight": "",
67-
"height": 650,
68-
"left": 50,
67+
"height": 700,
68+
"left": 550,
6969
"textAlign": "",
7070
"textMarginLeft": 20,
7171
"textMarginTop": 20,
72-
"top": 300,
72+
"top": 250,
7373
"width": 400
7474
},
7575
{
76-
"name": "right",
77-
"background": "rgba(80,80,80,0.5)",
78-
"border": "1px solid gray",
76+
"name": "main content",
77+
"background": "",
78+
"border": "",
7979
"borderRadius": "",
8080
"fontColor": "yellow",
8181
"fontFamily": "",
8282
"fontSize": 50,
8383
"fontStyle": "",
8484
"fontWeight": "",
85-
"height": 650,
86-
"left": 550,
85+
"height": 800,
86+
"left": 50,
8787
"textAlign": "",
88-
"textMarginLeft": 20,
89-
"textMarginTop": 20,
88+
"textMarginLeft": 10,
89+
"textMarginTop": "",
9090
"top": 300,
91-
"width": 400
91+
"width": "100%"
9292
}
9393
],
9494
"content": [
@@ -98,11 +98,11 @@
9898
},
9999
{
100100
"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 a dated product organized mainly around static text blocks and tied to the desktop."
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."
102102
},
103103
{
104104
"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 a modern product built to handle color, movement and a mobile environment."
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."
106106
}
107107
],
108108
"steps": [

js/plugins/iwsy.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ const EasyCoder_IWSY = {
5959
target
6060
});
6161
return true;
62+
case `block`:
63+
const block = compiler.getNextValue();
64+
compiler.addCommand({
65+
domain: `iwsy`,
66+
keyword: `iwsy`,
67+
lino,
68+
action,
69+
block
70+
});
71+
return true;
6272
case `run`:
6373
const pc = compiler.getPc();
6474
compiler.next();
@@ -148,6 +158,8 @@ const EasyCoder_IWSY = {
148158
EasyCoder.iwsyFunctions.gotoStep(program.getValue(command.target));
149159
}
150160
break;
161+
case `block`:
162+
break;
151163
case `run`:
152164
if (EasyCoder.iwsyFunctions) {
153165
EasyCoder.iwsyFunctions.run(function() {

0 commit comments

Comments
 (0)