Home Reference Source
public class | source

Queue

Example:

let queue = new Queue();

Constructor Summary

Public Constructor
public

Class constructor

Method Summary

Public Methods
public

Adds classes for browser type to body for use in CSS

public

Helper function to upcase first letter of string

public

checkQueueable(name: *, obj: *): boolean

public

cleanMemory(pid: *)

Called at the end of a queue run to flush any garbage

public

Clean up any finished queues

public

commandParse(command: *): object

This will take a command string in the format object.command({},{}); and split it down into it parts as an object

public

commandsBind(commandObj: *)

Bind the events to the dom based on the command Object

public

commandsQueue(commandObj: *)

Take the commands array with command objects in it and add them to the queue if they are marked as instant.

public

consoleBadge(options: *)

public

deepCopy(inputObject: *): any

Deep copy and object IE remove references

public

deleteMemory(name: *): boolean

Delete Memory TODO clean up perms

public

delete a register

public

execute(prepareName: *, json: *, silentFail: *): boolean

Execute a queue that is loaded into prepare

public

findQueueByPid(pid: *): *

Find a queue item by searching for its PID

public

finished(pid: *, mode: *)

Called to flag a queue item as finished

public

getCookie(name: *): *

Retrieve a cookie by name

public

getElement(elementTarget: *, errorTrap: *): object | false

Finds an element in the dom using the jquery formant IE #id .class tag (will only ever return one)

public

getElements(elementTarget: *): object | false

Finds an element(s) in the dom using the jquery formant IE #id .class tag (can return one or more)

public

getIframeElements(iframeTarget: *, elementTarget: *, errorTrap: *): object | false

Finds elements in the dom of an iframe (or current document) using the query selector

public

handleFetchErrors(response: *): Object

Error Handler for fetch calls

public

isWork(): *

Is there any work to do in the queue?

public

jsonVars(json: *): any

Process a json object and replace {{!}} tags + # tags

public

memory(name: *, value: *, pid: *): boolean

Called by queueables to add something to our memory stack

public

menu()

Work in progress,

public

objectMap(obj: *, mapFunction: *)

Map an object with sub objects using a map function

public

prettyCommandObject(commandObject: *, indent: *)

Make a pretty version of the currrent commandObject and dump it to the console

public

queueProcess(sync: *)

Force a queue processing

public

renderToDom(domObject: *, text: *, mode: *): boolean

Render some text/html to the dom

public

reportError(error: *, message: *)

Report an error to the console, adds various internal stats

public

setCookie(name: *, value: *): *

set a cookie by name and value

public

setMemory(name: *, value: *, mode: *): boolean

Set memory that is not associated with a running queueable (IE from the templates)

public

setRegister(name: *): boolean

Set a register

public

setStack(pid: *, name: *, value: *): boolean

Set a queue stack item

public

show()

Show current queue status in the console DEBUG function

public

templateLoader(): void

Loads templates from the template stack.

public

templateParse(template: *): string

Takes a template and runs any template commands contained in it to create a HTML template ready to be put into the dom

public

templateProcessor(templateId: *, targetId: *): boolean | string

Template processor Takes a template, process it and places into the dom

public

templateVars(template: *): *

Process the template looking for {{}} instances

public

urlToJson(): *

Get any params from the url in json format

public

varsParser(parseString: *): any

parse a var string

Private Methods
private

Load perm memory items from cookies

private

Flush any permanent memory to cookies

Public Constructors

public constructor() source

Class constructor

Public Methods

public browserClasses() source

Adds classes for browser type to body for use in CSS

public capitalizeFirstLetter(string: *): string source

Helper function to upcase first letter of string

Params:

NameTypeAttributeDescription
string *

Return:

string

public checkQueueable(name: *, obj: *): boolean source

Params:

NameTypeAttributeDescription
name *
obj *

Return:

boolean

public cleanMemory(pid: *) source

Called at the end of a queue run to flush any garbage

Params:

NameTypeAttributeDescription
pid *

public cleanQueue() source

Clean up any finished queues

public commandParse(command: *): object source

This will take a command string in the format object.command({},{}); and split it down into it parts as an object

TODO no concept of the context of the command IE was it from inside a div that need binding?

Params:

NameTypeAttributeDescription
command *

{string}

Return:

object

public commandsBind(commandObj: *) source

Bind the events to the dom based on the command Object

Params:

NameTypeAttributeDescription
commandObj *

public commandsQueue(commandObj: *) source

Take the commands array with command objects in it and add them to the queue if they are marked as instant. IE ready to execute

Params:

NameTypeAttributeDescription
commandObj *

public consoleBadge(options: *) source

Params:

NameTypeAttributeDescription
options *

public deepCopy(inputObject: *): any source

Deep copy and object IE remove references

Params:

NameTypeAttributeDescription
inputObject *

Return:

any

public deleteMemory(name: *): boolean source

Delete Memory TODO clean up perms

Params:

NameTypeAttributeDescription
name *

Return:

boolean

public deleteRegister(name: *): boolean source

delete a register

Params:

NameTypeAttributeDescription
name *

Return:

boolean

