-
Notifications
You must be signed in to change notification settings - Fork 215
Open
Description
class CalcController {
constructor(){
this._locale = 'pt-BR';
this._displayCalcEl = document.querySelector("#display");
this._timeEl = document.querySelector("#hora");
this._dateEl = document.querySelector("#data");
this._currentDate;
this.initialize();
this.initButtonsEvents();
}
initialize(){
setInterval(()=>{
this.displayDate = this.currentDate.toLocaleDateString(this._locale);
this.displayTime = this.currentDate.toLocaleTimeString(this._locale);
}, 1000);
}
addEventListenerAll(element, events, fn){
events.split(' ').forEach(event =>{
element.addEvenrListener(event, fn, false);
});
}
initButtonsEvents(){
let buttons = document.querySelectorAll("#buttons > g, #parts > g");
buttons.forEach((btn, index)=>{
this.addEventListenerAll(btn, "click drag mouseover", e =>{
console.log(btn.className.baseVal.replace("btn-",""));
})
})
}
get displayTime(){
return this._timeEl.innerHTML;
}
set displayTime(value){
return this._timeEl.innerHTML = value;
}
get displayDate(){
return this._dateEl.innerHTML;
}
set displayDate(value){
return this._dateEl.innerHTML = value;
}
get displayCalc(){
return this._displayCalcEl.innerHTML;
}
set displayCalc(value){
this._displayCalcEl.innerHTML = value;
}
get currentDate(){
return new Date();
}
set currentDate(value){
this._currentDate = value;
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels