Title: | Web Interface to 'R' Functions |
---|---|
Description: | Web front end for your 'R' functions producing plots or tables. If you have a function or set of related functions, you can make them available over the internet through a web browser. This is the same motivation as the 'shiny' package, but note that the development of 'shinylight' is not in any way linked to that of 'shiny' (beyond the use of the 'httpuv' package). You might prefer 'shinylight' to 'shiny' if you want a lighter weight deployment with easier horizontal scaling, or if you want to develop your front end yourself in JavaScript and HTML just using a lightweight remote procedure call interface to your R code on the server. |
Authors: | Pieter Vermeesch [aut], Tim Band [aut, cre] |
Maintainer: | Tim Band <[email protected]> |
License: | GPL-3 |
Version: | 1.2 |
Built: | 2025-03-08 04:30:43 UTC |
Source: | https://github.com/tim-band/shinylight |
Opens a browser to look at the server
browseTo(server)
browseTo(server)
server |
The server to browse to |
No return value
Encodes a data frame as a CSV file to be downloaded
downloadCsv(results)
downloadCsv(results)
results |
Data frame to be returned |
A list to be returned to the browser describing a CSV file to be downloaded.
Renders a plot as a base64-encoded image
encodePlot(device, mimeType, width, height, plotFn)
encodePlot(device, mimeType, width, height, plotFn)
device |
Graphics device function, such as
|
mimeType |
Mime type for the data produced by |
width |
Width of the plot in units applicable to |
height |
Height of the plot in units applicable to |
plotFn |
Function to call to perform the plot |
list with two keys, whose values can each be NULL:
'plot'
is a plot in HTML img src form and 'data'
is a
data frame or other non-plot result.
pdf <- encodePlot(grDevices::png, "image/png", 200, 300, function() { barplot(c(1, 2, 3, 4)) }) grDevices::png() # workaround; you do not have to do this
pdf <- encodePlot(grDevices::png, "image/png", 200, 300, function() { barplot(c(1, 2, 3, 4)) }) grDevices::png() # workaround; you do not have to do this
The result can be set as the src
attribute of an <img>
element in HTML.
encodePlotAs(format, plotFn)
encodePlotAs(format, plotFn)
format |
An object specifying the output, with the following members:
format$type is |
plotFn |
Function to call to perform the plot |
You will not need to call this function unless you want to return more
than one plot per call, as the last plot produced will be returned
in the plot
property of the result from shinylight.call
anyway.
list with two keys, whose values can each be NULL:
'plot'
is a plot in HTML img src form and 'data'
is a
data frame or other non-plot result.
A list with an element named plot
containing the
plot encoded as required either for an HTML image
element's
src
attribute, or a
element's href
attribute.
If the function returns a matrix or data frame, this will be returned
in the list's data
element.
pdf <- encodePlotAs(list(type="pdf", width=7, height=8), function() { barplot(c(1, 2, 3, 4)) }) grDevices::png() # workaround; you do not have to do this
pdf <- encodePlotAs(list(type="pdf", width=7, height=8), function() { barplot(c(1, 2, 3, 4)) }) grDevices::png() # workaround; you do not have to do this
The Shinylight Framework allows you to declare all your functions in R and have a nice-looking web front end for your code without having to write any JavaScript.
You should never need to call this function yourself; if you do not
provide your own index.html
, the default Shinylight one
will be used that will call this function on page load.
Using the Shinylight Framework entails calling the slServer
function with the interface
argument set to
list(getSchema=schema)
, where
schema
is defined in the following section.
options |
|
options.createFileInput |
|
It is a list with the following members:
functions
a list of functions (keyed by their names), each of which is a list with the following members:
params
a list of the main parameters the function
accepts. The keys are the parameter names and the values are
keys into the schema's params
list.
optiongroups
a vector of keys into the schema's
optiongroups
list giving other parameters to this function.
functiongroups
optional: the menu structure for the
functions menu. Each item in the list is either a function name (a
string referencing a key in the functions
list) or a list
representing a submenu. Submenu keys are the name to be
displayed in the list, which can be overridden in the app.json
file's functions
object, just like providing localized
names for functions.
params
a list of the parameters the functions take, each of which is a list with the following members:
type
either a key into the schema's types
list,
giving the type of this parameter or the values it can take, or one
of a set of standard types:
'b'
Boolean
'f'
Floating point
'u8'
8-bit unsigned integer
'color'
Colour
'subheader'
Vector of settings the user can choose for each column using selectors in the subheader row. This is usually used to select units (for example percent-by-weight versus parts-per-million) for the columns.
data
a key into the schema's data
list,
giving initial or example data for this parameter.
types
a list of types with keys referened from the
schema's params
lists's type
values. The values
are a list with the following members:
kind
Mandatory; one of:
'enum'
Enumeration type
'column'
A column from the input grid
values
A vector of permitted values (only if
kind='enum'
)
factors
Only if kind='enum'
and this enum
is used as the unit type for some column; a vector of factors to
multiply column data by if the unit is changed by the user. Must
have the same number of elements as the values
vector. For every n, factors[[n]]
of unit
values[[n]]
must be equal. For example, if
values=c('mm', 'cm', 'inch')
then factors
could be
c(25.4, 2.54, 1.0)
.
subtype
Only if kind='column'
. The type of
data that can be entered into the column. Currenly only 'f'
works well.
unittype
Optional and only if kind='column'
.
The name of an enum type defining the units that the data in this
column can be expressed in.
data
A list of initial data with which table columns and controls will be populated. Can be a single value or vector (or list) as appropriate.
optiongroups
A list of option groups. Each one is a set of parameters that can be added as a block to functions that want them. Each element is a list with the following keys:
type
The same as for param
's type
:
either a key into the schema's types
list or one of the
standard types ('b'
, 'u8'
, 'f'
or
'color'
).
initial
The initial value for this option.
There is one special key in the optiongroups
list; this is the
framework
key. This is reserved for options that apply to
the framework itself, not to any of your functions. So far, the only
option it has is autorefresh=list(type="b", initial=FALSE)
.
You can set its initial value to TRUE
if you prefer. If you add
this option, it controls whether the GUI has a "Calculate" button
(FALSE
) or whether the output should refresh a second or
two after the user finishes changing parameters (TRUE
).
To display human-friendly text on the controls and to get tooltip
help text, you need one or more localization files. These files
are named inst/www/locales/XX/app.json
where
XX
is replaced with the appropriate ISO language code.
These files are JSON files containing an object with the following keys:
title
Text for the link to put in the top left
homepage
Destination for the link to put in the top left
functions
One pair of translations for each function in the schema.
params
One pair of translations for each parameter in the schema.
optiongroups
Each of the optiongroups
in the schema gets a key which maps to an object which has
the following keys:
@title
A translation pair for the option group itself.
One translation pair for each option in the group.
types
One object for each 'enum'
type in
the schema. Each value is an object with one key per possible
enum value. Each value in this object is that enum value's
translation pair.
A "translation pair" is an object with the following keys:
name
A short name
help
Tooltip text
toolkit.loadFileButton
Obtains the address that the server is listening on
getAddress(server)
getAddress(server)
server |
The server (returned by |
The HTTP address as protocol://address:port
server <- slServer( port = 50051, interface = list( multiply = function(x, y) { x * y } ) ) address <- getAddress(server) # ... slStop(server) stopifnot(address == "http://127.0.0.1:50051")
server <- slServer( port = 50051, interface = list( multiply = function(x, y) { x * y } ) ) address <- getAddress(server) # ... slStop(server) stopifnot(address == "http://127.0.0.1:50051")
Get index.html with (potentially) the JSON data in 'text' inserted.
indexWithInit(text, path)
indexWithInit(text, path)
text |
The text to insert as shinylight_initial_data |
path |
File system path to the index.html file |
The updated text
It will serve files from the app directories specified by appDirs.
If a file is requested that is not in one of those directories, the
files in Shinylight's own inst/www directory will be served.
Some paths have special meanings: /
returns
/index.html
, /lang/
is redirected to
/locales/<language-code>/
depending
on the language selected in the request's Accept-Language
header (that is, the browser's language setting) and the
availability of the file requested. A POST request to /init
with a data
parameter will return /index.html
, except
that if the file has a line containing shinylight_initial_data =
then this line with be replaced with a line initializing
shinylight_initial_data
to the data passed. This is used in
shinylight-framework
to permit linking to a framework app
with specific data preloaded – the text should be as is downloaded
with the "Save Data" button. Of course, this is available to
non-framework apps, too.
rrpcServer( interface, host = "0.0.0.0", port = NULL, appDirs = NULL, root = "/", initialize = NULL, testFunction = NULL )
rrpcServer( interface, host = "0.0.0.0", port = NULL, appDirs = NULL, root = "/", initialize = NULL, testFunction = NULL )
interface |
List of functions to be served. The names of the elements are the names that the client will use to call them. |
host |
Interface to listen on (default is |
port |
Port to listen on |
appDirs |
List of directories in which to find static files to serve |
root |
Root of the app on the server (with trailing slash) |
initialize |
A json string or list (that will be converted to a
JSON string) to be passed to the JavaScript as initial data. For
non-framework apps, the index.html must contain a line containing
|
testFunction |
Function to be called if the |
The server object, can be passed to slStop
If you set this as a part of your interface, like:
runR=shinylight::runR(c("+", "plot", "c", "x", "y"))
then you can call it from Javascript like this:
rrpc.call("runR", { Rcommand:"2+2" }, function(x) {console.log(x);}); rrpc.call("runR", { Rcommand:"y<-c(2,0,1);plot(c(1,2,3),y);y", 'rrpc.resultformat': { type: 'png', width: 200, height: 300, } }, function(x) {img.setAttribute('src', x.plot[0])});
runR(symbolList)
runR(symbolList)
symbolList |
A list of permitted symbols in the R command |
A function that can be passed as one of the elements of
slServer
's interface
argument.
server <- slServer( port = 50050, interface = list( run_the_users_r_code = runR( list("c", "$", "list", "+", "-", "/", "*", "sqrt") ) ) ) # ... slStop(server)
server <- slServer( port = 50050, interface = list( run_the_users_r_code = runR( list("c", "$", "list", "+", "-", "/", "*", "sqrt") ) ) ) # ... slStop(server)
During a slow remote procedure call, call this to inform the client of progress.
sendInfoText(text)
sendInfoText(text)
text |
The text to send |
No return value
sendProgress
for sending a progress completion
ratio to the user.
server <- slServer( port = 50051, interface = list(long_and_complicated = function(x) { # First part of work that takes some time # ... sendInfoText("We are about half way through") # Second part of work that takes some time # ... }) ) # ... slStop(server)
server <- slServer( port = 50051, interface = list(long_and_complicated = function(x) { # First part of work that takes some time # ... sendInfoText("We are about half way through") # Second part of work that takes some time # ... }) ) # ... slStop(server)
During a slow remote procedure call, call this to inform the client of progress.
sendProgress(numerator, denominator = 1)
sendProgress(numerator, denominator = 1)
numerator |
The progress, out of |
denominator |
What the progress is out of. You could use this for the number of known items to be completed so that each call increases either the numerator (for more items done) and/or the denominator (for more items discovered that need to be done). However, it is not necessary to be so precise; you can set the numerator and denominator however you like on each call as long as it makes sense to the user. |
No return value
sendInfoText
for sending text to the user.
server <- slServer( port = 50051, interface = list(long_and_complicated = function(x) { sendProgress(0,3) # First part of work that takes some time # ... sendProgress(1,3) # Second part of work that takes some time # ... sendProgress(2,3) # Last part of work that takes some time # ... sendProgress(3,3) }) ) # ... slStop(server)
server <- slServer( port = 50051, interface = list(long_and_complicated = function(x) { sendProgress(0,3) # First part of work that takes some time # ... sendProgress(1,3) # Second part of work that takes some time # ... sendProgress(2,3) # Last part of work that takes some time # ... sendProgress(3,3) }) ) # ... slStop(server)
Calls a server function as defined in the server's call to the
slServer
function.
fn |
|
data |
|
plotElement |
|
extra |
|
Result object that might have a plot
property (giving a string that would work as the src
attribute of an img
element, representing graphics
drawn by the command), a data
property (giving
the value returned by the command) and a headers
property (giving the column names in the data returned if any).
If the promise resolves to an error, the argument to the error
function is a string representing the cause of the error.
Call this before calling any other ShinyLight function. Returns a promise that resolves (to nothing) when the connection is ready.
Turns data received from R into a form that can be set into dataentrygrid.js.
data |
|
extraColumns |
|
Headers and rows
## Not run: t = shinylight.makeTable(data); grid.init(t.headers, t.rows); ## End(Not run)
## Not run: t = shinylight.makeTable(data); grid.init(t.headers, t.rows); ## End(Not run)
Open another tab with another (possibly remote from this one) instance of shinylight, initializing it with our own data.
url |
|
data |
|
The R side must be running the slRunRServer function.
rCommand |
|
data |
|
plotElement |
|
extra |
|
Result object that might have a plot
property (giving a string that would work as the src
attribute of an img
element, representing graphics
drawn by the command) and a data
property (giving
the value returned by the command). If the promise resolves
to an error, the argument to the error function is a string
representing the cause of the error.
Sets the text content of an element (or its value
as
appropriate) to the JSON representation of an object.
elementOrId |
|
object |
|
<img>
element to display a plot returned by
runR
.Normally you do not need to call this because to get
shinylight
to produce a plot you need to set the
plotElement
argument, and doing so will cause this
element to receive the plot automatically.
elementOrId |
|
result |
|
Sets the text content of an element (or its value
as
appropriate).
elementOrId |
|
text |
|
Sets a dataentrygrid
object to the result of
runR
, if appropriate.
grid |
|
result |
|
Sets a dataentrygrid
object to the result of
runR
. The object will have fixed rows, with
names derived from the row names in the original
data frame.
grid |
|
result |
|
Start a ShinyLight server which runs R that it is sent
slRunRServer( permittedSymbols, appDir = NULL, host = "127.0.0.1", port = NULL, daemonize = FALSE, initialize = NULL )
slRunRServer( permittedSymbols, appDir = NULL, host = "127.0.0.1", port = NULL, daemonize = FALSE, initialize = NULL )
permittedSymbols |
List of symbols that are permitted in the R
commands passed. Remember to include |
appDir |
Directory containing files to serve (for example system.file("www", package = "your-package")) |
host |
IP address to listen on, default is |
port |
Internet port of the virtual server. If not defined, a random free port will be chosen and the browser will be opened to show the GUI. |
daemonize |
If TRUE, keep serving forever without returning.
This is useful when called from |
initialize |
A json string or list (that will be converted to a
JSON string) to be passed to the JavaScript as initial data. The
index.html must contain a line containing
|
server object, unless daemonize is TRUE.
slServer
for the more general form of this
function, or slStop
to stop a running server.
shinylight.runR
is the JavaScript function you need
to call to pass R code from the browser to the server.
server <- slRunRServer( permitted = list("*"), port = 50053 ) # Normally we would use shinylight.js to send the function over # and receive the result, not R and websocket. ws <- websocket::WebSocket$new("ws://127.0.0.1:50053/x") resultdata <- NULL ws$onMessage(function(event) { resultdata <<- jsonlite::fromJSON(event$data)$result$data }) ws$onOpen(function(event) { ws$send('{"method":"runR","params":{"Rcommand":"3 * 57"}}') }) timeout = 30 while(is.null(resultdata) && 0 < timeout) { later::run_now() Sys.sleep(0.1) timeout <- timeout - 1 } ws$close() slStop(server) stopifnot(resultdata == 171) # 3 * 57 == 171 grDevices::png() # workaround; you do not have to do this
server <- slRunRServer( permitted = list("*"), port = 50053 ) # Normally we would use shinylight.js to send the function over # and receive the result, not R and websocket. ws <- websocket::WebSocket$new("ws://127.0.0.1:50053/x") resultdata <- NULL ws$onMessage(function(event) { resultdata <<- jsonlite::fromJSON(event$data)$result$data }) ws$onOpen(function(event) { ws$send('{"method":"runR","params":{"Rcommand":"3 * 57"}}') }) timeout = 30 while(is.null(resultdata) && 0 < timeout) { later::run_now() Sys.sleep(0.1) timeout <- timeout - 1 } ws$close() slStop(server) stopifnot(resultdata == 171) # 3 * 57 == 171 grDevices::png() # workaround; you do not have to do this
Start a ShinyLight server
slServer( interface, appDir = NULL, host = "127.0.0.1", port = NULL, daemonize = FALSE, initialize = NULL )
slServer( interface, appDir = NULL, host = "127.0.0.1", port = NULL, daemonize = FALSE, initialize = NULL )
interface |
List of functions you want to be able to call from
the browser. If you want to use the Shinylight Framework, this should
have one member |
appDir |
Directory containing files to serve (for example system.file("www", package = "your-package")) |
host |
IP address to listen on, default is |
port |
Internet port of the virtual server. If not defined, a random free port will be chosen and the browser will be opened to show the GUI. |
daemonize |
If TRUE, keep serving forever without returning.
This is useful when called from |
initialize |
A json string or list (that will be converted to a
JSON string) to be passed to the JavaScript as initial data. For
non-framework apps, the index.html must contain a line containing
|
server object, unless daemonize is TRUE in which case the function will not return.
slStop
to stop a running server, and
slRunRServer
to run a server that just accepts R code.
# You can leave out port and daemonize to launch a browser # pointing at your server server <- slServer( port = 50052, interface = list( multiply = function(x, y) { x * y } ) ) # Normally we would use shinylight.js to send the function over # and receive the result, not R and websocket. ws <- websocket::WebSocket$new("ws://127.0.0.1:50052/x") resultdata <- NULL ws$onMessage(function(event) { resultdata <<- jsonlite::fromJSON(event$data)$result$data }) ws$onOpen(function(event) { ws$send('{ "method": "multiply", "params": { "x": 3, "y": 47 } }') }) timeout = 30 while(is.null(resultdata) && 0 < timeout) { later::run_now() Sys.sleep(0.1) timeout <- timeout - 1 } ws$close() slStop(server) stopifnot(resultdata == 141) # multiply(3, 47) == 141 grDevices::png() # workaround; you do not have to do this
# You can leave out port and daemonize to launch a browser # pointing at your server server <- slServer( port = 50052, interface = list( multiply = function(x, y) { x * y } ) ) # Normally we would use shinylight.js to send the function over # and receive the result, not R and websocket. ws <- websocket::WebSocket$new("ws://127.0.0.1:50052/x") resultdata <- NULL ws$onMessage(function(event) { resultdata <<- jsonlite::fromJSON(event$data)$result$data }) ws$onOpen(function(event) { ws$send('{ "method": "multiply", "params": { "x": 3, "y": 47 } }') }) timeout = 30 while(is.null(resultdata) && 0 < timeout) { later::run_now() Sys.sleep(0.1) timeout <- timeout - 1 } ws$close() slStop(server) stopifnot(resultdata == 141) # multiply(3, 47) == 141 grDevices::png() # workaround; you do not have to do this
Stops a ShinyLight GUI
slStop(server = NULL)
slStop(server = NULL)
server |
The server (returned by |
No return value
server <- slServer( port = 50051, # leave this out if you don't care about the port number interface = list( multiply = function(x, y) { x * y } ) ) # ... slStop(server)
server <- slServer( port = 50051, # leave this out if you don't care about the port number interface = list( multiply = function(x, y) { x * y } ) ) # ... slStop(server)
Calls a function for each member of an array or object until either
one of them returns false (in which case all
returns false) or
we run out of elements (in which case all
returns true).
a |
|
p |
|
Calls a function for each member of an array or object until either
one of them returns true (in which case any
returns true) or
we run out of elements (in which case any
returns false).
a |
|
p |
|
Returns a Container Element for displaying controls horizontally.
elements |
|
className |
|
The banner element.
This button is an HTML element, but it is not an HTML button. Styling and JavaScript provide the button-like look-and-feel.
id |
|
fn |
|
translations |
|
The button.
deref(o, [a,b,c], d)
is a safe way of doing
o[a][b][c]
. If that path does not exist, d is returned.
If d is not supplied, null is returned. Any undefined values in
path are ignored.
object |
|
path |
|
defaultValue |
|
Object dereferenced, defaultValue
, or null.
Calls a function for each member of an array or object.
a |
|
f |
|
Adds a group title to an toolkit.optionsPage
.
container |
|
labelTranslations |
|
Returns a Positioned Element consisting of a header and a body.
hdr |
|
main |
|
The element containing the header and body.
HTMLElement
.A Container Element is an element for displaying a set of controls and their labels.
function
Gets an element in which a control and its label can be stored. You do not need
to call this unless you have made your own custom control; it will be called
by functions such as toolkit.paramText
. Pass in the ID of the control
(you will need the ID for the getData
and setData
calls).
function
Returns an object mapping contained
controls (or nested containers) to their current values.
function
Sets the values
of the contained controls. data
is a mapping from the IDs of
the contained controls to the data that should be set on them.
A container for a single control.
function
Adds an element. Should be called once with a control's label, and then
again with the control itself.
A monkey-patched HTMLElement
representing a control with its
label.
function
Returns the current displayed value.
function
Sets the value.
function
Makes the element invisible and non-interactive
function
makes the element visible and (potentially) interactive
HTMLElement
with some extra methods.Certain elements returned by Toolkit methods are Positioned Elements. It is necessary for elements in some places in the document to be Positioned Elements for the document resizing and formatting to work.
If you have an HTML element that is not a Positioned Element that you want
to add to a place where only Positioned Elements are required, wrap it in
toolkit.scrollingWrapper
or toolkit.nonScrollingWrapper
.
function
Sets the position of the element on the document in pixels, with parameters
for left, top, width and height in that order.
function
Returns an object with members left
, top
, width
and height
for the position of the element.
function
Makes the element invisible and non-interactive
function
makes the element visible and (potentially) interactive
An image element.
updateSizeFunction |
|
Image element. It has a
getSize()
method, returning an object with width and height
members. This is the width and height set by reposition()
,
not the actual on-screen width and height, if that is different
for some reason. In other words, it returns the width and height
the image "should" have.
Returns a Positioned Element consisting of a left side bar and a body.
bar |
|
main |
|
The Toolkit Positioned Element containing the side bar and body.
This button is an HTML element, but it is not an HTML button. Styling and JavaScript provide the button-like look-and-feel.
id |
|
fn |
|
translations |
|
createFileInput |
|
The button.
The label has translatable text and a help tooltip (if translated for).
translations |
|
container |
|
id |
|
idFor |
|
The label.
This element does not gain scrollbars if it is too large for this returned container, and it will try to take up its full size in the layout.
element |
|
verticalPadding |
|
horizontalPadding |
|
The wrapper.
Returns an element with a makeSubElement
method that
adds elements vertically. This differs from toolkit.stack
in that the
labels will be aligned on the left and the controls will be aligned on the
right. It would make a nice options page, for example.
A Container Element for displaying elements vertically.
Returns a Positioned Element consisting of two elements
placed in the same position. To be able to see the lower (main)
element you must either call hide()
on the overlay,
or make it transparent with CSS.
overlay |
|
main |
|
The element containing both elements.
Only one page will be visible at a time. The returned element
has getData
and setData
methods that take or
return (respectively) an object with keys that are the IDs of the
pages.
pageElements |
|
labelTranslations |
|
tabIdPrefix |
|
An element that has the
tabs and the tabs that switch between them. The active tab has
the "active" class. It has the following extra methods:
setData(data)
: data is a dictionary with keys matching the
pageIds. The values are passed to the setData()
functions
of the corresponding elements. Pages without any data (and their
corresponding radio buttons) are summarily disabled. Pages with
data are enabled. reposition()
: sets each page to the same
dimensions as the container and calls each page's
reposition()
method (if it exists).
A control for a boolean value rendered as a checkbox.
id |
|
container |
|
translations |
|
initial |
|
callback |
|
Checkbox input control.
It is a standard HTML input control with type color
. The value
returned is a six-hex-digit string prefixed with a #
.
id |
|
container |
|
translations |
|
initial |
|
callback |
|
Text input control.
Values outside the permitted range will gain the "invalid" class, but there is no other effect.
id |
|
container |
|
translations |
|
initial |
|
callback |
|
min |
|
max |
|
Text input control.
Values outside the permitted range will gain the "invalid" class, but there is no other effect.
id |
|
container |
|
translations |
|
initial |
|
callback |
|
min |
|
max |
|
Text input control.
This is different to a normal selection box because it allows tooltips on the items within the list.
id |
|
container |
|
labelTranslations |
|
values |
|
valueTranslations |
|
initial |
|
callback |
|
The selection box.
Any text is permitted unless a validate
function is supplied.
id |
|
container |
|
translations |
|
initial |
|
callback |
|
validate |
|
Text input control.
This element is like a control in that it has a label and actual text content, but it is not interactive.
id |
|
container |
|
translations |
|
The static text element. The text content
can be set by calling its setData()
function with any plain
text.
The progress is set by calling the setData()
method.
The progress bar element.
Returns a Positioned Element consisting of a right side bar and a body.
bar |
|
main |
|
The Toolkit Positioned Element containing the side bar and body.
This element gains scrollbars if it is too large for this returned container.
element |
|
verticalPadding |
|
horizontalPadding |
|
The wrapper.
<main>
tag in the document with this element.The element will have its resize
event wired up. If el
is a Toolkit Positioned Element, it will be resized correctly when the
window is resized.
el |
|
Returns a Container Element with a
makeSubElement
method that adds elements vertically,
with the labels above the controls they correspond to.
elements |
|
A Container Element for displaying elements vertically.
This element is like a control in that it has a label and actual text content, but it is not interactive.
id |
|
container |
|
translations |
|
The static text element. The text
content can be set by calling its setData()
function. This text
can include HTML entities, so you might want to replace &
with &
and <
with <
if it is plain
text.
Returns a Positioned Element with a draggable vertical divider bordering two other Positioned Elements.
container |
|
left |
|
right |
|
The element created. If a container was provided it is this argument.
The returned function can be called as often as you like with
whatever arguments you like. If it is called again within
ticks
ticks (a tick is 100ms), this call is ignored. If
it is not called again within this time, the arguments are passed
on to the delegate function. In other words, in a string of calls
less than ticks
x 100ms apart from each other, only
the last of these calls actually happens.
ticks |
|
f |
|
Function that can be called often, resulting in fewer
calls to the delegate function f
.
Perhaps you have a nullary function that you want called
when the user clicks a button, but the toolkit.button
function wants a unary function that has a completion callback
so that the button knows when to pop back up again. In this
situation you might wrap your function with a call to
toolkit.withTimeout
.
fn |
|
Unary function (taking one function as
an argument) that simply calls fn
immediately then
calls its argument again after 200ms.