css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <html lang="en-US">
<!-- Still in Progress/ Being Worked On -->
<head>

  <title>RDaniels34 | Calculator --- Not Finished</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="css/normalize.css">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
  <link href='https://fonts.googleapis.com/css?family=Montserrat:400,700|Bitter:400,400italic|Josefin+Sans:400,300italic' rel='stylesheet' type='text/css'>

  <style>
    <!-- #main {
        width: 100px;
        height: 200px;
        border: 3px solid #c3c3c3;
        display: -webkit-flex;
        /* Safari */
        -webkit-flex-flow: row-reverse wrap;
        /* Safari 6.1+ */
        display: flex;
        flex-flow: wrap;
        justify-content: space-around;
      }
      
      #main div {
        width: 55px;
        height: 50px;
      }  -->
  </style>
</head>

<body style="background-color: lightyellow;">
  <header>
    <div class="header-div">
      <h1>Calculator</h1>
      <h3>Made by: RDaniels34</h3>
    </div>
  </header>

  <container class="container">

    <div class="well well-lg" id="numberDisplay">
      <div id="numberDisplay1">0</div>
      <br>
      <div id="numberDisplay2" class="display">0</div>
    </div>

    <div id="separator-line"></div>

    <div id="buttonGroup">
      <button type="button" onclick="clrFunction()" value="C" id="clr" class="btn btn-default btn-sm">C</button>
      <button type="button" onclick="divideFunction()" value="/" id="divideNum" class="divideNum operators btn btn-default btn-sm">/</button>
      <button type="button" onclick="timesFunction()" value="X" id="timesNum" class="timesNum btn btn-default btn-sm">X</button>
      <button type="button" onclick="backspaceFunction()" id="backspace" class="backspace btn btn-default btn-sm fa fa-caret-left" style="font-size:20px"></button>
      <button type="button" onclick="sevenFunction()" value="7" id="numbers" class="numbers btn btn-default btn-sm">7</button>
      <button type="button" onclick="eightFunction()" value="8" id="numbers" class="numbers btn btn-default btn-sm">8</button>
      <button type="button" onclick="nineFunction()" value="9" id="numbers" class="numbers btn btn-default btn-sm">9</button>
      <button type="button" onclick="addFunction()" value="+" id="addNum" class="addNum btn btn-default btn-sm">+</button>
      <button type="button" onclick="fourFunction()" value="4" id="numbers" class="numbers btn btn-default btn-sm">4</button>
      <button type="button" onclick="fiveFunction()" value="5" id="numbers" class="numbers btn btn-default btn-sm">5</button>
      <button type="button" onclick="sixFunction()" value="6" id="numbers" class="numbers btn btn-default btn-sm">6</button>
      <button type="button" onclick="subtractFunction()" value="-" id="minusNum" class="minusNum btn btn-default btn-sm">-</button>
      <button type="button" onclick="oneFunction()" value="1" id="numbers" class="numbers btn btn-default btn-sm">1</button>
      <button type="button" onclick="twoFunction()" value="2" id="numbers" class="numbers btn btn-default btn-sm">2</button>
      <button type="button" onclick="threeFunction()" value="3" id="numbers" class="numbers btn btn-default btn-sm">3</button>
      <button type="button" onclick="percentFunction()" value="%" id="percentNum" class="percentNum btn btn-default btn-sm ">%</button>
      <button type="button" onclick="zeroFunction()" value="0" id="numbers" class="numbers btn btn-default btn-sm">0</button>
      <button type="button" onclick="decimalFunction()" value="." id="numbers" class="numbers btn btn-default btn-sm ">.</button>
      <button type="button" onclick="plusminusFunction()" value="+/-" id="plusminus" class="plusminus btn btn-default btn-sm">+/-</button>
      <button type="button" onclick="rd34Function()" id="rd34" class="btn btn-default btn-sm">RD</button>
      <button type="button" onclick="equalsFunction()" val="=" id="equals" class="btn btn-default btn-sm">=</button>
    </div>
  </container>


  <div id="footer">
    Copyright © RDaniels34 - 2016
  </div>

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="vendor/angular.js" type="text/javascript"></script>
  <script src="scripts/app.js" type="text/javascript"></script>

</body>
            
          
!
            
              /*******************************
         Header
*******************************/

body
/* {background-image:url(https://cdn.shopify.com/s/files/1/0269/7611/products/248_54434c9ede99e_3_1413696670_rustic-table-4.jpeg?v=1444237519);
  background-repeat: no-repeat;
  background-position: 0px 0px;
  /*background-attachment: ;*/

