5
5
import div Panel and variable Presentation
6
6
7
7
div Editor
8
+ div Title
9
+ div Table
8
10
div Row
9
11
div Cell
10
- div Title
11
- table Table
12
- tr TR
13
- td TD
14
- span BlockNameSpan
15
- input BlockNameInput
16
12
input PropertyValue
17
13
button EditButton
18
14
button SaveButton
21
17
a Link
22
18
variable Blocks
23
19
variable Block
24
- variable BlockNames
25
- variable BlockName
20
+ variable PropertyDefaults
26
21
variable PropertyNames
27
22
variable PropertyName
28
- variable Properties
29
23
variable SelectedBlock
30
- variable Action
31
24
variable Message
32
25
variable N
33
- variable B
26
+ variable NBlocks
34
27
35
28
put -1 into SelectedBlock
36
29
37
- rest get Properties from `/resources/json/properties .json`
38
- put the json keys of Properties into PropertyNames
30
+ rest get PropertyNames from `/resources/json/propertyNames .json`
31
+ rest get PropertyDefaults from `/resources/json/propertyDefaults.json`
39
32
40
33
on message go to Start
41
34
set ready
50
43
51
44
Restart:
52
45
put property `blocks` of Presentation into Blocks
53
- put the json keys of Blocks into BlockNames
54
-
55
46
clear Panel
56
47
create Row in Panel
57
48
set the style of Row to `display:flex`
@@ -67,98 +58,72 @@ Restart:
67
58
set attribute `src` of AddBlock to `resources/icon/plus.png`
68
59
on click AddBlock
69
60
begin
70
- put prompt `Name of new block:` with `new block` into BlockName
71
61
set Block to object
72
62
put 0 into N
73
63
while N is less than the json count of PropertyNames
74
64
begin
75
65
put element N of PropertyNames into PropertyName
76
- set property PropertyName of Block to property PropertyName of Properties
66
+ set property PropertyName of Block to property PropertyName of PropertyDefaults
77
67
add 1 to N
78
68
end
79
- set property BlockName of Blocks to Block
69
+ json add Block to Blocks
80
70
set property `blocks` of Presentation to Blocks
81
71
go to Restart
82
72
end
83
73
84
- put the json count of BlockNames into N
85
- set the elements of BlockNameSpan to N
86
- set the elements of BlockNameInput to N
87
- set the elements of EditButton to N
88
- set the elements of SaveButton to N
89
- set the elements of Editor to N
90
- set the elements of DeleteBlock to N
74
+ put the json count of Blocks into NBlocks
75
+ set the elements of EditButton to NBlocks
76
+ set the elements of SaveButton to NBlocks
77
+ set the elements of Editor to NBlocks
78
+ set the elements of DeleteBlock to NBlocks
91
79
create Table in Panel
92
80
set the style of Table to `width:100%`
93
- put 0 into B
94
- while B is less than the elements of EditButton
81
+ put 0 into N
82
+ while N is less than NBlocks
95
83
begin
96
- put element B of BlockNames into BlockName
97
- create TR in Table
98
- create TD in TR
99
- set the style of TD to `width:8em;border:1px solid black;padding-left:0.5em`
100
- index BlockNameSpan to B
101
- create BlockNameSpan in TD
102
- set the content of BlockNameSpan to BlockName
103
- index BlockNameInput to B
104
- create BlockNameInput in TD
105
- set the style of BlockNameInput to `width:100%;display:none`
106
- set the content of BlockNameInput to BlockName
107
- create TD in TR
108
- set the style of TD to `border:1px solid black`
109
- index EditButton to B
110
- index DeleteBlock to B
111
- index Editor to B
112
- create Row in TD
113
- set the style of Row to `display:flex`
114
- create EditButton in Row
115
- set the style of EditButton to `flex:1`
116
- set the text of EditButton to `Edit`
84
+ index EditButton to N
85
+ index DeleteBlock to N
86
+ index Editor to N
87
+ create Row in Table
117
88
create Cell in Row
118
- set the style of Cell to `width:1.4em;text-align:center`
89
+ set the style of Cell to `width:100%;display:flex`
90
+ create EditButton in Cell
91
+ set the style of EditButton to `flex:1`
92
+ put element N of Blocks into Block
93
+ set the text of EditButton to property `name` of Block
119
94
create Link in Cell
120
95
create DeleteBlock in Link
121
- set the style of DeleteBlock to `width:1em;margin-top :0.1em`
96
+ set the style of DeleteBlock to `width:1em;margin:0.1em 0 0 0.2em `
122
97
set attribute `src` of DeleteBlock to `/resources/icon/stop.png`
123
- create Editor in TD
124
- set the style of Editor to `display:none`
125
- add 1 to B
98
+ create Editor in Row
99
+ set the style of Editor to `margin:0.5em;border:1px solid black;padding:0.2em; display:none`
100
+ add 1 to N
126
101
end
127
102
on click EditButton
128
103
begin
129
104
gosub to SaveSelectedBlock
130
105
put the index of EditButton into SelectedBlock
131
106
put 0 into N
132
- while N is less than the json count of BlockNames
107
+ while N is less than NBlocks
133
108
begin
134
- index EditButton to N
135
- set style `background` of EditButton to ``
136
- if N is not SelectedBlock set the text of EditButton to `Edit`
137
- index BlockNameSpan to N
138
- index BlockNameInput to N
139
- set the content of BlockNameSpan to the text of BlockNameInput
140
- set style `display` of BlockNameSpan to `inline`
141
- set style `display` of BlockNameInput to `none`
142
- index Editor to N
143
- set style `display` of Editor to `none`
109
+ if N is not SelectedBlock
110
+ begin
111
+ index EditButton to N
112
+ set style `background` of EditButton to ``
113
+ index Editor to N
114
+ set style `display` of Editor to `none`
115
+ clear Editor
116
+ end
144
117
add 1 to N
145
118
end
146
119
index EditButton to SelectedBlock
147
- put the text of EditButton into Action
148
- if Action is `Edit `
120
+ index Editor to SelectedBlock
121
+ if style `display` of Editor is `none `
149
122
begin
150
123
set style `background` of EditButton to `lightgray`
151
- set the text of EditButton to `Properties`
152
- index BlockNameSpan to SelectedBlock
153
- index BlockNameInput to SelectedBlock
154
124
index SaveButton to SelectedBlock
155
- set style `display` of BlockNameSpan to `none`
156
- set style `display` of BlockNameInput to `inline`
157
- index Editor to SelectedBlock
158
125
set style `display` of Editor to `block`
159
- clear Editor
160
- put element SelectedBlock of BlockNames into BlockName
161
- put property BlockName of Blocks into Block
126
+ put element SelectedBlock of Blocks into Block
162
127
put the json count of PropertyNames into N
163
128
set the elements of PropertyValue to N
164
129
put 0 into N
@@ -173,7 +138,7 @@ Restart:
173
138
index PropertyValue to N
174
139
create PropertyValue in Row
175
140
set the style of PropertyValue to `flex:1`
176
- set the content of PropertyValue to property PropertyName of Block
141
+ set the text of PropertyValue to property PropertyName of Block
177
142
add 1 to N
178
143
end
179
144
create Row in Editor
@@ -185,17 +150,14 @@ Restart:
185
150
else
186
151
begin
187
152
gosub to SaveSelectedBlock
188
- set the text of EditButton to `Edit`
189
153
clear Editor
190
154
set style `display` of Editor to `none`
191
155
end
192
156
end
193
157
on click DeleteBlock
194
158
begin
195
159
put the index of DeleteBlock into N
196
- put element N of BlockNames into BlockName
197
- put property `blocks` of Presentation into Blocks
198
- json delete property BlockName of Blocks
160
+ json delete element N of Blocks
199
161
set property `blocks` of Presentation to Blocks
200
162
go to Restart
201
163
end
@@ -204,24 +166,16 @@ Restart:
204
166
! Save the seleced block
205
167
SaveSelectedBlock:
206
168
if SelectedBlock is -1 return
169
+ put element SelectedBlock of Blocks into Block
207
170
put 0 into N
208
171
while N is less than the json count of PropertyNames
209
172
begin
210
173
put element N of PropertyNames into PropertyName
211
174
index PropertyValue to N
212
- set property PropertyName of Block to PropertyValue
175
+ set property PropertyName of Block to the text of PropertyValue
213
176
add 1 to N
214
177
end
215
- index BlockNameInput to SelectedBlock
216
- put element SelectedBlock of BlockNames into BlockName
217
- if BlockNameInput is not BlockName
218
- begin
219
- print `deleting`
220
- json delete property BlockName of Blocks
221
- put BlockNameInput into BlockName
222
- set element SelectedBlock of BlockNames to BlockName
223
- end
224
- set property BlockName of Blocks to Block
178
+ set element SelectedBlock of Blocks to Block
225
179
set property `blocks` of Presentation to Blocks
226
180
227
181
! Tell the parent to refresh the script
0 commit comments