You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
inav-configurator/js/msp/MSPchainer.js

35 lines
707 B
JavaScript

/*global $*/
'use strict';
var MSPChainerClass = function () {
var self = {};
self.chain = [];
self.exitPoint = null;
self.chainIndex = 0;
self.setChain = function(chain) {
self.chain = chain;
};
self.setExitPoint = function (exitPoint) {
self.exitPoint = exitPoint;
};
self.returnCallback = function () {
self.chainIndex++;
if (self.chain[self.chainIndex]) {
self.chain[self.chainIndex](self.returnCallback);
} else {
self.exitPoint();
}
};
self.execute = function() {
self.chainIndex = 0;
self.chain[self.chainIndex](self.returnCallback);
};
return self;
};