Morse Code Converter Using Javascript
Have You heard about Morse Code?? Ha Ha Ha .. Well It is some kind of secret code used for communication during WWI and WWII.. Pretty Old Technology but Guess what we can replicate the same using ASP.Net and Javascript....
What is Morse Code?
Morse code is a method of transmitting text
information as a series of on-off tones, lights, or clicks that can be
directly understood by a skilled listener or observer without special
equipment. The International Morse Code encodes the ISO basic Latin alphabet, some extra Latin letters, the Arabic numerals
and a small set of punctuation and procedural signals as standardized
sequences of short and long signals called "dots" and "dashes", or "dits" and "dahs". Because many non-English natural languages use
more than the 26 Roman letters, extensions to the Morse alphabet exist
for those languages.
Read More Over here.
How can I generate My Own Brand New Morse Code Translator?
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Morse Code Generator</title> <script type="text/javascript" language="JavaScript"> var table = { "A" : ".-", "K" : "-.-", "U" : "..-", "5" : ".....", "," : "--..--", "$" : "...-..-", "B" : "-...", "L" : ".-..", "V" : "...-", "6" : "-....", "?" : "..--..", " " : "*", "C" : "-.-.", "M" : "--", "W" : ".--", "7" : "--...", "(" : "-.--.", "D" : "-..", "N" : "-.", "X" : "-..-", "8" : "---..", ")" : "-.--.-", "E" : ".", "O" : "---", "Y" : "-.--", "9" : "----.", "-" : "-....-", "F" : "..-.", "P" : ".--.", "Z" : "--..", "0" : "-----", "\"" : ".-..-.", "G" : "--.", "Q" : "--.-", "1" : ".----", "/" : "-..-.", "_" : "..--.-", "H" : "....", "R" : ".-.", "2" : "..---", "+" : ".-.-.", "'" : ".----.", "I" : "..", "S" : "...", "3" : "...--", "=" : "-...-", ":" : "---...", "J" : ".---", "T" : "-", "4" : "....-", "." : ".-.-.-", ";" : "-.-.-." }; function go() { var output = ""; var input = document.forms[0].ALPHA.value.toUpperCase(); for( var i = 0; i < input.length; i++ ) { var temp = table[ input.charAt(i) ]; if( temp ) { if( "*" == temp ) { temp = " "; } output += temp + " "; } else output += " "; } document.forms[0].MORSE.value = output; } function ungo() { var output = ""; var input = document.forms[0].MORSE.value.replace( / /g, " * " ).split( " " ); for( var ix = 0; ix < input.length; ix++ ) { for( var key in table ) { if( table[key] == input[ix]) { output += key; break; } } } document.forms[0].ALPHA.value = output; } </script> </head> <body> <h1>Morse Code Translator</h1> <form name="entree" id="entree"> <table> <tr> <td>Alphabet:</td> <td><input size="30" type="text" name='ALPHA'></td> <td><input type="button" value='To Morse Code' onclick="javascript:go()"></td> </tr> <tr> <td>Morse Code:</td> <td><input size="30" type="text" name="MORSE"></td> <td><input type="button" value='To Alphabet' onclick="javascript:ungo()"></td> </tr> <tr> <td colspan="3" align="center"><input type="reset" value='Clear All'></td> </tr> </table> </form> </body> </html>
No comments:
Post a Comment
Thank You for Your Comments. We will get back to you soon.