Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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 style='padding:0;margin:auto;text-align:center'>
  <h1 style='text-align:center'>Splitting</h1>
  <div style='text-align:center;margin:20px auto'>
    <input id='inputOne' placeholder="input here"
    size='20' type="text" placeholder='type something'
    title='enter, click, and focus will empty the value'>
    <button id='split'>split the characters</button>
  </div>
  <div id="splittedChar"></div>
  <div class='charWrapper'></div>
</div>
              
            
!

CSS

              
                /* This css is kinda messy, bwahaha*/
body {
  background: #ccc;
  font-family: 'Open Sans';
}

hr {
  background: none;
  border: 0;
  border-top: 1px solid #bbb;
  border-bottom: 1px solid #fff;
}

.charHolder {
  font-size: 1em;
  padding: 5px;
  width: 30px;
  border-radius: 6px;
  text-align: center;
  height: auto;
  margin: 3px;
  display: inline-block;
  box-shadow: 5px 8px 10px #777;
  background: #eee; 
  border: 2px solid #eee;
}

.charWrapper {
  padding: 10px;
}

#inputOne {
  padding: 10px;
  text-align: center;
  border-radius: 4px;
  font-family: consolas;
  border: 0;
  margin: 10px auto;
  font-size: 2em;
  display: block;
}

#outputChar[readonly], #outputNumb[readonly] {
  text-align: center;
}

#split {
  font-size: 2em;
  font-family: consolas;
}

#splittedChar {
  text-align: center;
  padding: 10px;
}

.list {
  display: inline-block;
  background: #fff;
  padding: 10px;
  border-radius: 6px;
  text-align: center;
  box-shadow: 2px 2px 5px #999;
  margin:3px 0;
}

.dim {
  opacity: .3;
  box-shadow: 0 0 0 #777;
}

/*um, pink isn't #999, it was actually pink, just so it blends with everything, I changed that*/
.pink {
  background: #999;
  border: 2px solid white;
  box-shadow: 2px 2px 5px #777;
  opacity: 1;
}
.pink > hr {
  border-top: 1px solid #888;
  border-bottom: 1px solid #aaa;
}

.pink > span {
  color: white;
}
              
            
!

JS

              
                //for "enter" key input
$('#inputOne').keyup(function (e) {
  var key = e.keyCode;
  if (key === 13) {
    $(this).val('');
    e.preventDefault();
  }
});

//input behavior and other elements around it
$('#inputOne').bind('click focus',
  function () {
    $(this).val('');
    $('#splittedChar').html('');
    $('#split').prop('disabled', false)
      .slideDown(100);
    $('.charHolder').removeClass(
      'dim pink');
  });

//arrays for the characters (carr) and the numbers (narr)
var carr = [],
  narr = [];

//generate view-able characters list
for (j = 32; j < 127; j++) {
  string = String.fromCharCode(j);
  carr.push(string);
  narr.push(j);  
  $('.charWrapper').append(
    '<div class="charHolder"><span>' +
    string +
    '</span><hr><small><small>' + j +
    '</small></small></div>');
}

//change the first character, the space
$('.charHolder').eq(0).children().eq(0).html("<small><sup>space</sup></small>");

//splitting and locating - button click
$('#split').click(function () {
  var string = $('#inputOne').val();
  //if there's no input (blank)
  if (string === '') {
    $('#splittedChar').html(
      'please enter something');
    $('#split').slideUp(100);
  } 
  //yo, there's input
  else {
    for (k = 0; k < string.length; k++) {
      //charAt() method
      var s = string.charAt(k),
      //indexOf() method
        n = carr.indexOf(s);
      //re-generate the input (splitted)
      $('#splittedChar').append(
        '<div class="list"><strong>' +
        s +
        '</strong>&nbsp;&nbsp;&nbsp;<small><sup>keycode is</sup></small>&nbsp;&nbsp;<em>' +
        narr[n] + '</em></div> ');
      
      //locate the characters
      //"hide" the chars list
      $('.charHolder').addClass('dim');
      //popping out only the chars from input
      $('.charHolder').eq(n).addClass(
        'pink');
    }
    $(this).prop('disabled', true).slideUp(
      100);
  }
});
              
            
!
999px

Console