You are on page 1of 2

<script>

var N = new Array(); //Array de Numeros


var Nt = '0'; //Numero Temporal
$(document).ready(function) () {
//Deshabilitamos el input del resultado
$('#tResult').prop('disable',tue);
$('#tResult').css({´color':'black','font-size':'1.3em','background':'write'});
});
//Boton clear,iniciamos todo por defecto
$('#btn_c´).click(funtion () {
$('#opr).tex('')
$(´#tResult').val('')
Nt='0'
N.length=0
});
//Botones aqui enviamos el valor a un numero Temporal
//Asi mismo es mostrado en el input de la operacion
//Esta accion se repite con todos los numeos
$('#btn_9´).click(function() {
-get('9','9')
});
$('#btn_8´).click(function() {
-get('8','8')
});
$('#btn_7´).click(function() {
-get('7','7')
});
$('#btn_6´).click(function() {
-get('6','6')
});
$('#btn_5´).click(function() {
-get('5','5')
});
$('#btn_4´).click(function() {
-get('4','4')
});
$('#btn_3´).click(function() {
-get('3','3')
});
$('#btn_2´).click(function() {
-get('2','2')
});
$('#btn_1´).click(function() {
-get('1','1')
});
$('#btn_0´).click(function() {
-get('0','0')
});
//Botones de operacion,aqui asignados la operacion deseada al input
//Donde mostramos la formula,ademas llenamos un Array con toda
//La operacion que se desea realizar,este proceso se repite
//Con toda las operaciones
$('#btn_sum').click(function() {
$('#opr').text($('#opr').text()+'+')
N.push(Nt);
Nt='0'
N.push('+')
});
$('#btn_rest').click(function() {
$('#opr').text($('#opr').text()+'-')
N.push(Nt);
N.push('-')
Nt='0'
});
$('#btn_Mul').click(function() {
$('#opr').text($('#opr').text()+'*')
N.push(Nt);
N.push('*')
Nt='0'
});
$('#btn_div').click(function() {
$('#opr').text($('#opr').text()+'/')
N.push(Nt);
N.push('/')
Nt='0'
});
$('#btn_div').click(function() {
N.push(Nt);
Calc(N)
Nt=NULL
});
//la funcion _get se encarga de mostrar la operacion en el imput
//Como de llenar el numero Temporal,"Numero armado"
function _get(n, num) {
$('#opr').text($('opr').text()+num)
if (Nt=='0') {
Nt=n
}else{
Nt+=n
}
}
//finalmente la funcion Calc se encarga de realizar las operaciones
//La operacion se encuentra almacenada en el Array
function Calc(v) {
try {
var r = eval(v.tostring).replace(/[,NULL/gi,''));
//verificamos que la operacion sea valida
if((isNaN(r)) || (!isfinite(r))){
//usamos Notify para enviar un mensaje de error
$.Notify('erro en la entrada :(');
}else{
//Mostramos el resultado en el imput
$('#Result').val(r)
}
} catch(err) {
//En este caso de exepcion mostramos un mensaje con Notify.js
$.Notify(error en la Entrada :(´);
}
}
</script>

You might also like