sunroof-compiler-0.2: Monadic Javascript Compiler

Maintainer???
Safe HaskellNone

Language.Sunroof.JS.Browser

Contents

Description

A reflection of the standard browser Javascript API.

Synopsis

Top level functions

alert :: JSString -> JS t ()Source

Display the given text in a message box.

See http://www.w3schools.com/js/js_popup.asp.

confirm :: JSString -> JS t JSBoolSource

Ask the user to confirm the given massege.

See http://www.w3schools.com/js/js_popup.asp.

prompt :: JSString -> JSString -> JS t JSObjectSource

Ask the user to give some input. May return null or a string. Don't forget to check against nullJS before casting to string.

See http://www.w3schools.com/js/js_popup.asp.

decodeURI :: JSString -> JS t JSStringSource

Decode the URI encoded in the given string.

encodeURI :: JSString -> JS t JSStringSource

Encode the given string in URI encoding.

decodeURIComponent :: JSString -> JS t JSStringSource

Decode the URI encoded string. For use with encodeURIComponent.

encodeURIComponent :: JSString -> JS t JSStringSource

Encode the string with URI encoding. This encodes a few more characters to make the string safe for direct server communication (AJAX).

eval :: Sunroof a => JSString -> JS t aSource

Evaluate the given JavaScript string if possible. Returns the result of evaluation. TODO: think about this a bit.

isFinite :: JSNumber -> JS t JSBoolSource

Check if a given number is within the valid JavaScript number range.

isNaN :: JSNumber -> JS t JSBoolSource

Check if a given number is NaN or not.

parseFloat :: JSString -> JS t JSNumberSource

Parse the given string to a number.

parseInt :: JSString -> JS t JSNumberSource

Parse the given string to a number.

Window API

window :: JSObjectSource

The window object.

setInterval :: (() -> JSB ()) -> JSNumber -> JSObject -> JS t JSNumberSource

Calls a function at specified intervals in milliseconds. It will continue calling the function until clearInterval is called, or the window is closed. The returned number is needed for clearInterval. This is supposed to be called on the window object. See: http://www.w3schools.com/jsref/met_win_setinterval.asp

clearInterval :: JSNumber -> JSObject -> JS t ()Source

Clears a timer set with the setInterval method. This is supposed to be called on the window object. See: http://www.w3schools.com/jsref/met_win_clearinterval.asp

setTimeout :: (() -> JSB ()) -> JSNumber -> JSObject -> JS t JSNumberSource

Execute the given continutation after the given amount of milliseconds. Returns a handler for the set timer. This is supposed to be called on the window object. See: http://www.w3schools.com/jsref/met_win_settimeout.asp

clearTimeout :: JSNumber -> JSObject -> JS t ()Source

Removes the timer associated with the given handler. This is supposed to be called on the window object. See: http://www.w3schools.com/jsref/met_win_cleartimeout.asp

Screen API

screen :: JSObjectSource

The screen object.

Document API

document :: JSObjectSource

The document object.

getElementByIdSource

Arguments

:: JSString

The id.

-> JSObject 
-> JS t JSObject 

Get the DOM object of the element with the given id. For use with document.

getElementsByNameSource

Arguments

:: JSString

The name.

-> JSObject 
-> JS t JSObject 

Get the DOM objects of the elements with the given name. For use with document.

getElementsByTagNameSource

Arguments

:: JSString

The tag name.

-> JSObject 
-> JS t JSObject 

Get the DOM objects of the elements with the given tag. For use with document.

createAttributeSource

Arguments

:: JSString

The name of the new attribute.

-> JSObject 
-> JS t JSObject 

Create a attribute DOM node with the given name. For use with document.

createElementSource

Arguments

:: JSString

The tag name of the new element.

-> JSObject 
-> JS t JSObject 

Create a element DOM node with the given tag name. For use with document.

createTextNodeSource

Arguments

:: JSString

The text of the new text node.

-> JSObject 
-> JS t JSObject 

Create a text DOM node with the given string as text. For use with document.

open :: JSObject -> JS t ()Source

Opens the document for writing. For use with document.

close :: JSObject -> JS t ()Source

Closes the document after writing. For use with document.

write :: JSString -> JSObject -> JS t ()Source

Writes something into the document. For use with document.

writeln :: JSString -> JSObject -> JS t ()Source

Write something into the document and appends a new line. For use with document.

setCookie :: JSString -> JSObject -> JS t ()Source

Sets the value of the cookie. For use with document.

cookie :: JSSelector JSStringSource

Returns the value of the cookie. For use with document.

referrer :: JSSelector JSStringSource

Returns the referrer of the document. For use with document.

setTitle :: JSString -> JSObject -> JS t ()Source

Sets the title of the document. For use with document.

title :: JSSelector JSStringSource

Returns the title of the document. For use with document.

url :: JSSelector JSStringSource

Returns the complete URL of the document. For use with document.

Image DOM

src :: JSSelector JSStringSource

Returns the src of a DOM image object.

The JavaScript Console

data JSConsole Source

Instances

Show JSConsole

Show the Javascript.

IfB JSConsole

Can be returned in branches.

EqB JSConsole

Reference equality, not value equality.

Sunroof JSConsole

First-class values in Javascript.

console :: JSConsoleSource

The console object.

log :: SunroofArgument a => a -> JSConsole -> JS t ()Source

Log the given message.

debug :: SunroofArgument a => a -> JSConsole -> JS t ()Source

Send a debug level message to the console.

info :: SunroofArgument a => a -> JSConsole -> JS t ()Source

Send a info message to the console.

warn :: SunroofArgument a => a -> JSConsole -> JS t ()Source

Send a warning message to the console.

error :: SunroofArgument a => a -> JSConsole -> JS t ()Source

Send an error message to the console.