background-size: cover;
*/
}
.header-div {
  margin: 0 0;
  height: 90px;
  background-color: black;
}
.header-div h1 {
  font-size: 35px;
  font-family: "Josefin Sans", Ariel, serif;
  font-weight: 900;
  color: black;
  text-align: center;
  margin-top: 0px;
  margin-bottom: -10px;
  padding-top: 5px;
  padding-bottom: 0;
}
.header-div h3 {
  font-size: 20px;
  font-family: "Josefin Sans", Ariel, serif;
  font-weight: 400;
  color: black;
  padding-top: 0;
  padding-bottom: 4px;
  text-align: center;
  border-bottom: 1px solid black;
}

/***********************************
        Body of Calculator
************************************/
.container {
  /* styles whole body of calculator */
  
  border: 2px solid grey;
  display: block;
  background: linear-gradient(to bottom right, Silver, DarkSlateGrey);
  background-color: grey;
  box-shadow: 10px 10px 15px 1px black;
  height: 420px;
  max-width: 280px;
  min-width: 280px;
  margin-top: 10px;
  padding-top: 0px;
  border-radius: 15px;
}
#numberDisplay {
  /* Display of Calc Output */
  
  height: 95px;
  box-shadow: 2px 2px 10px 1px DarkSlateGrey inset;
  border: 2px black DarkSlateGrey;
  font-family: "Montserrat", Ariel, serif;
  font-weight: 700;
  font-size: 16px;
  color: blue;
  text-align: right;
  width: 225px;
  padding-top: 15px;
  margin-top: 20px;
  margin-left: auto;
  margin-right: auto;
}
#numberDisplay1 {
  height: 16px;
}
#numberDisplay2 {
  height: 16px;
}
#separator-line {
  width: 85%;
  margin-left: 20px;
  border-top: 2px solid DarkSlateGrey;
}

/*****************************
        Buttons
******************************/
.btn:focus {
  /* Removes any outlining from button containers */
  
  outline: 0 !important;
}
.btn {
  /* Button Sizing and Spacing */
  
  display: block;
  width: 45px;
  margin: 4px;
  margin-bottom: 5px;
  text-align: center;
}
#buttonGroup {
  /* Buttons Container */
  
  padding-left: 1px;
  padding-top: 10px;
  align-content: center;
  font-family: "Montserrat", Ariel, serif;
  font-weight: 700;
  color: #000;
  text-align: center;
}

/*********************************
 Function Buttons Style on Hover
*********************************/
#buttonGroup #divideNum:hover,
#buttonGroup #percentNum:hover,
#buttonGroup #plusminus:hover,
#buttonGroup #addNum:hover,
#buttonGroup #minusNum:hover,
#buttonGroup #timesNum:hover,
#buttonGroup #enter:hover,
#buttonGroup #clr:hover,
#buttonGroup #backspace:hover,
#buttonGroup #equals:hover,
#buttonGroup #rd34:hover {
  background-color: silver;
}

/*********************************
  Function Buttons Normal Style
*********************************/
#buttonGroup #divideNum,
#buttonGroup #percentNum,
#buttonGroup #plusminus,
#buttonGroup #addNum,
#buttonGroup #minusNum,
#buttonGroup #timesNum,
#buttonGroup #clr,
#buttonGroup #backspace,
#buttonGroup #rd34 {
  font-weight: 900;
  background-color: lightgrey;
}
#buttonGroup #equals {
  /* Equals Button - Sizing and Style */
  /*align-items: stretch;*/
  
  font-size: 20px;
  padding-top: 2px;
  margin-top: 3px;
  width: 210px;
  height: 40px;
  background-color: lightgrey;
}
#buttonGroup .btn {
  /* Individual Button Styles */
  
  box-shadow: 4px 4px 15px 1px DarkSlateGrey;
  border: 3px solid Grey;
  border-style: ridge;
  border-radius: 15px;
  font-weight: 900;
  font-size: 14px;
}
#buttonGroup .btn:active {
  background-color: lightgrey;
  box-shadow: 0 3px #666;
  transform: translateY(1px);
}

/*************************************
        Footer
*************************************/
#footer {
  font-family: "Bitter", Ariel, serif;
  font-weight: 400;
  text-align: center;
  padding-top: 70px;
  padding-bottom: 30px;
}
            
          
!
            
              /**************************************************** 
   Mathematical Functions Buttons For Top Readout
*****************************************************/

var topNumber = [];
//eval(topNumber.join(''));
///var newAnswer = topNumber; 

function clrFunction() {
  topNumber.splice(0, topNumber.length);
  document.getElementById("numberDisplay1").innerHTML = 0;
}

function divideFunction() {
  topNumber[topNumber.length] = " / ";
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function timesFunction() {
  topNumber[topNumber.length] = " X ";
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function backspaceFunction() {
  topNumber.splice(topNumber.length - 1, 1);
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
  if (topNumber.length == []) {
    document.getElementById("numberDisplay2").innerHTML = "";
  }
}

function subtractFunction() {
  topNumber[topNumber.length] = " - ";
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function addFunction() {
  topNumber[topNumber.length] = " + ";
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function percentFunction() {
  topNumber[topNumber.length] = "% ";
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function rd34Function() {
  document.getElementById("numberDisplay1").innerHTML = "Programming is Fun!";
}

function decimalFunction() {
  topNumber[topNumber.length] = ".";
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

/********************************************* 
      Upper Display Number Button Functions 
**********************************************/

function oneFunction() {
  topNumber[topNumber.length] = 1;
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function twoFunction() {
  topNumber[topNumber.length] = 2;
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function threeFunction() {
  topNumber[topNumber.length] = 3;
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function fourFunction() {
  topNumber[topNumber.length] = 4;
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function fiveFunction() {
  topNumber[topNumber.length] = 5;
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function sixFunction() {
  topNumber[topNumber.length] = 6;
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function sevenFunction() {
  topNumber[topNumber.length] = 7;
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function eightFunction() {
  topNumber[topNumber.length] = 8;
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function nineFunction() {
  topNumber[topNumber.length] = 9;
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

function zeroFunction() {
  topNumber[topNumber.length] = 0;
  document.getElementById("numberDisplay1").innerHTML = topNumber.join("");
}

/**************************************************** 
   Mathematical Function Buttons For Bottom Readout
*****************************************************/

$(document).ready(function() {

  var testNumLength = function(firstNumber) {
    if (firstNumber.length > 9) {
      $("#numberDisplay2").text(firstNumber.substr(firstNumber.length - 9, 9));
      if (firstNumber.length > 15) {
        $("#numberDisplay1").text(firstNumber.substr(firstNumber.length - 15, 15));
        firstNumber = "";
        $("#numberDisplay2").text("Err");
      }
    }
  }
  var topNumber = "";
  //var firstNumber = "";
  var secondNumber = "";
  var answer = "";
  var newAnswer = "";
  var operator = "";

  $("#numberDisplay2").text("0");

  $(".numbers").click(function() {
    topNumber += $(this).text();
    $("#numberDisplay2").text(topNumber);
    testNumLength(topNumber);
  });

  // $(".operators").click(function() {
  //   operator = $(this).text();
  //   secondNumber = firstNumber;
  //   firstNumber = "";
  //   $("#numberDisplay2").text();
  // });

  $(".addNum").click(function() {
    operator = $(this).text();
    secondNumber = topNumber;
    topNumber = "";
    $("#numberDisplay2").text();
  });

  $(".minusNum").click(function() {
    operator = $(this).text();
    secondNumber = topNumber;
    topNumber = "";
    $("#numberDisplay2").text();
    //$("#numberDisplay1").text(newAnswer + operator);
    // answer =  newAnswer - secondNumber;
  });

  $(".divideNum").click(function() {
    operator = $(this).text();
    secondNumber = topNumber;
    topNumber = "";
    $("#numberDisplay2").text();
  });

  $(".timesNum").click(function() {
    operator = $(this).text();
    secondNumber = topNumber;
    topNumber = "";
    $("#numberDisplay2").text();
  });

  $(".percentNum").click(function() {
    if (operator = "-") {
      answer = parseFloat(topNumber) - ((parseFloat(topNumber) * ((parseFloat(secondNumber)) / 100)));
    } else if (operator = "*") {
      answer = parseFloat(topNumber) * (parseFloat(topNumber) * (parseFloat(secondNumber) / 100));
    } else if (operator = "+") {
      answer = parseFloat(topNumber) + (parseFloat(topNumber) * (parseFloat(secondNumber) / 100));
    } else if (operator = "/") {
      answer = (parseFloat(topNumber)) / ((parseFloat(secondNumber) / 100));
    }

    $("#numberDisplay2").text(answer);
  });

  $("#clr").click(function() {
    topNumber = "";
    $("#numberDisplay2").text("0");
    if ($(this).attr("id") == "clr") {
      topNumber = "";
    }
  });

  $("#backspace").click(function() {
    topNumber = topNumber.substring(0, topNumber.length - 1);
    document.getElementById("numberDisplay2").innerHTML = "";
  });

  $("#equals").click(function() {
    if (operator == "+") {
      answer = parseFloat(topNumber) + parseFloat(secondNumber);
    } else if (operator == "-") {
      answer = secondNumber - topNumber;
    } else if (operator == "X") {
      answer = secondNumber * topNumber;
    } else if (operator == "/") {
      answer = secondNumber / topNumber;
    } // else if (operator == "%") {
    //  answer = secondNumber / 100;
    //}

    answer; //newAnswer = 
    //newAnswer = eval(topNumber.join(""));
    $("#numberDisplay2").text(answer.toPrecision(6));
    //$("#numberDisplay2").text(eval(topNumber));
  });
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console