Ajax Tasker
by juvian
JavaScript
/*
Requires Jquery to run!!
Tasker(config)
config: {
ajaxsmaxRunning: ajaxsRunning ajaxs running at the same time
}
abort: public function --> cancel all running ajaxs, delete all processes, reset tasker variables (not groups)
reset: public function --> erase ajax queue, set running processes and ajaxs to 0
cleanProcesses: public function --> delete all processes
addProcess: public function(key, config) --> adds process to tasker, throws error if already exists
key: string with the name of the process
config:{
runMode: Array that sets when to fire tasks. Defaults to [0,1] Array can have :
0: run on tasker.run()
1: run on tasker.run(processKey)
2: run when task is added to process
}
run(key): public function --> If key is not given, runs all processes with 0 in runMode. If key is given, runs given process name if it has 1 in runMode
prototype functions:
ajax(config) --> makes ajax with configuration given, can give a callback and error function. returns jqXHR object
param(obj) --> returns string out of object get parameters
runTasks: private function --> runs ajaxs on tasker queue if has few ajaxs running
internal varibles: -- > do not use without care
processes: processes the tasker has
running: ajax currently running between all processes
runningProcesses: amount of processes currently running at least 1 ajax
groups: groups of dependencies for tasker -- > view function Groups()
taskQueue: queue of missing tasks (ajaxs)
public variables:
done: optional callback function...