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.

            
              h1.title chmod numeric calculator
p.description For when you just can't remember if you need 644 or 755 and just decide to use 777.

.calc
  .bits
    .spacer.bit
    .owner.bit Owner
    .group.bit Group
    .other.bit Other
  .modes
    .label
      .read Read (4)
      .write Write (2)
      .execute Execute (1)
    each i in ['owner', 'group', 'other']
      .who(class=i)
        each value, name in {'read': 4, 'write': 2, 'execute': 1}
          input.mode(class=name, type='checkbox', value=value)
  .results
    .result.spacer Result
    .result.owner 0
    .result.group 0
    .result.other 0
      
            
          
!
            
              html {
  box-sizing: border-box;

  *,
  *:before,
  *:after {
    box-sizing: inherit;
  }
}

body {
  background: transparentize(#333333, 0.8);
}

.title,
.description {
  text-align: center;
}

.title {
  text-transform: uppercase;
  font-weight: 100;
}

.description {
  margin: 0 auto;
  max-width: 500px;
  font-weight: 100;
}

.calc {
  margin: 50px auto;
  max-width: 400px;
  background: white;
  box-shadow: 0 1px 1px rgba(100, 100, 100, 0.5);
}

.bits {
  overflow: hidden;
  
  .bit {
    width: 25%;
    float: left;
    text-align: center;
    padding: 10px;
  }
}

.modes {
  overflow: hidden;
  
  .label {
    width: 25%;
    float: left;
    
    .read,
    .write,
    .execute {
      display: block;
      margin: 25px auto;
      text-align: right;
      padding-left: 10px;
    }
  }
  
  .who {
    width: 25%;
    float: left;
    text-align: center;
    
    .mode {
      display: block;
      margin: 25px auto;
    }
  }
}

.results {
  border-top: 1px solid #666666;
  background: #f3f3f3;
  overflow: hidden;
  
  .result {
    width: 25%;
    float: left;
    margin: 10px 0;
    text-align: center;
  }
}
            
          
!
            
              $(document).ready(function() {
  var output = {
    owner: null,
    group: null,
    other: null
  };
  
  var input = {
    owner: {
      read: null,
      write: null,
      execute: null
    },
    
    group: {
      read: null,
      write: null,
      execute: null
    },
    
    other: {
      read: null,
      write: null,
      execute: null
    }
  };
  
  output.owner = $('.result.owner');
  output.group = $('.result.group');
  output.other = $('.result.other');
  
  input.owner.read = $('.who.owner .mode.read');
  input.owner.write = $('.who.owner .mode.write');
  input.owner.execute = $('.who.owner .mode.execute');
  
  input.group.read = $('.who.group .mode.read');
  input.group.write = $('.who.group .mode.write');
  input.group.execute = $('.who.group .mode.execute');
  
  input.other.read = $('.who.other .mode.read');
  input.other.write = $('.who.other .mode.write');
  input.other.execute = $('.who.other .mode.execute');
  
  function calculateBit(bit) {
    var result = 0,
    		mode;
    
    for (mode in input[bit]) {
      result += (input[bit][mode][0].checked) ? parseInt(input[bit][mode].val()) : 0;
    }
    
    return result;
  }
  
  function calculateNumeric() {
    var bit;
    
    for (bit in input) {
      output[bit].text(calculateBit(bit));
    }
  }
  
  $('input[type=checkbox]').on('change', calculateNumeric);
});
            
          
!
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