Task manager

Project Implicit

Created by Elad Zlotnick

Introduction

  • Javascript
  • The task wrapper

Javascript types


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
}
						

The Wrapper


define(['managerAPI'], function(Manager){

  var API = new Manager();

  /* Your wondrous script */

  return API.script;
});
						

The structure of a task

Tasks are created using a uniform API object.

  • The element object
  • The sequence
  • Using the API

The element object

Each isolated element within the system is represented by an object:


var task = {
	type: 'message',
	template: 'Some arbitrary content.',
	keys: ' '
}
						

The sequence

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:' '}
]
						

Using the API

  • The API is an object with methods.
  • It breaks the tasks down into components.

API.addSequence([
	element1,
	element2,
	element3
]);
						

Inheritance

  • Sets
  • Abstracting element objects
  • Advanced sequencing

Sets

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'}}
]);
						

Abstracting element objects


API.addTasksSet('default', [
	{
		type:'message',
		keys: ' '
	}
]);

API.addSequence([
	{inherit:'default', template:'Task 1'},
	{inherit:'default', template:'Task 2'},
	{inherit:'default', template:'Task 3'}
]);
						

Advanced sequencing


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'}}
]);						

The mixer

  • The mixer object
  • Random example
  • Repeat example

The mixer object

Is used within the sequence instead of element objects, it allows you to control the flow of the sequence.

Random example


API.addSequence([
	{
		mixer:'random',
		data: [
			{type:'message',keys: ' ',template: 'Task 1'},
			{type:'message',keys: ' ',template: 'Task 2'},
			{type:'message',keys: ' ',template: 'Task 3'}
		]
	}
]);

Repeat example


API.addSequence([
	{
		mixer:'repeat',
		times: 10,
		data: [
			{inherit:'default'}
		]
	}
]);

Variables

  • Global and Current
  • Local variables

Global and Current

Manually defined variables


API.addGlobal({
	condition: 'myCond'
});

Local variables

Variables available only in specific contexts


var task = {
	data: {handle:'main', flag:true}
}

The data object becomes available as tasksData

Templates

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'}}
]);

Read the documentation

- piPlayer
- piQuest
- piManager

The End