Created
November 11, 2011 22:44
-
-
Save atoulme/1359555 to your computer and use it in GitHub Desktop.
Use the nato phonetic alphabet to spell words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Get your computer to spell for you</title> | |
<script type="text/javascript"> | |
function spellText(text) { | |
for (var i = 0; i <= text.length; i++) { | |
var c = text.substring(i, i + 1).toLowerCase(); | |
var duration = null; | |
if (c == ' ') { | |
audio_tag = document.getElementById('space'); | |
} else { | |
audio_tag = document.getElementById(c); | |
} | |
if (audio_tag != null) { | |
audio_tag.currentTime = 0; | |
audio_tag.play(); | |
duration = audio_tag.duration * 1000; | |
} | |
if (duration != null) { | |
wait_for = new Date(); | |
wait_for.setTime(wait_for.getTime() + duration + 200); | |
while (wait_for > new Date()) { | |
} | |
} | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<audio preload='auto' src='space.wav' id='space'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='alpha.wav' id='a'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='bravo.wav' id='b'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='charlie.wav' id='c'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='delta.wav' id='d'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='echo.wav' id='e'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='foxtrot.wav' id='f'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='golf.wav' id='g'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='hotel.wav' id='h'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='india.wav' id='i'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='juliet.wav' id='j'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='kilo.wav' id='k'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='lima.wav' id='l'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='mike.wav' id='m'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='november.wav' id='n'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='oscar.wav' id='o'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='papa.wav' id='p'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='quebec.wav' id='q'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='romeo.wav' id='r'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='sierra.wav' id='s'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='tango.wav' id='t'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='uniform.wav' id='u'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='victor.wav' id='v'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='whiskey.wav' id='w'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='x-ray.wav' id='x'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='yankee.wav' id='y'>Your browser does not support the audio element.</audio> | |
<audio preload='auto' src='zulu.wav' id='z'>Your browser does not support the audio element.</audio> | |
<input type="text" width="200" id="text"/> | |
<input type="button" onClick="spellText(document.getElementById('text').value)" value="Spell it for me"/> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment