Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                


<br />
<div id="surrounding">
<div id="case">
  <div id="top-section">
    <div class="logo-left text-center">BUSICON</div>
    <div class="logo-right text-center">handi</div>
  <div id="panel-bottom">
    <div id="display-border">
<div id="led-display">
  <div id="d0" class="led-digit led-on">0</div>
  <div id="d1" class="led-digit led-off">8.</div>
  <div id="d2" class="led-digit led-off">8.</div>
  <div id="d3" class="led-digit led-off">8.</div>
  <div id="d4" class="led-digit led-off">8.</div>
  <div id="d5" class="led-digit led-off">8.</div>
  <div id="d6" class="led-digit led-off">8.</div>
  <div id="d7" class="led-digit led-off">8.</div>
  <div id="dN" class="led-digit led-off">-</div>
</div> <!-- LED display -->
    </div> <!-- LED display border -->
  </div> <!-- brushed metal panel -->
  </div> <!-- top section -->
  <div style="height: 10px"></div>
<div id="btn-enclosure" class="container-fluid">
  
<!-- it may be better to do these rows as button groups 
      need to clean the divs up anyway-->
  <div>
    <div class="column"><button id="n7" class="num-btn"><p>7</p></button></div>
    <div class="column"><button id="n8" class="num-btn"><p>8</p></button></div>
    <div class="column"><button id="n9" class="num-btn"><p>9</p></button></div>
    <div class="column"><button id="oX" class="op-btn"><p>X</p></button></div>
  </div>
  
  <div>
    <div class="column"><button id="n4" class="num-btn"><p>4</p></button></div>
    <div class="column"><button id="n5" class="num-btn"><p>5</p></button></div>
    <div class="column"><button id="n6" class="num-btn"><p>6</p></button></div>
    <div class="column"><button id="oD" class="op-btn"><p>÷</p></button></div>
  </div>
  
  <div>
    <div class="column"><button id="n1" class="num-btn"><p>1</p></button></div>
    <div class="column"><button id="n2" class="num-btn"><p>2</p></button></div>
    <div class="column"><button id="n3" class="num-btn"><p>3</p></button></div>
    <div class="column"><button id="oS" class="op-btn"><p>-=</p></button></div>
  </div>

  <div>
    <div class="column"><button id="n0" class="num-btn"><p>0</p></button></div>
    <div class="column"><button id="nP" class="num-btn"><p>.</p></button></div>
    <div class="column"><button id="oC" class="op-btn"><p>C</p></button></div>
    <div class="column"><button id="oA" class="op-btn"><p>+=</p></button></div>
  </div>
  
</div> <!-- button enclosure -->
</div> <!-- case -->
  <br />

<h4 style="text-align: center; text-shadow: 0px 0px 30px white;">Learn about <a href="http://www.vintagecalculators.com/html/busicom_le-80a_handy.html" target="_blank">the real Busicom Handy</a> and<br /><a href="https://en.wikipedia.org/wiki/Intel_4004" target="_blank">Busicom's instrumental role in Intel's early history.</a></h4>
  
  
              
            
!

CSS

              
                body, html {
  background-color: black;
  padding: 0px;
  margin: 0px;
  background-color: #a0a0a0;
}

#case {
  width: 296px;
  padding: 8px 3px 3px 3px;
  border-radius: 7px;
  margin: 0 auto;
  background-color: #101316;
  box-shadow: 6px 7px 15px 1px #101316;
}

#top-section {
  width: 100%;
  border-style: solid;
  border-color: #101316;
  border-width: 2px;
  border-radius: 7px;
  background: url(https://res.cloudinary.com/dnrhtjoay/image/upload/calculator/brushed-texture.gif) left top repeat;
}

.logo-left {
  height: 50px;
  width: 46%;
  float: left;
  text-align: center;
  font-family: 'Dhurjati', sans-serif;
  font-size: 25px;
  padding-top: 10px;
}

.logo-right {
  height: 50px;
  width: 54%;
  float: right;
  text-align: left;
  font-family: 'Gruppo';
  font-size: 50px;
  margin-top: -10px;
}

#panel-bottom {
  width: 100%;
  display:flex;
  justify-content: center;
  padding-top: 10px;
  padding-bottom: 20px;
}

#display-border {
  background-color: #262930;
  width: 93%;
  height: 78px;
  border-radius: 3px;
  box-shadow: 6px 6px 6px -4px black inset;
}

#led-display {
  background: #1e1616;
  height: 35px;
  margin: 20px;
}

.led-digit {
  font-family: 'Rationale', sans-serif;
  font-size: 24px;
  text-align: center;
  float: right;
  width: 25px;
  margin-top: 1px;
}

.led-on {
  color: #ff4f3f;
  background-color: #7a261d;
  text-shadow: 1px 0px 6px red;
  box-shadow: 0px 0px 15px 10px #2b1d1c inset;
}

.led-off {
  color: #3a2624;
  background-color: #2b1d1c;
}

#btn-enclosure {
  width: 100%;
  border-style: solid;
  border-color: #101316;
  border-width: 2px;
  border-radius: 3px;
  background-color: #262930;
  background: url(https://res.cloudinary.com/dnrhtjoay/image/upload/calculator/plastic-texture2.gif) left top repeat;
  padding: 0px 10px 20px 10px;
}

button {
  font-family: 'Chathura', sans-serif;
  font-weight: bold;
  font-size: 30px;
  height: 32px;
  width: 45px;
  border-radius: 6px;
  box-shadow: 1px 1px 6px 2px black;
  border-width: 1px;
  border-color: #9d9fa5;
}

button:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 3px 1px black;
  border-color: #252c33;
}

button:focus {
  outline: none;
}

.op-btn {
  color: white;
  background-color: #62bbdd;
  border-color: #62bbdd;
}

.num-btn {
  color: black;
  background-color: #f7f9ee;
  border-color: silver;
}

.column {
  width: 48px;
  float: left;
  margin-left: 15px;
  padding-top: 20px;
}

p {
  margin: -7px;
}
              
            
!

JS

              
                /* This design was inspired by the Busicom LE-80A Handy, a very early pocket calculator sold in the 70s. It has an unusual key layout, lacking a dedicated equals key. There are eight, seven-segment LED digit displays and a ninth display for error flags and the negative indicator.
*/

var inputBuffer = [];   // display inputBuffer
var memory = null;  // left argument
var operator = '';  // operator memory

$('button').click(function() {
  this.id[0] === "n" ?
    pressNumber(this.id[1]) :
    performOperation(this.id[1], inputBuffer);
});

function pressNumber(num) {
  if (num === '0' && inputBuffer.length === 0) {return;}
  if (num === 'P') {
    if (inputBuffer.indexOf('.') !== -1) {return;}
    if (inputBuffer.length === 0) inputBuffer.unshift('0')
    num = '.';
  }
  
  if (inputBuffer.filter(char => char !== '.').length < 8 ) {
    inputBuffer.push(num);
    updateDisplay(inputBuffer);
  }
}


function performOperation(type, arr) {
  arr.unshift('0');
  var number = parseFloat(arr.join(""));
  inputBuffer = [];
  
  if (type === 'C') {
    clearDisplay();
    memory = null;
    operator = '';
  } else if (type === operator && memory != null) {
    switch (type) {
      case 'A':
        memory += number;
        convertToDisplay(memory);
        break;
      case 'S':
        memory -= number;
        convertToDisplay(memory);
        break;
      case 'X':
        memory *= number;
        convertToDisplay(memory);
        break;
      case 'D':
        memory /= number;
        convertToDisplay(memory);
        break;
    }
  } else if (type !== operator && memory != null) {
      performOperation(operator, arr);
      operator = type;
  } else {
    operator = type;
    memory = number;
  }
}


function convertToDisplay(float) {
  var ans = []
  if (float > 99999999 || float < -99999999) {
    ans = ['E'];
  } else {
    ans = Math.abs(float)
              .toFixed(7) // BUG: can display rounding error when chaining operations
              .slice(0,9)
              .replace(/[0]+$/g, "") // suppress trailing zeros caused by floating point error
              .split('')
  }
  updateDisplay(ans, float < 0 ? true : false);
}


function updateDisplay(digitArr, neg){
  digitArr = digitArr.reduce(function(a, b, index) {
          b === '.' ? a[index] += b : a.push(b);
          return a;
        }, [0]).reverse();
  
  clearDisplay();
  if (neg === true) {$('#dN').removeClass('led-off').addClass('led-on');}

    for (var i = 0; i < digitArr.length - 1; i++) {
      $('#d' + i).html(digitArr[i]).removeClass('led-off').addClass('led-on')
    }
}


function clearDisplay() {
  $('#d0').html('0');
  $('#d1').removeClass('led-on').addClass('led-off').html('8.');
  $('#d2').removeClass('led-on').addClass('led-off').html('8.');
  $('#d3').removeClass('led-on').addClass('led-off').html('8.');
  $('#d4').removeClass('led-on').addClass('led-off').html('8.');
  $('#d5').removeClass('led-on').addClass('led-off').html('8.');
  $('#d6').removeClass('led-on').addClass('led-off').html('8.');
  $('#d7').removeClass('led-on').addClass('led-off').html('8.');
  $('#dN').removeClass('led-on').addClass('led-off');
}
              
            
!
999px

Console