|
Data.DOM | Portability | portable | Stability | experimental | Maintainer | golubovsky@gmail.com |
|
|
|
|
|
Description |
This module will most likely be imported by any Haskell program that uses DOM.
Other modules from Data.DOM namespace are to be imported as needed, sometimes
qualified because there are some name clashes in attributes and methods across
the DOM interfaces.
Below is an example of Haskell code which generates Javascript to display
traditional Hello World. This example shows that even a simplest
Control.Monad.Identity will do. Of course, a more sofisticated Monad
might provide more benefits, such as assigning some of expressions to
Javascript variables to share and prevent repeated evaluation,
automatic declaration of functions, etc.
module Main where
import WebBits.JavaScript
import Control.Monad
import Control.Monad.Identity
import Data.DOM
import Data.DOM.Dom
import Data.DOM.Node
import Data.DOM.HTMLDocument
main = putStrLn $ show $ pp $
FunctionStmt undefined (Id undefined "main") []
(ExprStmt undefined $ runIdentity q)
q = do
d <- htmlDocument
t <- mkText (string "Hello World") d
b <- getm'body d
addChild t b
Below is Javascript generated by this example. All expressions just nest
where necessary, and method calls may be chained.
function main()
{
window.document.body.appendChild(window.document.createTextNode("Hello World"));
}
|
|
Synopsis |
|
|
|
|
Module Data.DOM.WBTypes re-exported for convenience
|
|
module Data.DOM.WBTypes |
|
Additional DOM support functions
|
|
|
Access the global Window object.
|
|
|
Access the current document. This indeed should be made through the
Window interface, but current (incomplete) specification does not
provide an easy way for that.
|
|
|
Same as above, using the HTMLDocument interface.
|
|
|
Access the BODY node of the current HTML document. Same as 'get\'body', but with
proper type of the returned value.
|
|
|
Access the HEAD node of the current HTML document.
|
|
|
Obtain an inline style (TCSS2Properties) interface of an object
|
|
|
Obtain an inline style (TCSSStyleDeclaration) interface of an object
|
|
|
A maker function for a TEXT element.
|
|
|
Same as appendChild, but with type signature reflecting that returned
value is the node added.
|
|
Functions to construct Javascript values
|
|
|
Create a Javascript string literal out of a string.
|
|
|
Create a Javascript numeric literal out of a numeric value.
|
|
|
Create a Javascript boolean literal out of a Boolean.
|
|
|
Javascript True value
|
|
|
Javascript False value
|
|
Produced by Haddock version 2.4.2 |