Verified Commit 0a639676 authored by Camil Staps's avatar Camil Staps 🚀

Update iTasks.Extensions.Clock to new JS interface; fix BasicAPIExamples

parent 6b552a7a
Pipeline #21046 failed with stage
in 1 minute and 54 seconds
......@@ -27,7 +27,8 @@ Global
Time: False
Stack: False
Dynamics: True
DescExL: False
GenericFusion: False
DescExL: True
Output
Output: ShowConstructors
Font: Courier
......@@ -42,7 +43,9 @@ Global
ResourceSource:
GenerateDLL: False
ExportedNames:
StripByteCode: False
StripByteCode: True
KeepByteCodeSymbols: True
PrelinkByteCode: True
Paths
Path: {Project}
Path: {Project}/Ligretto
......
......@@ -8,6 +8,7 @@ import iTasks.UI.JS.Interface
import iTasks.Extensions.DateTime
import qualified Data.Map as DM, Data.Tuple, Data.Error
import Text.HTML, Data.Func
import StdEnv
derive JSONEncode AnalogClock
derive JSONDecode AnalogClock
......@@ -54,20 +55,25 @@ where
# world = (me .# "onAttributeChange" .= jsOnAttributeChange) world
= world
onAttributeChange me args world
| jsArgToString (args !! 0) == "diff"
# (changes, world) = fromJSArray (toJSVal (args !! 1)) id world
# world = foldl (updateHand me) world changes
= (jsNull,world)
onAttributeChange me {[0]=name,[1]=changes} world
| jsValToString name == Just "diff"
# (length,world) = changes .# "length" .? world
# length = jsValToInt` 0 length
# world = updateHand me (changes .# 0) world
| length < 2 = world
# world = updateHand me (changes .# 1) world
| length < 3 = world
# world = updateHand me (changes .# 2) world
= world
| otherwise
= (jsNull,jsTrace "Unknown attribute change" world)
= jsTrace "Unknown attribute change" world
updateHand me world change
# (which,world) = appFst jsValToInt (.? (change .# 0) world)
# (value,world) = appFst jsValToInt (.? (change .# 1) world)
# (svgEl,world) = .? (me .# "domEl" .# "children" .# 0) world
# (handEl,world) = .? (svgEl .# "children" .# (13 + which)) world //The first 13 svg elements are the clock face and markers
# (_,world) = (handEl .# "setAttribute" .$ [toJSArg "transform",toJSArg ("rotate("+++toString (degrees which value - 90)+++" 50 50)")]) world
updateHand me change world
# (which,world) = appFst (jsValToInt` 0) (change .# 0 .? world)
# (value,world) = appFst (jsValToInt` 0) (change .# 1 .? world)
# svgEl = me .# "domEl.children" .# 0
# (handEl,world) = svgEl .# "children" .# (13 + which) .? world //The first 13 svg elements are the clock face and markers
# world = (handEl .# "setAttribute" .$! ("transform","rotate("+++toString (degrees which value - 90)+++" 50 50)")) world
= world
degrees 0 v = 6 * v
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment