Calculadora desenvolvida como exemplo do Curso Completo de JavaScript na Udemy.com.
curso-javascript-projeto-calculadora-clone's Introduction
curso-javascript-projeto-calculadora-clone's People
Forkers
tarcisiopqdt michaelads legilsonbrito fevooduck carvale wilderlopes83 almirjr94 wrffilho matheussantos164 lluke8 felipedelta0 limhug zaidohdev albertogomesdasilva rrgoya srubens nonatodiego lindomarc joaquimrocha17 celiooppezzo jonatasdasilva react-native-ifto-2019-porto profjoaomoreira viniciuskawakami varelacouto douglasnbk herickfreitas marcoscamargo1 viniciuswz marcelianylarangote brunotwitte alexandreramosdev dev-ansouza cauenishijima dev-subversonics wendhio leticiamazzo tairasantos gutugaluppo guhbigardi andregartner eullercdr navarroguimaraes s7thiago matheuseufrasio2 l3omonk jorbson01 andilegal pgjbz fbred ruizsamara fabricio-alt kennymario3012 felipe-8847 magnomatos822 andreblb josivangomes renatoguara2004 gustavoarmoa allankovac marcosjmfilho vbndr emerson-javax alessandraluciana kaiansamuel leandromac wevertondiniz medicodedev muitnep maikecascaes hugo-cfc saurabgami977 freitassp rafaelhamaral nsadriano gnaboa sevenjra evenilson silvadias paulobartos michelcar luanrjjj joelp2003 alteonalves lurnakata gpereira305 pedrocardoso96 wilsilmom casintec joaogarbini duartegabriel68 christopherbertonzin michaelbonfogo tiago-sant antonioaopb mouractrlsf6 matsozza jhon-mauricio-mancera feateixeira henriquesabarahcurso-javascript-projeto-calculadora-clone's Issues
Secão 2 - aula 12.C07 Adicionando evento click -ERRO
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;
}
}
Erro na aula C11
@anthony1910 @joaohcrangel @glauciodaniel
Boa noite, favor verificar qual erro nesse codigo no metodo this._Operation.push(value) não funciona.
class CalcController {
constructor() {
this._locale = 'pt-BR';
this._Operation = [];
this._displayCalcEl = document.querySelector("#display");
this._dateEl = document.querySelector("#data");
this._timeEl = document.querySelector("#hora");
this._currentDate;
this.initialize();
this.initButtonsEvents();
};
initialize(){
this.setDisplayDateTime();
setInterval(() =>{
this.setDisplayDateTime();
},1000);
};
setDisplayDateTime(){
this.displayDate = this.currentDate.toLocaleDateString(this._locale);
this.displayTime = this.currentDate.toLocaleTimeString(this._locale);
};
addEventListenerAll(element, events, fn){
events.split(' ').forEach(event =>{
element.addEventListener(event,fn,false);
});
};
clearAll(){
this._Operation = [];
};
clearEntry(){
this._Operation.pop();
}
setError(){
this.displayCalc = "Error";
}
getLastOperation(){
return this._Operation[this._Operation-1];
}
isOperator(value) {
return (['+','-','/','*','%'].indexOf(value) > - 1);
}
addOperation(value){
console.log(value);
console.log(this.getLastOperation());
console.log(this.isOperator());
if(isNaN(this.getLastOperation())){
if (this.isOperator(value)) {
this._Operation[this._Operation.length - 1] = value;
} else if (isNaN(value)) {
console.log(value);
} else {
this._Operation.push(value);
}
} else{
let newValue = this.getLastOperation().toString() + value.toString();
this._Operation.push(newValue);
}
}
execButton(value) {
switch (value) {
case 'ac':
this.clearAll();
break;
case 'ce':
this.clearEntry();
break;
case 'soma':
this.addOperation('+');
break;
case 'subtracao':
this.addOperation('-');
break;
case 'multiplicacao':
this.addOperation('*');
break;
case 'divisao':
this.addOperation('/');
break;
case 'porcento':
this.addOperation('%');
break;
case 'igual':
this.addOperation('=');
break;
case 'ponto':
this.addOperation('-');
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
this.addOperation(parseInt(value));
break;
default:
this.setError();
break;
}
}
initButtonsEvents(){
let buttons = document.querySelectorAll("#buttons > g, #parts > g");
buttons.forEach((button,index)=>{
this.addEventListenerAll(button,"click drag" , e=>{
let txtbutton = (button.className.baseVal.replace("btn-",""));
this.execButton(txtbutton);
});
this.addEventListenerAll(button, "mouseover mouseup mousedown", e=> {
button.style.cursor = "pointer";
});
});
};
get displayTime() {
return this._timeEl.innerHTML;
}
set displayTime(value) {
this._timeEl.innerHTML = value;
}
get displayDate() {
return this._dateEl.innerHTML;
}
set displayDate(value) {
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.innerHTML = value;
}
}
Fazer o upload dos códigos JS
Seria possível vocês disponibilizarem os códigos JavaScript do projeto final?
Desde já, grato.
Aula 14 - calculadora hcode - array não faz o push
Meu array:
addOperation(value){
this._operation.push(value);
console.log(this._operation);
}
Não fez o push para o array.
Acredito que meu código esta igual a aula número 14, porem o value deveria vir de initButtonsEvents().
Este não deu certo. Tentei, revisei, as aulas, igual.. talvez tenha esquecido ou feito algo errado quem puder ajudar. vlw
`
class CalcController{
constructor(){
this._locale='pt-BR';
this._operation=[];
this._displayCalcEl=document.querySelector('#display');
this._dateEl = document.querySelector('#data');
this._timeEl = document.querySelector('#hora');
this._currentDate;
this.initialize();
this.initButtonsEvents();
};
initialize(){
this.setDisplayDateTime();
setInterval(() => {
this.setDisplayDateTime();
}, 1000);
};
setDisplayDateTime(){
this.displayDate=this.currentDate.toLocaleDateString(this._locale,{day:"2-digit",month:"long",year:"numeric"});
this.displayTime=this.currentDate.toLocaleTimeString(this._locale);
};
addEventListenerAll(element, events, fn){
events.split(' ').forEach(event=>{
element.addEventListener(event,fn,false);
});
};
clearAll(){
this._operation=[];
}
clearEntry(){
this._operation.pop();
}
setError(){
this.displayCalc="Error";
}
addOperation(value){
this._operation.push(value);
console.log(this._operation);
}
execBtn(value){
switch(value){
case 'ac':
this.clearAll();
break;
case 'c':
this.clearEntry();
break;
case 'soma':
break;
case 'subtracao':
break;
case 'divisao':
break;
case 'multiplicacao':
break;
case 'porcento':
break;
case 'igual':
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
this.addOperation(parseInt(value));
break;
default:
this.setError();
break;
}
}
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-",""));
});
this.addEventListenerAll(btn, "mouseover mouseup mousedown",e=>{
let textBtn=btn.style.cursor="pointer";
this.execBtn(textBtn);
});
});
}
get displayTime(){
return this._timeEl.innerHTML;
}
set displayTime(value){
return this._timeEl.innerHTML=value;
}
get displayDate(){
return this._dateEl.innerHTML;
}
set displayDate(date){
return this._dateEl.innerHTML=date;
}
get displayCalc(){
return this._displayCalcEl.innerHTML;
}
set displayCalc(valor){
this._displayCalcEl.innerHTML=valor;
}
get currentDate(){
return new Date();
}
set currentDate(data){
this._currentDate=data;
}
}
`
Erro na aula C09
Boa tarde a todos.
Qualquer click meu retorna "error".
Eu já revisei o código algumas vezes e não encontrei o motivo.
Podem me ajudar?
Abs e Feliz Natal!
class CalcController{
constructor(){
this.operation = [];
this._locale = 'pt-BR';
this._displayCalcEl = document.querySelector("#display");
this._dateEl = document.querySelector("#data");
this._timeEl = document.querySelector("#hora");
this._currentDate;
this.initialize();
this.initButtonsEvents();
}
initialize(){
this.setDisplayDateTime();
setInterval(() => {
this.setDisplayDateTime();
}, 1000);
}
addEventListenerAll(element, events, fn){
events.split(' ').forEach(event => {
element.addEventListener(event, fn, false);
});
}
clearAll(){
this._operation = [];
}
clearEntry(){
this._operation.pop();
}
addOperation(value){
this._operation.push(value);
console.log(this._operation);
}
setError(){
this.displayCalc = "Error";
}
execBtn(value){
switch (value) {
case 'ac':
break;
case 'ce':
break;
case 'soma':
break;
case 'subtracao':
break;
case 'multiplicacao':
break;
case 'divisao':
break;
case 'porcento':
break;
case 'igual':
break;
case 'ponto':
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
this.addOperation(parseInt(value));
break;
default:
this.setError();
break;
}
}
initButtonsEvents(){
let buttons = document.querySelectorAll("#buttons > g, #parts > g");
buttons.forEach((btn, index)=>{
this.addEventListenerAll(btn, "click drag", e=> {
let textBtn = btn.className.baseVal.replace("btn-", "");
this.execBtn();
});
this.addEventListenerAll(btn, "mouseover mouseup mousedown", e =>{
btn.style.cursor = "pointer";
});
});
}
setDisplayDateTime(){
this.displayDate = this.currentDate.toLocaleDateString(this._locale, {
day: "2-digit",
month: "short",
year: "numeric"
});
this.displayTime = this.currentDate.toLocaleTimeString(this._locale);
}
get displayDate(){
this._dateEl.innerHTML
}
set displayDate(value){
return this._dateEl.innerHTML = value;
}
get displayTime(){
this._timeEl.innerHTML
}
set displayTime(value){
return this._timeEl.innerHTML = value;
}
get displayCalc(){
return this._displayCalcEl.innerHTML;
}
set displayCalc(valor){
this._displayCalcEl.innerHTML = valor;
}
get currentDate(){
return new Date();
}
set currentDate(value){
this._currentDate = value;
}
}
Adicionar funções de raiz quadrada e potenciação
Como sugestão, sugiro que como próximas features a serem adicionadas à calculadora sejam de potenciação e radiciação.
Cordialmente,
Carlos.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.