Начало
Эквиваленты
Азбука Морзе
Преобразовывает английское слово или фразу в комбинацию Азбуки Морзе точек и черт.
Please type your phrase in plain English
JavaScript Equivalents: Азбука Морзе
<!-- TWO STEPS TO INSTALL MORSE CODE: 1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document --> <!-- STEP ONE: Paste this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <! > <! > <!-- Begin function translate(form) { letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,?:-!"; morse = new Array( ".-","-...","-.-.","-..",".","..-.", "--.","....","..",".---","-.-",".-..", "--","-.","---",".--.","--.-",".-.", "...","-","..-","...-",".--","-..-", "-.--","--..",".-","-...","-.-.","-..", ".","..-.","--.","....","..",".---", "-.-",".-..","--","-.","---",".--.", "--.-",".-.","...","-","..-","...-", ".--","-..-","-.--","--.."," ",".-.-.-", "--..--","..--..","---...","-....-","!"); form.output.value = ""; var input = form.input.value; output = ""; for(count = 0; count < input.length; count++) { daChar = input.charAt(count); for (i = 0; i < letters.length; i++) { if (daChar == letters.charAt(i)) { output += morse[i]; break; } } } form.output.value = output; } // End --> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <center> <form> <table> <tr> <td align=center> Please type your phrase in plain English<br> <textarea name=input cols=50 rows=4 wrap=physical></textarea> </td> </tr> <tr> <td align=center> <input type=button value="Translate!" onClick="javascript:translate(this.form)"> </td> </tr> <tr> <td align=center> <textarea name=output cols=50 rows=4 wrap=physical></textarea> </td> </tr> </table> </form> </center> <!-- Script Size: 1.89 KB -->