1
0
mirror of synced 2024-12-20 10:45:53 +01:00

Fixed code spacing and formatting

This commit is contained in:
martin gillow 2019-03-30 13:42:29 +00:00
parent 23ddb87c9f
commit 4d39c3bbd2

View File

@ -227,22 +227,9 @@ class Lorenz extends Operation {
pattern = args[1],
kt = args[2],
mode = args[3],
format = args[6];
let intype = args[4],
intype = args[4],
outtype = args[5],
s1 = args[7],
s2 = args[8],
s3 = args[9],
s4 = args[10],
s5 = args[11],
m37 = args[12],
m61 = args[13],
x1 = args[14],
x2 = args[15],
x3 = args[16],
x4 = args[17],
x5 = args[18],
format = args[6],
lugs1 = args[19],
lugs2 = args[20],
lugs3 = args[21],
@ -254,7 +241,20 @@ class Lorenz extends Operation {
lugx2 = args[27],
lugx3 = args[28],
lugx4 = args[29],
lugx5 = args[30],
lugx5 = args[30];
let s1 = args[7],
s2 = args[8],
s3 = args[9],
s4 = args[10],
s5 = args[11],
m37 = args[12],
m61 = args[13],
x1 = args[14],
x2 = args[15],
x3 = args[16],
x4 = args[17],
x5 = args[18],
figShifted = false;
this.reverseTable();
@ -273,9 +273,9 @@ class Lorenz extends Operation {
if (x5<1 || x5>23) throw new OperationError("Χ5 start must be between 1 and 23");
// Initialise chosen wheel pattern
let chosenSetting = '';
let chosenSetting = "";
if (pattern === "Custom") {
let re = new RegExp("^[.xX]*$");
const re = new RegExp("^[.xX]*$");
if (lugs1.length !== 43 || !re.test(lugs1)) throw new OperationError("Ψ1 custom lugs must be 43 long and can only include . or x ");
if (lugs2.length !== 47 || !re.test(lugs2)) throw new OperationError("Ψ2 custom lugs must be 47 long and can only include . or x");
if (lugs3.length !== 51 || !re.test(lugs3)) throw new OperationError("Ψ3 custom lugs must be 51 long and can only include . or x");
@ -304,16 +304,16 @@ class Lorenz extends Operation {
} else {
chosenSetting = INIT_PATTERNS[pattern];
}
var chiSettings = chosenSetting.X; // Pin settings for Chi links (X)
var psiSettings = chosenSetting.S; // Pin settings for Psi links (S)
var muSettings = chosenSetting.M; // Pin settings for Motor links (M)
const chiSettings = chosenSetting.X; // Pin settings for Chi links (X)
const psiSettings = chosenSetting.S; // Pin settings for Psi links (S)
const muSettings = chosenSetting.M; // Pin settings for Motor links (M)
let ita2 = "";
if (mode === "Send") {
// Convert input text to ITA2 (including figure/letter shifts)
ita2 = Array.prototype.map.call(input, function(character) {
let letter = character.toUpperCase();
const letter = character.toUpperCase();
if (intype === "Plaintext") {
if (validChars.indexOf(letter) === -1) throw new OperationError("Invalid Plaintext character : "+letter);
@ -357,9 +357,9 @@ class Lorenz extends Operation {
// Receive input should always be ITA2
ita2 = Array.prototype.map.call(input, function(character) {
let letter = character.toUpperCase();
const letter = character.toUpperCase();
if (validITA2.indexOf(letter) === -1) {
var errltr = letter;
let errltr = letter;
if (errltr==="\n") errltr = "Carriage Return";
if (errltr===" ") errltr = "Space";
throw new OperationError("Invalid ITA2 character : "+errltr);
@ -375,7 +375,7 @@ class Lorenz extends Operation {
let thisChi = [];
let m61lug = muSettings[1][m61-1];
let m37lug = muSettings[2][m37-1];
let p5 = [0,0,0];
const p5 = [0, 0, 0];
const self = this;
const letters = Array.prototype.map.call(ita2Input, function(character) {
@ -406,8 +406,8 @@ class Lorenz extends Operation {
return "";
}
let xorSum = [];
for(var i=0;i<=4;i++) {
const xorSum = [];
for (let i=0;i<=4;i++) {
xorSum[i] = ITA2_TABLE[letter][i] ^ thisPsi[i] ^ thisChi[i];
}
const resultStr = xorSum.join("");
@ -427,7 +427,7 @@ class Lorenz extends Operation {
if (--m37 < 1) m37 = 37;
}
let basicmotor = m37lug;
const basicmotor = m37lug;
let totalmotor = basicmotor;
let lim = 0;
@ -440,11 +440,16 @@ class Lorenz extends Operation {
}
// Limitations here
if (model==='SZ42a') {
if (model==="SZ42a") {
// Chi 2 one back lim - The active character of chi 2 (2nd Chi wheel) in the previous position
lim = chiSettings[2][x2bptr-1];
if (kt) {
if (lim===p5[2]) { lim = 0; } else { lim=1; } //p5 back 2
//p5 back 2
if (lim===p5[2]) {
lim = 0;
} else {
lim=1;
}
}
// If basic motor = 0 and limitation = 1, Total motor = 0 [no move], otherwise, total motor = 1 [move]
@ -454,14 +459,19 @@ class Lorenz extends Operation {
totalmotor = 1;
}
} else if(model=='SZ42b') {
} else if (model==="SZ42b") {
// Chi 2 one back + Psi 1 one back.
const x2b1lug = chiSettings[2][x2bptr-1];
const s1b1lug = psiSettings[1][s1bptr-1];
lim = 1;
if (x2b1lug===s1b1lug) lim=0;
if (kt) {
if (lim===p5[2]) { lim=0; } else { lim=1; } //p5 back 2
//p5 back 2
if (lim===p5[2]) {
lim=0;
} else {
lim=1;
}
}
// If basic motor = 0 and limitation = 1, Total motor = 0 [no move], otherwise, total motor = 1 [move]
if (basicmotor===0 && lim===1) {
@ -498,7 +508,7 @@ class Lorenz extends Operation {
return rtnstr;
});
let ita2output = letters.join("");
const ita2output = letters.join("");
let output = "";
if (mode === "Receive") {
@ -563,9 +573,12 @@ class Lorenz extends Operation {
}
}
/**
* Read lugs settings - convert to 0|1
*/
readLugs(lugstr) {
let arr = Array.prototype.map.call(lugstr, function(lug) {
if(lug==".") {
const arr = Array.prototype.map.call(lugstr, function(lug) {
if (lug===".") {
return 0;
} else {
return 1;
@ -617,7 +630,7 @@ const ITA2_TABLE = {
const validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+-'()/:=?,. \n\r";
const validITA2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ34589+-./";
const figShiftedChars = "1234567890+-'()/:=?,."
const figShiftedChars = "1234567890+-'()/:=?,.";
const figShiftArr = {
"1": "Q",