ghcjs-dom-hello 1.2.0.0 → 2.0.0.0
raw patch · 2 files changed
+17/−20 lines, 2 filesdep ~ghcjs-dom
Dependency ranges changed: ghcjs-dom
Files
- ghcjs-dom-hello.cabal +5/−6
- src/Main.hs +12/−14
ghcjs-dom-hello.cabal view
@@ -1,5 +1,5 @@ name: ghcjs-dom-hello-version: 1.2.0.0+version: 2.0.0.0 cabal-version: >=1.6 build-type: Simple license: MIT@@ -16,16 +16,15 @@ category: Web author: Hamish Mackenzie data-dir: ""- + source-repository head type: git location: https://github.com/ghcjs/ghcjs-dom-hello- + executable ghcjs-dom-hello build-depends: mtl >=2.1 && <2.3,- base >=4.2 && <5, ghcjs-dom >=0.0.7 && <0.2+ base >=4.2 && <5,+ ghcjs-dom >=0.2 && <0.3 main-is: Main.hs buildable: True hs-source-dirs: src- -
src/Main.hs view
@@ -3,27 +3,25 @@ ) where import Control.Applicative ((<$>))-import Control.Monad.Trans (liftIO) import GHCJS.DOM (enableInspector, webViewGetDomDocument, runWebGUI)-import GHCJS.DOM.Document (documentGetBody, documentCreateElement)-import GHCJS.DOM.HTMLElement (htmlElementSetInnerHTML, htmlElementSetInnerText)-import GHCJS.DOM.Element (elementOnclick)+import GHCJS.DOM.Document (getBody, createElement, click)+import GHCJS.DOM.HTMLElement (setInnerText)+import GHCJS.DOM.Element (setInnerHTML) import GHCJS.DOM.HTMLParagraphElement (castToHTMLParagraphElement)-import GHCJS.DOM.Node (nodeAppendChild)-import GHCJS.DOM.EventM (mouseClientXY)+import GHCJS.DOM.Node (appendChild)+import GHCJS.DOM.EventM (on, mouseClientXY) main = runWebGUI $ \ webView -> do enableInspector webView Just doc <- webViewGetDomDocument webView- Just body <- documentGetBody doc- htmlElementSetInnerHTML body "<h1>Hello World</h1>"- elementOnclick body $ do+ Just body <- getBody doc+ setInnerHTML body (Just "<h1>Hello World</h1>")+ on doc click $ do (x, y) <- mouseClientXY- liftIO $ do- Just newParagraph <- fmap castToHTMLParagraphElement <$> documentCreateElement doc "p"- htmlElementSetInnerText newParagraph $ "Click " ++ show (x, y)- nodeAppendChild body (Just newParagraph)- return ()+ Just newParagraph <- fmap castToHTMLParagraphElement <$> createElement doc (Just "p")+ setInnerText newParagraph $ Just $ "Click " ++ show (x, y)+ appendChild body (Just newParagraph)+ return () return ()