public execute(prepareName: *, json: *, silentFail: *): boolean source

Execute a queue that is loaded into prepare

Params:

NameTypeAttributeDescription
prepareName *

{string} Name of the prepared queue

json *

{object}

silentFail *

{boolean}

Return:

boolean

public findQueueByPid(pid: *): * source

Find a queue item by searching for its PID

Params:

NameTypeAttributeDescription
pid *

Return:

*

public finished(pid: *, mode: *) source

Called to flag a queue item as finished

Normally hooked down from queueable this is a queue item saying I have finished in mode (see define.js)

Params:

NameTypeAttributeDescription
pid *
mode *

public getCookie(name: *): * source

Retrieve a cookie by name

Params:

NameTypeAttributeDescription
name *

Cookie name

Return:

*

public getElement(elementTarget: *, errorTrap: *): object | false source

Finds an element in the dom using the jquery formant IE #id .class tag (will only ever return one)

Params:

NameTypeAttributeDescription
elementTarget *
errorTrap *

{boolean} Trap any errors?

Return:

object | false

public getElements(elementTarget: *): object | false source

Finds an element(s) in the dom using the jquery formant IE #id .class tag (can return one or more)

Params:

NameTypeAttributeDescription
elementTarget *

Return:

object | false

public getIframeElements(iframeTarget: *, elementTarget: *, errorTrap: *): object | false source

Finds elements in the dom of an iframe (or current document) using the query selector

Params:

NameTypeAttributeDescription
iframeTarget *

Iframe or false

elementTarget *

query

errorTrap *

{boolean} Trap any errors?

Return:

object | false

public handleFetchErrors(response: *): Object source

Error Handler for fetch calls

Params:

NameTypeAttributeDescription
response *

{object} - Fetch response object

Return:

Object

public isWork(): * source

Is there any work to do in the queue?

Return:

*

public jsonVars(json: *): any source

Process a json object and replace {{!}} tags + # tags

Params:

NameTypeAttributeDescription
json *

Return:

any

public memory(name: *, value: *, pid: *): boolean source

Called by queueables to add something to our memory stack

Params:

NameTypeAttributeDescription
name *
value *
pid *

Return:

boolean

public menu() source

Work in progress,

public objectMap(obj: *, mapFunction: *) source

Map an object with sub objects using a map function

Params:

NameTypeAttributeDescription
obj *
mapFunction *

public prettyCommandObject(commandObject: *, indent: *) source

Make a pretty version of the currrent commandObject and dump it to the console

Params:

NameTypeAttributeDescription
commandObject *
indent *

public queueProcess(sync: *) source

Force a queue processing

This launches the actual objects using a timeout

Params:

NameTypeAttributeDescription
sync *

{boolean} - Send true to force sync mode (Really only for test mode)

public renderToDom(domObject: *, text: *, mode: *): boolean source

Render some text/html to the dom

Params:

NameTypeAttributeDescription
domObject *

{object} - The object in the dom to write to

text *

{string} - The text/HTML to write

mode *

{number} - Mode to use while writing see define.js

Return:

boolean

public reportError(error: *, message: *) source

Report an error to the console, adds various internal stats

Params:

NameTypeAttributeDescription
error *
message *

public setCookie(name: *, value: *): * source

set a cookie by name and value

Params:

NameTypeAttributeDescription
name *

Cookie name

value *

Value of cookie

Return:

*

public setMemory(name: *, value: *, mode: *): boolean source

Set memory that is not associated with a running queueable (IE from the templates)

Params:

NameTypeAttributeDescription
name *
value *
mode *

Return:

boolean

public setRegister(name: *): boolean source

Set a register

Params:

NameTypeAttributeDescription
name *

Return:

boolean

public setStack(pid: *, name: *, value: *): boolean source

Set a queue stack item

Params:

NameTypeAttributeDescription
pid *
name *
value *

Return:

boolean

public show() source

Show current queue status in the console DEBUG function

public templateLoader(): void source

Loads templates from the template stack. Recursively calls self until stack is empty

Return:

void

public templateParse(template: *): string source

Takes a template and runs any template commands contained in it to create a HTML template ready to be put into the dom

Params:

NameTypeAttributeDescription
template *

{string}

Return:

string

public templateProcessor(templateId: *, targetId: *): boolean | string source

Template processor Takes a template, process it and places into the dom

Params:

NameTypeAttributeDescription
templateId *

{string} - ID of the template

targetId *

{string|false} - Place in the dom the put the result. In the event of false we process without dom

Return:

boolean | string

success status

public templateVars(template: *): * source

Process the template looking for {{}} instances

Params:

NameTypeAttributeDescription
template *

Return:

*

public urlToJson(): * source

Get any params from the url in json format

Return:

*

public varsParser(parseString: *): any source

parse a var string

TODO This is massively insecure. If as user can input {{}} into a form and have it displayed to other users they can take over. We either clean all input as you would with <script> etc tags or we manually write a parser.

Params:

NameTypeAttributeDescription
parseString *

Return:

any

Private Methods

private _loadMemoryPerms() source

Load perm memory items from cookies

private _updateMemoryPerms() source

Flush any permanent memory to cookies