Skip to content

Redesign block & content structure #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions iwsy/iwsy.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,13 @@ const IWSY = (container, text) => {
if (!block.element) {
createBlock(block);
}
const content = script.content[item.content];
const converter = new showdown.Converter();
block.textPanel.innerHTML = converter.makeHtml(content.split(`%0a`).join(`\n`));
for (const text of script.content) {
if (text.name === item.content) {
const converter = new showdown.Converter();
block.textPanel.innerHTML =
converter.makeHtml(text.content.split(`%0a`).join(`\n`));
}
}
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions iwsy/resources/ecs/blocks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
variable PropertyNames
variable PropertyName
variable SelectedBlock
variable SavedIndex
variable Message
variable N
variable NBlocks
Expand Down Expand Up @@ -93,16 +94,17 @@ Restart:
set the text of EditButton to property `name` of Block
create Link in Cell
create DeleteBlock in Link
set the style of DeleteBlock to `width:1em;margin:0.1em 0 0 0.2em`
set the style of DeleteBlock to `width:1em;margin:0.2em 0 0 0.2em`
set attribute `src` of DeleteBlock to `/resources/icon/stop.png`
create Editor in Row
set the style of Editor to `margin:0.5em;border:1px solid black;padding:0.2em;display:none`
add 1 to N
end
on click EditButton
begin
gosub to SaveSelectedBlock
put the index of EditButton into SelectedBlock
put the index of EditButton into SavedIndex
gosub to SaveSelectedBlock
put SavedIndex into SelectedBlock
put 0 into N
while N is less than NBlocks
begin
Expand All @@ -118,10 +120,10 @@ Restart:
end
index EditButton to SelectedBlock
index Editor to SelectedBlock
index SaveButton to SelectedBlock
if style `display` of Editor is `none`
begin
set style `background` of EditButton to `lightgray`
index SaveButton to SelectedBlock
set style `display` of Editor to `block`
put element SelectedBlock of Blocks into Block
put the json count of PropertyNames into N
Expand Down Expand Up @@ -149,7 +151,6 @@ Restart:
end
else
begin
gosub to SaveSelectedBlock
clear Editor
set style `display` of Editor to `none`
end
Expand All @@ -166,6 +167,7 @@ Restart:
! Save the seleced block
SaveSelectedBlock:
if SelectedBlock is -1 return
index EditButton to SelectedBlock
put element SelectedBlock of Blocks into Block
put 0 into N
while N is less than the json count of PropertyNames
Expand All @@ -175,6 +177,7 @@ SaveSelectedBlock:
set property PropertyName of Block to the text of PropertyValue
add 1 to N
end
set the text of EditButton to property `name` of Block
set element SelectedBlock of Blocks to Block
set property `blocks` of Presentation to Blocks

Expand Down
162 changes: 79 additions & 83 deletions iwsy/resources/ecs/content.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
import div Panel and variable Presentation

div Editor
div Title
div Table
div Row
div Cell
div Title
table Table
tr TR
td TD
span ItemNameSpan
input ItemNameInput
textarea TextArea
button EditButton
Expand All @@ -24,10 +21,11 @@
variable ItemNames
variable ItemName
variable SelectedItem
variable Action
variable SavedIndex
variable Message
variable N
variable B
variable NumItems
variable Content

put -1 into SelectedItem

Expand All @@ -44,7 +42,14 @@ Start:

Restart:
put property `content` of Presentation into Items
put the json keys of Items into ItemNames
set ItemNames to array
put 0 into N
while N is less than the json count of Items
begin
put element N of Items into Item
json add property `name` of Item to ItemNames
add 1 to N
end

clear Panel
create Row in Panel
Expand All @@ -68,99 +73,89 @@ Restart:
go to Restart
end

