28 lines
799 B
JavaScript
28 lines
799 B
JavaScript
function BaseObject() {
|
|
this.actions = [];
|
|
}
|
|
|
|
BaseObject.prototype.registerAction = function (actionName, args) {
|
|
const timestamp = new Date().toISOString();
|
|
this.actions.push({ actionName, args, timestamp });
|
|
};
|
|
|
|
BaseObject.prototype.clearActions = function () {
|
|
this.actions = [];
|
|
};
|
|
|
|
BaseObject.prototype.getActions = function () {
|
|
return Array.from(this.actions);
|
|
};
|
|
|
|
BaseObject.prototype.formatAction = function (action) {
|
|
return `Действие: ${action.actionName}\n\tПараметры: ${action.args}\n\tВремя: ${action.timestamp}`;
|
|
};
|
|
|
|
BaseObject.prototype.logActions = function () {
|
|
console.log('Зарегистрированные действия:');
|
|
this.actions.forEach((action) => {
|
|
console.log(this.formatAction(action));
|
|
});
|
|
};
|