From 2838d896ceef727ab0f307b2302bf9fcc3305a76 Mon Sep 17 00:00:00 2001 From: Graham Trott Date: Wed, 15 Apr 2020 23:10:33 +0100 Subject: [PATCH] Examples --- dist/easycoder-min.js | 2 +- dist/easycoder.js | 2 +- js/easycoder/Main.js | 2 +- resources/ecs/diceroller.ecs | 94 +++++++++++++++++++++++++++++++++++ resources/ecs/examples.ecs | 27 +++++++++- resources/ecs/usercapture.ecs | 4 +- resources/md/examples.md | 7 ++- 7 files changed, 130 insertions(+), 8 deletions(-) create mode 100644 resources/ecs/diceroller.ecs diff --git a/dist/easycoder-min.js b/dist/easycoder-min.js index 536b757..320f622 100644 --- a/dist/easycoder-min.js +++ b/dist/easycoder-min.js @@ -212,7 +212,7 @@ keyword:"goto",lino:a,goto:this.getPc()+1}),this.continue=!1):this.addCommand({d name:f.token,elements:1,index:0,value:[{}],element:[],extra:d};"dom"===d&&(a.element=[]);this.addCommand(a);return a},compileToken:function(){var a=this.getToken();if(a){this.mark();for(var b=$jscomp.makeIterator(Object.keys(this.domain)),c=b.next();!c.done;c=b.next()){if((c=this.domain[c.value])&&(c=c.getHandler(a))&&c.compile(this))return;this.rewind()}console.log("No handler found");throw Error("I don't understand '"+a+"...'");}},compileOne:function(){var a=this.getToken();if(a){this.warnings= [];var b=this.program.length;if(a.endsWith(":")){a=a.substring(0,a.length-1);if(this.symbols[a])throw Error("Duplicate symbol: '"+a+"'");this.symbols[a]={pc:b};this.index++}else this.compileToken()}},compileFromHere:function(a){for(;this.indexe?0:e;eShow` in Content replace `/SHOW-IMAGESWITCHER/` with `` in Content replace `/SHOW-USERCAPTURE/` with `` in Content replace `/SHOW-LIFE/` with `` in Content @@ -40,6 +44,17 @@ Start: scroll to 0 send Content to Showdown + + if DiceRollerModule is not running + begin + wait 10 ticks + rest get Script from `/resources/ecs/diceroller.ecs` + run Script as DiceRollerModule + attach DiceRoller to `ex-diceroller` + attach ShowDiceRoller to `show-diceroller` + fork to InitDiceRoller + end + if ImageSwitcherModule is not running begin wait 10 ticks @@ -73,9 +88,19 @@ Start: attach ShowLifeDoc to `show-lifedoc` on click ShowLifeDoc send `life` to parent - send to ImageSwitcherModule stop +InitDiceRoller: + send `hide` to DiceRollerModule + set the text of ShowDiceRoller to `Show` + on click ShowDiceRoller + begin + set the text of ShowDiceRoller to `Hide` + on click ShowDiceRoller go to InitDiceRoller + send `show` to DiceRollerModule + end + stop + InitImageSwitcher: set style `display` of ImageSwitcher to `none` set the text of ShowImageSwitcher to `Show` diff --git a/resources/ecs/usercapture.ecs b/resources/ecs/usercapture.ecs index bce0a5a..fd4be17 100644 --- a/resources/ecs/usercapture.ecs +++ b/resources/ecs/usercapture.ecs @@ -11,7 +11,6 @@ div Dialog div Row div Label - div Text span Cell input Name input Email @@ -23,7 +22,6 @@ variable W variable H variable Message - variable Markup variable ECPayload variable Payload callback DecoratorCallback @@ -192,4 +190,4 @@ Decorate: put from 5 of Payload into Payload end set the payload of DecoratorCallback to Payload - stop \ No newline at end of file + stop diff --git a/resources/md/examples.md b/resources/md/examples.md index feb9a7a..58c9493 100644 --- a/resources/md/examples.md +++ b/resources/md/examples.md @@ -8,6 +8,11 @@ The following websites were all built entirely in EasyCoder script: - [Rembrandt.ie](https://rembrandt.ie) - [Storyteller](https://storyteller20.neocities.org) +## Dice roller /SHOW-DICEROLLER/ + +This simple demo shows two dice with a random choice of faces. Click either dice to select a new pair of value. A simple animation simulates the rolling of the dice. +~
~ + ## Image switcher /SHOW-IMAGESWITCHER/ There are 9 images with only 1 showing. A row of thumbnail icons lets the user move left or right or select a specific image. @@ -17,7 +22,7 @@ There are 9 images with only 1 showing. A row of thumbnail icons lets the user m This is a rewrite of a script published in [Smashing Magazine](https://www.smashingmagazine.com/2020/03/introduction-alpinejs-javascript-framework/) as an example of how to use the Alpine.js micro-framework. It represents a block added to a web page, that displays an announcement and handles feedback from users. ~
~ -The User Capture can be run as an independent web page; see [User Capture](/usercapture.html). If you view the page source you will see the entire script inside its special preformatted element. +The User Capture can be run as an independent web page; see [User Capture](https://easycoder.github.io/examples/usercapture). If you view the page source you will see the entire script inside its special preformatted element. ## Storyteller