on master help sign in
Correct bug in jsevent import. Fix some of the pre-compiled examples.
commit962e6ac57adb0a2d652f58984254d3d38d3634eb authorevancz <info@elm-lang.org> dateFri 19 Oct 2012, 01:28 (14 years ago) parenta10b131
5 files changed+16−14
Examples/elm-js/FrameRate/FrameRate.elm+5−5 Examples/elm-js/Maps/Map.elm+2−2 Examples/elm-js/Pong/Pong.elm+3−3 elm/elm-runtime-0.5.0.js+4−2 elm/src/Gen/CompileToJS.hs+2−2
Examples/elm-js/FrameRate/FrameRate.elm+5−5
@@ -1,10 +1,10 @@
11
22module FrameRate where
33
4−import Data.Maybe (mapMaybe)
5−import Foreign.JavaScript
6−import Signal.Keyboard.Raw
7−import Signal.Input
4+import Maybe (mapMaybe)
5+import JavaScript
6+import Keyboard.Raw
7+import Input
88
99(drop,dFPS) = dropDown
1010 [ ( "30", 30)
@@ -58,7 +58,7 @@ position = foldp addVecs (0,0) delta
5858screen pos actual =
5959 flow down [ collage 400 400 [ outlined black (rect 40 40 pos) ]
6060 , plainText "Move the square around with the arrow keys."
61− , text $ toText "Actual frames per second: " ++ show actual
61+ , plainText $ "Actual frames per second: " ++ show actual
6262 , plainText "Desired frames per second: " `beside` drop
6363 ]
6464
Examples/elm-js/Maps/Map.elm+2−2
@@ -1,8 +1,8 @@
11
22module Map where
33
4−import Signal.Window as Win
5−import Foreign.JavaScript.Experimental
4+import Window as Win
5+import JavaScript.Experimental
66
77foreign import jsevent "provideMap"
88 (castElementToJSElement $ spacer 640 360)
Examples/elm-js/Pong/Pong.elm+3−3
@@ -55,9 +55,9 @@
5555
5656module Pong where
5757
58−import Foreign.JavaScript
59−import Signal.Keyboard.Raw
60−import Signal.Window as Win
58+import JavaScript
59+import Keyboard.Raw
60+import Window as Win
6161
6262
6363------------------------------------------------------------------------
elm/elm-runtime-0.5.0.js+4−2
@@ -75,6 +75,7 @@ Elm.JavaScript = function() {
7575}();
7676
7777var Elm = Elm || {};
78+var JSjson = JSON;
7879Elm.JSON = function() {
7980 var JS = Elm.JavaScript;
8081 var empty = ['JSON',{}];
@@ -163,11 +164,11 @@ Elm.JSON = function() {
163164 return v[1];
164165 }
165166 }
166− return JSON.stringify(fromValue([ 'JsonObject', obj ]), null, JS.castStringToJSString(sep));
167+ return JSjson.stringify(fromValue([ 'JsonObject', obj ]), null, JS.castStringToJSString(sep));
167168 };
168169 }
169170 function fromJSString(str) {
170− var obj = JSON.parse(str);
171+ var obj = JSjson.parse(str);
171172 function toValue(v) {
172173 switch (typeof v) {
173174 case 'string' : return [ "JsonString", JS.castJSStringToString(v) ];
@@ -210,6 +211,7 @@ Elm.JSON = function() {
210211 JsonObject : JsonObject
211212 };
212213}();
214+
213215var Value = function(){
214216
215217 var eq = function(x,y) {
elm/src/Gen/CompileToJS.hs+2−2
@@ -117,8 +117,8 @@ stmtToJS (Datatype _ _ tcs) = concatMap (stmtToJS . toDef) tcs
117117 where toDef (name,args) = Def name vars $ Data (derename name) (map Var vars)
118118 where vars = map (('a':) . show) [1..length args]
119119stmtToJS (ImportEvent js base elm _) =
120− concat [ "\nvar " ++ elm ++ " = Elm.Input(" ++ toJS base ++ ");"
121− , "\nSignal.addListener(document, '" ++ js
120+ concat [ "\nvar " ++ elm ++ " = Elm.Signal.constant(" ++ toJS base ++ ");"
121+ , "\nValue.addListener(document, '" ++ js
122122 , "', function(e) { Dispatcher.notify(" ++ elm
123123 , ".id, e.value); });" ]
124124stmtToJS (ExportEvent js elm _) =