cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              main
  form
    input(
      type='text'
      id='string'
      placeholder='Word or phrase'
      autofocus
      )
  button(id='btn-go') Go!
  button(id='btn-reset') Reset
  div
    p(id='result')
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Cutive+Mono');
$color_darkest: #114B5F;
$color_dark: #1A936F;
$color_light: #88D498;
$color_lightest: #F3E9D2;
button,
input, p {
  font-family: inherit;
  font-size: 1.25em;
}

body {
  background: $color_dark;
  color: $color_lightest;
  font-family: 'Cutive Mono', monospace;
  text-align: center;
}

button {
  border: 3px solid $color_light;
  border-radius: 150px;
  cursor: pointer;
  margin: 0 2vw 1em 2vw;
  outline: 0;
  text-transform: uppercase;
  transition: all .25s ease;
  width: 140px;
  height: 70px;
  vertical-align: center;
}

form {
  margin-bottom: 2em;
}

input {
  background: transparent;
  border: none;
  border-bottom: 3px solid $color_light;
  color: $color_lightest;
  font-size: 1.25em;
  outline: none;
  width: 85%;
  height: 1.5em;
}

::-webkit-input-placeholder {
  color: $color_light;
}

main {
  margin-top: 3em;
  width: 100vw;
}

#btn-go {
  background-color: $color_dark;
  color: $color_lightest;
}

#btn-reset {
  background-color: $color_dark;
  color: $color_light;
}

@media (min-width: 1025px) {
  input {
    width: 900px;
  }
  #btn-go:hover {
    background-color: $color_darkest;
    color: $color_lightest;
  }
  #btn-reset:hover {
    background-color: $color_light;
    color: $color_dark;
  }
}
            
          
!
            
              var nato = letter => {
  var re = /[a-zA-Z0-9]/g;
  letter = letter.toLowerCase();
  const cases = {
    'a': 'Alpha',
    'b': 'Bravo',
    'c': 'Charlie',
    'd': 'Delta',
    'e': 'Echo',
    'f': 'Foxtrot',
    'g': 'Golf',
    'h': 'Hotel',
    'i': 'India',
    'j': 'Juliette',
    'k': 'Kilo',
    'l': 'Lima',
    'm': 'Mike',
    'n': 'November',
    'o': 'Oscar',
    'p': 'Papa',
    'q': 'Quebec',
    'r': 'Romeo',
    's': 'Sierra',
    't': 'Tango',
    'u': 'Uniform',
    'v': 'Victor',
    'w': 'Whiskey',
    'x': 'Xray',
    'y': 'Yankee',
    'z': 'Zulu',
    '0': 'Zero',
    '1': 'Won',
    '2': 'Two',
    '3': 'Three',
    '4': 'Four',
    '5': 'Five',
    '6': 'Six',
    '7': '7',
    '8': 'Eight',
    '9': 'Niner',
    ' ': '</br></br>'
  };
  if (cases[letter]) {
    return cases[letter];
  } else if (letter.search(re) === -1) {
    return '';
  }
};

var capture = function() {
  str = $('#string').val().toLowerCase();
  str = str.split('');
  str = str.map(function(el) {
    return nato(el);
  });
  return str.map(function(el) {
    return el += ' ';
  });
}

var clear = function() {
  $('#result').empty();
}

$(document).ready(function() {

  $('form').keydown(function(event) {
    var input = $('#string').val();
    if (event.keyCode === 13 && input.length == '') {
      event.preventDefault();
      clear();
      return false;
    } else if (event.keyCode === 13 && input.length < 100) {
      event.preventDefault();
      clear();
      $('#result').append(capture());
      return false;
    } else if (event.keyCode === 13 && input.length > 100) {
      event.preventDefault();
      clear();
      $('#result').append('Say again. Try a shorter message. Over.');
    }
  });
  
  $('#btn-go').on('click', function() {
    var input = $('#string').val();
    if (input.length > 100) {
      clear();
      $('#result').append('Say again. Try a shorter message. Over.');
    }
    clear();
      $('#result').append(capture());
  });

  $('#btn-reset').on('click', function() {
    clear();
    $('form')[0].reset();
  });

});
            
          
!
999px
Loading ..................

Console