(function () {
var Resume = window.Resume = function (value) {
value = value || {};
if (!value.name) {
throw 'Нам интересны реальные люди...';
}
if (!value.phone && !value.email) {
throw '...c которыми мы сможем связаться...';
}
if (value.city != 'Москва') {
throw '... и только из Москвы!';
}
this.name = value.name;
this.phone = value.phone;
this.email = value.email;
this.skills = value.skills || [];
}
var Employee = window.Employee = function (name, email, phone, position) {
this.name = name;
this.email = email;
this.phone = phone;
this.position = position;
this.account = 0;
};
Employee.prototype.work = function () {
return result;
}
var cto = new Employee('Пожар Николай', 'nick@teatrall.ru', '+7 (495) 792-34-77', 'CTO');
var Company = window.Company = function (value) {
value = value || {};
this.name = value.name || '';
this.address = value.address || '';
this.phone = value.phone || '';
this.email = value.email || '';
this.website = value.website || '';
this.description = value.description || '';
this.employees = {};
this.workInterval = setInterval(this.doWork, 1000 * 60 * 60 * 24);
this.payInterval = setInterval(this.paySalary, 1000 * 60 * 60 * 24 * 30);
};
Company.prototype = {
addEmployee: function (employee) {
this.employees[employee.position] = employee;
},
respondToVacancy: function (vacancy, resume) {
if (vacancy.check(resume)) {
window.open('mailto:'+ employees['CTO'].email);
}
},
doWork: function () {
var result;
for (position in this.employees) {
result += this.employees[position].work();
}
return result;
},
paySalary: function () {
for (position in this.employees) {
this.employees[position].account++;
}
}
};
var TeatrAll = new Company({
name: 'ТеатрALL',
address: 'Москва, Пушкарев переулок, 9',
phone: '+7 (495) 792-34-77',
email: 'info@teatrall.ru',
website: 'teatrall.ru',
description: 'Мы пишем о театре. Мы продаем билеты. Мы любим код.'
});
TeatrAll.addEmployee(cto);
})();