Created
September 25, 2013 04:43
Revisions
-
jacksonhenry3 created this gist
Sep 25, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ <html> <link href='http://fonts.googleapis.com/css?family=Raleway:200' rel='stylesheet' type='text/css'> <style> body {font-family: 'Raleway', sans-serif; background-color: #E74C3C; color:white; text-align:center; } h1 { font-size: 50px; background-color: rgba(0,0,0,.4) } #result { font-size: 30px; color:white; font-weight: bold; padding:25px; } </style> <h1>Type the message to be translated in to morse code</h1> <textarea id="myTextarea" rows="4" cols="50">Morse Code</textarea> <div id = 'result'></div> <script> dictionary = {" ":" ","A":".-","B":"-...","C":"-.-.","D":"-..","E":".","F":"..-.","G":"--.","H":"....","I":"..","J":".---","K":"-.-","L":".-..","M":"--","N":"-.","O":"---","P":".--.","Q":"--.-","R":".-.","S":"...","T":"-","U":"..-","V":"...-","W":".--","X":"-..-","Y":"-.--","Z":"--..","0":"-----","1":".----","2":"..---","3":"...--","4":"....-","5":".....","6":"-....","7":"--...","8":"---..","9":"----.",".":".-.-.-",",":"--..--",":":"---...","?":"..--..","'":".----.","-":"-....-","/":"-..-.","|":"-.--.-","\"":".-..-.","@":".--.-.","=":"-...-","\n":"\n","!":"!"}; function displayResult() { a = document.getElementById("myTextarea").value b = '' a = a.toUpperCase() for (var i = 0; i < a.length; i++) { b = b+dictionary[a[i]]+' ' }; document.getElementById("result").innerHTML = b }; </script> <button type="button" onclick="displayResult()">translate!</button> </html>