2018-07-13 16:58:13 +02:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
(function(){
|
|
|
|
"use strict";
|
|
|
|
|
2019-11-28 01:26:35 +01:00
|
|
|
let scope;
|
2018-07-13 16:58:13 +02:00
|
|
|
if ((typeof exports) !== "undefined"){
|
|
|
|
scope = exports;
|
|
|
|
}
|
|
|
|
else {
|
2019-03-12 22:24:23 +01:00
|
|
|
scope = require.register("./modifiedAPIFunctions", {});
|
2018-07-13 16:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
scope.checkerWrapper = function checkerWrapper(checker, object, args, callback){
|
2018-09-21 16:42:58 +02:00
|
|
|
const check = checker.call(object);
|
2018-07-13 16:58:13 +02:00
|
|
|
if (check.allow){
|
|
|
|
if (check.allow === true){
|
2019-05-10 01:11:31 +02:00
|
|
|
return args.length?
|
2019-12-29 23:40:39 +01:00
|
|
|
check.original.call(object, ...args):
|
2019-05-10 01:11:31 +02:00
|
|
|
check.original.call(object);
|
2018-07-13 16:58:13 +02:00
|
|
|
}
|
|
|
|
return callback.call(object, args, check);
|
|
|
|
}
|
2018-09-21 16:42:58 +02:00
|
|
|
check.notify("blocked");
|
2018-07-13 16:58:13 +02:00
|
|
|
return undefined;
|
|
|
|
};
|
2019-01-24 15:43:20 +01:00
|
|
|
|
2019-12-10 15:07:22 +01:00
|
|
|
scope.getStatusByFlag = function getStatusByFlag(flag){
|
|
|
|
return function getStatus(obj, status, prefs){
|
|
|
|
status = Object.create(status);
|
|
|
|
status.active = prefs(flag, status.url);
|
|
|
|
return status;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-01-24 15:43:20 +01:00
|
|
|
scope.setFunctionProperties = function setFunctionProperties(functions, data){
|
|
|
|
Object.keys(functions).forEach(function(key){
|
2019-11-28 01:26:35 +01:00
|
|
|
const func = functions[key];
|
2019-01-24 15:43:20 +01:00
|
|
|
["type", "api", "getStatus"].forEach(function(property){
|
|
|
|
if (data[property] && !func[property]){
|
|
|
|
func[property] = data[property];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
scope.setGetterProperties = function setGetterProperties(getters, data){
|
|
|
|
getters.forEach(function(getter){
|
|
|
|
["type", "api", "getStatus"].forEach(function(property){
|
|
|
|
if (data[property] && !getter[property]){
|
|
|
|
getter[property] = data[property];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
scope.setProperties = function setProperties(functions, getters, data){
|
|
|
|
scope.setFunctionProperties(functions, data);
|
|
|
|
scope.setGetterProperties(getters, data);
|
|
|
|
};
|
2018-07-13 16:58:13 +02:00
|
|
|
}());
|