put the json keys of Items into ItemNames
put the json count of ItemNames into N
set the elements of ItemNameSpan to N
set the elements of ItemNameInput to N
set the elements of EditButton to N
set the elements of Editor to N
set the elements of SaveButton to N
set the elements of DeleteItem to N
set the elements of TextArea to N
put the json count of Items into NumItems
set the elements of EditButton to NumItems
set the elements of Editor to NumItems
set the elements of SaveButton to NumItems
set the elements of DeleteItem to NumItems
set the elements of ItemNameInput to NumItems
set the elements of TextArea to NumItems
create Table in Panel
set the style of Table to `width:100%`
put 0 into B
while B is less than the elements of EditButton
put 0 into N
while N is less than the elements of EditButton
begin
index EditButton to B
index DeleteItem to B
index ItemNameSpan to B
index ItemNameInput to B
put element B of ItemNames into ItemName
create TR in Table
create TD in TR
set the style of TD to `width:8em;border:1px solid black`
index ItemNameSpan to B
create ItemNameSpan in TD
set the content of ItemNameSpan to ItemName
index ItemNameInput to B
create ItemNameInput in TD
set the style of ItemNameInput to `width:100%;display:none`
set the content of ItemNameInput to ItemName
create TD in TR
set the style of TD to `border:1px solid black`
index Editor to B
create Row in TD
set the style of Row to `display:flex`
create EditButton in Row
set the style of EditButton to `flex:1`
set the text of EditButton to `Edit`
index EditButton to N
index DeleteItem to N
index Editor to N
index ItemNameInput to N
put element N of Items into Item
put property `name` of Item into ItemName
create Row in Table
create Cell in Row
set the style of Cell to `width:1.4em;text-align:center`
set the style of Cell to `width:100%;display:flex`
create EditButton in Cell
set the style of EditButton to `flex:1`
set the text of EditButton to ItemName
create Link in Cell
create DeleteItem in Link
set the style of DeleteItem to `width:1em;margin-top:0.1em`
set the style of DeleteItem to `width:1em;margin:0.2em 0 0 0.2em`
set attribute `src` of DeleteItem to `/resources/icon/stop.png`
create Editor in TD
set the style of Editor to `display:none`
add 1 to B
create Editor in Row
set the style of Editor to `margin:0.5em;border:1px solid black;padding:0.2em;display:none`
add 1 to N
end
on click EditButton
begin
gosub to SaveSelectedItem
put the index of EditButton into SelectedItem
put the text of EditButton into Action
put the index of EditButton into SavedIndex
gosub to SaveSelectedItem
put SavedIndex into SelectedItem
put 0 into N
while N is less than the json count of ItemNames
while N is less than NumItems
begin
index EditButton to N
set style `background` of EditButton to ``
set the text of EditButton to `Edit`
index ItemNameSpan to N
index ItemNameInput to N
set the content of ItemNameSpan to the text of ItemNameInput
set style `display` of ItemNameSpan to `inline`
set style `display` of ItemNameInput to `none`
index Editor to N
set style `display` of Editor to `none`
if N is not SelectedItem
begin
index EditButton to N
set style `background` of EditButton to ``
index Editor to N
set style `display` of Editor to `none`
clear Editor
end
add 1 to N
end
index EditButton to SelectedItem
if Action is `Edit`
index ItemNameInput to SelectedItem
index TextArea to SelectedItem
index SaveButton to SelectedItem
index Editor to SelectedItem
if style `display` of Editor is `none`
begin
put element SelectedItem of Items into Item
set style `background` of EditButton to `lightgray`
set the text of EditButton to `Close`
index ItemNameSpan to SelectedItem
index ItemNameInput to SelectedItem
index TextArea to SelectedItem
index SaveButton to SelectedItem
set style `display` of ItemNameSpan to `none`
set style `display` of ItemNameInput to `inline`
index Editor to SelectedItem
create Row in Editor
set the style of Row to `display:flex`
create Cell in Row
set the style of Cell to `width:5em`
set the content of Cell to `Name`
create ItemNameInput in Row
set the style of ItemNameInput to `flex:1`
set the text of ItemNameInput to property `name` of Item
set style `display` of Editor to `block`
clear Editor
create TextArea in Editor
set the style of TextArea to `width:100%;max-width:100%;height:8em`
put element SelectedItem of ItemNames into ItemName
put property ItemName of Items into Item
replace `%0a` with newline in Item
set the content of TextArea to Item
put property `content` of Item into Content
replace `%0a` with newline in Content
set the content of TextArea to Content
create SaveButton in Editor
set the style of SaveButton to `width:100%`
set the text of SaveButton to `Save`
on click SaveButton gosub to SaveSelectedItem
end
else gosub to SaveSelectedItem
else
begin
clear Editor
set style `display` of Editor to `none`
end
end
on click DeleteItem
begin
Expand All @@ -177,14 +172,15 @@ Restart:
SaveSelectedItem:
if SelectedItem is -1 return
index ItemNameInput to SelectedItem
index EditButton to SelectedItem
put element SelectedItem of Items into Item
set property `name` of Item to the text of ItemNameInput
set the text of EditButton to the text of ItemNameInput
index TextArea to SelectedItem
put the content of TextArea into Item
replace newline with `%0a` in Item
set property ItemName of Items to Item
if ItemNameInput is not ItemName json delete property ItemName of Items
put ItemNameInput into ItemName
set element SelectedItem of ItemNames to ItemName
set property ItemName of Items to Item
put the content of TextArea into Content
replace newline with `%0a` in Content
set property `content` of Item to Content
set element SelectedItem of Items to Item
set property `content` of Presentation to Items

! Tell the parent to refresh the script
Expand Down
1 change: 0 additions & 1 deletion iwsy/resources/ecs/scripted.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
button Save
button Delete
variable Name
variable CurrentName
variable Content
variable Current
variable Password
Expand Down
12 changes: 10 additions & 2 deletions iwsy/resources/ecs/steps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
variable Blocks
variable Block
variable Contents
variable Content
variable Target
variable Duration
variable URL
Expand Down Expand Up @@ -303,7 +304,6 @@ CreateNewStep:
! Edit a single step
EditStep:
put property `blocks` of Presentation into Blocks
put property `content` of Presentation into Contents
set BlockNames to array
put 0 into N
while N is less than the json count of Blocks
Expand All @@ -312,7 +312,15 @@ EditStep:
json add property `name` of Block to BlockNames
add 1 to N
end
put the json keys of Contents into ContentNames
put property `content` of Presentation into Contents
set ContentNames to array
put 0 into N
while N is less than the json count of Contents
begin
put element N of Contents into Content
json add property `name` of Content to ContentNames
add 1 to N
end
put element SelectedStep of Steps into CurrentStep

clear Editor
Expand Down
Loading