lab 8
This commit is contained in:
27
Лаб8/Сайт/base.js
Normal file
27
Лаб8/Сайт/base.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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));
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user