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

              
                <div ng-app="TICalc" ng-controller="Ctrl" >
  <div class="columns">
    <div id="row-1" class="rows">
      <div id="screen">
        <div id="line1" class="line ng-cloak">{{ line[0] }}&nbsp;</div>
        <div id="line2" class="line ng-cloak">{{ line[1] }}&nbsp;</div>
        <div id="line3" class="line ng-cloak">{{ line[2] }}&nbsp;</div>
        <div id="line4" class="line ng-cloak">{{ line[3] }}&nbsp;</div>
        <div id="line5" class="line ng-cloak">{{ line[4] }}&nbsp;</div>
      </div>
      <div id="ce" class="cell">
        CE
      </div>
      <div id="c" class="cell" ng-click="clearAll()">
        C
      </div>
      <div id="del" class="cell" ng-click="deleteInput()";>
        Del
      </div>
      <div id="div" class="cell" ng-click="input('/')">
        /
      </div>
    <div>


    <div id="row-2" class="rows">
      <div id="7" class="cell" ng-click="input(7)">
        7
      </div>
      <div id="8" class="cell" ng-click="input(8)">
        8
      </div>
      <div id="9" class="cell" ng-click="input(9)">
        9
      </div>
      <div id="mul" class="cell" ng-click="input('*')">
        X
      </div>
    <div>

    <div id="row-3" class="rows">
      <div id="4" class="cell" ng-click="input(4)">
        4
      </div>
      <div id="5" class="cell" ng-click="input(5)">
        5
      </div>
      <div id="6" class="cell" ng-click="input(6)">
        6
      </div>
      <div id="minus" class="cell" ng-click="input('-')">
        &mdash;
      </div>
    <div>

    <div id="row-4" class="rows">
      <div id="1" class="cell" ng-click="input(1)">
        1
      </div>
      <div id="2" class="cell" ng-click="input(2)">
        2
      </div>
      <div id="3" class="cell" ng-click="input(3)">
        3
      </div>
      <div id="add" class="cell" ng-click="input('+')">
        +
      </div>
    <div>

    <div id="row-3" class="rows">
      <div id="n" class="cell" ng-click="input('!')">
        n!
      </div>
      <div id="0" class="cell" ng-click="input(0)">
        0
      </div>
      <div id="." class="cell" ng-click="input('.')">
        .
      </div>
      <div id="equal" class="cell" ng-click="calculate()">
        =
      </div>
    <div>
  </div>
</div>
              
            
!

CSS

              
                [ng\:cloak], [ng-cloak], .ng-cloak {
  display: none !important;
}

#screen
{
  border:5px solid gray;
  border-top-left-radius: 10px 10px;
  border-top-right-radius: 10px 10px;
  font-size:24px;
  padding:5px;
  overflow:hidden;
  text-overflow:clip;
  background:silver;
}

.line
{
  overflow:hidden;
  text-overflow:clip;
  max-width:100%;
  display:block;
  width:210px;
}

#line2, #line4
{
  text-align:right;
}

.columns
{
  border:1px solid black;
  display:inline-block;
  padding:15px;
  border-top-left-radius: 10px 10px;
  border-top-right-radius: 10px 10px;
  border-bottom-left-radius: 90px 10px;
  border-bottom-right-radius: 90px 10px;
  background: black;
}

.rows
{
  display:inline-block;
  background: black;
}

.cell
{
  background:white;
  border:2px outset gray;
  display:inline-block;
  padding:10px;
  width:32px;
  text-align:center;
  float:left;
  border-top-left-radius:10px;
  border-top-right-radius:10px;
  border-bottom-left-radius:25px;
  border-bottom-right-radius:25px;
}

.cell:hover
{
  background:lightblue;
}

.cell:active
{
  background:blue;
  color:white;
  border:2px inset gray;
}
              
            
!

JS

              
                var app = angular.module('TICalc', []);
app.controller('Ctrl', function($scope, $sce) 
{
    $scope.onLine = 0;
    var cursor = $sce.trustAsHtml("▓")
    $scope.line = [cursor,"","","", ""];
  $scope.number = "";
    $scope.input = function(number) 
    {
      $scope.number += number;
        $scope.line[$scope.onLine] = $scope.number + cursor;
    }
    $scope.clearAll = function() 
    {
        $scope.line = [];
        $scope.onLine = 0;
      $scope.line[$scope.onLine] = cursor;
    }
    $scope.deleteInput = function() 
    {
        var changed = $scope.number.substring(0, $scope.number.length - 1);
      $scope.number = changed;
         $scope.line[$scope.onLine] = $scope.number + cursor;
    }
    $scope.calculate = function() 
    {
      var numbers = [];
      var ops = [];
      temp = [];
      var answer = 0;
      var nums = 0;
      var noCursor = $scope.line[$scope.onLine].toString().substring(0, $scope.line[$scope.onLine].length-1);
      for(a = 0; a != noCursor.length; a++) // char by char check
      {
        var char = noCursor.substring(a,a+1);

        if(!isNaN(char) || char === ".") // if char is a number
          nums = nums + char; // add chars until find a non number
        else
        {
          if(char === "+" || char === "-" || char == "*" || char == "/" || char == "!") // if found math sign
          {
            numbers.push(nums); 
            nums = "";
            ops.push(char);
          }
        }
      }
      numbers.push(nums); 
      nums = "";
      var answer = 0;
      for(b = 0; b != ops.length; b++)
      {
        if(ops[b] == "+")
        {
          if(b == 0)
          {
            var num1 = 0 + parseFloat(numbers[b]);
            var num2 = 0 + parseFloat(numbers[b+1]);
            answer = num1 + num2;
          }
          else
            answer = answer + parseFloat(numbers[b+1]);
        }
        if(ops[b] == "-")
        {
          if(b == 0)
          {
            var num1 = parseFloat(numbers[b]);
            var num2 = parseFloat(numbers[b+1]);
            answer = num1 - num2;
          }
          else
            answer = answer - parseFloat(numbers[b+1]);
        }
        if(ops[b] == "*")
        {
          if(b == 0)
          {
            var num1 = parseFloat(numbers[b]);
            var num2 = parseFloat(numbers[b+1]);
            answer = num1 * num2;
          }
          else
            answer = answer * parseFloat(numbers[b+1]);
        }
        if(ops[b] == "/")
        {
          if(b == 0)
          {
            var num1 = parseFloat(numbers[b]);
            var num2 = parseFloat(numbers[b+1]);
            answer = num1 / num2;
          }
          else
            answer = answer / parseFloat(numbers[b+1]);
        }
        if(ops[b] == "!")
        {
          if(b == 0)
          {
            var n = parseInt(numbers[b]);
            var num = 1;
            while(n != 1)
            {
              num = num * n;
              n--;
            }
            answer = num;
          }
          else
          {
            var n = parseInt(numbers[b]);
            var num = 1;
            while(n != 1)
            {
              num = num * n;
              n--;
            }
            answer = num;
          }
        }
      }

      var changed = $scope.line[$scope.onLine].toString().substring(0, $scope.line[$scope.onLine].length-1);
      if($scope.onLine > 3)
      {
        $scope.line[0] =  $scope.line[2].substring(0,$scope.line[2].length);
        $scope.line[1] =  $scope.line[3].substring(0,$scope.line[3].length);
        $scope.line[2] = changed;
        $scope.line[3] = "=" + answer;
        $scope.line[4] = cursor;
        $scope.onLine = 4;
      }
      else
      {
        $scope.line[$scope.onLine] = changed;
        $scope.onLine++;
        $scope.line[$scope.onLine] = "=" + answer;
        $scope.onLine++;
        $scope.line[$scope.onLine] = cursor;
      }
      $scope.number = "";
    }
});
              
            
!
999px

Console