Compare commits

...

14 Commits
v0.2 ... master

Author SHA1 Message Date
Marcel Kapfer 269e501336 Updated README. 2018-01-03 09:25:21 +01:00
Marcel Kapfer (mmk2410) 295fd7c855 Version bump to 0.3.1 2016-06-01 11:26:31 +02:00
Marcel Kapfer (mmk2410) e56d470231 Ripple effect added to drawer items 2016-06-01 11:05:57 +02:00
Marcel Kapfer (mmk2410) 92304957d5 Bower dependencies updated 2016-06-01 11:05:05 +02:00
Marcel Kapfer (mmk2410) 0368513a73 Added missing dependencies 2016-06-01 11:01:14 +02:00
Marcel Kapfer (mmk2410) a547b10a13 Fixed bower.json app name 2016-06-01 11:00:35 +02:00
Marcel Kapfer (mmk2410) 59bf32f038 README typo fix 2016-05-30 23:34:36 +02:00
Marcel Kapfer (mmk2410) 403c2fc64e Version bump to 0.3.0 2016-05-30 23:31:09 +02:00
Marcel Kapfer (mmk2410) 90463bd8c9 Switched from GitHub to GitLab 2016-05-30 23:29:34 +02:00
Marcel Kapfer (mmk2410) 4cb09eea21 Switched to cacheFirst caching 2016-05-30 23:20:05 +02:00
Marcel Kapfer (mmk2410) 20220a30fa Tests for Dart code 2016-05-30 23:18:43 +02:00
Marcel Kapfer (mmk2410) 497a087270 Switch from CoffeeScript to Dart with convert engine 2016-05-30 23:16:30 +02:00
Marcel Kapfer (mmk2410) b100eb0d3f Added GulpJS development server task (gulp serve) 2016-05-30 22:55:54 +02:00
Marcel Kapfer (mmk2410) 27f2a6fd5f Added missing license informations 2016-05-30 22:50:20 +02:00
22 changed files with 523 additions and 1951 deletions

10
.gitignore vendored
View File

@ -4,3 +4,13 @@ test/temp
bower_components
.tmp
test/bower_components/
# Dart files
pubspec.lock
packages/
.pub/
.packages
app/scripts/MorseConverter.js*
# Atom editor
.atom/

19
CHANGELOG.md Normal file
View File

@ -0,0 +1,19 @@
# Version 0.3.1 (01 June 2016)
- Updated Bower dependencies
- Ripple effect on drawer items
# Version 0.3.0 (30 May 2016)
- Convert engine completly rewritten in Dart
- More efficient on larger texts
- Unit tests
# Version 0.2.0
- All features also available in the Android and desktop app
- Complete rewrite with Polymer
# Version 0.1.0
- Initial release

View File

