diff --git a/dist/plugins/iwsy.js b/dist/plugins/iwsy.js index a105746..c69b485 100644 --- a/dist/plugins/iwsy.js +++ b/dist/plugins/iwsy.js @@ -137,20 +137,20 @@ const EasyCoder_IWSY = { script = program.getValue(command.script); try { script = JSON.parse(script); - EasyCoder.iwsyFunctions = IWSY(player, script); } catch (err) { - alert(`Badly formatted script`); + alert(`iwsy load: Badly formatted script`); } + EasyCoder.iwsyFunctions = IWSY(player, script); break; case `script`: script = program.getValue(command.script); try { script = JSON.parse(script); - if (EasyCoder.iwsyFunctions) { - EasyCoder.iwsyFunctions.setScript(script); - } } catch (err) { - alert(`Badly formatted script`); + alert(`iwsy script: Badly formatted script`); + } + if (EasyCoder.iwsyFunctions) { + EasyCoder.iwsyFunctions.setScript(script); } break; case `goto`: @@ -159,6 +159,9 @@ const EasyCoder_IWSY = { } break; case `block`: + if (EasyCoder.iwsyFunctions) { + EasyCoder.iwsyFunctions.block(program.getValue(command.block)); + } break; case `run`: if (EasyCoder.iwsyFunctions) { diff --git a/iwsy/iwsy.js b/iwsy/iwsy.js index 7e72692..52d92c9 100644 --- a/iwsy/iwsy.js +++ b/iwsy/iwsy.js @@ -744,7 +744,9 @@ const IWSY = (container, text) => { initScript(); IWSY.plugins = {}; preloadImages(); - doStep(script.steps[0]); + if (script.steps.length > 0) { + doStep(script.steps[0]); + } return { setScript, gotoStep, diff --git a/iwsy/resources/ecs/iwsy.txt b/iwsy/resources/ecs/iwsy.txt index a244b85..46995c5 100644 --- a/iwsy/resources/ecs/iwsy.txt +++ b/iwsy/resources/ecs/iwsy.txt @@ -24,7 +24,6 @@ img Save img RunStop img Delete - img Cycle a Link module StepsModule module BlocksModule @@ -138,11 +137,6 @@ L2: set the style of RunStop to `width:40px;margin-right:1.5em` set attribute `src` of RunStop to `resources/icon/run.png` set attribute `title` of RunStop to `Run` - create Link in Buttons - create Cycle in Link - set the style of Cycle to `width:40px` - set attribute `src` of Cycle to `resources/icon/cycle.png` - set attribute `title` of Cycle to `Cycle screens` create Status in Buttons if Mobile set the style of Status to `height:1em` @@ -321,6 +315,7 @@ L2: put 0 into N gosub to SelectSection clear Running + iwsy load Player Presentation on message begin @@ -351,17 +346,16 @@ L2: CreateNewPresentation: set Presentation to object - set Item to object - set property `content` of Presentation to Item set Item to array set property `steps` of Presentation to Item set property `blocks` of Presentation to Item + set property `content` of Presentation to Item return SetupSteps: if StepsModule is not running begin - rest get Script from `/resources/ecs/steps.txt` + rest get Script from `/resources/ecs/steps.txt?v=` cat now run Script with StepsPanel and Presentation as StepsModule end return @@ -369,7 +363,7 @@ SetupSteps: SetupBlocks: if BlocksModule is not running begin - rest get Script from `/resources/ecs/blocks.txt` + rest get Script from `/resources/ecs/blocks.txt?v=` cat now run Script with BlocksPanel and Presentation as BlocksModule end return @@ -377,7 +371,7 @@ SetupBlocks: SetupContent: if ContentModule is not running begin - rest get Script from `/resources/ecs/content.txt` + rest get Script from `/resources/ecs/content.txt?v=` cat now run Script with ContentPanel and Presentation as ContentModule end return @@ -521,7 +515,7 @@ SelectFile: index File to the index of FileName set the content of NameEditor to File put File into CurrentScriptName - if PasswordValid rest get Presentation from `/resources/json/` cat File + if PasswordValid rest get Presentation from `/resources/json/` cat File cat `?v=` cat now else get Presentation from storage as File put Presentation into LastSavedState gosub to UpdateCurrentSection @@ -559,10 +553,16 @@ DoRunStop: end else begin + put property `steps` of Presentation into Item + if the json count of Item is 0 stop + put element 0 of Item into Item + if property `action` of Item is not `init` + begin + alert `The first step of a presentation must be an 'init' action.` + stop + end set Running gosub to ClearStepsButtons - put property `steps` of Presentation into Item - if the json count of Item is 0 stop set attribute `src` of RunStop to `resources/icon/runstop.png` put 0 into N @@ -578,8 +578,8 @@ DoRunStop: set property `action` of Message to `running` send Message to StepsModule end - - iwsy run then + + iwsy run then begin gosub to ClearStepsButtons set attribute `src` of RunStop to `resources/icon/run.png` diff --git a/iwsy/resources/ecs/steps.txt b/iwsy/resources/ecs/steps.txt index 4894d1b..4ff83b9 100644 --- a/iwsy/resources/ecs/steps.txt +++ b/iwsy/resources/ecs/steps.txt @@ -61,6 +61,7 @@ variable Response variable Message variable Running + variable SavedIndex variable N variable B @@ -170,9 +171,10 @@ Restart: end on click StepButton begin + put the index of StepButton into SavedIndex gosub to SaveCurrentStep put SelectedStep into N - put the index of StepButton into SelectedStep + put SavedIndex into SelectedStep if SelectedStep is N begin index Editor to N @@ -246,7 +248,6 @@ Restart: json add `goto` to ActionNames json add `load` to ActionNames set InitProperties to array - json add `title` to InitProperties json add `aspect ratio` to InitProperties json add `background` to InitProperties json add `border` to InitProperties @@ -380,7 +381,8 @@ ReloadStepEditor: if Response begin index StepButton to SelectedStep - set property `title` of CurrentStep to TitleInput + index TitleInput to SelectedStep + set property `title` of CurrentStep to the text of TitleInput put the selected item in ActionSelect into Action gosub to CreateNewAction clear Table @@ -702,7 +704,7 @@ CreateNewAction: while N is less than the json count of InitProperties begin put element N of InitProperties into InitProperty - set property InitProperty of CurrentStep to empty + set property InitProperty of CurrentStep to empty add 1 to N end set property `aspect ratio` of CurrentStep to `WW:HH` diff --git a/iwsy/resources/json/demo.json b/iwsy/resources/json/demo.json new file mode 100644 index 0000000..b3f2248 --- /dev/null +++ b/iwsy/resources/json/demo.json @@ -0,0 +1,182 @@ +{ + "blocks": [ + { + "name": "center title", + "background": "", + "border": "", + "borderRadius": "", + "fontColor": "#dddd88", + "fontFamily": "", + "fontSize": 80, + "fontStyle": "", + "fontWeight": "", + "height": 300, + "left": 0, + "textAlign": "center", + "textMarginLeft": "", + "textMarginTop": "", + "top": 300, + "width": "100%" + }, + { + "name": "top title", + "background": "", + "border": "", + "borderRadius": "", + "fontColor": "#ffffff", + "fontFamily": "", + "fontSize": 50, + "fontStyle": "", + "fontWeight": "", + "height": 300, + "left": 0, + "textAlign": "center", + "textMarginLeft": "", + "textMarginTop": "", + "top": 30, + "width": "100%" + }, + { + "name": "left", + "background": "rgba(80,80,80,0.5)", + "border": "1px solid gray", + "borderRadius": "", + "fontColor": "yellow", + "fontFamily": "", + "fontSize": 50, + "fontStyle": "", + "fontWeight": "", + "height": 700, + "left": 50, + "textAlign": "", + "textMarginLeft": 20, + "textMarginTop": 20, + "top": 250, + "width": 400 + }, + { + "name": "right", + "background": "rgba(80,80,80,0.5)", + "border": "1px solid gray", + "borderRadius": "", + "fontColor": "yellow", + "fontFamily": "", + "fontSize": 50, + "fontStyle": "", + "fontWeight": "", + "height": 700, + "left": 550, + "textAlign": "", + "textMarginLeft": 20, + "textMarginTop": 20, + "top": 250, + "width": 400 + }, + { + "name": "main content", + "background": "", + "border": "", + "borderRadius": "", + "fontColor": "yellow", + "fontFamily": "", + "fontSize": 50, + "fontStyle": "", + "fontWeight": "", + "height": 800, + "left": 50, + "textAlign": "", + "textMarginLeft": 10, + "textMarginTop": "", + "top": 300, + "width": "100%" + } + ], + "content": [ + { + "name": "iwannashowyou", + "content": "# I Wanna Show You%0a%0a### _knockout web-based presentations_" + }, + { + "name": "page 1 left", + "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." + }, + { + "name": "page 1 right", + "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." + } + ], + "steps": [ + { + "title": "My demo presentation", + "action": "init", + "label": "", + "aspect ratio": "16:9", + "background": "url('resources/img/SemoigoDawn.jpg')", + "border": "1px solid gray" + }, + { + "title": "Pause before starting", + "action": "pause", + "label": "", + "duration": 1 + }, + { + "title": "Setup main title and initial content", + "action": "set content", + "label": "", + "blocks": [ + { + "block": "center title", + "content": "iwannashowyou" + }, + { + "block": "left", + "content": "page 1 left" + }, + { + "block": "right", + "content": "page 1 right" + } + ] + }, + { + "title": "Fade up title", + "action": "fade up", + "label": "", + "blocks": [ + "center title" + ], + "duration": 1 + }, + { + "title": "Wait 3 seconds", + "action": "hold", + "label": "", + "duration": 3 + }, + { + "title": "Move the title to the top", + "action": "transition", + "label": "", + "target": "top title", + "duration": 2, + "block": "center title" + }, + { + "title": "Wait 1 second", + "action": "hold", + "label": "", + "duration": 1 + }, + { + "title": "Fade up first page", + "action": "fade up", + "label": "", + "blocks": [ + "left", + "right" + ], + "duration": 1 + } + ] +} diff --git a/iwsy/resources/json/properties.json b/iwsy/resources/json/properties.json deleted file mode 100644 index 86e2c24..0000000 --- a/iwsy/resources/json/properties.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "left": 0, - "top": 0, - "width": "100%", - "height": "100%", - "background": "", - "border": "", - "borderRadius": "", - "fontFamily": "", - "fontSize": 30, - "fontWeight": "", - "fontStyle": "", - "fontColor": "", - "textAlign": "", - "textMarginLeft": "", - "textMarginTop": "" -} diff --git a/iwsy/resources/json/test.json b/iwsy/resources/json/test.json index ce3838a..f6fd61e 100644 --- a/iwsy/resources/json/test.json +++ b/iwsy/resources/json/test.json @@ -1,183 +1 @@ -{ - "blocks": [ - { - "name": "center title", - "background": "", - "border": "", - "borderRadius": "", - "fontColor": "#dddd88", - "fontFamily": "", - "fontSize": 80, - "fontStyle": "", - "fontWeight": "", - "height": 300, - "left": 0, - "textAlign": "center", - "textMarginLeft": "", - "textMarginTop": "", - "top": 300, - "width": "100%" - }, - { - "name": "top title", - "background": "", - "border": "", - "borderRadius": "", - "fontColor": "#ffffff", - "fontFamily": "", - "fontSize": 50, - "fontStyle": "", - "fontWeight": "", - "height": 300, - "left": 0, - "textAlign": "center", - "textMarginLeft": "", - "textMarginTop": "", - "top": 50, - "width": "100%" - }, - { - "name": "left", - "background": "rgba(80,80,80,0.5)", - "border": "1px solid gray", - "borderRadius": "", - "fontColor": "yellow", - "fontFamily": "", - "fontSize": 50, - "fontStyle": "", - "fontWeight": "", - "height": 700, - "left": 50, - "textAlign": "", - "textMarginLeft": 20, - "textMarginTop": 20, - "top": 250, - "width": 400 - }, - { - "name": "right", - "background": "rgba(80,80,80,0.5)", - "border": "1px solid gray", - "borderRadius": "", - "fontColor": "yellow", - "fontFamily": "", - "fontSize": 50, - "fontStyle": "", - "fontWeight": "", - "height": 700, - "left": 550, - "textAlign": "", - "textMarginLeft": 20, - "textMarginTop": 20, - "top": 250, - "width": 400 - }, - { - "name": "main content", - "background": "", - "border": "", - "borderRadius": "", - "fontColor": "yellow", - "fontFamily": "", - "fontSize": 50, - "fontStyle": "", - "fontWeight": "", - "height": 800, - "left": 50, - "textAlign": "", - "textMarginLeft": 10, - "textMarginTop": "", - "top": 300, - "width": "100%" - } - ], - "content": [ - { - "name": "iwannashowyou", - "content": "# I Wanna Show You%0a%0a### _for knockout presentations_" - }, - { - "name": "page 1 left", - "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." - }, - { - "name": "page 1 right", - "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." - } - ], - "steps": [ - { - "title": "My first presentation", - "action": "init", - "label": "", - "aspect ratio": "16:9", - "background": "url("resources/img/SemoigoDawn.jpg")", - "border": "1px solid gray" - }, - { - "title": "Pause before starting", - "action": "pause", - "label": "", - "duration": 1 - }, - { - "title": "Setup main title and initial content", - "action": "set content", - "label": "", - "blocks": [ - { - "block": "center title", - "content": "iwannashowyou" - }, - { - "block": "left", - "content": "page 1 left" - }, - { - "block": "right", - "content": "page 1 right" - } - ] - }, - { - "title": "Fade up title", - "action": "fade up", - "label": "", - "blocks": [ - "center title" - ], - "duration": 1 - }, - { - "title": "Wait 3 seconds", - "action": "hold", - "label": "", - "duration": 3 - }, - { - "title": "Move the title to the top", - "action": "transition", - "label": "", - "types": [], - "target": "top title", - "duration": 2, - "block": "center title" - }, - { - "title": "Wait 1 second", - "action": "hold", - "label": "", - "duration": 1 - }, - { - "title": "Fade up first page", - "action": "fade up", - "label": "", - "blocks": [ - "left", - "right" - ], - "duration": 1 - } - ] -} \ No newline at end of file +{"content":{},"steps":[{"title":"My demo presentation","action":"init","label":"","aspect ratio":"160:89","background":"yellow","border":"1px solid gray"}],"blocks":[]} \ No newline at end of file diff --git a/js/plugins/iwsy.js b/js/plugins/iwsy.js index a105746..c69b485 100644 --- a/js/plugins/iwsy.js +++ b/js/plugins/iwsy.js @@ -137,20 +137,20 @@ const EasyCoder_IWSY = { script = program.getValue(command.script); try { script = JSON.parse(script); - EasyCoder.iwsyFunctions = IWSY(player, script); } catch (err) { - alert(`Badly formatted script`); + alert(`iwsy load: Badly formatted script`); } + EasyCoder.iwsyFunctions = IWSY(player, script); break; case `script`: script = program.getValue(command.script); try { script = JSON.parse(script); - if (EasyCoder.iwsyFunctions) { - EasyCoder.iwsyFunctions.setScript(script); - } } catch (err) { - alert(`Badly formatted script`); + alert(`iwsy script: Badly formatted script`); + } + if (EasyCoder.iwsyFunctions) { + EasyCoder.iwsyFunctions.setScript(script); } break; case `goto`: @@ -159,6 +159,9 @@ const EasyCoder_IWSY = { } break; case `block`: + if (EasyCoder.iwsyFunctions) { + EasyCoder.iwsyFunctions.block(program.getValue(command.block)); + } break; case `run`: if (EasyCoder.iwsyFunctions) {