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", "XOR Brute Force",
"Vigenère Encode", "Vigenère Encode",
"Vigenère Decode", "Vigenère Decode",
"To Morse Code",
"From Morse Code",
"Substitute", "Substitute",
"Derive PBKDF2 key", "Derive PBKDF2 key",
"Derive EVP key", "Derive EVP key",
"To Morse code",
"From Morse code",
] ]
}, },
{ {

View File

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

View File

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

View File

@ -1,64 +1,21 @@
<<<<<<< HEAD 212 source files
203 source files 115050 lines
<<<<<<< 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
4.3M size 4.3M size
141 JavaScript source files 142 JavaScript source files
105680 lines 105890 lines
3.7M size 3.8M size
>>>>>>> master
83 third party JavaScript source files 83 third party JavaScript source files
86258 lines 86258 lines
3.0M size 3.0M size
58 first party JavaScript source files 59 first party JavaScript source files
<<<<<<< HEAD 19632 lines
<<<<<<< HEAD 740K size
<<<<<<< HEAD
18934 lines
729K size
=======
18936 lines
728K size
>>>>>>> master
=======
18939 lines
724K size
>>>>>>> master
=======
19422 lines
732K size
>>>>>>> master
3.4M uncompressed JavaScript size 3.4M uncompressed JavaScript size
1.9M compressed JavaScript size 1.9M compressed JavaScript size
15 categories 15 categories
165 operations 167 operations