@ -1,27 +1,32 @@
# [Morse Converter (web)](https://marcel-kapfer.de/writtenmorse/morseconverter)
# [Morse Converter (web)](https://mmk2410.org//morseconverter)
**This is a beta version. It may contains bugs**
This is a Morse and [writtenMorse](https://marcel-kapfer.de/writtenmorse) converter for the web. With mobile-first in mind I tried to create a beautiful converting experience. The webapp comes with [Material design](https://google.com/design) and with enhanced features (like instant converting) to simplify the converting time.
This is a Morse and [writtenMorse](https://gitlab.com/mmk2410/writtenmorse-specs/wikis/Home) converter for the web. With mobile-first in mind I tried to create a beautiful converting experience. The webapp is designed following the [Material design](https://material.io/) specifications and with enhanced features (like instant converting) to simplify the converting time.
## Use it
The webapp can be accessed at [marcel-kapfer.de/writtenmorse/morseconverter](https://marcel-kapfer.de/writtenmorse/morseconverter).
The webapp is accessible at [mmk2410.org/morseconverter](https://mmk2410.org//morseconverter).
## Contribute
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create New Pull Request
3. Write your code and the tests for it.
4. Check if the code passes the tests. (`pub run test`). A code which does not passes the tests will not merged.
5. Commit your changes (`git commit -am 'Add some feature'`)
6. Push to the branch (`git push origin my-new-feature`)
7. Create new merge request
## Technologies
* Polymer and JavaScript for the front end.
* Dart for the converting engine.
## Build
You need the following programs installed on your computer:
```
npm, bower, gulp
npm, bower, gulp, dart2js
```
To see your changes run the first time:
@ -30,10 +35,20 @@ To see your changes run the first time:
npm install && bower install
```
and the rebuild the webapp with:
Now change to `app/scripts/` and compile the `MorseConverter.dart`:
```
dart2js -m MorseConverter.dart -o MorseConverter.js
```
and then rebuild the webapp with:
```
gulp
```
The webapp is accessible in the `dist/` directory
The webapp is accessible in the `dist/` directory. A development server can be started with
```
gulp serve
```

View File

@ -1,3 +1,7 @@
<!--
2015 - 2016 (c) Marcel Kapfer (mmk2410)
Licensed under MIT License
-->
<style is="custom-style">
:root {
--dark-primary-color: #1976D2;

View File

@ -1,10 +1,14 @@
<!--
2015 - 2016 (c) Marcel Kapfer (mmk2410)
Licensed under MIT License
-->
<!-- Font -->
<link rel="import" href="../bower_components/font-roboto/roboto.html">
<!-- Icons -->
<link rel="import" href="../bower_components/iron-icons/iron-icons.html">
<!-- Page -->
<link rel="import" href="../bower_components/paper-styles/paper-styles-classes.html">
<link rel="import" href="../bower_components/iron-flex-layout/classes/iron-flex-layout.html">
<link rel="import" href="../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
<!-- Toolbar -->
<link rel="import" href="../bower_components/paper-header-panel/paper-header-panel.html">
<link rel="import" href="../bower_components/paper-toolbar/paper-toolbar.html">

View File

@ -2,6 +2,10 @@
<html>
<head>
<meta charset="utf-8">
<!--
2015 - 2016 (c) Marcel Kapfer (mmk2410)
Licensed under MIT License
-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Morse Converter</title>
<meta name="description" content="A writtenMorse and normal Morse converter for the web.">
@ -49,11 +53,11 @@
<!-- Drawer Content -->
<paper-menu selected="0">
<paper-item id="menuWrittenMorse">writtenMorse</paper-item>
<paper-item id="menuNormalMorse">Normal Morse</paper-item>
<paper-item id="menuReportBug">Report a bug</paper-item>
<paper-item id="menuFork">Fork me on GitHub</paper-item>
<paper-item id="menuAbout">About</paper-item>
<paper-item id="menuWrittenMorse"><paper-ripple></paper-ripple>writtenMorse</paper-item>
<paper-item id="menuNormalMorse"><paper-ripple></paper-ripple>Normal Morse</paper-item>
<paper-item id="menuReportBug"><paper-ripple></paper-ripple>Report a bug</paper-item>
<paper-item id="menuFork"><paper-ripple></paper-ripple>Fork me on GitLab</paper-item>
<paper-item id="menuAbout"><paper-ripple></paper-ripple>About</paper-item>
</paper-menu>
</paper-header-panel>
@ -104,7 +108,7 @@
clients-claim
skip-waiting
on-service-worker-installed="displayInstalledToast">
<platinum-sw-cache default-cache-strategy="networkFirst"
<platinum-sw-cache default-cache-strategy="cacheFirst"
precache-file="precache.json">
</platinum-sw-cache>
</platinum-sw-register>
@ -113,9 +117,7 @@
<!-- build:js scripts/app.js -->
<script src="scripts/app.js"></script>
<script src="scripts/CodeRecognization.js"></script>
<script src="scripts/writtenMorseConvert.js"></script>
<script src="scripts/normalMorseConvert.js"></script>
<script src="scripts/MorseConverter.js"></script>
<!-- endbuild-->
</body>

View File

@ -1,59 +0,0 @@
isNormalMorseCode = (input) ->
input = input.toLowerCase()
return !(input.indexOf("a") > -1 or input.indexOf("b") > -1 or
input.indexOf("c") > -1 or input.indexOf("d") > -1 or
input.indexOf("e") > -1 or input.indexOf("f") > -1 or
input.indexOf("g") > -1 or input.indexOf("h") > -1 or
input.indexOf("i") > -1 or input.indexOf("j") > -1 or
input.indexOf("k") > -1 or input.indexOf("l") > -1 or
input.indexOf("m") > -1 or input.indexOf("n") > -1 or
input.indexOf("o") > -1 or input.indexOf("p") > -1 or
input.indexOf("q") > -1 or input.indexOf("r") > -1 or
input.indexOf("s") > -1 or input.indexOf("t") > -1 or
input.indexOf("u") > -1 or input.indexOf("v") > -1 or
input.indexOf("w") > -1 or input.indexOf("x") > -1 or
input.indexOf("y") > -1 or input.indexOf("z") > -1 or
input.indexOf("0") > -1 or input.indexOf("1") > -1 or
input.indexOf("2") > -1 or input.indexOf("3") > -1 or
input.indexOf("4") > -1 or input.indexOf("5") > -1 or
input.indexOf("6") > -1 or input.indexOf("7") > -1 or
input.indexOf("8") > -1 or input.indexOf("9") > -1 or
input.indexOf("Ä") > -1 or input.indexOf("Ö") > -1 or
input.indexOf("Ü") > -1 or input.indexOf("ß") > -1 or
input.indexOf("$") > -1 or input.indexOf(",") > -1 or
input.indexOf(":") > -1 or input.indexOf(";") > -1 or
input.indexOf("!") > -1 or input.indexOf("?") > -1 or
input.indexOf("+") > -1 or input.indexOf("_") > -1 or
input.indexOf("(") > -1 or input.indexOf(")") > -1 or
input.indexOf("=") > -1 or input.indexOf("/") > -1 or
input.indexOf("@") > -1 or input.indexOf("'") > -1)
isWrittenMorseCode = (input) ->
input = input.toLowerCase()
return not (input.indexOf("a") > -1 or input.indexOf("b") > -1 or
input.indexOf("c") > -1 or input.indexOf("d") > -1 or
input.indexOf("e") > -1 or input.indexOf("f") > -1 or
input.indexOf("g") > -1 or input.indexOf("h") > -1 or
input.indexOf("i") > -1 or input.indexOf("j") > -1 or
input.indexOf("k") > -1 or input.indexOf("l") > -1 or
input.indexOf("m") > -1 or input.indexOf("n") > -1 or
input.indexOf("o") > -1 or input.indexOf("p") > -1 or
input.indexOf("q") > -1 or input.indexOf("r") > -1 or
input.indexOf("s") > -1 or input.indexOf("t") > -1 or
input.indexOf("u") > -1 or input.indexOf("v") > -1 or
input.indexOf("w") > -1 or input.indexOf("x") > -1 or
input.indexOf("y") > -1 or input.indexOf("z") > -1 or
input.indexOf("2") > -1 or input.indexOf("3") > -1 or
input.indexOf("4") > -1 or input.indexOf("5") > -1 or
input.indexOf("6") > -1 or input.indexOf("7") > -1 or
input.indexOf("8") > -1 or input.indexOf("9") > -1 or
input.indexOf("Ä") > -1 or input.indexOf("Ö") > -1 or
input.indexOf("Ü") > -1 or input.indexOf("ß") > -1 or
input.indexOf(".") > -1 or input.indexOf(",") > -1 or
input.indexOf(":") > -1 or input.indexOf(";") > -1 or
input.indexOf("!") > -1 or input.indexOf("?") > -1 or
input.indexOf("-") > -1 or input.indexOf("_") > -1 or
input.indexOf("(") > -1 or input.indexOf(")") > -1 or
input.indexOf("=") > -1 or input.indexOf("/") > -1 or
input.indexOf("@") > -1 or input.indexOf("'") > -1 or
input.indexOf("$") > -1)

View File

@ -0,0 +1,60 @@
/**
* 2016 (c) Marcel Kapfer (mmk2410)
* Licensed under MIT License
*/
import 'Convert.dart';
/**
* Detect code.
*/
class CodeRecognization {
/**
* Detect if message is Morse code.
*
* @param message string to be checked.
* @return Boolean true if message is Morse code.
*/
static bool isMorseCode(String message) {
List<String> alphabet = new List.from(Convert.alphabet);
alphabet = alphabet
..remove('.')
..remove('-')
..remove(' ');
for (String char in message.toUpperCase().split('')) {
if (alphabet.contains(char)) {
return false;
}
}
return true;
}
/**
* Detect if message is writtenMorse code.
*
* @param message string to be checked.
* @return Boolean true if message is writtenMorse coe.
*/
static bool isWrittenMorseCode(String message) {
List<String> alphabet = new List.from(Convert.alphabet);
alphabet = alphabet
..remove('0')
..remove('1')
..remove('#')
..remove('+');
for (String char in message.toUpperCase().split('')) {
if (alphabet.contains(char)) {
return false;
}
}
return true;
}
}

View File

@ -1,11 +0,0 @@
var isNormalMorseCode, isWrittenMorseCode;
isNormalMorseCode = function(input) {
input = input.toLowerCase();
return !(input.indexOf("a") > -1 || input.indexOf("b") > -1 || input.indexOf("c") > -1 || input.indexOf("d") > -1 || input.indexOf("e") > -1 || input.indexOf("f") > -1 || input.indexOf("g") > -1 || input.indexOf("h") > -1 || input.indexOf("i") > -1 || input.indexOf("j") > -1 || input.indexOf("k") > -1 || input.indexOf("l") > -1 || input.indexOf("m") > -1 || input.indexOf("n") > -1 || input.indexOf("o") > -1 || input.indexOf("p") > -1 || input.indexOf("q") > -1 || input.indexOf("r") > -1 || input.indexOf("s") > -1 || input.indexOf("t") > -1 || input.indexOf("u") > -1 || input.indexOf("v") > -1 || input.indexOf("w") > -1 || input.indexOf("x") > -1 || input.indexOf("y") > -1 || input.indexOf("z") > -1 || input.indexOf("0") > -1 || input.indexOf("1") > -1 || input.indexOf("2") > -1 || input.indexOf("3") > -1 || input.indexOf("4") > -1 || input.indexOf("5") > -1 || input.indexOf("6") > -1 || input.indexOf("7") > -1 || input.indexOf("8") > -1 || input.indexOf("9") > -1 || input.indexOf("Ä") > -1 || input.indexOf("Ö") > -1 || input.indexOf("Ü") > -1 || input.indexOf("ß") > -1 || input.indexOf("$") > -1 || input.indexOf(",") > -1 || input.indexOf(":") > -1 || input.indexOf(";") > -1 || input.indexOf("!") > -1 || input.indexOf("?") > -1 || input.indexOf("+") > -1 || input.indexOf("_") > -1 || input.indexOf("(") > -1 || input.indexOf(")") > -1 || input.indexOf("=") > -1 || input.indexOf("/") > -1 || input.indexOf("@") > -1 || input.indexOf("'") > -1);
};
isWrittenMorseCode = function(input) {
input = input.toLowerCase();
return !(input.indexOf("a") > -1 || input.indexOf("b") > -1 || input.indexOf("c") > -1 || input.indexOf("d") > -1 || input.indexOf("e") > -1 || input.indexOf("f") > -1 || input.indexOf("g") > -1 || input.indexOf("h") > -1 || input.indexOf("i") > -1 || input.indexOf("j") > -1 || input.indexOf("k") > -1 || input.indexOf("l") > -1 || input.indexOf("m") > -1 || input.indexOf("n") > -1 || input.indexOf("o") > -1 || input.indexOf("p") > -1 || input.indexOf("q") > -1 || input.indexOf("r") > -1 || input.indexOf("s") > -1 || input.indexOf("t") > -1 || input.indexOf("u") > -1 || input.indexOf("v") > -1 || input.indexOf("w") > -1 || input.indexOf("x") > -1 || input.indexOf("y") > -1 || input.indexOf("z") > -1 || input.indexOf("2") > -1 || input.indexOf("3") > -1 || input.indexOf("4") > -1 || input.indexOf("5") > -1 || input.indexOf("6") > -1 || input.indexOf("7") > -1 || input.indexOf("8") > -1 || input.indexOf("9") > -1 || input.indexOf("Ä") > -1 || input.indexOf("Ö") > -1 || input.indexOf("Ü") > -1 || input.indexOf("ß") > -1 || input.indexOf(".") > -1 || input.indexOf(",") > -1 || input.indexOf(":") > -1 || input.indexOf(";") > -1 || input.indexOf("!") > -1 || input.indexOf("?") > -1 || input.indexOf("-") > -1 || input.indexOf("_") > -1 || input.indexOf("(") > -1 || input.indexOf(")") > -1 || input.indexOf("=") > -1 || input.indexOf("/") > -1 || input.indexOf("@") > -1 || input.indexOf("'") > -1 || input.indexOf("$") > -1);
};

217
app/scripts/Convert.dart Normal file
View File

@ -0,0 +1,217 @@
/**
* 2016 (c) Marcel Kapfer (mmk2410)
* Licensed under MIT License
*/
/**
* Methods for converting Morse and writtenMorse code.
*/
class Convert {
// Normal alphabet.
static List<String> alphabet = [
'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', " ", '<br>'
];
// Normal alphabet signal words.
static List<String> alphabetExtra = [
'LETTERSPACE', 'END OF WORK', 'ERROR', 'STARTING SIGNAL', 'ENDING SIGNAL',
'UNDERSTOOD', 'WAIT', 'SOS', 'LETTER SPACE', 'WORD SPACE'
];
// writtenMorse Alphabet.
static List<String> writtenMorse = [
'01', '1000', '1010', '100', '0', '0010',
'110', '0000', '00', '0111', '101', '0100',
'11', '10', '111', '0110', '1101', '010',
'000', '1', '001', '0001', '011', '1001',
'1011', '1100', '11111', '01111', '00111',
'00011', '00001', '00000', '10000', '11000',
'11100', '11110', '0101', '1110', '0011',
'00011000', '010101', '110011', '111000',
'101010', '001100', '101011', '100001', '001101',
'10110', '101101', '10001', '01010', '10010',
'011010', '011110', '0001001', '<br>', "+", '\n'
];
// writtenMorse alphabet signal words.
static List<String> writtenMorseExtra = [
'#', '000101', '00000000', '10101', '01010', '00010', '01000',
'000111000', '#', '+'
];
// writtenMorse separators.
static List<String> writtenMorseSeparators = ['#', '+'];
// Morse alphabet.
static List<String> morse = [
'.-', '-...', '-.-.', '-..', '.', '..-.', '--.', '....', '..', '.---',
'-.-', '.-..', '--', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-',
'...-', '.--', '-..-', '-.--', '--..', '-----', '.----', '..---', '...--',
'....-', '.....', '-....', '--...', '---..', '----.', '.-.-', '---.', '..--',
'...--...', '.-.-.-', '--..--', '---...', '-.-.-.', '..--..', '-.-.--',
'-....-', '..--.-', '-.--.', '-.--.-', '-...-', '.-.-.', '-..-.', '.--.-.',
'.----.', '...-..-', '<br>', ' ', '\n'
];
// Morse alphabet signal words.
static List<String> morseExtra = [
' ', '...-.-', '........', '-.-.-', '.-.-.', '...-.', '.-...',
'...---...', ' ', ' '
];
// Morse separators.
static List<String> morseSeparators = [' ', ' '];
/**
* Convert message to writtenMorse code.
*
* @param message Message to convert.
* @return converted message.
*/
static String getWrittenMorseEncoded(String message) {
return _encode(
message, writtenMorse, writtenMorseExtra, writtenMorseSeparators);
}
/**
* Convert messgae from writtenMorse code.
*
* @param message Message to convert.
* @return converted Message.
*/
static String getWrittenMorseDecoded(String message) {
return _decode(
message, writtenMorse, writtenMorseExtra, writtenMorseSeparators);
}
/**
* Convert messgae to Morse code.
*
* @param message Message to convert.
* @return converted Message.
*/
static String getMorseEncoded(String message) {
return _encode(
message, morse, morseExtra, morseSeparators).replaceAll(" ", "&nbsp;");
}
/**
* Convert messgae from Morse code.
*
* @param message Message to convert.
* @return converted Message.
*/
static String getMorseDecoded(String message) {
return _decode(
message, morse, morseExtra, morseSeparators);
}
/**
* Convert message to given alphabet.
*
* @param message Message to convert.
* @param codeAlphabet Alphabet of the code to convert to.
* @param codeAlphabetExtra Signal words of code to convert to.
* @param separators Separators of code to convert to.
* @return Converted message.
*/
static String _encode(String message, List<String> codeAlphabet, List<String> codeAlphabetExtra, List<String> separators) {
message = message.trim().toUpperCase();
if (message.isEmpty) {
return null;
}
if (alphabetExtra.contains(message)) {
return codeAlphabetExtra[alphabetExtra.indexOf(message)];
}
StringBuffer converted = new StringBuffer();
List<String> messageList = message.split('');
for (int i = 0; i < messageList.length; i++) {
String char = messageList[i];
converted.write(
codeAlphabet[alphabet.indexOf(char)]
);
if ((i < messageList.length - 1)
&& (char != " ")
&& (messageList[i + 1] != " ")
) {
converted.write(separators[0]);
}
}
return converted.toString().substring(0, converted.length);
}
/**
* Convert message from given alphabet.
*
* @param message Message to convert.
* @param codeAlphabet Alphabet of the code to convert from.
* @param codeAlphabetExtra Signal words of code to convert from.
* @param separators Separators of code to convert from.
* @return Converted message.
*/
static String _decode(String message, List<String> codeAlphabet, List<String> codeAlphabetExtra, List<String> separators) {
message = message.trim().toUpperCase();
if(message.isEmpty) {
return null;
}
if(codeAlphabetExtra.contains(message)) {
return alphabetExtra[codeAlphabetExtra.indexOf(message)];
}
StringBuffer converted = new StringBuffer();
List<String> lineList = message.split("\n");
for (String line in lineList) {
List<String> wordList = line.split(separators[1]);
for(int i = 0; i < wordList.length; i++) {
String word = wordList[i];
List<String> charList = word.split(separators[0]);
for(String char in charList) {
if (codeAlphabet.contains(char)) {
converted.write(
alphabet[codeAlphabet.indexOf(char)]
);
}
}
if (i < wordList.length - 1) {
converted.write(" ");
}
}
converted.write("\n");
}
return converted.toString().substring(0, converted.length - 1);
}
}

View File

@ -0,0 +1,39 @@
/**
* 2016 (c) Marcel Kapfer (mmk2410)
* Licensed under MIT License
*/
/**
* JS interopt file for making the Dart methods accessible in JavaScript.
*/
import 'dart:js' as js;
import 'Convert.dart';
import 'CodeRecognization.dart';
void main() {
js.context['isMorseCode'] = (message) {
return CodeRecognization.isMorseCode(message);
};
js.context['isWrittenMorseCode'] = (message) {
return CodeRecognization.isWrittenMorseCode(message);
};
js.context['getWrittenMorseEncoded'] = (message) {
return Convert.getWrittenMorseEncoded(message);
};
js.context['getWrittenMorseDecoded'] = (message) {
return Convert.getWrittenMorseDecoded(message);
};
js.context['getMorseEncoded'] = (message) {
return Convert.getMorseEncoded(message);
};
js.context['getMorseDecoded'] = (message) {
return Convert.getMorseDecoded(message);
};
}

View File

@ -1,3 +1,7 @@
/*
* 2015 - 2016 (c) Marcel Kapfer (mmk2410)
* Licensed under MIT License
*/
(function (document) {
'use strict';
@ -9,8 +13,8 @@
app.addEventListener('template-bound', function() {
console.log("Marcel Kapfer (mmk2410)");
console.log("Morse Converter beta");
console.log("Version 0.2");
console.log("Morse Converter");
console.log("Version 0.3.1");
});
window.addEventListener('WebComponentsReady', function() {
@ -46,7 +50,7 @@
});
menuReportBug = document.querySelector('#menuReportBug');
menuReportBug.addEventListener('click', function() {
window.open("https://github.com/mmk2410/morse-converter-web/issues", "_blank");
window.open("https://phab.mmk2410.org/maniphest/query/2c8tO32QJimD/", "_blank");
drawerPanel.closeDrawer();
});
menuAbout = document.querySelector('#menuAbout');
@ -56,7 +60,7 @@
});
menuFork = document.querySelector('#menuFork');
menuFork.addEventListener('click', function() {
window.open("https://github.com/mmk2410/morse-converter-web/", "_blank");
window.open("https://gitlab.com/mmk2410/morse-converter-web/", "_blank");
drawerPanel.closeDrawer();
});
inputArea.addEventListener('keyup', function() {
@ -67,15 +71,15 @@
}
if (writtenMorse) {
if (isWrittenMorseCode(input.value)) {
string = getWrittenMorseEncoded(input.value);
} else {
string = getWrittenMorseDecoded(input.value);
} else {
string = getWrittenMorseEncoded(input.value);
}
} else {
if (isNormalMorseCode(input.value)) {
string = getNormalMorseEncoded(input.value);
if (isMorseCode(input.value)) {
string = getMorseDecoded(input.value);
} else {
string = getNormalMorseDecoded(input.value);
string = getMorseEncoded(input.value);
}
}
outputArea.innerHTML = string;

View File

@ -1,522 +0,0 @@
getNormalMorseDecoded = (input) ->
# Well, this shouldn't happen...
if !(input)
return null
# remove trailing whitspaces
if input.charAt input.length is " "
input.substring 0, input.length - 1
input = input.toUpperCase()
output = ""
# Return special signs
if input is "LETTERSPACE"
return "&nbsp;&nbsp;&nbsp;"
else if input is "END OF WORK"
return "...-.-"
else if input is "ERROR"
return "........"
else if input is "STARTING SIGNAL"
return "-.-.-"
else if input is "ENDING SIGNAL"
return ".-.-."
else if input is "UNDERSTOOD"
return "...-."
else if input is "WAIT"
return ".-..."
else if input is "SOS"
return "...---..."
else if input is "LETTER SPACE"
return "&nbsp;&nbsp;&nbsp;"
else if input is "WORD SPACE"
return "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
else # the converting part
while input.length > 0
if input.charAt(0) is " "
if output.charAt(output.length) is " "
output = output.substring 0, output.length - 1
output += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "\n"
output += "<br>"
input = input.substring 1
else if input.charAt(0) is "A"
output += ".-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "B"
output += "-...&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "C"
output += "-.-.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "D"
output += "-..&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "E"
output += ".&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "F"
output += "..-.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "G"
output += "--.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "H"
output += "....&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "I"
output += "..&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "J"
output += ".---&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "K"
output += "-.-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "L"
output += ".-..&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "M"
output += "--&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "N"
output += "-.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "O"
output += "---&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "P"
output += ".--.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "Q"
output += "--.-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "R"
output += ".-.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "S"
output += "...&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "T"
output += "-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "U"
output += "..-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "V"
output += "...-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "W"
output += ".--&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "X"
output += "-..-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "Y"
output += "-.--&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "Z"
output += "--..&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "0"
output += "-----&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "1"
output += ".----&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "2"
output += "..---&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "3"
output += "...--&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "4"
output += "....-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "5"
output += ".....&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "6"
output += "-....&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "7"
output += "--...&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "8"
output += "---..&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "9"
output += "----.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "Ä"
output += ".-.-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "Ö"
output += "---.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "Ü"
output += "..--&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "ß"
output += "...--...&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "."
output += ".-.-.-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is ","
output += "--..--&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is ":"
output += "---...&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is ""
output += "-.-.-.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "?"
output += "..--..&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "!"
output += "-.-.--&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "-"
output += "-....-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "_"
output += "..--.-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "("
output += "-.--.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is ")"
output += "-.--.-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "="
output += "-...-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "+"
output += ".-.-.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "/"
output += "-..-.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "@"
output += ".--.-.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "'"
output += ".----.&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else if input.charAt(0) is "$"
output += "...-..-&nbsp;&nbsp;&nbsp;"
input = input.substring 1
else
return "Code not listed or wrong."
if output.charAt(output.length - 1) is " "
output = output.substring 0, output.length - 1
return output
getNormalMorseEncoded = (input) ->
# Well, this shouldn't happen...
if !(input) then return null
# remove trailing whitspaces
while input.charAt(input.length - 1) is " "
input = input.substring 0, input.length - 1
input = input.toUpperCase()
# remove all trailing new lines
while input.charAt(input.length - 1) is "\n"
input = input.substring 0, input.length - 1
# add one letterspace to the input
input += " "
inputToSign = input
output = ""
while inputToSign isnt " "
d = 0
signFull = true
sign = ""
while signFull
if inputToSign.substring(d, d + 7) is " " or
inputToSign.substring(d, d + 3) is " " or
inputToSign.charAt(0) is "\n"
if d is 0
if inputToSign.substring(0, 7) is " "
output += " "
inputToSign = inputToSign.substring 7, inputToSign.length
if inputToSign.substring(0, 3) is " "
inputToSign = inputToSign.substring 3, inputToSign.length
if inputToSign.charAt(0) is "\n"
output += "<br>"
inputToSign = inputToSign.substring 1, inputToSign.length
else
sign = inputToSign.substring 0, d
inputToSign = inputToSign.substring d, inputToSign.length
signFull = false
else
d++
if sign is ".-"
output += "A"
else if sign is "-..."
output += "B"
else if sign is "-.-."
output += "C"
else if sign is "-.."
output += "D"
else if sign is "."
output += "E"
else if sign is "..-."
output += "F"
else if sign is "--."
output += "G"
else if sign is "...."
output += "H"
else if sign is ".."
output += "I"
else if sign is ".---"
output += "J"
else if sign is "-.-"
output += "K"
else if sign is ".-.."
output += "L"
else if sign is "--"
output += "M"
else if sign is "-."
output += "N"
else if sign is "---"
output += "O"
else if sign is ".--."
output += "P"
else if sign is "--.-"
output += "Q"
else if sign is ".-."
output += "R"
else if sign is "..."
output += "S"
else if sign is "-"
output += "T"
else if sign is "..-"
output += "U"
else if sign is "...-"
output += "V"
else if sign is ".--"
output += "W"
else if sign is "-..-"
output += "X"
else if sign is "-.--"
output += "Y"
else if sign is "--.."
output += "Z"
else if sign is "-----"
output += "0"
else if sign is ".----"
output += "1"
else if sign is "..---"
output += "2"
else if sign is "...--"
output += "3"
else if sign is "....-"
output += "4"
else if sign is "....."
output += "5"
else if sign is "-...."
output += "6"
else if sign is "--..."
output += "7"
else if sign is "---.."
output += "8"
else if sign is "----."
output += "9"
else if sign is ".-.-"
output += "Ä"
else if sign is "---."
output += "Ö"
else if sign is "..--"
output += "Ü"
else if sign is "...--..."
output += "ß"
else if sign is "----"
output += "CH"
else if sign is ".-.-.-"
output += "."
else if sign is "--..--"
output += ","
else if sign is "---..."
output += ":"
else if sign is "-.-.-."
output += ";"
else if sign is "..--.."
output += "?"
else if sign is "-.-.--"
output += "!"
else if sign is "-....-"
output += "-"
else if sign is "..--.-"
output += "_"
else if sign is "-.--."
output += "("
else if sign is "-.--.-"
output += ")"
else if sign is ".----."
output += "'"
else if sign is "-...-"
output += "="
else if sign is ".-.-."
output += "+"
else if sign is "-..-."
output += "/"
else if sign is ".--.-."
output += "@"
else if sign is "-.-.-"
output += "Begin of the signal"
else if sign is "-...-"
output += "Wait"
else if sign is "...-."
output += "Understood"
else if sign is "...-.-"
output += "End of work"
else if sign is "...---..."
output += "SOS"
else if sign is "........"
output += "Error"
else
return "Code not listed or wrong."
return output

View File

@ -1,394 +0,0 @@
var getNormalMorseDecoded, getNormalMorseEncoded;
getNormalMorseDecoded = function(input) {
var output;
if (!input) {
return null;
}
if (input.charAt(input.length === " ")) {
input.substring(0, input.length - 1);
}
input = input.toUpperCase();
output = "";
if (input === "LETTERSPACE") {
return "&nbsp;&nbsp;&nbsp;";
} else if (input === "END OF WORK") {
return "...-.-";
} else if (input === "ERROR") {
return "........";
} else if (input === "STARTING SIGNAL") {
return "-.-.-";
} else if (input === "ENDING SIGNAL") {
return ".-.-.";
} else if (input === "UNDERSTOOD") {
return "...-.";
} else if (input === "WAIT") {
return ".-...";
} else if (input === "SOS") {
return "...---...";
} else if (input === "LETTER SPACE") {
return "&nbsp;&nbsp;&nbsp;";
} else if (input === "WORD SPACE") {
return "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
while (input.length > 0) {
if (input.charAt(0) === " ") {
if (output.charAt(output.length) === " ") {
output = output.substring(0, output.length - 1);
}
output += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "\n") {
output += "<br>";
input = input.substring(1);
} else if (input.charAt(0) === "A") {
output += ".-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "B") {
output += "-...&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "C") {
output += "-.-.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "D") {
output += "-..&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "E") {
output += ".&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "F") {
output += "..-.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "G") {
output += "--.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "H") {
output += "....&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "I") {
output += "..&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "J") {
output += ".---&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "K") {
output += "-.-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "L") {
output += ".-..&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "M") {
output += "--&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "N") {
output += "-.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "O") {
output += "---&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "P") {
output += ".--.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "Q") {
output += "--.-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "R") {
output += ".-.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "S") {
output += "...&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "T") {
output += "-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "U") {
output += "..-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "V") {
output += "...-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "W") {
output += ".--&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "X") {
output += "-..-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "Y") {
output += "-.--&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "Z") {
output += "--..&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "0") {
output += "-----&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "1") {
output += ".----&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "2") {
output += "..---&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "3") {
output += "...--&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "4") {
output += "....-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "5") {
output += ".....&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "6") {
output += "-....&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "7") {
output += "--...&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "8") {
output += "---..&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "9") {
output += "----.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "Ä") {
output += ".-.-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "Ö") {
output += "---.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "Ü") {
output += "..--&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "ß") {
output += "...--...&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === ".") {
output += ".-.-.-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === ",") {
output += "--..--&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === ":") {
output += "---...&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "") {
output += "-.-.-.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "?") {
output += "..--..&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "!") {
output += "-.-.--&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "-") {
output += "-....-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "_") {
output += "..--.-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "(") {
output += "-.--.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === ")") {
output += "-.--.-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "=") {
output += "-...-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "+") {
output += ".-.-.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "/") {
output += "-..-.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "@") {
output += ".--.-.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "'") {
output += ".----.&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else if (input.charAt(0) === "$") {
output += "...-..-&nbsp;&nbsp;&nbsp;";
input = input.substring(1);
} else {
return "Code not listed or wrong.";
}
}
if (output.charAt(output.length - 1) === " ") {
output = output.substring(0, output.length - 1);
}
}
return output;
};
getNormalMorseEncoded = function(input) {
var d, inputToSign, output, sign, signFull;
if (!input) {
return null;
}
while (input.charAt(input.length - 1) === " ") {
input = input.substring(0, input.length - 1);
}
input = input.toUpperCase();
while (input.charAt(input.length - 1) === "\n") {
input = input.substring(0, input.length - 1);
}
input += " ";
inputToSign = input;
output = "";
while (inputToSign !== " ") {
d = 0;
signFull = true;
sign = "";
while (signFull) {
if (inputToSign.substring(d, d + 7) === " " || inputToSign.substring(d, d + 3) === " " || inputToSign.charAt(0) === "\n") {
if (d === 0) {
if (inputToSign.substring(0, 7) === " ") {
output += " ";
inputToSign = inputToSign.substring(7, inputToSign.length);
}
if (inputToSign.substring(0, 3) === " ") {
inputToSign = inputToSign.substring(3, inputToSign.length);
}
if (inputToSign.charAt(0) === "\n") {
output += "<br>";
inputToSign = inputToSign.substring(1, inputToSign.length);
}
} else {
sign = inputToSign.substring(0, d);
inputToSign = inputToSign.substring(d, inputToSign.length);
signFull = false;
}
} else {
d++;
}
}
if (sign === ".-") {
output += "A";
} else if (sign === "-...") {
output += "B";
} else if (sign === "-.-.") {
output += "C";
} else if (sign === "-..") {
output += "D";
} else if (sign === ".") {
output += "E";
} else if (sign === "..-.") {
output += "F";
} else if (sign === "--.") {
output += "G";
} else if (sign === "....") {
output += "H";
} else if (sign === "..") {
output += "I";
} else if (sign === ".---") {
output += "J";
} else if (sign === "-.-") {
output += "K";
} else if (sign === ".-..") {
output += "L";
} else if (sign === "--") {
output += "M";
} else if (sign === "-.") {
output += "N";
} else if (sign === "---") {
output += "O";
} else if (sign === ".--.") {
output += "P";
} else if (sign === "--.-") {
output += "Q";
} else if (sign === ".-.") {
output += "R";
} else if (sign === "...") {
output += "S";
} else if (sign === "-") {
output += "T";
} else if (sign === "..-") {
output += "U";
} else if (sign === "...-") {
output += "V";
} else if (sign === ".--") {
output += "W";
} else if (sign === "-..-") {
output += "X";
} else if (sign === "-.--") {
output += "Y";
} else if (sign === "--..") {
output += "Z";
} else if (sign === "-----") {
output += "0";
} else if (sign === ".----") {
output += "1";
} else if (sign === "..---") {
output += "2";
} else if (sign === "...--") {
output += "3";
} else if (sign === "....-") {
output += "4";
} else if (sign === ".....") {
output += "5";
} else if (sign === "-....") {
output += "6";
} else if (sign === "--...") {
output += "7";
} else if (sign === "---..") {
output += "8";
} else if (sign === "----.") {
output += "9";
} else if (sign === ".-.-") {
output += "Ä";
} else if (sign === "---.") {
output += "Ö";
} else if (sign === "..--") {
output += "Ü";
} else if (sign === "...--...") {
output += "ß";
} else if (sign === "----") {
output += "CH";
} else if (sign === ".-.-.-") {
output += ".";
} else if (sign === "--..--") {
output += ",";
} else if (sign === "---...") {
output += ":";
} else if (sign === "-.-.-.") {
output += ";";
} else if (sign === "..--..") {
output += "?";
} else if (sign === "-.-.--") {
output += "!";
} else if (sign === "-....-") {
output += "-";
} else if (sign === "..--.-") {
output += "_";
} else if (sign === "-.--.") {
output += "(";
} else if (sign === "-.--.-") {
output += ")";
} else if (sign === ".----.") {
output += "'";
} else if (sign === "-...-") {
output += "=";
} else if (sign === ".-.-.") {
output += "+";
} else if (sign === "-..-.") {
output += "/";
} else if (sign === ".--.-.") {
output += "@";
} else if (sign === "-.-.-") {
output += "Begin of the signal";
} else if (sign === "-...-") {
output += "Wait";
} else if (sign === "...-.") {
output += "Understood";
} else if (sign === "...-.-") {
output += "End of work";
} else if (sign === "...---...") {
output += "SOS";
} else if (sign === "........") {
output += "Error";
} else {
return "Code not listed or wrong.";
}
}
return output;
};

View File

@ -1,523 +0,0 @@
getWrittenMorseDecoded = (input) ->
# Well, this shouldn't happen...
if !(input)
return null
# remove trailing whitspaces
if input.charAt input.length is " "
input.substring 0, input.length - 1
input = input.toUpperCase()
output = ""
# Return special signs
if input is "LETTERSPACE"
return "#"
else if input is "END OF WORK"
return "000101"
else if input is "ERROR"
return "00000000"
else if input is "STARTING SIGNAL"
return "10101"
else if input is "ENDING SIGNAL"
return "01010"
else if input is "UNDERSTOOD"
return "00010"
else if input is "WAIT"
return "01000"
else if input is "SOS"
return "000111000"
else if input is "LETTER SPACE"
return "#"
else if input is "WORD SPACE"
return "+"
else # the converting part
while input.length > 0
if input.charAt(0) is " "
if output.charAt(output.length) is "#"
output = output.substring 0, output.length - 1
output += "+"
input = input.substring 1
else if input.charAt(0) is "\n"
output += "<br>"
input = input.substring 1
else if input.charAt(0) is "A"
output += "01#"
input = input.substring 1
else if input.charAt(0) is "B"
output += "1000#"
input = input.substring 1
else if input.charAt(0) is "C"
output += "1010#"
input = input.substring 1
else if input.charAt(0) is "D"
output += "100#"
input = input.substring 1
else if input.charAt(0) is "E"
output += "0#"
input = input.substring 1
else if input.charAt(0) is "F"
output += "0010#"
input = input.substring 1
else if input.charAt(0) is "G"
output += "110#"
input = input.substring 1
else if input.charAt(0) is "H"
output += "0000#"
input = input.substring 1
else if input.charAt(0) is "I"
output += "00#"
input = input.substring 1
else if input.charAt(0) is "J"
output += "0111#"
input = input.substring 1
else if input.charAt(0) is "K"
output += "101#"
input = input.substring 1
else if input.charAt(0) is "L"
output += "0100#"
input = input.substring 1
else if input.charAt(0) is "M"
output += "11#"
input = input.substring 1
else if input.charAt(0) is "N"
output += "10#"
input = input.substring 1
else if input.charAt(0) is "O"
output += "111#"
input = input.substring 1
else if input.charAt(0) is "P"
output += "0110#"
input = input.substring 1
else if input.charAt(0) is "Q"
output += "1101#"
input = input.substring 1
else if input.charAt(0) is "R"
output += "010#"
input = input.substring 1
else if input.charAt(0) is "S"
output += "000#"
input = input.substring 1
else if input.charAt(0) is "T"
output += "1#"
input = input.substring 1
else if input.charAt(0) is "U"
output += "001#"
input = input.substring 1
else if input.charAt(0) is "V"
output += "0001#"
input = input.substring 1
else if input.charAt(0) is "W"
output += "011#"
input = input.substring 1
else if input.charAt(0) is "X"
output += "1001#"
input = input.substring 1
else if input.charAt(0) is "Y"
output += "1011#"
input = input.substring 1
else if input.charAt(0) is "Z"
output += "1100#"
input = input.substring 1
else if input.charAt(0) is "0"
output += "11111#"
input = input.substring 1
else if input.charAt(0) is "1"
output += "01111#"
input = input.substring 1
else if input.charAt(0) is "2"
output += "00111#"
input = input.substring 1
else if input.charAt(0) is "3"
output += "00011#"
input = input.substring 1
else if input.charAt(0) is "4"
output += "00001#"
input = input.substring 1
else if input.charAt(0) is "5"
output += "00000#"
input = input.substring 1
else if input.charAt(0) is "6"
output += "10000#"
input = input.substring 1
else if input.charAt(0) is "7"
output += "11000#"
input = input.substring 1
else if input.charAt(0) is "8"
output += "11100#"
input = input.substring 1
else if input.charAt(0) is "9"
output += "11110#"
input = input.substring 1
else if input.charAt(0) is "Ä"
output += "0101#"
input = input.substring 1
else if input.charAt(0) is "Ö"
output += "1110#"
input = input.substring 1
else if input.charAt(0) is "Ü"
output += "0011#"
input = input.substring 1
else if input.charAt(0) is "ß"
output += "00011000#"
input = input.substring 1
else if input.charAt(0) is "."
output += "010101#"
input = input.substring 1
else if input.charAt(0) is ","
output += "110011#"
input = input.substring 1
else if input.charAt(0) is ":"
output += "111000#"
input = input.substring 1
else if input.charAt(0) is ""
output += "101010#"
input = input.substring 1
else if input.charAt(0) is "?"
output += "001100#"
input = input.substring 1
else if input.charAt(0) is "!"
output += "101011#"
input = input.substring 1
else if input.charAt(0) is "-"
output += "100001#"
input = input.substring 1
else if input.charAt(0) is "_"
output += "001101#"
input = input.substring 1
else if input.charAt(0) is "("
output += "10110#"
input = input.substring 1
else if input.charAt(0) is ")"
output += "101101#"
input = input.substring 1
else if input.charAt(0) is "="
output += "10001#"
input = input.substring 1
else if input.charAt(0) is "+"
output += "01010#"
input = input.substring 1
else if input.charAt(0) is "/"
output += "10010#"
input = input.substring 1
else if input.charAt(0) is "@"
output += "011010#"
input = input.substring 1
else if input.charAt(0) is "'"
output += "011110#"
input = input.substring 1
else if input.charAt(0) is "$"
output += "0001001#"
input = input.substring 1
else
return "Code not listed or wrong."
if output.charAt(output.length - 1) is "#"
output = output.substring 0, output.length - 1
return output
getWrittenMorseEncoded = (input) ->
# Well, this shouldn't happen...
if !(input) then return null
# remove trailing whitspaces
while input.charAt(input.length - 1) is " "
input = input.substring 0, input.length - 1
input = input.toUpperCase()
while input.charAt(input.length - 1) is "#" or
input.charAt(input.length - 1) is "+" or
input.charAt(input.length - 1) is "\n"
input = input.substring 0, input.length - 1
if input.charAt(input.length - 1) isnt "#"
input += "#"
inputToSign = input
output = ""
while inputToSign isnt "#"
d = 0
signFull = true
sign = ""
while signFull
if inputToSign.charAt(d) is "+" or
inputToSign.charAt(d) is "#" or
inputToSign.charAt(0) is "\n"
if d is 0
if inputToSign.charAt(0) is "+"
output += " "
inputToSign = inputToSign.substring 1, inputToSign.length
if inputToSign.charAt(0) is "#"
inputToSign = inputToSign.substring 1, inputToSign.length
if inputToSign.charAt(0) is "\n"
output += "<br>"
inputToSign = inputToSign.substring 1, inputToSign.length
else
sign = inputToSign.substring 0, d
inputToSign = inputToSign.substring d, inputToSign.length
signFull = false
else
d++
if sign is "01"
output += "A"
else if sign is "1000"
output += "B"
else if sign is "1010"
output += "C"
else if sign is "100"
output += "D"
else if sign is "0"
output += "E"
else if sign is "0010"
output += "F"
else if sign is "110"
output += "G"
else if sign is "0000"
output += "H"
else if sign is "00"
output += "I"
else if sign is "0111"
output += "J"
else if sign is "101"
output += "K"
else if sign is "0100"
output += "L"
else if sign is "11"
output += "M"
else if sign is "10"
output += "N"
else if sign is "111"
output += "O"
else if sign is "0110"
output += "P"
else if sign is "1101"
output += "Q"
else if sign is "010"
output += "R"
else if sign is "000"
output += "S"
else if sign is "1"
output += "T"
else if sign is "001"
output += "U"
else if sign is "0001"
output += "V"
else if sign is "011"
output += "W"
else if sign is "1001"
output += "X"
else if sign is "1011"
output += "Y"
else if sign is "1100"
output += "Z"
else if sign is "11111"
output += "0"
else if sign is "01111"
output += "1"
else if sign is "00111"
output += "2"
else if sign is "00011"
output += "3"
else if sign is "00001"
output += "4"
else if sign is "00000"
output += "5"
else if sign is "10000"
output += "6"
else if sign is "11000"
output += "7"
else if sign is "11100"
output += "8"
else if sign is "11110"
output += "9"
else if sign is "0101"
output += "Ä"
else if sign is "1110"
output += "Ö"
else if sign is "0011"
output += "Ü"
else if sign is "00011000"
output += "ß"
else if sign is "1111"
output += "CH"
else if sign is "010101"
output += "."
else if sign is "110011"
output += ","
else if sign is "111000"
output += ":"
else if sign is "101010"
output += ";"
else if sign is "001100"
output += "?"
else if sign is "101011"
output += "!"
else if sign is "100001"
output += "-"
else if sign is "001101"
output += "_"
else if sign is "10110"
output += "("
else if sign is "101101"
output += ")"
else if sign is "011110"
output += "'"
else if sign is "10001"
output += "="
else if sign is "01010"
output += "+"
else if sign is "10010"
output += "/"
else if sign is "011010"
output += "@"
else if sign is "10101"
output += "Begin of the signal"
else if sign is "10001"
output += "Wait"
else if sign is "00010"
output += "Understood"
else if sign is "000101"
output += "End of work"
else if sign is "000111000"
output += "SOS"
else if sign is "00000000"
output += "Error"
else
return "Code not listed or wrong."
return output

View File

@ -1,396 +0,0 @@
var getWrittenMorseDecoded, getWrittenMorseEncoded;
getWrittenMorseDecoded = function(input) {
var output;
if (!input) {
return null;
}
if (input.charAt(input.length === " ")) {
input.substring(0, input.length - 1);
}
input = input.toUpperCase();
output = "";
if (input === "LETTERSPACE") {
return "#";
} else if (input === "END OF WORK") {
return "000101";
} else if (input === "ERROR") {
return "00000000";
} else if (input === "STARTING SIGNAL") {
return "10101";
} else if (input === "ENDING SIGNAL") {
return "01010";
} else if (input === "UNDERSTOOD") {
return "00010";
} else if (input === "WAIT") {
return "01000";
} else if (input === "SOS") {
return "000111000";
} else if (input === "LETTER SPACE") {
return "#";
} else if (input === "WORD SPACE") {
return "+";
} else {
while (input.length > 0) {
if (input.charAt(0) === " ") {
if (output.charAt(output.length) === "#") {
output = output.substring(0, output.length - 1);
}
output += "+";
input = input.substring(1);
} else if (input.charAt(0) === "\n") {
output += "<br>";
input = input.substring(1);
} else if (input.charAt(0) === "A") {
output += "01#";
input = input.substring(1);
} else if (input.charAt(0) === "B") {
output += "1000#";
input = input.substring(1);
} else if (input.charAt(0) === "C") {
output += "1010#";
input = input.substring(1);
} else if (input.charAt(0) === "D") {
output += "100#";
input = input.substring(1);
} else if (input.charAt(0) === "E") {
output += "0#";
input = input.substring(1);
} else if (input.charAt(0) === "F") {
output += "0010#";
input = input.substring(1);
} else if (input.charAt(0) === "G") {
output += "110#";
input = input.substring(1);
} else if (input.charAt(0) === "H") {
output += "0000#";
input = input.substring(1);
} else if (input.charAt(0) === "I") {
output += "00#";
input = input.substring(1);
} else if (input.charAt(0) === "J") {
output += "0111#";
input = input.substring(1);
} else if (input.charAt(0) === "K") {
output += "101#";
input = input.substring(1);
} else if (input.charAt(0) === "L") {
output += "0100#";
input = input.substring(1);
} else if (input.charAt(0) === "M") {
output += "11#";
input = input.substring(1);
} else if (input.charAt(0) === "N") {
output += "10#";
input = input.substring(1);
} else if (input.charAt(0) === "O") {
output += "111#";
input = input.substring(1);
} else if (input.charAt(0) === "P") {
output += "0110#";
input = input.substring(1);
} else if (input.charAt(0) === "Q") {
output += "1101#";
input = input.substring(1);
} else if (input.charAt(0) === "R") {
output += "010#";
input = input.substring(1);
} else if (input.charAt(0) === "S") {
output += "000#";
input = input.substring(1);
} else if (input.charAt(0) === "T") {
output += "1#";
input = input.substring(1);
} else if (input.charAt(0) === "U") {
output += "001#";
input = input.substring(1);
} else if (input.charAt(0) === "V") {
output += "0001#";
input = input.substring(1);
} else if (input.charAt(0) === "W") {
output += "011#";
input = input.substring(1);
} else if (input.charAt(0) === "X") {
output += "1001#";
input = input.substring(1);
} else if (input.charAt(0) === "Y") {
output += "1011#";
input = input.substring(1);
} else if (input.charAt(0) === "Z") {
output += "1100#";
input = input.substring(1);
} else if (input.charAt(0) === "0") {
output += "11111#";
input = input.substring(1);
} else if (input.charAt(0) === "1") {
output += "01111#";
input = input.substring(1);
} else if (input.charAt(0) === "2") {
output += "00111#";
input = input.substring(1);
} else if (input.charAt(0) === "3") {
output += "00011#";
input = input.substring(1);
} else if (input.charAt(0) === "4") {
output += "00001#";
input = input.substring(1);
} else if (input.charAt(0) === "5") {
output += "00000#";
input = input.substring(1);
} else if (input.charAt(0) === "6") {
output += "10000#";
input = input.substring(1);
} else if (input.charAt(0) === "7") {
output += "11000#";
input = input.substring(1);
} else if (input.charAt(0) === "8") {
output += "11100#";
input = input.substring(1);
} else if (input.charAt(0) === "9") {
output += "11110#";
input = input.substring(1);
} else if (input.charAt(0) === "Ä") {
output += "0101#";
input = input.substring(1);
} else if (input.charAt(0) === "Ö") {
output += "1110#";
input = input.substring(1);
} else if (input.charAt(0) === "Ü") {
output += "0011#";
input = input.substring(1);
} else if (input.charAt(0) === "ß") {
output += "00011000#";
input = input.substring(1);
} else if (input.charAt(0) === ".") {
output += "010101#";
input = input.substring(1);
} else if (input.charAt(0) === ",") {
output += "110011#";
input = input.substring(1);
} else if (input.charAt(0) === ":") {
output += "111000#";
input = input.substring(1);
} else if (input.charAt(0) === "") {
output += "101010#";
input = input.substring(1);
} else if (input.charAt(0) === "?") {
output += "001100#";
input = input.substring(1);
} else if (input.charAt(0) === "!") {
output += "101011#";
input = input.substring(1);
} else if (input.charAt(0) === "-") {
output += "100001#";
input = input.substring(1);
} else if (input.charAt(0) === "_") {
output += "001101#";
input = input.substring(1);
} else if (input.charAt(0) === "(") {
output += "10110#";
input = input.substring(1);
} else if (input.charAt(0) === ")") {
output += "101101#";
input = input.substring(1);
} else if (input.charAt(0) === "=") {
output += "10001#";
input = input.substring(1);
} else if (input.charAt(0) === "+") {
output += "01010#";
input = input.substring(1);
} else if (input.charAt(0) === "/") {
output += "10010#";
input = input.substring(1);
} else if (input.charAt(0) === "@") {
output += "011010#";
input = input.substring(1);
} else if (input.charAt(0) === "'") {
output += "011110#";
input = input.substring(1);
} else if (input.charAt(0) === "$") {
output += "0001001#";
input = input.substring(1);
} else {
return "Code not listed or wrong.";
}
}
if (output.charAt(output.length - 1) === "#") {
output = output.substring(0, output.length - 1);
}
}
return output;
};
getWrittenMorseEncoded = function(input) {
var d, inputToSign, output, sign, signFull;
if (!input) {
return null;
}
while (input.charAt(input.length - 1) === " ") {
input = input.substring(0, input.length - 1);
}
input = input.toUpperCase();
while (input.charAt(input.length - 1) === "#" || input.charAt(input.length - 1) === "+" || input.charAt(input.length - 1) === "\n") {
input = input.substring(0, input.length - 1);
}
if (input.charAt(input.length - 1) !== "#") {
input += "#";
}
inputToSign = input;
output = "";
while (inputToSign !== "#") {
d = 0;
signFull = true;
sign = "";
while (signFull) {
if (inputToSign.charAt(d) === "+" || inputToSign.charAt(d) === "#" || inputToSign.charAt(0) === "\n") {
if (d === 0) {
if (inputToSign.charAt(0) === "+") {
output += " ";
inputToSign = inputToSign.substring(1, inputToSign.length);
}
if (inputToSign.charAt(0) === "#") {
inputToSign = inputToSign.substring(1, inputToSign.length);
}
if (inputToSign.charAt(0) === "\n") {
output += "<br>";
inputToSign = inputToSign.substring(1, inputToSign.length);
}
} else {
sign = inputToSign.substring(0, d);
inputToSign = inputToSign.substring(d, inputToSign.length);
signFull = false;
}
} else {
d++;
}
}
if (sign === "01") {
output += "A";
} else if (sign === "1000") {
output += "B";
} else if (sign === "1010") {
output += "C";
} else if (sign === "100") {
output += "D";
} else if (sign === "0") {
output += "E";
} else if (sign === "0010") {
output += "F";
} else if (sign === "110") {
output += "G";
} else if (sign === "0000") {
output += "H";
} else if (sign === "00") {
output += "I";
} else if (sign === "0111") {
output += "J";
} else if (sign === "101") {
output += "K";
} else if (sign === "0100") {
output += "L";
} else if (sign === "11") {
output += "M";
} else if (sign === "10") {
output += "N";
} else if (sign === "111") {
output += "O";
} else if (sign === "0110") {
output += "P";
} else if (sign === "1101") {
output += "Q";
} else if (sign === "010") {
output += "R";
} else if (sign === "000") {
output += "S";
} else if (sign === "1") {
output += "T";
} else if (sign === "001") {
output += "U";
} else if (sign === "0001") {
output += "V";
} else if (sign === "011") {
output += "W";
} else if (sign === "1001") {
output += "X";
} else if (sign === "1011") {
output += "Y";
} else if (sign === "1100") {
output += "Z";
} else if (sign === "11111") {
output += "0";
} else if (sign === "01111") {
output += "1";
} else if (sign === "00111") {
output += "2";
} else if (sign === "00011") {
output += "3";
} else if (sign === "00001") {
output += "4";
} else if (sign === "00000") {
output += "5";
} else if (sign === "10000") {
output += "6";
} else if (sign === "11000") {
output += "7";
} else if (sign === "11100") {
output += "8";
} else if (sign === "11110") {
output += "9";
} else if (sign === "0101") {
output += "Ä";
} else if (sign === "1110") {
output += "Ö";
} else if (sign === "0011") {
output += "Ü";
} else if (sign === "00011000") {
output += "ß";
} else if (sign === "1111") {
output += "CH";
} else if (sign === "010101") {
output += ".";
} else if (sign === "110011") {
output += ",";
} else if (sign === "111000") {
output += ":";
} else if (sign === "101010") {
output += ";";
} else if (sign === "001100") {
output += "?";
} else if (sign === "101011") {
output += "!";
} else if (sign === "100001") {
output += "-";
} else if (sign === "001101") {
output += "_";
} else if (sign === "10110") {
output += "(";
} else if (sign === "101101") {
output += ")";
} else if (sign === "011110") {
output += "'";
} else if (sign === "10001") {
output += "=";
} else if (sign === "01010") {
output += "+";
} else if (sign === "10010") {
output += "/";
} else if (sign === "011010") {
output += "@";
} else if (sign === "10101") {
output += "Begin of the signal";
} else if (sign === "10001") {
output += "Wait";
} else if (sign === "00010") {
output += "Understood";
} else if (sign === "000101") {
output += "End of work";
} else if (sign === "000111000") {
output += "SOS";
} else if (sign === "00000000") {
output += "Error";
} else {
return "Code not listed or wrong.";
}
}
return output;
};

View File

@ -1,7 +1,7 @@
{
"name": "Morse Converter (beta)",
"version": "0.2.0",
"homepage": "https://github.com/mmk2410/morse-converter-web",
"name": "Morse Converter",
"version": "0.3.1",
"homepage": "https://gitlab.com/mmk2410/morse-converter-web",
"authors": [
"mmk2410 <marcelmichaelkapfer@yahoo.co.nz>"
],
@ -21,15 +21,17 @@
"dependencies": {
"iron-input": "PolymerElements/iron-input#~1.0.5",
"paper-drawer-panel": "PolymerElements/paper-drawer-panel#~1.0.3",
"paper-header-panel": "PolymerElements/paper-header-panel#~1.0.5",
"paper-icon-button": "PolymerElements/paper-icon-button#~1.0.3",
"paper-input": "PolymerElements/paper-input#~1.0.12",
"paper-item": "PolymerElements/paper-item#~1.0.2",
"paper-header-panel": "PolymerElements/paper-header-panel#~1.1.6",
"paper-icon-button": "PolymerElements/paper-icon-button#~1.1.1",
"paper-input": "PolymerElements/paper-input#~1.1.11",
"paper-item": "PolymerElements/paper-item#~1.2.1",
"paper-material": "PolymerElements/paper-material#~1.0.2",
"paper-menu": "PolymerElements/paper-menu#~1.1.0",
"paper-toast": "PolymerElements/paper-toast#~1.0.0",
"paper-toolbar": "PolymerElements/paper-toolbar#~1.0.4",
"platinum-sw": "PolymerElements/platinum-sw#~1.2.0",
"polymer": "Polymer/polymer#^1.0.0"
"paper-menu": "PolymerElements/paper-menu#~1.2.2",
"paper-toast": "PolymerElements/paper-toast#~1.2.2",
"paper-toolbar": "PolymerElements/paper-toolbar#~1.1.4",
"platinum-sw": "PolymerElements/platinum-sw#~1.3.0",
"polymer": "Polymer/polymer#^1.0.0",
"iron-icons": "PolymerElements/iron-icons#^1.1.3",
"paper-ripple": "PolymerElements/paper-ripple#^1.0.5"
}
}

View File

@ -1,3 +1,5 @@
# 2015 - 2016 (c) Marcel Kapfer (mmk2410)
# Licensed under MIT License
gulp = require 'gulp'
coffee = require 'gulp-coffee'
gutil = require 'gulp-util'
@ -9,6 +11,7 @@ merge = require 'merge-stream'
path = require 'path'
fs = require 'fs'
glob = require 'glob'
connect = require 'gulp-connect'
gulp.task 'coffee', () ->
@ -96,6 +99,12 @@ gulp.task 'precache', (callback) ->
filePath = path.join dir, 'precache.json'
fs.writeFile filePath, JSON.stringify(files), callback
gulp.task 'serve', (callback) ->
connect.server({
port: 8080
root: 'dist'
})
gulp.task 'clean', del.bind null, ['dist']
gulp.task 'default', ['clean'], (cb) ->

View File

@ -1,6 +1,6 @@
{
"name": "morseconverter",
"version": "0.2.0",
"version": "0.3.1",
"description": "A Morse converter for the web",
"main": "index.js",
"scripts": {
@ -8,7 +8,7 @@
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/mmk2410/morse-converter-web.git"
"url": "git+ssh://git@gitlab.com/mmk2410/morse-converter-web.git"
},
"keywords": [
"Morse",
@ -17,9 +17,9 @@
"author": "mmk2410 <marcelmichaelkapfer@yahoo.co.nz>",
"license": "MIT",
"bugs": {
"url": "https://github.com/mmk2410/morse-converter-web/issues"
"url": "https://phab.mmk2410.org/maniphest/query/2c8tO32QJimD/"
},
"homepage": "https://github.com/mmk2410/morse-converter-web#readme",
"homepage": "https://gitlab.com/mmk2410/morse-converter-web",
"devDependencies": {
"coffee-script": "^1.9.3",
"del": "^1.2.1",
@ -29,6 +29,7 @@
"gulp-autoprefixer": "^2.1.0",
"gulp-cache": "^0.2.10",
"gulp-coffee": "^2.3.1",
"gulp-connect": "^4.0.0",
"gulp-if": "^1.2.5",
"gulp-imagemin": "^2.3.0",
"gulp-load-plugins": "^0.10.0",

9
pubspec.yaml Normal file
View File

@ -0,0 +1,9 @@
name: morse_converter_web
version: 0.3.1
description: >
A Morse and writtenMorse converter for the web using modern technologies like Dart and Polymer.
author: Marcel Kapfer (mmk2410) <marcelmichaelkapfer@yahoo.co.nz>
homepage: https://mmk2410.org/writtenmorse/
documentation: https://mmk2410.org/writtenmorse/
dependencies:
test: "^0.12.13+4"

View File

@ -0,0 +1,19 @@
import "package:test/test.dart";
import '../app/scripts/CodeRecognization.dart';
void main() {
group("writtenMorse", () {
test("CodeRecognization.isMorse() check if text is morse code", () {
expect(CodeRecognization.isMorseCode(".-.. --- .-. . --"), isTrue);
});
test("CodeRecognization.isMorse() check if text is not morse code", () {
expect(CodeRecognization.isMorseCode("message1238170"), isFalse);
});
});
}

63
test/Convert_test.dart Normal file
View File

@ -0,0 +1,63 @@
import 'package:test/test.dart';
import '../app/scripts/Convert.dart';
String text = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque in varius augue. Suspendisse non elit tristique est fringilla tempor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vestibulum dui eu neque efficitur consequat. Donec ornare congue facilisis. Duis consequat est lectus, sit amet hendrerit erat euismod vel.
Maecenas nisi leo, commodo eget vehicula a, aliquet nec purus. Aenean eget dictum turpis. In sit amet volutpat nisl, et ornare urna. Etiam eget cursus ipsum. Vestibulum et magna id metus cursus ullamcorper. Donec ornare libero ac enim consectetur, sit amet malesuada odio dignissim. Aenean dui nisl, posuere a orci sed, bibendum fringilla lectus.""";
String writtenMorse = """
0100#111#010#0#11+00#0110#000#001#11+100#111#0100#111#010+000#00#1+01#11#0#1#110011+1010#111#10#000#0#1010#1#0#1#001#010+01#100#00#0110#00#000#1010#00#10#110+0#0100#00#1#010101+0110#0#0100#0100#0#10#1#0#000#1101#001#0+00#10+0001#01#010#00#001#000+01#001#110#001#0#010101+000#001#000#0110#0#10#100#00#000#000#0+10#111#10+0#0100#00#1+1#010#00#000#1#00#1101#001#0+0#000#1+0010#010#00#10#110#00#0100#0100#01+1#0#11#0110#111#010#010101+0100#111#010#0#11+00#0110#000#001#11+100#111#0100#111#010+000#00#1+01#11#0#1#110011+1010#111#10#000#0#1010#1#0#1#001#010+01#100#00#0110#00#000#1010#00#10#110+0#0100#00#1#010101+10#001#0100#0100#01+0001#0#000#1#00#1000#001#0100#001#11+100#001#00+0#001+10#0#1101#001#0+0#0010#0010#00#1010#00#1#001#010+1010#111#10#000#0#1101#001#01#1#010101+100#111#10#0#1010+111#010#10#01#010#0+1010#111#10#110#001#0+0010#01#1010#00#0100#00#000#00#000#010101+100#001#00#000+1010#111#10#000#0#1101#001#01#1+0#000#1+0100#0#1010#1#001#000#110011+000#00#1+01#11#0#1+0000#0#10#100#010#0#010#00#1+0#010#01#1+0#001#00#000#11#111#100+0001#0#0100#010101#<br>#11#01#0#1010#0#10#01#000+10#00#000#00+0100#0#111#110011+1010#111#11#11#111#100#111+0#110#0#1+0001#0#0000#00#1010#001#0100#01+01#110011+01#0100#00#1101#001#0#1+10#0#1010+0110#001#010#001#000#010101+01#0#10#0#01#10+0#110#0#1+100#00#1010#1#001#11+1#001#010#0110#00#000#010101+00#10+000#00#1+01#11#0#1+0001#111#0100#001#1#0110#01#1+10#00#000#0100#110011+0#1+111#010#10#01#010#0+001#010#10#01#010101+0#1#00#01#11+0#110#0#1+1010#001#010#000#001#000+00#0110#000#001#11#010101+0001#0#000#1#00#1000#001#0100#001#11+0#1+11#01#110#10#01+00#100+11#0#1#001#000+1010#001#010#000#001#000+001#0100#0100#01#11#1010#111#010#0110#0#010#010101+100#111#10#0#1010+111#010#10#01#010#0+0100#00#1000#0#010#111+01#1010+0#10#00#11+1010#111#10#000#0#1010#1#0#1#001#010#110011+000#00#1+01#11#0#1+11#01#0100#0#000#001#01#100#01+111#100#00#111+100#00#110#10#00#000#000#00#11#010101+01#0#10#0#01#10+100#001#00+10#00#000#0100#110011+0110#111#000#001#0#010#0+01+111#010#1010#00+000#0#100#110011+1000#00#1000#0#10#100#001#11+0010#010#00#10#110#00#0100#0100#01+0100#0#1010#1#001#000#010101""";
String morse = """
.-.. --- .-. . -- .. .--. ... ..- -- -.. --- .-.. --- .-. ... .. - .- -- . - --..-- -.-. --- -. ... . -.-. - . - ..- .-. .- -.. .. .--. .. ... -.-. .. -. --. . .-.. .. - .-.-.- .--. . .-.. .-.. . -. - . ... --.- ..- . .. -. ...- .- .-. .. ..- ... .- ..- --. ..- . .-.-.- ... ..- ... .--. . -. -.. .. ... ... . -. --- -. . .-.. .. - - .-. .. ... - .. --.- ..- . . ... - ..-. .-. .. -. --. .. .-.. .-.. .- - . -- .--. --- .-. .-.-.- .-.. --- .-. . -- .. .--. ... ..- -- -.. --- .-.. --- .-. ... .. - .- -- . - --..-- -.-. --- -. ... . -.-. - . - ..- .-. .- -.. .. .--. .. ... -.-. .. -. --. . .-.. .. - .-.-.- -. ..- .-.. .-.. .- ...- . ... - .. -... ..- .-.. ..- -- -.. ..- .. . ..- -. . --.- ..- . . ..-. ..-. .. -.-. .. - ..- .-. -.-. --- -. ... . --.- ..- .- - .-.-.- -.. --- -. . -.-. --- .-. -. .- .-. . -.-. --- -. --. ..- . ..-. .- -.-. .. .-.. .. ... .. ... .-.-.- -.. ..- .. ... -.-. --- -. ... . --.- ..- .- - . ... - .-.. . -.-. - ..- ... --..-- ... .. - .- -- . - .... . -. -.. .-. . .-. .. - . .-. .- - . ..- .. ... -- --- -.. ...- . .-.. .-.-.- <br> -- .- . -.-. . -. .- ... -. .. ... .. .-.. . --- --..-- -.-. --- -- -- --- -.. --- . --. . - ...- . .... .. -.-. ..- .-.. .- .- --..-- .- .-.. .. --.- ..- . - -. . -.-. .--. ..- .-. ..- ... .-.-.- .- . -. . .- -. . --. . - -.. .. -.-. - ..- -- - ..- .-. .--. .. ... .-.-.- .. -. ... .. - .- -- . - ...- --- .-.. ..- - .--. .- - -. .. ... .-.. --..-- . - --- .-. -. .- .-. . ..- .-. -. .- .-.-.- . - .. .- -- . --. . - -.-. ..- .-. ... ..- ... .. .--. ... ..- -- .-.-.- ...- . ... - .. -... ..- .-.. ..- -- . - -- .- --. -. .- .. -.. -- . - ..- ... -.-. ..- .-. ... ..- ... ..- .-.. .-.. .- -- -.-. --- .-. .--. . .-. .-.-.- -.. --- -. . -.-. --- .-. -. .- .-. . .-.. .. -... . .-. --- .- -.-. . -. .. -- -.-. --- -. ... . -.-. - . - ..- .-. --..-- ... .. - .- -- . - -- .- .-.. . ... ..- .- -.. .- --- -.. .. --- -.. .. --. -. .. ... ... .. -- .-.-.- .- . -. . .- -. -.. ..- .. -. .. ... .-.. --..-- .--. --- ... ..- . .-. . .- --- .-. -.-. .. ... . -.. --..-- -... .. -... . -. -.. ..- -- ..-. .-. .. -. --. .. .-.. .-.. .- .-.. . -.-. - ..- ... .-.-.-""";
void main() {
group("writtenMorse", () {
test("Convert.getWrittenMorseEncoded() convert lorem ipsum text.", () {
expect(Convert.getWrittenMorseEncoded(text), equals(writtenMorse));
});
test("Convert.getWrittenMorseEncoded() convert a special symbol.", () {
String string = "UNDERSTOOD";
expect(Convert.getWrittenMorseEncoded(string), equals("00010"));
});
test("Convert.getWrittenMorseDecoded() convert lorem ipsum writtenMorse code.", () {
String string = writtenMorse.replaceAll("<br>", "\n");
expect(Convert.getWrittenMorseDecoded(string), equals(text.toUpperCase()));
});
test("Convert.getWrittenMorseDecoded() convert a special symbol.", () {
String string = "00010";
expect(Convert.getWrittenMorseDecoded(string), equals("UNDERSTOOD"));
});
});
group("Morse", () {
test("Convert.getMorseEncoded() convert lorem ipsum text.", () {
expect(Convert.getMorseEncoded(text), equals(morse));
});
test("Convert.getMorseEncoded() convert a special symbol.", () {
String string = "UNDERSTOOD";
expect(Convert.getMorseEncoded(string), equals("...-."));
});
test("Convert.getMorseDecoded() convert lorem ipsum writtenMorse code.", () {
String string = morse.replaceAll("<br>", "\n");
expect(Convert.getMorseDecoded(string), equals(text.toUpperCase()));
});
test("Convert.getMorseDecoded() convert a special symbol.", () {
String string = "...-.";
expect(Convert.getMorseDecoded(string), equals("UNDERSTOOD"));
});
});
}