Fixed code spacing and formatting
This commit is contained in:
parent
23ddb87c9f
commit
4d39c3bbd2
@ -227,22 +227,9 @@ class Lorenz extends Operation {
|
|||||||
pattern = args[1],
|
pattern = args[1],
|
||||||
kt = args[2],
|
kt = args[2],
|
||||||
mode = args[3],
|
mode = args[3],
|
||||||
format = args[6];
|
intype = args[4],
|
||||||
|
|
||||||
let intype = args[4],
|
|
||||||
outtype = args[5],
|
outtype = args[5],
|
||||||
s1 = args[7],
|
format = args[6],
|
||||||
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],
|
|
||||||
lugs1 = args[19],
|
lugs1 = args[19],
|
||||||
lugs2 = args[20],
|
lugs2 = args[20],
|
||||||
lugs3 = args[21],
|
lugs3 = args[21],
|
||||||
@ -254,7 +241,20 @@ class Lorenz extends Operation {
|
|||||||
lugx2 = args[27],
|
lugx2 = args[27],
|
||||||
lugx3 = args[28],
|
lugx3 = args[28],
|
||||||
lugx4 = args[29],
|
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;
|
figShifted = false;
|
||||||
|
|
||||||
this.reverseTable();
|
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");
|
if (x5<1 || x5>23) throw new OperationError("Χ5 start must be between 1 and 23");
|
||||||
|
|
||||||
// Initialise chosen wheel pattern
|
// Initialise chosen wheel pattern
|
||||||
let chosenSetting = '';
|
let chosenSetting = "";
|
||||||
if (pattern === "Custom") {
|
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 (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 (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");
|
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 {
|
} else {
|
||||||
chosenSetting = INIT_PATTERNS[pattern];
|
chosenSetting = INIT_PATTERNS[pattern];
|
||||||
}
|
}
|
||||||
var chiSettings = chosenSetting.X; // Pin settings for Chi links (X)
|
const chiSettings = chosenSetting.X; // Pin settings for Chi links (X)
|
||||||
var psiSettings = chosenSetting.S; // Pin settings for Psi links (S)
|
const psiSettings = chosenSetting.S; // Pin settings for Psi links (S)
|
||||||
var muSettings = chosenSetting.M; // Pin settings for Motor links (M)
|
const muSettings = chosenSetting.M; // Pin settings for Motor links (M)
|
||||||
|
|
||||||
let ita2 = "";
|
let ita2 = "";
|
||||||
if (mode === "Send") {
|
if (mode === "Send") {
|
||||||
|
|
||||||
// Convert input text to ITA2 (including figure/letter shifts)
|
// Convert input text to ITA2 (including figure/letter shifts)
|
||||||
ita2 = Array.prototype.map.call(input, function(character) {
|
ita2 = Array.prototype.map.call(input, function(character) {
|
||||||
let letter = character.toUpperCase();
|
const letter = character.toUpperCase();
|
||||||
|
|
||||||
if (intype === "Plaintext") {
|
if (intype === "Plaintext") {
|
||||||
if (validChars.indexOf(letter) === -1) throw new OperationError("Invalid Plaintext character : "+letter);
|
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
|
// Receive input should always be ITA2
|
||||||
ita2 = Array.prototype.map.call(input, function(character) {
|
ita2 = Array.prototype.map.call(input, function(character) {
|
||||||
let letter = character.toUpperCase();
|
const letter = character.toUpperCase();
|
||||||
if (validITA2.indexOf(letter) === -1) {
|
if (validITA2.indexOf(letter) === -1) {
|
||||||
var errltr = letter;
|
let errltr = letter;
|
||||||
if (errltr==="\n") errltr = "Carriage Return";
|
if (errltr==="\n") errltr = "Carriage Return";
|
||||||
if (errltr===" ") errltr = "Space";
|
if (errltr===" ") errltr = "Space";
|
||||||
throw new OperationError("Invalid ITA2 character : "+errltr);
|
throw new OperationError("Invalid ITA2 character : "+errltr);
|
||||||
@ -375,7 +375,7 @@ class Lorenz extends Operation {
|
|||||||
let thisChi = [];
|
let thisChi = [];
|
||||||
let m61lug = muSettings[1][m61-1];
|
let m61lug = muSettings[1][m61-1];
|
||||||
let m37lug = muSettings[2][m37-1];
|
let m37lug = muSettings[2][m37-1];
|
||||||
let p5 = [0,0,0];
|
const p5 = [0, 0, 0];
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
const letters = Array.prototype.map.call(ita2Input, function(character) {
|
const letters = Array.prototype.map.call(ita2Input, function(character) {
|
||||||
@ -406,8 +406,8 @@ class Lorenz extends Operation {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
let xorSum = [];
|
const xorSum = [];
|
||||||
for(var i=0;i<=4;i++) {
|
for (let i=0;i<=4;i++) {
|
||||||
xorSum[i] = ITA2_TABLE[letter][i] ^ thisPsi[i] ^ thisChi[i];
|
xorSum[i] = ITA2_TABLE[letter][i] ^ thisPsi[i] ^ thisChi[i];
|
||||||
}
|
}
|
||||||
const resultStr = xorSum.join("");
|
const resultStr = xorSum.join("");
|
||||||
@ -427,7 +427,7 @@ class Lorenz extends Operation {
|
|||||||
if (--m37 < 1) m37 = 37;
|
if (--m37 < 1) m37 = 37;
|
||||||
}
|
}
|
||||||
|
|
||||||
let basicmotor = m37lug;
|
const basicmotor = m37lug;
|
||||||
let totalmotor = basicmotor;
|
let totalmotor = basicmotor;
|
||||||
let lim = 0;
|
let lim = 0;
|
||||||
|
|
||||||
@ -440,11 +440,16 @@ class Lorenz extends Operation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Limitations here
|
// 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
|
// Chi 2 one back lim - The active character of chi 2 (2nd Chi wheel) in the previous position
|
||||||
lim = chiSettings[2][x2bptr-1];
|
lim = chiSettings[2][x2bptr-1];
|
||||||
if (kt) {
|
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 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;
|
totalmotor = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(model=='SZ42b') {
|
} else if (model==="SZ42b") {
|
||||||
// Chi 2 one back + Psi 1 one back.
|
// Chi 2 one back + Psi 1 one back.
|
||||||
const x2b1lug = chiSettings[2][x2bptr-1];
|
const x2b1lug = chiSettings[2][x2bptr-1];
|
||||||
const s1b1lug = psiSettings[1][s1bptr-1];
|
const s1b1lug = psiSettings[1][s1bptr-1];
|
||||||
lim = 1;
|
lim = 1;
|
||||||
if (x2b1lug===s1b1lug) lim=0;
|
if (x2b1lug===s1b1lug) lim=0;
|
||||||
if (kt) {
|
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 basic motor = 0 and limitation = 1, Total motor = 0 [no move], otherwise, total motor = 1 [move]
|
||||||
if (basicmotor===0 && lim===1) {
|
if (basicmotor===0 && lim===1) {
|
||||||
@ -498,7 +508,7 @@ class Lorenz extends Operation {
|
|||||||
return rtnstr;
|
return rtnstr;
|
||||||
});
|
});
|
||||||
|
|
||||||
let ita2output = letters.join("");
|
const ita2output = letters.join("");
|
||||||
let output = "";
|
let output = "";
|
||||||
|
|
||||||
if (mode === "Receive") {
|
if (mode === "Receive") {
|
||||||
@ -563,9 +573,12 @@ class Lorenz extends Operation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read lugs settings - convert to 0|1
|
||||||
|
*/
|
||||||
readLugs(lugstr) {
|
readLugs(lugstr) {
|
||||||
let arr = Array.prototype.map.call(lugstr, function(lug) {
|
const arr = Array.prototype.map.call(lugstr, function(lug) {
|
||||||
if(lug==".") {
|
if (lug===".") {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
@ -617,7 +630,7 @@ const ITA2_TABLE = {
|
|||||||
|
|
||||||
const validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+-'()/:=?,. \n\r";
|
const validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+-'()/:=?,. \n\r";
|
||||||
const validITA2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ34589+-./";
|
const validITA2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ34589+-./";
|
||||||
const figShiftedChars = "1234567890+-'()/:=?,."
|
const figShiftedChars = "1234567890+-'()/:=?,.";
|
||||||
|
|
||||||
const figShiftArr = {
|
const figShiftArr = {
|
||||||
"1": "Q",
|
"1": "Q",
|
||||||
|
Loading…
Reference in New Issue
Block a user