Hexdecimal to decimal conversor

Tutorials of (Hexdecimal to decimal conversor) by Luck747

<!DOCTYPE html>
<html >
<head>
  <meta charset="UTF-8">
  <title>Hexdecimal to decimal conversor</title>
  
  
  
  
  
</head>

<body>
  <html>
<head>
<title> Calculadora - Hexadecimal para decimal </title>
</head>
<body bgcolor = "black">
  <center><FORM>
<INPUT TYPE="button" style="width:350px;height:60px; onClick="history.go(0)" VALUE="Calcular novo numero">
</FORM></center>
<center><font color = "white" size = "40"><i><h2> Hexdecimal to decimal conversor xD </h2></i></font></center>
<center><font color = "white" size = "35"><i><h3> Enjoy :D </h3></i></font></center>
</body>
</html>
  
    <script  src="js/index.js"></script>

</body>
</html>
/* Downloaded from https://www.codeseek.co/ */
/* Downloaded from https://www.codeseek.co/ */
var c1 = '0';
var c2 = '0';
var c3 = '0';
var c4 = '0';

var input = prompt("input your hexdecimal number").toUpperCase();

switch(input.length) {
    case 1:
    var valueHexC1 = function() {
  switch(input[0]) {
    case '0':
      c1 = 0;
      break;
    case '1':
      c1 = 1;
      break;
    case '2':
      c1 = 2;
      break;
    case '3':
      c1 = 3;
      break;
    case '4':
      c1 = 4;
      break;
    case '5':
      c1 = 5;
      break;
    case '6':
      c1 = 6;
      break;
    case '7':
      c1 = 7;
      break;
    case '8':
      c1 = 8;
      break;
    case '9':
      c1 = 9;
      break;
    case 'A':
      c1 = 10;
      break;
    case 'B':
      c1 = 11;
      break;
    case 'C':
      c1 = 12;
      break;
    case 'D':
      c1 = 13;
      break;
    case 'E':
      c1 = 14;
      break;
    case 'F':
      c1 = 15;
      break;
    default:
      console.log("Ha um problema com o primeiro caractere!");
                 }
}
valueHexC1();
    var result = ( input + " === " + ( (c1 * 1) ) );
    alert(result);
    break;
    //Finish Case length 1 (switch) global!
    //Finish Case length 1 (switch) global!
    case 2:
    var valueHexC2 = function() {
  switch(input[0]) {
    case '0':
      c1 = 0;
      break;
    case '1':
      c1 = 1;
      break;
    case '2':
      c1 = 2;
      break;
    case '3':
      c1 = 3;
      break;
    case '4':
      c1 = 4;
      break;
    case '5':
      c1 = 5;
      break;
    case '6':
      c1 = 6;
      break;
    case '7':
      c1 = 7;
      break;
    case '8':
      c1 = 8;
      break;
    case '9':
      c1 = 9;
      break;
    case 'A':
      c1 = 10;
      break;
    case 'B':
      c1 = 11;
      break;
    case 'C':
      c1 = 12;
      break;
    case 'D':
      c1 = 13;
      break;
    case 'E':
      c1 = 14;
      break;
    case 'F':
      c1 = 15;
      break;
    default:
      console.log("Ha um problema com o primeiro caractere!");
                 }
        switch(input[1]) {
    case '0':
      c2 = 0;
      break;
    case '1':
      c2 = 1;
      break;
    case '2':
      c2 = 2;
      break;
    case '3':
      c2 = 3;
      break;
    case '4':
      c2 = 4;
      break;
    case '5':
      c2 = 5;
      break;
    case '6':
      c2 = 6;
      break;
    case '7':
      c2 = 7;
      break;
    case '8':
      c2 = 8;
      break;
    case '9':
      c2 = 9;
      break;
    case 'A':
      c2 = 10;
      break;
    case 'B':
      c2 = 11;
      break;
    case 'C':
      c2 = 12;
      break;
    case 'D':
      c2 = 13;
      break;
    case 'E':
      c2 = 14;
      break;
    case 'F':
      c2 = 15;
      break;
    default:
      console.log("Ha um problema com o segundo caractere!");
                 }
}
valueHexC2();
    var result = ( input + " === " + ( (c1 * 16) + (c2 * 1) ) );
    alert(result);
    break;
    //Finish Case length 2 (switch) global!
    //Finish Case length 2 (switch) global!
    case 3:
    var valueHexC3 = function() {
  switch(input[0]) {
    case '0':
      c1 = 0;
      break;
    case '1':
      c1 = 1;
      break;
    case '2':
      c1 = 2;
      break;
    case '3':
      c1 = 3;
      break;
    case '4':
      c1 = 4;
      break;
    case '5':
      c1 = 5;
      break;
    case '6':
      c1 = 6;
      break;
    case '7':
      c1 = 7;
      break;
    case '8':
      c1 = 8;
      break;
    case '9':
      c1 = 9;
      break;
    case 'A':
      c1 = 10;
      break;
    case 'B':
      c1 = 11;
      break;
    case 'C':
      c1 = 12;
      break;
    case 'D':
      c1 = 13;
      break;
    case 'E':
      c1 = 14;
      break;
    case 'F':
      c1 = 15;
      break;
    default:
      console.log("Ha um problema com o primeiro caractere!");
                 }
        switch(input[1]) {
    case '0':
      c2 = 0;
      break;
    case '1':
      c2 = 1;
      break;
    case '2':
      c2 = 2;
      break;
    case '3':
      c2 = 3;
      break;
    case '4':
      c2 = 4;
      break;
    case '5':
      c2 = 5;
      break;
    case '6':
      c2 = 6;
      break;
    case '7':
      c2 = 7;
      break;
    case '8':
      c2 = 8;
      break;
    case '9':
      c2 = 9;
      break;
    case 'A':
      c2 = 10;
      break;
    case 'B':
      c2 = 11;
      break;
    case 'C':
      c2 = 12;
      break;
    case 'D':
      c2 = 13;
      break;
    case 'E':
      c2 = 14;
      break;
    case 'F':
      c2 = 15;
      break;
    default:
      console.log("Ha um problema com o segundo caractere!");
                 }
    switch(input[2]) {
    case '0':
      c3 = 0;
      break;
    case '1':
      c3 = 1;
      break;
    case '2':
      c3 = 2;
      break;
    case '3':
      c3 = 3;
      break;
    case '4':
      c3 = 4;
      break;
    case '5':
      c3 = 5;
      break;
    case '6':
      c3 = 6;
      break;
    case '7':
      c3 = 7;
      break;
    case '8':
      c3 = 8;
      break;
    case '9':
      c3 = 9;
      break;
    case 'A':
      c3 = 10;
      break;
    case 'B':
      c3 = 11;
      break;
    case 'C':
      c3 = 12;
      break;
    case 'D':
      c3 = 13;
      break;
    case 'E':
      c3 = 14;
      break;
    case 'F':
      c3 = 15;
      break;
    default:
      console.log("Ha um problema com o terceiro caractere!");
                 }
}
valueHexC3();
    var result = ( input + " === " + ( (c1 * 256) + (c2 * 16) + (c3 * 1) ) );
    alert(result);
    break;
    //Finish Case length 3 (switch) global!
    //Finish Case length 3 (switch) global!
    case 4:
    var valueHexC4 = function() {
  switch(input[0]) {
    case '0':
      c1 = 0;
      break;
    case '1':
      c1 = 1;
      break;
    case '2':
      c1 = 2;
      break;
    case '3':
      c1 = 3;
      break;
    case '4':
      c1 = 4;
      break;
    case '5':
      c1 = 5;
      break;
    case '6':
      c1 = 6;
      break;
    case '7':
      c1 = 7;
      break;
    case '8':
      c1 = 8;
      break;
    case '9':
      c1 = 9;
      break;
    case 'A':
      c1 = 10;
      break;
    case 'B':
      c1 = 11;
      break;
    case 'C':
      c1 = 12;
      break;
    case 'D':
      c1 = 13;
      break;
    case 'E':
      c1 = 14;
      break;
    case 'F':
      c1 = 15;
      break;
    default:
      console.log("Ha um problema com o primeiro caractere!");
                 }
        switch(input[1]) {
    case '0':
      c2 = 0;
      break;
    case '1':
      c2 = 1;
      break;
    case '2':
      c2 = 2;
      break;
    case '3':
      c2 = 3;
      break;
    case '4':
      c2 = 4;
      break;
    case '5':
      c2 = 5;
      break;
    case '6':
      c2 = 6;
      break;
    case '7':
      c2 = 7;
      break;
    case '8':
      c2 = 8;
      break;
    case '9':
      c2 = 9;
      break;
    case 'A':
      c2 = 10;
      break;
    case 'B':
      c2 = 11;
      break;
    case 'C':
      c2 = 12;
      break;
    case 'D':
      c2 = 13;
      break;
    case 'E':
      c2 = 14;
      break;
    case 'F':
      c2 = 15;
      break;
    default:
      console.log("Ha um problema com o segundo caractere!");
                 }
    switch(input[2]) {
    case '0':
      c3 = 0;
      break;
    case '1':
      c3 = 1;
      break;
    case '2':
      c3 = 2;
      break;
    case '3':
      c3 = 3;
      break;
    case '4':
      c3 = 4;
      break;
    case '5':
      c3 = 5;
      break;
    case '6':
      c3 = 6;
      break;
    case '7':
      c3 = 7;
      break;
    case '8':
      c3 = 8;
      break;
    case '9':
      c3 = 9;
      break;
    case 'A':
      c3 = 10;
      break;
    case 'B':
      c3 = 11;
      break;
    case 'C':
      c3 = 12;
      break;
    case 'D':
      c3 = 13;
      break;
    case 'E':
      c3 = 14;
      break;
    case 'F':
      c3 = 15;
      break;
    default:
      console.log("Ha um problema com o terceiro caractere!");
                 }
    switch(input[3]) {
    case '0':
      c4 = 0;
      break;
    case '1':
      c4 = 1;
      break;
    case '2':
      c4 = 2;
      break;
    case '3':
      c4 = 3;
      break;
    case '4':
      c4 = 4;
      break;
    case '5':
      c4 = 5;
      break;
    case '6':
      c4 = 6;
      break;
    case '7':
      c4 = 7;
      break;
    case '8':
      c4 = 8;
      break;
    case '9':
      c4 = 9;
      break;
    case 'A':
      c4 = 10;
      break;
    case 'B':
      c4 = 11;
      break;
    case 'C':
      c4 = 12;
      break;
    case 'D':
      c4 = 13;
      break;
    case 'E':
      c4 = 14;
      break;
    case 'F':
      c4 = 15;
      break;
    default:
      console.log("Ha um problema com o quarto caractere!");
                 }
}
valueHexC4();
    var result = ( input + " === " + ( (c1 * 4096) + (c2 * 256) + (c3 * 16) + (c4 * 1) ) );
    alert(result);
    break;
    //Finish Case length 4 (switch) global!
    //Finish Case length 4 (switch) global!
  default:
    console.log("Syntax Error");
}

This awesome code ( Hexdecimal to decimal conversor ) is write by luck747, you can se more from this user in the personal repository

You can find the original code on Codepen.io

2018 © luck747