Created by Elad Zlotnick
var number = 123;
var string = 'value';
var obj = {property:'value'};
var array = [1,2,3];
var boolean = true;
var fn = function(arg1, arg2){
// your code here
}
define(['managerAPI'], function(Manager){
var API = new Manager();
/* Your wondrous script */
return API.script;
});
Tasks are created using a uniform API object.
Each isolated element within the system is represented by an object:
var task = {
type: 'message',
template: 'Some arbitrary content.',
keys: ' '
}
The sequence is simply an ordered list of element objects. We will learn how to manipulate it later on.
var sequence = [
{type:'message', template:'Task 1', keys:' '},
{type:'message', template:'Task 1', keys:' '}
]
API.addSequence([
element1,
element2,
element3
]);
Sets are groups of element objects that can be inherited. They are grouped into sets:
API.addTasksSet('setName', setArray);
API.addSequence([
{inherit:{type:'random',set:'setName'}},
{inherit:{type:'random',set:'setName'}}
]);
API.addTasksSet('default', [
{
type:'message',
keys: ' '
}
]);
API.addSequence([
{inherit:'default', template:'Task 1'},
{inherit:'default', template:'Task 2'},
{inherit:'default', template:'Task 3'}
]);
API.addTasksSet('default', [{
type:'message',
keys: ' '
}]);
API.addTasksSet('tasks',[
{inherit:'default', template:'Task 1'},
{inherit:'default', template:'Task 2'},
{inherit:'default', template:'Task 3'}
]);
API.addSequence([
{inherit:{set:'tasks', type:'exRandom'}},
{inherit:{set:'tasks', type:'exRandom'}},
{inherit:{set:'tasks', type:'exRandom'}}
]);
Is used within the sequence instead of element objects, it allows you to control the flow of the sequence.
API.addSequence([
{
mixer:'random',
data: [
{type:'message',keys: ' ',template: 'Task 1'},
{type:'message',keys: ' ',template: 'Task 2'},
{type:'message',keys: ' ',template: 'Task 3'}
]
}
]);
API.addSequence([
{
mixer:'repeat',
times: 10,
data: [
{inherit:'default'}
]
}
]);
Manually defined variables
API.addGlobal({
condition: 'myCond'
});
Variables available only in specific contexts
var task = {
data: {handle:'main', flag:true}
}
The data object becomes available as tasksData
Any string property can be replaced by a template.
API.addTasksSet('default', [{
type:'message',
keys: ' ',
template: 'Do you like <%= tasksData.fruitName %>?'
}]);
API.addSequence([
{inherit:'default',data:{fruitName:'apples'}},
{inherit:'default',data:{fruitName:'bannanas'}}
]);