cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console