Morse Signals Translator - Result Window
");
// -- Store all letters as UPPERCASE in array "PHRASE": --
for (INT=0; INTTEXT:
//*******************************************************
STATUS="OK";
if ( INPUT=="·" ) { INPUT="."; } // Do not mix "." and "·"...
if ( INPUT=="_" ) { INPUT="-"; } // Do not mix "_" and "-"...
if ( SIGNAL!=null )
{
SIGNAL=SIGNAL+INPUT;
//A morse code for one letter contains several characters!
}
if ( SIGNAL==null )
{
SIGNAL=INPUT;
}
}
if ( (INPUT==" "||INPUT=="|"||INPUT=="/"||INT==LENGTH||INT==TEST)&&STATUS=="OK" ) //Adjustment
{
//*************************************************************
//IF: we find separator (/ or |)...
//OR IF: user only typed one morseletter, i.e. INT==LENGTH...
// + STATUS is OK (i.e. we are decoding morse signals)...
//...then we have succesfully decoded a letter:
//*************************************************************
if (SIGNAL == "|"||SIGNAL == "/") { SIGNAL=" "; }
if (SIGNAL == ".-") { SIGNAL="A"; }
if (SIGNAL == "-...") { SIGNAL="B"; }
if (SIGNAL == "-.-.") { SIGNAL="C"; }
if (SIGNAL == "-..") { SIGNAL="D"; }
if (SIGNAL == ".") { SIGNAL="E"; }
if (SIGNAL == "..-.") { SIGNAL="F"; }
if (SIGNAL == "--.") { SIGNAL="G"; }
if (SIGNAL == "....") { SIGNAL="H"; }
if (SIGNAL == "..") { SIGNAL="I"; }
if (SIGNAL == ".---") { SIGNAL="J"; }
if (SIGNAL == "-.-") { SIGNAL="K"; }
if (SIGNAL == ".-..") { SIGNAL="L"; }
if (SIGNAL == "--") { SIGNAL="M"; }
if (SIGNAL == "-.") { SIGNAL="N"; }
if (SIGNAL == "---") { SIGNAL="O"; }
if (SIGNAL == ".--.") { SIGNAL="P"; }
if (SIGNAL == "--.-") { SIGNAL="Q"; }
if (SIGNAL == ".-.") { SIGNAL="R"; }
if (SIGNAL == "...") { SIGNAL="S"; }
if (SIGNAL == "-") { SIGNAL="T"; }
if (SIGNAL == "..-") { SIGNAL="U"; }
if (SIGNAL == "...-") { SIGNAL="V"; }
if (SIGNAL == ".--") { SIGNAL="W"; }
if (SIGNAL == "-..-") { SIGNAL="X"; }
if (SIGNAL == "-.--") { SIGNAL="Y"; }
if (SIGNAL == "--..") { SIGNAL="Z"; }
if (SIGNAL == ".--.-") { SIGNAL="Å"; }
if (SIGNAL == ".-.-") { SIGNAL="Ä"; }
if (SIGNAL == "---.") { SIGNAL="Ö"; }
if (SIGNAL == ".----") { SIGNAL="1"; }
if (SIGNAL == "..---") { SIGNAL="2"; } //Fixed
if (SIGNAL == "...--") { SIGNAL="3"; }
if (SIGNAL == "....-") { SIGNAL="4"; }
if (SIGNAL == ".....") { SIGNAL="5"; }
if (SIGNAL == "-....") { SIGNAL="6"; }
if (SIGNAL == "--...") { SIGNAL="7"; }
if (SIGNAL == "---..") { SIGNAL="8"; }
if (SIGNAL == "----.") { SIGNAL="9"; }
if (SIGNAL == "-----") { SIGNAL="0"; }
YourName.document.writeln(SIGNAL); //Show result for user!
SIGNAL=null; //Reset signal, new letter to decode!
}
if ( INPUT==" " )
{
YourName.document.write(" ");
}
if ( INPUT=="A" )
{
YourName.document.write("·- ");
}
if ( INPUT=="B" )
{
YourName.document.write("-··· ");
}
if ( INPUT=="C" )
{
YourName.document.write("-·-· ");
}
if ( INPUT=="D" )
{
YourName.document.write("-·· ");
}
if ( INPUT=="E" )
{
YourName.document.write("· ");
}
if ( INPUT=="F" )
{
YourName.document.write("··-· ");
}
if ( INPUT=="G" )
{
YourName.document.write("--· ");
}
if ( INPUT=="H" )
{
YourName.document.write("···· ");
}
if ( INPUT=="I" )
{
YourName.document.write("·· ");
}
if ( INPUT=="J" )
{
YourName.document.write("·--- ");
}
if ( INPUT=="K" )
{
YourName.document.write("-·- ");
}
if ( INPUT=="L" )
{
YourName.document.write("·-·· ");
}
if ( INPUT=="M" )
{
YourName.document.write("-- ");
}
if ( INPUT=="N" )
{
YourName.document.write("-· ");
}
if ( INPUT=="O" )
{
YourName.document.write("--- ");
}
if ( INPUT=="P" )
{
YourName.document.write("·--· ");
}
if ( INPUT=="Q" )
{
YourName.document.write("--·- ");
}
if ( INPUT=="R" )
{
YourName.document.write("·-· ");
}
if ( INPUT=="S" )
{
YourName.document.write("··· ");
}
if ( INPUT=="T" )
{
YourName.document.write("- ");
}
if ( INPUT=="U" )
{
YourName.document.write("··- ");
}
if ( INPUT=="V" )
{
YourName.document.write("···- ");
}
if ( INPUT=="W" )
{
YourName.document.write("·-- ");
}
if ( INPUT=="X" )
{
YourName.document.write("-··- ");
}
if ( INPUT=="Y" )
{
YourName.document.write("-·-- ");
}
if ( INPUT=="Z" )
{
YourName.document.write("--·· ");
}
if ( INPUT=="Å"||INPUT=="å" )
{
YourName.document.write("·--·- ");
}
if ( INPUT=="Ä"||INPUT=="ä" )
{
YourName.document.write("·-·- ");
}
if ( INPUT=="Ö"||INPUT=="ö" )
{
YourName.document.write("---· ");
}
if ( INPUT=="0" )
{
YourName.document.write("----- ");
}
if ( INPUT=="1" )
{
YourName.document.write("·---- ");
}
if ( INPUT=="2" )
{
YourName.document.write("··--- ");
}
if ( INPUT=="3" )
{
YourName.document.write("···-- ");
}
if ( INPUT=="4" )
{
YourName.document.write("····- ");
}
if ( INPUT=="5" )
{
YourName.document.write("····· ");
}
if ( INPUT=="6" )
{
YourName.document.write("-···· ");
}
if ( INPUT=="7" )
{
YourName.document.write("--··· ");
}
if ( INPUT=="8" )
{
YourName.document.write("---·· ");
}
if ( INPUT=="9" )
{
YourName.document.write("----· ");
}
} // End of For-loop
// -- Some layout: --
YourName.document.writeln("
Close this window