@acaprojects/a2-composer
Version:
Angular 2 Interface for composer
106 lines • 4.09 kB
JavaScript
import { Observable } from 'rxjs/Observable';
var COMPOSER = (function () {
function COMPOSER() {
throw new Error('This class is static');
}
COMPOSER.get = function (name) {
return this.data[name];
};
COMPOSER.observe = function (var_name) {
if (!COMPOSER.obs[var_name]) {
COMPOSER.obs[var_name] = new Observable(function (observer) {
COMPOSER._obs[var_name] = observer;
setTimeout(function () {
COMPOSER._obs[var_name].next(COMPOSER.data[var_name]);
}, 200);
});
}
return COMPOSER.obs[var_name];
};
COMPOSER.loadSettings = function () {
var globalScope = self;
if (globalScope) {
var _loop_1 = function (i) {
if (globalScope[i] !== undefined &&
(COMPOSER.data[i] === undefined || globalScope[i] !== COMPOSER.data[i])) {
COMPOSER.data[i] = globalScope[i];
if (!COMPOSER.obs[i] || !COMPOSER._obs[i]) {
COMPOSER.obs[i] = new Observable(function (observer) {
COMPOSER._obs[i] = observer;
COMPOSER._obs[i].next(COMPOSER.data[i]);
});
}
else if (COMPOSER._obs[i]) {
COMPOSER._obs[i].next(COMPOSER.data[i]);
}
}
};
for (var _i = 0, _a = COMPOSER.var_list; _i < _a.length; _i++) {
var i = _a[_i];
_loop_1(i);
}
if (globalScope.systemData) {
COMPOSER.data.control = globalScope.systemData;
}
else if (globalScope.systemsData) {
COMPOSER.data.control = globalScope.systemsData;
}
else if (globalScope.control && globalScope.control.systems) {
COMPOSER.data.control = globalScope.control.systems;
}
}
};
COMPOSER.log = function (type, msg, args, out, color) {
if (out === void 0) { out = 'debug'; }
if (COMPOSER.data && COMPOSER.data.debug) {
var clr = color ? color : '#009688';
var COLOURS = ['color: #0288D1', "color:" + clr, 'color:rgba(0,0,0,0.87)'];
if (args) {
if (COMPOSER.hasColours()) {
console[out].apply(console, ["%c[COMPOSER]%c[" + type + "] %c" + msg].concat(COLOURS, [args]));
}
else {
console[out]("[COMPOSER][" + type + "] " + msg, args);
}
}
else {
if (COMPOSER.hasColours()) {
console[out].apply(console, ["%c[COMPOSER]%c[" + type + "] %c" + msg].concat(COLOURS));
}
else {
console[out]("[COMPOSER][" + type + "] " + msg);
}
}
}
};
COMPOSER.error = function (type, msg, args) {
COMPOSER.log(type, msg, args, 'error');
};
COMPOSER.version = function (version, build, out) {
if (out === void 0) { out = 'debug'; }
var COLOURS = ['color: #f44336', "color: #9c27b0", 'color:rgba(0,0,0,0.87)'];
if (COMPOSER.hasColours()) {
console[out].apply(console, ["%c[ACA]%c[LIBRARY] %cComposer - Version: " + version + " | Build: " + build].concat(COLOURS));
}
else {
console[out]("[ACA][LIBRARY] Composer - Version: " + version + " | Build: " + build);
}
};
COMPOSER.hasColours = function () {
var doc = document;
return !(doc.documentMode || /Edge/.test(navigator.userAgent));
};
return COMPOSER;
}());
export { COMPOSER };
COMPOSER.var_list = ['debug'];
COMPOSER.data = {};
COMPOSER.obs = {};
COMPOSER._obs = {};
setTimeout(function () {
COMPOSER.loadSettings();
setInterval(function () {
COMPOSER.loadSettings();
}, 1000);
}, 50);
//# sourceMappingURL=settings.js.map