Created
June 3, 2013 11:43
-
-
Save valdiney/5697611 to your computer and use it in GitHub Desktop.
Core atual do console Semba-semba-code
Versão:0.1 BETA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////// | |
// | |
// CORE INICIAL DO PROGRAMA... | |
// VAERSÃO: 0.1 BETA | |
// AUTOR: VALDINEY FRANÇA | |
// | |
//////////////////////////////////////// | |
window.onload = function(){ | |
///////////////////////////////////////////////// | |
// VALORES USADOS EM TODO 'SCRIPT'... | |
var display_null = document.getElementById('display_null'); | |
var display = document.getElementById('display').focus();//FOCO AO CARREGAR A PÁGINA | |
var erro = document.getElementById('erro'); | |
//////////////////////////////////////////////// | |
////////////////////////////// | |
// CARREGA NA TELA OS DADOS DO STORAGE | |
document.getElementById('display').value = localStorage.getItem("codigo"); | |
///////////////////////////////// | |
// computar() FUNÇÃO EXECUTA O CALCULO APÔS O CLICK DO BOTÃO COMPUTAR. | |
///////////////////////////////// | |
var computar = document.getElementById('computar').onclick = function(){ | |
var display = document.getElementById('display').value; | |
if(display ==''){ | |
display_null.innerHTML = "Digite uma expressão Matemática..."; | |
document.getElementById('display').focus();//FOCO | |
}else{ | |
computerCalc();// CHAMA A FUNÇÃO QUE COMPUTA AS EXPRESSÕES... | |
display_null.innerHTML = document.getElementById('display_result').value; | |
gravar_noStotage = localStorage.setItem("codigo",display); | |
} | |
} | |
/////////////////////////////// | |
// computerCalc() FUNÇÃO REALIZA OS CALCULOS | |
////////////////////////////// | |
function computerCalc(){ | |
try{ | |
{ | |
document.getElementById('display_result').value = eval(document.getElementById('display').value); | |
erro.innerHTML ="";//LIMPA A MENSAGEM DE ERRO... | |
} | |
}catch(e){ | |
if(e.name == "SyntaxError"){ | |
erro.innerHTML ="Você escreveu alguma coisa errada em relação a sintaxe da linguagem, ou seja, a forma com que se escreve as palavras que compõem a mesma = "+"<span>"+e+"</span>"; | |
} | |
if(e.name == "ReferenceError"){ | |
erro.innerHTML ="A variável não está definida = "+"<span>"+e+"</span>"; | |
} | |
document.getElementById('display_result').value = eval(document.getElementById('display').value); | |
} | |
} | |
/////////////////////////////// | |
// cleanDisplay FUNÇÃO LIMPA O DISPLAY | |
////////////////////////////// | |
var cleanDisplay = document.getElementById('limpar').onclick = function(){ | |
document.getElementById('display').value = ''; | |
} | |
}//END WINDOW... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment