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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                body
  div.container
    div.screen-item.screen 
      span screen
    dl.touche__box
      dt.clear-item 
        span clear
      dt.touche__box-item 
        span.soustraction _
      dt.touche__box-item
        span.sign +
      dt.touche__box-item.clearme 
        span 7
      dt.touche__box-item 
        span 8
      dt.touche__box-item 
        span 9
      dt.touche__box-item
        span.sign /
      dt.touche__box-item 
        span 4
      dt.touche__box-item 
        span 5
      dt.touche__box-item 
        span 6
      dt.touche__box-item
        span.sign x
      dt.touche__box-item 
        span 1
      dt.touche__box-item 
        span 2
      dt.touche__box-item 
        span 3
      dt.equal-item
        span.sign-equal =
      dt.touche__box-item.zero-item 
        span 0
      dt.touche__box-item.un-item
        span.sign .

              
            
!

CSS

              
                //background: transparent url(http://artot.net/freecodecamp-project/calculator-html/index.html/frontal.png) no-repeat
body
  background-color: #B2B9C2
  color #000
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  align-content: center;
  font-family: 'Roboto', sans-serif;
  .container
     background: transparent url(http://artot.net/freecodecamp-project/calculator-html/index.html/frontal.png) no-repeat
     width: 408px
     height: 837px;
     position relative
     color #fff
     font-size: 3em

     .screen-item  
       position absolute
       width: 352px
       height: 37px
       background #FF7F24
       border 1px solid #fff
       top: 100px;
       left: 28px;
       text-align right
       span
         position: absolute;
         top: 50%;
         left: 50%;
         transform: translateX(-50%) translateY(-50%); 
       .error
         color: #f00;
         border: 1px solid;
         /* padding: 10px 60px; */
         border-radius: 5px;
         display: block;
         width: 73%;
         font-size: 1em;
         text-align: center;
         font-weight: bold;
         background: #fff;
         font-size: .8em;
         padding: 20px 11px;
         line-height: 1.2;

     .touche__box
       position: relative;
       top: 91px;
       left: 27px;
       span
         //transform: translate(-50%, -50%)
         width: 100%
         height: 100%
         display: block
         text-indent: 29px;
         line-height: 2.1;
       span.soustraction 
         line-height: 1.5
       .touche__box-item
         width: 85px
         height: 96px
         background-color: #FFD6D6
         font-weight bold
         color #FF7F24
         float: left
         position relative
         margin 2px
       .clear-item   
         //position absolute
         width: 173px
         height: 95px
         background #53e4ed
         border 1px solid #fff
         float: left
         position relative
         margin 2px
         span
           text-indent: 35px;
           line-height: 1.99;

       .zero-item
         width: 174px
         height: 96px
         span
           text-indent: 79px
       .zero-item, .un-item
         position: relative;
         margin-top: -97px;
       .equal-item 
         width: 85px
         height: 96px
         background-color: #ea2131
         float: left
         position relative
         margin 2px
         height: 194px;
         span
           line-height: 4
       .clearme
         clear: both;
  div
    padding-top: 2em


              
            
!

JS

              
                //Generate by BABEL -:)
'use strict';

//DESIGN
//loading page: 
//en meme temps
//page blanche vers page noir
//iphone cocke noir vers iphone cocke blanche
//https://tympanus.net/codrops/2016/10/12/animated-decorative-lines/
(function () {

  var arrSign = ['-', '+', '/', '*', 'x'],
      arr = [],
      result = 0,
      printCalcul = '',
      arrSort = void 0,
      strSign = void 0,
      error = void 0,
      screen = document.querySelector('.screen span'),
      ele = document.querySelectorAll('.touche__box-item > span'),
      equal = document.querySelector('.sign-equal'),
      clear = document.querySelector('.clear-item  span');

  //operation
  for (var i = 0; i < ele.length; i++) {
    ele[i].addEventListener('click', function (e) {
      var cible = e.target.innerHTML === '_' ? cible = '-' : e.target.innerHTML;
      //on memorise dans le tableau
      arr.push(cible);
      //printCalcul display the screen
      printCalcul += cible;
      screen.innerHTML = printCalcul;
      e.preventDefault();
    });
  }
  clear.addEventListener('click', function (e) {
    screen.innerHTML = 'screen';
    arr.splice(0, arr.length);
    printCalcul = '';
    screen.classList.remove('error');
    e.preventDefault();
  });

  error = function error(strSignMessage) {
    screen.innerHTML = 'err with sign ' + strSignMessage;
    screen.classList.add('error');
  };

  equal.addEventListener('click', function (e) {
    result = 0;
    strSign = arr.join('');
    //return an array with the number together
    arrSort = strSign.match(/(\d+)|\D/g); //[ '4', '-', '94', '-', '8' ]
    for (var _i = 0, l = arrSort.length; _i < l; _i++) {
      var current = arrSort[_i],
          prev = arrSort[_i - 1],
          next = arrSort[_i + 1];
      prev = prev !== undefined && arrSign.indexOf(prev) === -1 ? parseInt(prev, 10) : '';
      next = next !== undefined && arrSign.indexOf(next) === -1 ? parseInt(next, 10) : '';
      //debugger
      //
      // if value current it's a sign: +-/*x 
      if (arrSign.indexOf(current) >= 0) {
        if (current === '+') {
          if (_i === 1) {
            //if is the first sign +-/* we're count the prev and next element
            result = prev + next;
            //console.log(result + ' : ' + i + ' : ' + arrSort[i] + ' : ' + arrSort[j] );
          } else if (_i > 1) {
            result += next;
            //console.log(result + ' : ' + i + ' : ' + arrSort[i+1]);
          } else if (_i === 0) {
            error('+');
            break;
          }
        }
        if (current === '-') {
          if (_i === 1) {
            //first sign +-/*
            result = prev - next;
            //console.log(result + ' - ' + ' : ' + i + ' : ' + arrSort[i] + ' : ' + arrSort[j] );
          } else if (_i > 1) {
            result -= next;
            //console.log(result + ' - ' +' : ' + i + ' : ' + arrSort[i+1]);
          } else if (_i === 0) {
            error('-');
            break;
          }
        }
        if (current === 'x') {
          if (_i === 1) {
            //first sign +-/*
            result += prev * next;
          } else if (_i > 1) {
            result *= next;
            //console.log(result + ' * ' +' : ' + i + ' : ' + arrSort[i+1]);
          } else if (_i === 0) {
            error('*');
            break;
          }
        }
        if (current === '/') {
          if (_i === 1) {
            //first sign +-/*
            result += prev / next;
          } else if (_i > 1) {
            result /= next;
          } else if (_i === 0) {
            error('/');
            break;
          }
        }
      }
    }
    if (!screen.classList.contains('error')) {
      screen.innerHTML = result;
    }
    e.preventDefault();
  }); //end click equal
})(); //END
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyJdLCJuYW1lcyI6WyJhcnJTaWduIiwiYXJyIiwicmVzdWx0IiwicHJpbnRDYWxjdWwiLCJhcnJTb3J0Iiwic3RyU2lnbiIsImVycm9yIiwic2NyZWVuIiwiZG9jdW1lbnQiLCJxdWVyeVNlbGVjdG9yIiwiZWxlIiwicXVlcnlTZWxlY3RvckFsbCIsImVxdWFsIiwiY2xlYXIiLCJpIiwibGVuZ3RoIiwiYWRkRXZlbnRMaXN0ZW5lciIsImUiLCJjaWJsZSIsInRhcmdldCIsImlubmVySFRNTCIsInB1c2giLCJwcmV2ZW50RGVmYXVsdCIsInNwbGljZSIsImNsYXNzTGlzdCIsInJlbW92ZSIsInN0clNpZ25NZXNzYWdlIiwiYWRkIiwiam9pbiIsIm1hdGNoIiwibCIsImN1cnJlbnQiLCJwcmV2IiwibmV4dCIsInVuZGVmaW5lZCIsImluZGV4T2YiLCJwYXJzZUludCIsImNvbnRhaW5zIl0sIm1hcHBpbmdzIjoiOztBQUFBO0FBQ0U7QUFDRTtBQUNFO0FBQ0E7QUFDTjtBQUNDLGFBQVc7O0FBRVYsTUFBSUEsVUFBUSxDQUFDLEdBQUQsRUFBSyxHQUFMLEVBQVMsR0FBVCxFQUFhLEdBQWIsRUFBaUIsR0FBakIsQ0FBWjtBQUFBLE1BQWtDQyxNQUFJLEVBQXRDO0FBQUEsTUFDRUMsU0FBTyxDQURUO0FBQUEsTUFDWUMsY0FBWSxFQUR4QjtBQUFBLE1BQzRCQyxnQkFENUI7QUFBQSxNQUNxQ0MsZ0JBRHJDO0FBQUEsTUFDOENDLGNBRDlDO0FBQU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gKyAnIDogJyArIGFyclNvcnRbal0gKTtcbiAgICAgICAgICB9ZWxzZSBpZiAoaSA+IDEpIHtcbiAgICAgICAgICAgIHJlc3VsdCArPSBuZXh0IFxuICAgICAgICAgICAgLy9jb25zb2xlLmxvZyhyZXN1bHQgKyAnIDogJyArIGkgKyAnIDogJyArIGFyclNvcnRbaSsxXSk7XG4gICAgICAgICAgfSBlbHNlIGlmKGkgPT09IDApe1xuICAgICAgICAgICAgZXJyb3IoJysnKVxuICAgICAgICAgICAgYnJlYWtcbiAgICAgICAgICB9IFxuICAgICAgICB9XG4gICAgICAgIGlmIChjdXJyZW50ID09PSAnLScpIHtcbiAgICAgICAgICBpZiAoaSA9PT0gMSkgey8vZmlyc3Qgc2lnbiArLS8qXG4gICAgICAgICAgICByZXN1bHQgPSBwcmV2IC0gbmV4dFxuICAgICAgICAgICAgLy9jb25zb2xlLmxvZyhyZXN1bHQgKyAnIC0gJyArICcgOiAnICsgaSArICcgOiAnICsgYXJyU29ydFtpXSArICcgOiAnICsgYXJyU29ydFtqXSApO1xuICAgICAgICAgIH1lbHNlIGlmIChpID4gMSkge1xuICAgICAgICAgICAgcmVzdWx0IC09IG5leHQgXG4gICAgICAgICAgICAvL2NvbnNvbGUubG9nKHJlc3VsdCArICcgLSAnICsnIDogJyArIGkgKyAnIDogJyArIGFyclNvcnRbaSsxXSk7XG4gICAgICAgICAgfSBlbHNlIGlmKGkgPT09IDApe1xuICAgICAgICAgICAgZXJyb3IoJy0nKVxuICAgICAgICAgICAgYnJlYWtcbiAgICAgICAgICB9IFxuICAgICAgICB9XG4gICAgICAgIGlmIChjdXJyZW50ID09PSAneCcpIHtcbiAgICAgICAgICBpZiAoaSA9PT0gMSkgey8vZmlyc3Qgc2lnbiArLS8qXG4gICAgICAgICAgICByZXN1bHQgKz0gcHJldiAqIG5leHRcbiAgICAgICAgICB9ZWxzZSBpZiAoaSA+IDEpIHtcbiAgICAgICAgICAgIHJlc3VsdCAqPSBuZXh0IFxuICAgICAgICAgICAgLy9jb25zb2xlLmxvZyhyZXN1bHQgKyAnICogJyArJyA6ICcgKyBpICsgJyA6ICcgKyBhcnJTb3J0W2krMV0pO1xuICAgICAgICAgIH0gZWxzZSBpZihpID09PSAwKXtcbiAgICAgICAgICAgIGVycm9yKCcqJylcbiAgICAgICAgICAgIGJyZWFrXG4gICAgICAgICAgfSBcbiAgICAgICAgfVxuICAgICAgICBpZiAoY3VycmVudCA9PT0gJy8nKSB7XG4gICAgICAgICAgaWYgKGkgPT09IDEpIHsvL2ZpcnN0IHNpZ24gKy0vKlxuICAgICAgICAgICAgcmVzdWx0ICs9IHByZXYgLyBuZXh0XG4gICAgICAgICAgfWVsc2UgaWYgKGkgPiAxKSB7XG4gICAgICAgICAgICByZXN1bHQgLz0gbmV4dCBcbiAgICAgICAgICB9IGVsc2UgaWYoaSA9PT0gMCl7XG4gICAgICAgICAgICBlcnJvcignLycpXG4gICAgICAgICAgICBicmVha1xuICAgICAgICAgIH0gXG4gICAgICAgIH1cbiAgICAgIH0gXG5cbiAgICB9XG4gICAgaWYgKCFzY3JlZW4uY2xhc3NMaXN0LmNvbnRhaW5zKCdlcnJvcicpKSB7XG4gICAgICBzY3JlZW4uaW5uZXJIVE1MID0gcmVzdWx0IFxuICAgIH0gXG4gICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xuICB9KTsgLy9lbmQgY2xpY2sgZXF1YWxcblxufSgpKTsvL0VORFxuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

              
            
!
999px

Console