Artem Flo edited this page Nov 1, 2015 · 11 revisions

If you want to add some logic in your app, you should define a script file with following functions:

  • ASMBOOT – this function will be run after all media loading finished.
  • ONSCR – this function will run on screen change.
  • LOADSTEP - this function runs on loading state update

Also bitASM provides you public API (case-sensitive):

  • D – is short-hand alias for console.log
  • GETBYCLS – returns a set of elements by a class name
  • GETBYTAG – returns a set of elements by a tag name
  • GETBYID – returns an element by the ID
  • ERR – throws a bitASM error.
  • LSTNTAG – add event listeners to new elements by a tag name
  • LSTNCLS – add event listeners to new elements by a class name
  • MAP – a simple asynchronous array map function
  • MAPRET – a synchronous array map function, that return a new array
  • SCR – function to show a specified screen
  • SCRBACK – function to show previous screen from a stack
  • SND – plays a specified sound
  • SYSSND – plays a specified system sound
  • WAIT – run the callback with timeout
  • ALRT – an object that manipulates the bitASM alert dialog system

Functions and other

Every function name is case-sensitive.

ALRT

API Object

ALRT.show(color, data, callback, onshow)

ALRT.hide()

ASMBOOT

Defined

function ASMBOOT(){ … }

Runs after all media loaded and a current screen shown.

D

API

D (arg, [arg, …])

Short-hand alias for console.log. Use for debug.

ERR

API

ERR (code,data)

Powerful and useful function. Has two way of using:

  1. If code is started from “0” – throws a system exception.
  2. In other hand throws an exceptions found in 0x90000XXX, where XXX is the code.

Code

Codes structure:

XYZ

X is a type. If “0” it processed as a system exception. System exceptions is build-in and cannot be modified. See List of System Exceptions. Y is a state. 0 – unknown\information, 1 – warning, 2 – error, 3 – critical. State “critical” breaks all app into the Red Screen of Death. Z is a serial number of an error.

Data

Some data used in message. For system errors see List of System Exceptions.

GETBYCLS

API

GETBYCLS (className [,parentElement])

Returns a set of elements with class matching the search. Second parameter could be an element, where bitASM should search. If it is empty, document element will be used.

GETBYID

API

GETBYID(id)

Returns an element with matching id.

GETBYTAG

API

GETBYTAG(tagName [,parentElement]

Returns a set of elements with tag name matching the search. Second parameter could be an element, where bitASM should search. If it is empty, document element will be used.

LOADSTEP

Defined

LOADSTEP (currentLoadedElements, totalElementsToLoad)

Function runs everytime media is loaded. Use to update your progress bar or something. Not neccessary to define, has a default implementation: searches for the element with ID "loading-state" and sets its content to "Loading.. (XX%)"

LSTNTAG

API

LSTNTAG (tagName, eventType, handler)

Add an event listener to dynamically created elements selecting them by tag.

eventType

“click”,”onload”, etc.

LSTNCLS

API

LSTNTAG (className, eventType, handler)

Add an event listener to dynamically created elements selecting them by className.

eventType

“click”,”onload”, etc.

MAP

API

MAP (array, handler)

Simple mapping function. Takes each element in array and modify it with specified handler.

MAPRET

API

MAPRET(array,handler)

Another type of mapping function. Returns new array where each element is a an element of given array modified with specified handler.

ONSCR

Defined

function ONSCR(screenNum){ … }

This function will run every time screen is changed. Receives a screen number (parsed (x) from “addr0x0xxxxxxx”).

SCR

API

SCR (screenNum)

Changes current screen to the specified.

SCRBACK

API

SCRBACK (event)

Receives an event object, because usually uses in onclick=”SCRBACK(event)”

SND

API

SND(soundNum)

Plays a sound defined at address 0x3%soundNum%

SYSSND

API

SYSSND(soundNum)

Plays a system sound.

List of System Sounds

0 - Information, 1 - Warning, 2 - Error, 3 - Critical Error (Red Screen of Death Sound)

WAIT

API

WAIT(callback[, timeout = 1000])

Function that timeout the callback for a second by default.

XIMG

Idea

<ximg src="" ...></ximg>

An element for images in templates. Will be automatically replaced by an img element on screen build. Implemented to prevent images src preload when it contains variables.

Other functions

A lot of functions hidden inside the framework, but you do not need them.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.