Tidied Morse Code operations to match the project conventions.

This commit is contained in:
n1474335 2017-02-07 14:20:34 +00:00
parent 718e1dc153
commit 8f69ee441e
7 changed files with 42 additions and 210 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -82,11 +82,11 @@ var Categories = [
"XOR Brute Force",
"Vigenère Encode",
"Vigenère Decode",
"To Morse Code",
"From Morse Code",
"Substitute",
"Derive PBKDF2 key",
"Derive EVP key",
"To Morse code",
"From Morse code",
]
},
{

View File

@ -2953,9 +2953,9 @@ var OperationConfig = {
}
]
},
"To Morse code": {
description: "Translates alphanumeric characters into International Morse code.<br><br>Ignores non-Morse characters.<br><br>e.g. SOS becomes ... --- ...",
run: MorseCode.translateTo,
"To Morse Code": {
description: "Translates alphanumeric characters into International Morse Code.<br><br>Ignores non-Morse characters.<br><br>e.g. <code>SOS</code> becomes <code>... --- ...</code>",
run: MorseCode.runTo,
inputType: "string",
outputType: "string",
args: [
@ -2976,9 +2976,9 @@ var OperationConfig = {
}
]
},
"From Morse code": {
description: "Translates Morse code into (upper case) alphanumeric characters.",
run: MorseCode.translateFrom,
"From Morse Code": {
description: "Translates Morse Code into (upper case) alphanumeric characters.",
run: MorseCode.runFrom,
inputType: "string",
outputType: "string",
args: [

View File

@ -14,29 +14,16 @@ var MorseCode = {
* @default
*/
FORMAT_OPTIONS: ["-/.", "_/.", "Dash/Dot", "DASH/DOT", "dash/dot"],
/**
* @constant
* @default
*/
LETTER_DELIM_OPTIONS: ["space", "line feed", "crlf"],
LETTER_DELIM_OPTIONS: ["Space", "Line feed", "CRLF", "Comma", "Semi-colon", "Colon"],
/**
* @constant
* @default
*/
WORD_DELIM_OPTIONS: ["line feed", "crlf", "space"],
/**
* @constant
* @default
*/
OPTION_TABLE: {
"space": " ",
"line feed": "\n",
"crlf": "\r\n"
},
WORD_DELIM_OPTIONS: ["Line feed", "CRLF", "Space", "Comma", "Semi-colon", "Colon"],
/**
* @constant
* @default
@ -88,13 +75,13 @@ var MorseCode = {
* @param {Object[]} args
* @returns {string}
*/
translateTo: function(input, args) {
runTo: function(input, args) {
var format = args[0].split("/");
var dash = format[0];
var dot = format[1];
var letterDelim = MorseCode.OPTION_TABLE[args[1]];
var wordDelim = MorseCode.OPTION_TABLE[args[2]];
var letterDelim = Utils.charRep[args[1]];
var wordDelim = Utils.charRep[args[2]];
input = input.split(/\r?\n/);
input = Array.prototype.map.call(input, function(line) {
@ -139,7 +126,7 @@ var MorseCode = {
* @param {Object[]} args
* @returns {string}
*/
translateFrom: (function() {
runFrom: (function() {
var reversedTable = null;
var reverseTable = function() {
reversedTable = {};
@ -155,8 +142,8 @@ var MorseCode = {
reverseTable();
}
var letterDelim = MorseCode.OPTION_TABLE[args[0]];
var wordDelim = MorseCode.OPTION_TABLE[args[1]];
var letterDelim = Utils.charRep[args[0]];
var wordDelim = Utils.charRep[args[1]];
input = input.replace(/-|_|dash/ig, "<dash>");
input = input.replace(/\.|dot/ig, "<dot>");

View File

@ -1,64 +1,21 @@
<<<<<<< HEAD
203 source files
<<<<<<< HEAD
<<<<<<< HEAD
104401 lines
size
136 JavaScript source files
95311 lines
3.4M size
=======
104403 lines
4.0M size
136 JavaScript source files
95313 lines
3.5M size
>>>>>>> master
=======
104466 lines
4.0M size
136 JavaScript source files
95316 lines
3.4M size
>>>>>>> master
=======
211 source files
114840 lines
212 source files
115050 lines
4.3M size
141 JavaScript source files
105680 lines
3.7M size
>>>>>>> master
142 JavaScript source files
105890 lines
3.8M size
83 third party JavaScript source files
86258 lines
3.0M size
58 first party JavaScript source files
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
18934 lines
729K size
=======
18936 lines
728K size
>>>>>>> master
=======
18939 lines
724K size
>>>>>>> master
=======
19422 lines
732K size
>>>>>>> master
59 first party JavaScript source files
19632 lines
740K size
3.4M uncompressed JavaScript size
1.9M compressed JavaScript size
15 categories
165 operations
167 operations