function mapLetter(number, ringstellung, wheelposition, wheel, pass)
{
	// Variables: number = input letter; ringstellung = wheel ring setting (static);
	// wheelposition = wheel position (rotates); wheel = current wheel;
	// pass = are we going R->L (1) or L->R (2)

	// Change number according to ringstellung (ring setting)
	// Wheel turns anti-clockwise (looking from right)
	var offset = ringstellung - wheelposition;
    document.getElementById('showDebug').value += "offset: " + offset + "\n";
	number = number - ringstellung;

		// Check number is between 1 and 26
		number = validLetter(number);

	// Change number according to wheel position
	// Wheel turns clockwise (looking from right)

	number = number + wheelposition;

		// Check number is between 1 and 26
		number = validLetter(number);

	// Do internal connection 'x' to 'y' according to direction  
	if (pass == 2) {
		var let = ENIGMA.plaintext.charAt(number);
		document.getElementById('showDebug').value += "true input character: " + let + "\n";
		number = ENIGMA.arrRotors[wheel].indexOf(let);
	} else {
		var let = ENIGMA.arrRotors[wheel].charAt(number);
		document.getElementById('showDebug').value += "true input character: " + let + "\n";
		number = ENIGMA.plaintext.indexOf(let);
	}

	// 
	// NOW WORK IT BACKWARDS : subtract where we added and vice versa
	// 

	// Change according to wheel position (anti-clockwise)

	document.getElementById('showDebug').value += "true output character (number): " + ENIGMA.plaintext.charAt(number) + "\n";
	number = number - wheelposition;

		// Check number is between 1 and 26
		number = validLetter(number);

	// Change according to ringstellung (clockwise)

	number = number + ringstellung;
	document.getElementById('showDebug').value += "final output character (pre-normalized number) " + number + "\n";

		// Check number is between 1 and 26
		number = validLetter(number);
	document.getElementById('showDebug').value += "final output character (post-normalized number) " + number + "\n";
	document.getElementById('showDebug').value += "final output character (post-normalized) " + ENIGMA.plaintext.charAt(number) + "\n";

	return number;
}
/* FUNCTION --------------------------------------------------------
	Map one letter to another through current wheel
   ----------------------------------------------------------------- */
FUNCTION
Map one letter to another through current wheel
FUNCTION Map one letter to another through current wheel
function mapLetter(number, ringstellung, wheelposition, wheel, pass)
{
	var offset = ringstellung - wheelposition;
    document.getElementById('showDebug').value += "offset: " + offset + "\n";
	number = number - ringstellung;
		number = validLetter(number);
	number = number + wheelposition;
		number = validLetter(number);
	if (pass == 2) {
		var let = ENIGMA.plaintext.charAt(number);
		document.getElementById('showDebug').value += "true input character: " + let + "\n";
		number = ENIGMA.arrRotors[wheel].indexOf(let);
	} else {
		var let = ENIGMA.arrRotors[wheel].charAt(number);
		document.getElementById('showDebug').value += "true input character: " + let + "\n";
		number = ENIGMA.plaintext.indexOf(let);
	}
	NOW WORK IT BACKWARDS : subtract where we added and vice versa
	Change according to wheel position (anti-clockwise)
	document.getElementById('showDebug').value += "true output character (number): " + ENIGMA.plaintext.charAt(number) + "\n";
	number = number - wheelposition;
		number = validLetter(number);
	Change according to ringstellung (clockwise)
	number = number + ringstellung;
	document.getElementById('showDebug').value += "final output character (pre-normalized number) " + number + "\n";
		number = validLetter(number);
	document.getElementById('showDebug').value += "final output character (post-normalized number) " + number + "\n";
	document.getElementById('showDebug').value += "final output character (post-normalized) " + ENIGMA.plaintext.charAt(number) + "\n";
	return number;
}
function mapLetter ( number , ringstellung , wheelposition , wheel , pass ) { var offset = ringstellung - wheelposition ; document . getElementById ( 'showDebug' ) . value += "offset: " + offset + "\n" ; number = number - ringstellung ; number = validLetter ( number ) ; number = number + wheelposition ; number = validLetter ( number ) ; if ( pass == 2 ) { var let = ENIGMA . plaintext . charAt ( number ) ; document . getElementById ( 'showDebug' ) . value += "true input character: " + let + "\n" ; number = ENIGMA . arrRotors [ wheel ] . indexOf ( let ) ; } else { var let = ENIGMA . arrRotors [ wheel ] . charAt ( number ) ; document . getElementById ( 'showDebug' ) . value += "true input character: " + let + "\n" ; number = ENIGMA . plaintext . indexOf ( let ) ; } document . getElementById ( 'showDebug' ) . value += "true output character (number): " + ENIGMA . plaintext . charAt ( number ) + "\n" ; number = number - wheelposition ; number = validLetter ( number ) ; number = number + ringstellung ; document . getElementById ( 'showDebug' ) . value += "final output character (pre-normalized number) " + number + "\n" ; number = validLetter ( number ) ; document . getElementById ( 'showDebug' ) . value += "final output character (post-normalized number) " + number + "\n" ; document . getElementById ( 'showDebug' ) . value += "final output character (post-normalized) " + ENIGMA . plaintext . charAt ( number ) + "\n" ; return number ; }
FUNCTION
Map one letter to another through current wheel
FUNCTION Map one letter to another through current wheel
// Variables: number = input letter; ringstellung = wheel ring setting (static); // wheelposition = wheel position (rotates); wheel = current wheel; // pass = are we going R->L (1) or L->R (2) // Change number according to ringstellung (ring setting) // Wheel turns anti-clockwise (looking from right) // Check number is between 1 and 26 // Change number according to wheel position // Wheel turns clockwise (looking from right) // Check number is between 1 and 26 // Do internal connection 'x' to 'y' according to direction   //  // NOW WORK IT BACKWARDS : subtract where we added and vice versa //  // Change according to wheel position (anti-clockwise) // Check number is between 1 and 26 // Change according to ringstellung (clockwise) // Check number is between 1 and 26