diff --git a/calc/calc.js b/calc/calc.js
index 559b868..7442d9a 100644
--- a/calc/calc.js
+++ b/calc/calc.js
@@ -1,1492 +1,2104 @@
// ============================== Init ==============================
-var compactViewportWidth = 911 // viewport width threshold
-var mobileUserAgent = navigator.userAgent.match('Mobile')
+var compactViewportWidth = 911; // viewport width threshold
+var mobileUserAgent = navigator.userAgent.match("Mobile");
-var cipherList = [] // list of all available ciphers
-var cipherListSaved = [] // copy of all initially available ciphers
-var defaultCipherArray = [] // default ciphers
-var defaultCipherArraySaved = [] // copy of default ciphers
+var cipherList = []; // list of all available ciphers
+var cipherListSaved = []; // copy of all initially available ciphers
+var defaultCipherArray = []; // default ciphers
+var defaultCipherArraySaved = []; // copy of default ciphers
var cCat = []; // list of all available cipher categories
// Layout
-var colorMenuColumns = ($(window).width() < 1600) ? 2 : 4 // number of columns inside Color Menu
-var encodingMenuColumns = 4 // number of columns inside Encoding menu
-var enabledCiphColumns = 4 // number of columns for enabled ciphers table (for phrase)
-var optForceTwoColumnLayout = false // force 2 cipher columns
-var optColoredCiphers = true // use colored ciphers
+var colorMenuColumns = $(window).width() < 1600 ? 2 : 4; // number of columns inside Color Menu
+var encodingMenuColumns = 4; // number of columns inside Encoding menu
+var enabledCiphColumns = 4; // number of columns for enabled ciphers table (for phrase)
+var optForceTwoColumnLayout = false; // force 2 cipher columns
+var optColoredCiphers = true; // use colored ciphers
-var colorControlsMenuOpened = false // color controls menu state
-var editCiphersMenuOpened = false // edit ciphers menu state
-var dateCalcMenuOpened = false // date calculator menu state
-var encodingMenuOpened = false // encoding menu state
+var colorControlsMenuOpened = false; // color controls menu state
+var editCiphersMenuOpened = false; // edit ciphers menu state
+var dateCalcMenuOpened = false; // date calculator menu state
+var encodingMenuOpened = false; // encoding menu state
-var enabledCiphCount = 0 // number of enabled ciphers
-var optShowExtraCiphers = true // enable extra ciphers
+var enabledCiphCount = 0; // number of enabled ciphers
+var optShowExtraCiphers = true; // enable extra ciphers
// Cipher colors
-var origColors = [] // preserve original cipher colors
-var chkboxColors = [] // individual cipher color modifiers
-var globColors = [] // global color modifiers
+var origColors = []; // preserve original cipher colors
+var chkboxColors = []; // individual cipher color modifiers
+var globColors = []; // global color modifiers
-var sHistory = [] // user search history (history table)
-var optPhraseLimit = 5 // word limit to enter input as separate phrases, "End" key
+var sHistory = []; // user search history (history table)
+var optPhraseLimit = 5; // word limit to enter input as separate phrases, "End" key
-var compactHistoryTable = false // compact mode - vertical cipher names
-var optNewPhrasesGoFirst = false // new phrases are inserted at the beginning of history table
-var optCompactCiphCount = 8 // compact mode threshold
-var optLoadUserHistCiphers = true // load ciphers when CSV file is imported
+var compactHistoryTable = false; // compact mode - vertical cipher names
+var optNewPhrasesGoFirst = false; // new phrases are inserted at the beginning of history table
+var optCompactCiphCount = 8; // compact mode threshold
+var optLoadUserHistCiphers = true; // load ciphers when CSV file is imported
-var optMatrixCodeRain = true // code rain
+var optMatrixCodeRain = true; // code rain
-var optShowOnlyMatching = false // set opacity of nonmatching values to zero
+var optShowOnlyMatching = false; // set opacity of nonmatching values to zero
-var optNumCalcMethod = 1 // 0 - "Off", 1 - "Full", 2 - "Reduced"
-var optLetterWordCount = true // show word/letter count
-var optCompactBreakdown = true // compact breakdown - "phrase = 67 (English Ordinal)" is not included inside the chart
-var optWordBreakdown = true // word breakdown
-var optShowCipherChart = true // cipher breakdown chart
+var optNumCalcMethod = 1; // 0 - "Off", 1 - "Full", 2 - "Reduced"
+var optLetterWordCount = true; // show word/letter count
+var optCompactBreakdown = true; // compact breakdown - "phrase = 67 (English Ordinal)" is not included inside the chart
+var optWordBreakdown = true; // word breakdown
+var optShowCipherChart = true; // cipher breakdown chart
-var optGemSubstitutionMode = true // simple substitution of characters with correspondent values
-var optGemMultCharPos = false // value of each character is multiplied by character index
-var optGemMultCharPosReverse = false // value of each character is multiplied by character index in reverse order
+var optGemSubstitutionMode = true; // simple substitution of characters with correspondent values
+var optGemMultCharPos = false; // value of each character is multiplied by character index
+var optGemMultCharPosReverse = false; // value of each character is multiplied by character index in reverse order
-var optFiltSameCipherMatch = false // filter shows only phrases that match in the same cipher
-var optFiltCrossCipherMatch = true // filter shows only ciphers that have matching values
-var alphaHlt = 0.15 // opacity for values that do not match - change value here and in conf_SOM()
+var optFiltSameCipherMatch = false; // filter shows only phrases that match in the same cipher
+var optFiltCrossCipherMatch = true; // filter shows only ciphers that have matching values
+var alphaHlt = 0.15; // opacity for values that do not match - change value here and in conf_SOM()
-var optAllowPhraseComments = true // allow phrase comments, text inside [...] is not evaluated
-var liveDatabaseMode = true // live database mode
+var optAllowPhraseComments = true; // allow phrase comments, text inside [...] is not evaluated
+var liveDatabaseMode = true; // live database mode
-var dbPageItems = 15 // number of phrases in one section
-var dbScrollItems = 1 // used for scrolling
+var dbPageItems = 15; // number of phrases in one section
+var dbScrollItems = 1; // used for scrolling
-var optGradientCharts = true // gradient fill for breakdown/cipher charts
-var optGradientChartsDefault = optGradientCharts
+var optGradientCharts = true; // gradient fill for breakdown/cipher charts
+var optGradientChartsDefault = optGradientCharts;
-var interfaceHue = 222 // calculator interface color
-var interfaceHueDefault = 222 // value for reset, updated on first run of updateInterfaceHue()
-var interfaceSat = 1.0 // interface saturation multiplier
-var interfaceSatDefault = 1.0
-var interfaceLit = 1.0 // interface lightness multiplier
-var interfaceLitDefault = 1.0
+var interfaceHue = 222; // calculator interface color
+var interfaceHueDefault = 222; // value for reset, updated on first run of updateInterfaceHue()
+var interfaceSat = 1.0; // interface saturation multiplier
+var interfaceSatDefault = 1.0;
+var interfaceLit = 1.0; // interface lightness multiplier
+var interfaceLitDefault = 1.0;
-var fontHue = 0 // font and outline hue
-var fontHueDefault = 0 // value for reset, updated on first run of updateFontHue()
-var fontSat = 0 // font saturation
-var fontSatDefault = 0
-var fontLit = 1.0 // font lightness multiplier
-var fontLitDefault = 1.0
+var fontHue = 0; // font and outline hue
+var fontHueDefault = 0; // value for reset, updated on first run of updateFontHue()
+var fontSat = 0; // font saturation
+var fontSatDefault = 0;
+var fontLit = 1.0; // font lightness multiplier
+var fontLitDefault = 1.0;
-var coderainHue = 148 // coderain hue
-var coderainHueDefault = 148 // value for reset, updated on first run of updateCoderainHue()
-var coderainSat = 0.2 // coderain saturation
-var coderainSatDefault = 0.2
-var coderainLit = 0.19 // coderain lightness
-var coderainLitDefault = 0.19
+var coderainHue = 148; // coderain hue
+var coderainHueDefault = 148; // value for reset, updated on first run of updateCoderainHue()
+var coderainSat = 0.2; // coderain saturation
+var coderainSatDefault = 0.2;
+var coderainLit = 0.19; // coderain lightness
+var coderainLitDefault = 0.19;
-var optImageScale = 1.0 // image scaling factor for screenshots
+var optImageScale = 1.0; // image scaling factor for screenshots
-var calcOptionsArr = [ // used to export/import settings
- "'optNumCalcMethod'+' = '+optNumCalcMethod",
- "'optFiltCrossCipherMatch'+' = '+optFiltCrossCipherMatch",
- "'optFiltSameCipherMatch'+' = '+optFiltSameCipherMatch",
- "'optShowOnlyMatching'+' = '+optShowOnlyMatching",
- "'optNewPhrasesGoFirst'+' = '+optNewPhrasesGoFirst",
- "'optShowExtraCiphers'+' = '+optShowExtraCiphers",
- "'optAllowPhraseComments'+' = '+optAllowPhraseComments",
- "'liveDatabaseMode'+' = '+liveDatabaseMode",
- "'optLetterWordCount'+' = '+optLetterWordCount",
- "'optWordBreakdown'+' = '+optWordBreakdown",
- "'optCompactBreakdown'+' = '+optCompactBreakdown",
- "'optShowCipherChart'+' = '+optShowCipherChart",
- "'optGradientCharts'+' = '+optGradientCharts",
- "'optLoadUserHistCiphers'+' = '+optLoadUserHistCiphers",
- "'optMatrixCodeRain'+' = '+optMatrixCodeRain",
- "'interfaceHue'+' = '+interfaceHue",
- "'interfaceSat'+' = '+interfaceSat",
- "'interfaceLit'+' = '+interfaceLit",
- "'fontHue'+' = '+fontHue",
- "'fontSat'+' = '+fontSat",
- "'fontLit'+' = '+fontLit",
- "'coderainHue'+' = '+coderainHue",
- "'coderainSat'+' = '+coderainSat",
- "'coderainLit'+' = '+coderainLit",
- "'optPhraseLimit'+' = '+optPhraseLimit",
- "'dbPageItems'+' = '+dbPageItems",
- "'dbScrollItems'+' = '+dbScrollItems",
- "'optForceTwoColumnLayout'+' = '+optForceTwoColumnLayout",
- "'optColoredCiphers'+' = '+optColoredCiphers",
- "'optGemSubstitutionMode'+' = '+optGemSubstitutionMode",
- "'optGemMultCharPos'+' = '+optGemMultCharPos",
- "'optGemMultCharPosReverse'+' = '+optGemMultCharPosReverse",
- '"encDefAlphArr"+" = \x27"+String(encPrevAlphStr).replace(/,/g,"")+"\x27"',
- '"encDefVowArr"+" = \x27"+String(encPrevVowStr).replace(/,/g,"")+"\x27"',
- '"encDefExcLetArr"+" = \x27"+String(encPrevExcLetStr).replace(/,/g,"")+"\x27"',
- "'optImageScale'+' = '+optImageScale"
-]
+var calcOptionsArr = [
+ // used to export/import settings
+ "'optNumCalcMethod'+' = '+optNumCalcMethod",
+ "'optFiltCrossCipherMatch'+' = '+optFiltCrossCipherMatch",
+ "'optFiltSameCipherMatch'+' = '+optFiltSameCipherMatch",
+ "'optShowOnlyMatching'+' = '+optShowOnlyMatching",
+ "'optNewPhrasesGoFirst'+' = '+optNewPhrasesGoFirst",
+ "'optShowExtraCiphers'+' = '+optShowExtraCiphers",
+ "'optAllowPhraseComments'+' = '+optAllowPhraseComments",
+ "'liveDatabaseMode'+' = '+liveDatabaseMode",
+ "'optLetterWordCount'+' = '+optLetterWordCount",
+ "'optWordBreakdown'+' = '+optWordBreakdown",
+ "'optCompactBreakdown'+' = '+optCompactBreakdown",
+ "'optShowCipherChart'+' = '+optShowCipherChart",
+ "'optGradientCharts'+' = '+optGradientCharts",
+ "'optLoadUserHistCiphers'+' = '+optLoadUserHistCiphers",
+ "'optMatrixCodeRain'+' = '+optMatrixCodeRain",
+ "'interfaceHue'+' = '+interfaceHue",
+ "'interfaceSat'+' = '+interfaceSat",
+ "'interfaceLit'+' = '+interfaceLit",
+ "'fontHue'+' = '+fontHue",
+ "'fontSat'+' = '+fontSat",
+ "'fontLit'+' = '+fontLit",
+ "'coderainHue'+' = '+coderainHue",
+ "'coderainSat'+' = '+coderainSat",
+ "'coderainLit'+' = '+coderainLit",
+ "'optPhraseLimit'+' = '+optPhraseLimit",
+ "'dbPageItems'+' = '+dbPageItems",
+ "'dbScrollItems'+' = '+dbScrollItems",
+ "'optForceTwoColumnLayout'+' = '+optForceTwoColumnLayout",
+ "'optColoredCiphers'+' = '+optColoredCiphers",
+ "'optGemSubstitutionMode'+' = '+optGemSubstitutionMode",
+ "'optGemMultCharPos'+' = '+optGemMultCharPos",
+ "'optGemMultCharPosReverse'+' = '+optGemMultCharPosReverse",
+ '"encDefAlphArr"+" = \x27"+String(encPrevAlphStr).replace(/,/g,"")+"\x27"',
+ '"encDefVowArr"+" = \x27"+String(encPrevVowStr).replace(/,/g,"")+"\x27"',
+ '"encDefExcLetArr"+" = \x27"+String(encPrevExcLetStr).replace(/,/g,"")+"\x27"',
+ "'optImageScale'+' = '+optImageScale",
+];
-var runOnceRestoreCalcSet = true
-function initCalc(defSet = false) { // run after page has finished loading
- configureCalcInterface(true)
- if (defSet && typeof calcOpt !== 'undefined') importCalcOptions(calcOptions); // load settings from ciphers.js
- generateRndColors()
- if (runOnceRestoreCalcSet && window.localStorage.getItem('userCalcSettings') !== null) {
- runOnceRestoreCalcSet = false; restoreCalcSettingsLocalStorage(true); return; }
- saveInitialCiphers()
- initCiphers() // update default ciphers
- createCalcMenus()
- enableDefaultCiphers()
- saveCalcSettingsLocalStorage(true) // save default settings
- showWelcomeMessage("Hyperdope Gematria")
+var runOnceRestoreCalcSet = true;
+function initCalc(defSet = false) {
+ // run after page has finished loading
+ configureCalcInterface(true);
+ if (defSet && typeof calcOpt !== "undefined") importCalcOptions(calcOptions); // load settings from ciphers.js
+ generateRndColors();
+ if (
+ runOnceRestoreCalcSet &&
+ window.localStorage.getItem("userCalcSettings") !== null
+ ) {
+ runOnceRestoreCalcSet = false;
+ restoreCalcSettingsLocalStorage(true);
+ return;
+ }
+ saveInitialCiphers();
+ initCiphers(); // update default ciphers
+ createCalcMenus();
+ enableDefaultCiphers();
+ saveCalcSettingsLocalStorage(true); // save default settings
+ showWelcomeMessage("hyper calc");
}
-var welcomeShown = false
+var welcomeShown = false;
function showWelcomeMessage(msg, durMs = 2500, delMs = 1250) {
- if (!welcomeShown){
- setTimeout(function(){
- displayCalcNotification(msg, durMs)
- welcomeShown = true
- }, delMs)
- }
+ if (!welcomeShown) {
+ setTimeout(function () {
+ displayCalcNotification(msg, durMs);
+ welcomeShown = true;
+ }, delMs);
+ }
}
-function configureCalcInterface(initRun = false) { // switch interface layout (desktop or mobile devices)
- if (optMatrixCodeRain && !initRun) { // update code rain
- clearInterval(code_rain) // reset previous instance
- document.getElementById("canv").style.display = "none"
- initCodeRain() // recalculate canvas size
- code_rain = setInterval(matrix, 50)
- document.getElementById("canv").style.display = ""
- }
- if ($(window).width() < compactViewportWidth) { // viewport width (mobile)
- encodingMenuColumns = 1
- colorMenuColumns = 1
- enabledCiphColumns = 2
- optCompactCiphCount = 4
- chLimit = 17 // character limit, used to switch to a long breakdown style
- maxRowWidth = 20 // one row character limit (long breakdown)
- $('#queryDBbtn').val('Q') // change Query button label
- } else { // desktop
- encodingMenuColumns = 4
- colorMenuColumns = ($(window).width() < 1600) ? 2 : 4
- enabledCiphColumns = 4
- optCompactCiphCount = 8
- chLimit = 30 // character limit, used to switch to a long breakdown style
- maxRowWidth = 36 // one row character limit (long breakdown)
- $('#queryDBbtn').val('Query') // change Query button label
- }
- if (optForceTwoColumnLayout && $(window).width() > compactViewportWidth) { // override layout for desktop
- encodingMenuColumns = 2
- colorMenuColumns = 2
- enabledCiphColumns = 2
- }
+function configureCalcInterface(initRun = false) {
+ // switch interface layout (desktop or mobile devices)
+ if (optMatrixCodeRain && !initRun) {
+ // update code rain
+ clearInterval(code_rain); // reset previous instance
+ document.getElementById("canv").style.display = "none";
+ initCodeRain(); // recalculate canvas size
+ code_rain = setInterval(matrix, 50);
+ document.getElementById("canv").style.display = "";
+ }
+ if ($(window).width() < compactViewportWidth) {
+ // viewport width (mobile)
+ encodingMenuColumns = 1;
+ colorMenuColumns = 1;
+ enabledCiphColumns = 2;
+ optCompactCiphCount = 4;
+ chLimit = 17; // character limit, used to switch to a long breakdown style
+ maxRowWidth = 20; // one row character limit (long breakdown)
+ $("#queryDBbtn").val("Q"); // change Query button label
+ } else {
+ // desktop
+ encodingMenuColumns = 4;
+ colorMenuColumns = $(window).width() < 1600 ? 2 : 4;
+ enabledCiphColumns = 4;
+ optCompactCiphCount = 8;
+ chLimit = 30; // character limit, used to switch to a long breakdown style
+ maxRowWidth = 36; // one row character limit (long breakdown)
+ $("#queryDBbtn").val("Query"); // change Query button label
+ }
+ if (optForceTwoColumnLayout && $(window).width() > compactViewportWidth) {
+ // override layout for desktop
+ encodingMenuColumns = 2;
+ colorMenuColumns = 2;
+ enabledCiphColumns = 2;
+ }
}
-window.addEventListener('resize', function(){ // update interface on window resize
- if (!mobileUserAgent && navigator.maxTouchPoints <= 1) { // touch keyboard on Windows devices changes window size
- configureCalcInterface();
- updateTables();
- }
-})
+window.addEventListener("resize", function () {
+ // update interface on window resize
+ if (!mobileUserAgent && navigator.maxTouchPoints <= 1) {
+ // touch keyboard on Windows devices changes window size
+ configureCalcInterface();
+ updateTables();
+ }
+});
function displayCalcNotification(msg, timeMs = 1000) {
- if (document.getElementById('calcNotification') !== null) {
- document.getElementById('calcNotification').remove() }
- var alertDiv = $('
'
- o += ''
+ var o = '
';
+ o +=
+ '';
- o += '
'
+ o += '
'
- // checkboxes, reset button
- chkTPstate = (optForceTwoColumnLayout) ? " checked" : ""
- chkCCstate = (optColoredCiphers) ? " checked" : ""
- o += '
'
- o += '
'
- o += ''
+ // global color controls
+ o += "
";
+ o += '";
+ // checkboxes, reset button
+ chkTPstate = optForceTwoColumnLayout ? " checked" : "";
+ chkCCstate = optColoredCiphers ? " checked" : "";
+ o += '';
+ o += '";
+ o += "";
+
+ o += "
"; // colorControlsBG
+
+ document.getElementById("colorControlsMenuArea").innerHTML += o;
+ populateColorValues(); // update values for controls
+ } else {
+ document.getElementById("colorControlsMenuArea").innerHTML = ""; // clear
+ colorControlsMenuOpened = false;
+ }
}
function forceTwoColumnLayout() {
- optForceTwoColumnLayout = !optForceTwoColumnLayout
- configureCalcInterface()
- updateTables()
+ optForceTwoColumnLayout = !optForceTwoColumnLayout;
+ configureCalcInterface();
+ updateTables();
}
function toggleColoredCiphers() {
- optColoredCiphers = !optColoredCiphers
- updateTables()
+ optColoredCiphers = !optColoredCiphers;
+ updateTables();
}
-function updateInterfaceColor(firstrun = false) { // change interface color
- updateInterfaceHue(firstrun)
- updateInterfaceSat(firstrun)
- updateInterfaceLit(firstrun)
- updateFontHue(firstrun)
- updateFontSat(firstrun)
- updateFontLit(firstrun)
- updateCoderainHue(firstrun)
- updateCoderainSat(firstrun)
- updateCoderainLit(firstrun)
+function updateInterfaceColor(firstrun = false) {
+ // change interface color
+ updateInterfaceHue(firstrun);
+ updateInterfaceSat(firstrun);
+ updateInterfaceLit(firstrun);
+ updateFontHue(firstrun);
+ updateFontSat(firstrun);
+ updateFontLit(firstrun);
+ updateCoderainHue(firstrun);
+ updateCoderainSat(firstrun);
+ updateCoderainLit(firstrun);
}
-function updateInterfaceHue(firstrun = false) { // change interface hue
- // update hue from slider if element exists
- if (document.getElementById("interfaceHueSlider") !== null) interfaceHue = document.getElementById("interfaceHueSlider").value
- var root = document.documentElement
- root.style.setProperty("--global-hue", interfaceHue.toString()) // update :root CSS variable
- if (firstrun) interfaceHueDefault = interfaceHue // set default color for reset
+function updateInterfaceHue(firstrun = false) {
+ // change interface hue
+ // update hue from slider if element exists
+ if (document.getElementById("interfaceHueSlider") !== null)
+ interfaceHue = document.getElementById("interfaceHueSlider").value;
+ var root = document.documentElement;
+ root.style.setProperty("--global-hue", interfaceHue.toString()); // update :root CSS variable
+ if (firstrun) interfaceHueDefault = interfaceHue; // set default color for reset
}
-function updateInterfaceSat(firstrun = false) { // change interface saturation
- // update saturation from slider if element exists
- if (document.getElementById("interfaceSatSlider") !== null) interfaceSat = document.getElementById("interfaceSatSlider").value
- var root = document.documentElement
- root.style.setProperty("--global-sat", interfaceSat.toString()) // update :root CSS variable
- if (firstrun) interfaceSatDefault = interfaceSat // set default color for reset
+function updateInterfaceSat(firstrun = false) {
+ // change interface saturation
+ // update saturation from slider if element exists
+ if (document.getElementById("interfaceSatSlider") !== null)
+ interfaceSat = document.getElementById("interfaceSatSlider").value;
+ var root = document.documentElement;
+ root.style.setProperty("--global-sat", interfaceSat.toString()); // update :root CSS variable
+ if (firstrun) interfaceSatDefault = interfaceSat; // set default color for reset
}
-function updateInterfaceLit(firstrun = false) { // change interface lightness
- // update lightness from slider if element exists
- if (document.getElementById("interfaceLitSlider") !== null) interfaceLit = document.getElementById("interfaceLitSlider").value
- var root = document.documentElement
- root.style.setProperty("--global-lit", interfaceLit.toString()) // update :root CSS variable
- if (firstrun) interfaceLitDefault = interfaceLit // set default color for reset
+function updateInterfaceLit(firstrun = false) {
+ // change interface lightness
+ // update lightness from slider if element exists
+ if (document.getElementById("interfaceLitSlider") !== null)
+ interfaceLit = document.getElementById("interfaceLitSlider").value;
+ var root = document.documentElement;
+ root.style.setProperty("--global-lit", interfaceLit.toString()); // update :root CSS variable
+ if (firstrun) interfaceLitDefault = interfaceLit; // set default color for reset
}
-function updateFontHue(firstrun = false) { // change font and outline hue
- // update hue from slider if element exists
- if (document.getElementById("fontHueSlider") !== null) fontHue = document.getElementById("fontHueSlider").value
- var root = document.documentElement
- root.style.setProperty("--font-hue", fontHue.toString()) // update :root CSS variable
- if (firstrun) fontHueDefault = fontHue // set default color for reset
+function updateFontHue(firstrun = false) {
+ // change font and outline hue
+ // update hue from slider if element exists
+ if (document.getElementById("fontHueSlider") !== null)
+ fontHue = document.getElementById("fontHueSlider").value;
+ var root = document.documentElement;
+ root.style.setProperty("--font-hue", fontHue.toString()); // update :root CSS variable
+ if (firstrun) fontHueDefault = fontHue; // set default color for reset
}
-function updateFontSat(firstrun = false) { // change font and outline saturation
- // update saturation from slider if element exists
- if (document.getElementById("fontSatSlider") !== null) fontSat = document.getElementById("fontSatSlider").value
- var root = document.documentElement
- root.style.setProperty("--font-sat", fontSat.toString()) // update :root CSS variable
- if (firstrun) fontSatDefault = fontSat // set default color for reset
+function updateFontSat(firstrun = false) {
+ // change font and outline saturation
+ // update saturation from slider if element exists
+ if (document.getElementById("fontSatSlider") !== null)
+ fontSat = document.getElementById("fontSatSlider").value;
+ var root = document.documentElement;
+ root.style.setProperty("--font-sat", fontSat.toString()); // update :root CSS variable
+ if (firstrun) fontSatDefault = fontSat; // set default color for reset
}
-function updateFontLit(firstrun = false) { // change font and outline lightness
- // update lightness from slider if element exists
- if (document.getElementById("fontLitSlider") !== null) fontLit = document.getElementById("fontLitSlider").value
- var root = document.documentElement
- root.style.setProperty("--font-lit", fontLit.toString()) // update :root CSS variable
- if (firstrun) fontLitDefault = fontLit // set default color for reset
+function updateFontLit(firstrun = false) {
+ // change font and outline lightness
+ // update lightness from slider if element exists
+ if (document.getElementById("fontLitSlider") !== null)
+ fontLit = document.getElementById("fontLitSlider").value;
+ var root = document.documentElement;
+ root.style.setProperty("--font-lit", fontLit.toString()); // update :root CSS variable
+ if (firstrun) fontLitDefault = fontLit; // set default color for reset
}
-function updateCoderainHue(firstrun = false) { // change coderain hue
- // update hue from slider if element exists
- if (document.getElementById("coderainHueSlider") !== null) coderainHue = document.getElementById("coderainHueSlider").value
- if (firstrun) coderainHueDefault = coderainHue // set default color for reset
+function updateCoderainHue(firstrun = false) {
+ // change coderain hue
+ // update hue from slider if element exists
+ if (document.getElementById("coderainHueSlider") !== null)
+ coderainHue = document.getElementById("coderainHueSlider").value;
+ if (firstrun) coderainHueDefault = coderainHue; // set default color for reset
}
-function updateCoderainSat(firstrun = false) { // change coderain saturation
- // update saturation from slider if element exists
- if (document.getElementById("coderainSatSlider") !== null) coderainSat = document.getElementById("coderainSatSlider").value
- if (firstrun) coderainSatDefault = coderainSat // set default color for reset
+function updateCoderainSat(firstrun = false) {
+ // change coderain saturation
+ // update saturation from slider if element exists
+ if (document.getElementById("coderainSatSlider") !== null)
+ coderainSat = document.getElementById("coderainSatSlider").value;
+ if (firstrun) coderainSatDefault = coderainSat; // set default color for reset
}
-function updateCoderainLit(firstrun = false) { // change coderain lightness
- // update lightness from slider if element exists
- if (document.getElementById("coderainLitSlider") !== null) coderainLit = document.getElementById("coderainLitSlider").value
- if (firstrun) coderainLitDefault = coderainLit // set default color for reset
+function updateCoderainLit(firstrun = false) {
+ // change coderain lightness
+ // update lightness from slider if element exists
+ if (document.getElementById("coderainLitSlider") !== null)
+ coderainLit = document.getElementById("coderainLitSlider").value;
+ if (firstrun) coderainLitDefault = coderainLit; // set default color for reset
}
function updColorMenuLayout() {
- toggleColorControlsMenu(true) // flag to update layout
+ toggleColorControlsMenu(true); // flag to update layout
}
-function initColorArrays() { // store original cipher colors and current modifier values
- origColors = []
- chkboxColors = []
- globColors = []
- var tmp = {}
- for (i = 0; i < cipherList.length; i++) {
- tmp = {H:cipherList[i].H, S:cipherList[i].S, L:cipherList[i].L}
- origColors.push(tmp)
- tmp = {H:0, S:0, L:0}
- chkboxColors.push(tmp) // individual controls
- }
- globColors = {H:0, S:0, L:0}
+function initColorArrays() {
+ // store original cipher colors and current modifier values
+ origColors = [];
+ chkboxColors = [];
+ globColors = [];
+ var tmp = {};
+ for (i = 0; i < cipherList.length; i++) {
+ tmp = { H: cipherList[i].H, S: cipherList[i].S, L: cipherList[i].L };
+ origColors.push(tmp);
+ tmp = { H: 0, S: 0, L: 0 };
+ chkboxColors.push(tmp); // individual controls
+ }
+ globColors = { H: 0, S: 0, L: 0 };
}
-function resetColorControls() { // set all color controls to zero
- if (document.getElementById("globalSliderHue") !== null) document.getElementById("globalSliderHue").value = 0
- if (document.getElementById("globalSliderSaturation") !== null) document.getElementById("globalSliderSaturation").value = 0
- if (document.getElementById("globalSliderLightness") !== null) document.getElementById("globalSliderLightness").value = 0
- globColors = {H:0, S:0, L:0} // reset global color modifier
+function resetColorControls() {
+ // set all color controls to zero
+ if (document.getElementById("globalSliderHue") !== null)
+ document.getElementById("globalSliderHue").value = 0;
+ if (document.getElementById("globalSliderSaturation") !== null)
+ document.getElementById("globalSliderSaturation").value = 0;
+ if (document.getElementById("globalSliderLightness") !== null)
+ document.getElementById("globalSliderLightness").value = 0;
+ globColors = { H: 0, S: 0, L: 0 }; // reset global color modifier
- // reset values for individual colors
- chkboxColors = []
- var tmp_H, tmp_S, tmp_L
- for (i = 0; i < cipherList.length; i++) {
- chkboxColors.push({H:0, S:0, L:0}) // create new object for each cipher
- tmp_H = document.getElementById("sliderHue"+i)
- tmp_S = document.getElementById("sliderSaturation"+i)
- tmp_L = document.getElementById("sliderLightness"+i)
- if (tmp_H !== null && tmp_S !== null && tmp_L !== null) { // if individual sliders are visible
- tmp_H.value = 0
- tmp_S.value = 0
- tmp_L.value = 0
- }
- }
+ // reset values for individual colors
+ chkboxColors = [];
+ var tmp_H, tmp_S, tmp_L;
+ for (i = 0; i < cipherList.length; i++) {
+ chkboxColors.push({ H: 0, S: 0, L: 0 }); // create new object for each cipher
+ tmp_H = document.getElementById("sliderHue" + i);
+ tmp_S = document.getElementById("sliderSaturation" + i);
+ tmp_L = document.getElementById("sliderLightness" + i);
+ if (tmp_H !== null && tmp_S !== null && tmp_L !== null) {
+ // if individual sliders are visible
+ tmp_H.value = 0;
+ tmp_S.value = 0;
+ tmp_L.value = 0;
+ }
+ }
- // update colors
- changeCipherColors(0, "Hue")
- changeCipherColors(0, "Saturation")
- changeCipherColors(0, "Lightness")
+ // update colors
+ changeCipherColors(0, "Hue");
+ changeCipherColors(0, "Saturation");
+ changeCipherColors(0, "Lightness");
- interfaceHue = interfaceHueDefault // reset interface color
- interfaceSat = interfaceSatDefault
- interfaceLit = interfaceLitDefault
- if (document.getElementById("interfaceHueSlider") !== null) document.getElementById("interfaceHueSlider").value = interfaceHue
- if (document.getElementById("interfaceSatSlider") !== null) document.getElementById("interfaceSatSlider").value = interfaceSat
- if (document.getElementById("interfaceLitSlider") !== null) document.getElementById("interfaceLitSlider").value = interfaceLit
+ interfaceHue = interfaceHueDefault; // reset interface color
+ interfaceSat = interfaceSatDefault;
+ interfaceLit = interfaceLitDefault;
+ if (document.getElementById("interfaceHueSlider") !== null)
+ document.getElementById("interfaceHueSlider").value = interfaceHue;
+ if (document.getElementById("interfaceSatSlider") !== null)
+ document.getElementById("interfaceSatSlider").value = interfaceSat;
+ if (document.getElementById("interfaceLitSlider") !== null)
+ document.getElementById("interfaceLitSlider").value = interfaceLit;
- fontHue = fontHueDefault // reset font and outline color
- fontSat = fontSatDefault
- fontLit = fontLitDefault
- if (document.getElementById("fontHueSlider") !== null) document.getElementById("fontHueSlider").value = fontHue
- if (document.getElementById("fontSatSlider") !== null) document.getElementById("fontSatSlider").value = fontSat
- if (document.getElementById("fontLitSlider") !== null) document.getElementById("fontLitSlider").value = fontLit
- updateInterfaceColor()
+ fontHue = fontHueDefault; // reset font and outline color
+ fontSat = fontSatDefault;
+ fontLit = fontLitDefault;
+ if (document.getElementById("fontHueSlider") !== null)
+ document.getElementById("fontHueSlider").value = fontHue;
+ if (document.getElementById("fontSatSlider") !== null)
+ document.getElementById("fontSatSlider").value = fontSat;
+ if (document.getElementById("fontLitSlider") !== null)
+ document.getElementById("fontLitSlider").value = fontLit;
+ updateInterfaceColor();
- updateTables() // update
+ updateTables(); // update
}
function changeCipherColors(elem_id, col_mode, cipher_index) {
- var ciph_len, st_pos, cur_ciphColBox
+ var ciph_len, st_pos, cur_ciphColBox;
- var curVal
- if (typeof elem_id == "number") {
- curVal = elem_id // if a number was passed instead of element id
- } else {
- curVal = Number(document.getElementById(elem_id).value) // current slider value
- }
+ var curVal;
+ if (typeof elem_id == "number") {
+ curVal = elem_id; // if a number was passed instead of element id
+ } else {
+ curVal = Number(document.getElementById(elem_id).value); // current slider value
+ }
- if (cipher_index == undefined) { // no cipher_index, change all colors
- ciph_len = cipherList.length
- st_pos = 0
- } else { // else change individual color
- ciph_len = cipher_index+1
- st_pos = cipher_index
- }
- for (i = st_pos; i < ciph_len; i++) {
- if (col_mode == "Hue") {
- if (cipher_index == undefined) { globColors.H = curVal } // update global value modified
- else { chkboxColors[i].H = curVal } // update individual cipher value
- cipherList[i].H = colFmt(origColors[i].H + chkboxColors[i].H + globColors.H,"H")
- } else if (col_mode == "Saturation") {
- if (cipher_index == undefined) { globColors.S = curVal }
- else { chkboxColors[i].S = curVal }
- cipherList[i].S = colFmt(origColors[i].S + chkboxColors[i].S + globColors.S,"S")
- } else if (col_mode == "Lightness") {
- if (cipher_index == undefined) { globColors.L = curVal }
- else { chkboxColors[i].L = curVal }
- cipherList[i].L = colFmt(origColors[i].L + chkboxColors[i].L + globColors.L,"L")
- }
- cur_ciphColBox = document.getElementById("cipherHSL"+i) // textbox with HSLA values for current color
- if (cur_ciphColBox !== null) cur_ciphColBox.value = colPad(cipherList[i].H)+colPad(cipherList[i].S)+colPad(cipherList[i].L,true)
- }
- updateTables(false) // update without redrawing color controls
- updateWordBreakdown() // update word/cipher breakdown table
+ if (cipher_index == undefined) {
+ // no cipher_index, change all colors
+ ciph_len = cipherList.length;
+ st_pos = 0;
+ } else {
+ // else change individual color
+ ciph_len = cipher_index + 1;
+ st_pos = cipher_index;
+ }
+ for (i = st_pos; i < ciph_len; i++) {
+ if (col_mode == "Hue") {
+ if (cipher_index == undefined) {
+ globColors.H = curVal;
+ } // update global value modified
+ else {
+ chkboxColors[i].H = curVal;
+ } // update individual cipher value
+ cipherList[i].H = colFmt(
+ origColors[i].H + chkboxColors[i].H + globColors.H,
+ "H"
+ );
+ } else if (col_mode == "Saturation") {
+ if (cipher_index == undefined) {
+ globColors.S = curVal;
+ } else {
+ chkboxColors[i].S = curVal;
+ }
+ cipherList[i].S = colFmt(
+ origColors[i].S + chkboxColors[i].S + globColors.S,
+ "S"
+ );
+ } else if (col_mode == "Lightness") {
+ if (cipher_index == undefined) {
+ globColors.L = curVal;
+ } else {
+ chkboxColors[i].L = curVal;
+ }
+ cipherList[i].L = colFmt(
+ origColors[i].L + chkboxColors[i].L + globColors.L,
+ "L"
+ );
+ }
+ cur_ciphColBox = document.getElementById("cipherHSL" + i); // textbox with HSLA values for current color
+ if (cur_ciphColBox !== null)
+ cur_ciphColBox.value =
+ colPad(cipherList[i].H) +
+ colPad(cipherList[i].S) +
+ colPad(cipherList[i].L, true);
+ }
+ updateTables(false); // update without redrawing color controls
+ updateWordBreakdown(); // update word/cipher breakdown table
}
-function colFmt(val, mode) { // normalize HSLA color values
- if (mode == "H") {
- if (val < 0) { val = val % 360 + 360 } // fix 0-360 range
- else { val = val % 360 }
- } else if (mode == "S") {
- val = clampNum(val, 0, 100)
- } else if (mode == "L") {
- val = clampNum(val, 0, 100)
- }
- return val
+function colFmt(val, mode) {
+ // normalize HSLA color values
+ if (mode == "H") {
+ if (val < 0) {
+ val = (val % 360) + 360;
+ } // fix 0-360 range
+ else {
+ val = val % 360;
+ }
+ } else if (mode == "S") {
+ val = clampNum(val, 0, 100);
+ } else if (mode == "L") {
+ val = clampNum(val, 0, 100);
+ }
+ return val;
}
-function clampNum(number, min, max) { // clamp number within specified range
- return Math.max(min, Math.min(number, max))
+function clampNum(number, min, max) {
+ // clamp number within specified range
+ return Math.max(min, Math.min(number, max));
}
-function colPad(val, last = false) { // padding for color values (monospace)
- val = String(val+" ").substring(0,4)
- if (last) val = val.substring(0,val.length-1) // last value has no extra space
- return val
+function colPad(val, last = false) {
+ // padding for color values (monospace)
+ val = String(val + " ").substring(0, 4);
+ if (last) val = val.substring(0, val.length - 1); // last value has no extra space
+ return val;
}
-function populateColorValues() { // update color controls for each individual cipher
- var tmp_H, tmp_S, tmp_L, tmp_HSL
- for (i = 0; i < cipherList.length; i++) {
- tmp_H = document.getElementById("sliderHue"+i)
- tmp_S = document.getElementById("sliderSaturation"+i)
- tmp_L = document.getElementById("sliderLightness"+i)
- tmp_HSL = document.getElementById("cipherHSL"+i)
- if (tmp_H !== null) tmp_H.value = chkboxColors[i].H
- if (tmp_S !== null) tmp_S.value = chkboxColors[i].S
- if (tmp_L !== null) tmp_L.value = chkboxColors[i].L
- if (tmp_HSL !== null) tmp_HSL.value = colPad(cipherList[i].H)+colPad(cipherList[i].S)+colPad(cipherList[i].L,true)
- }
+function populateColorValues() {
+ // update color controls for each individual cipher
+ var tmp_H, tmp_S, tmp_L, tmp_HSL;
+ for (i = 0; i < cipherList.length; i++) {
+ tmp_H = document.getElementById("sliderHue" + i);
+ tmp_S = document.getElementById("sliderSaturation" + i);
+ tmp_L = document.getElementById("sliderLightness" + i);
+ tmp_HSL = document.getElementById("cipherHSL" + i);
+ if (tmp_H !== null) tmp_H.value = chkboxColors[i].H;
+ if (tmp_S !== null) tmp_S.value = chkboxColors[i].S;
+ if (tmp_L !== null) tmp_L.value = chkboxColors[i].L;
+ if (tmp_HSL !== null)
+ tmp_HSL.value =
+ colPad(cipherList[i].H) +
+ colPad(cipherList[i].S) +
+ colPad(cipherList[i].L, true);
+ }
}
// ====================== Enabled Cipher Table ======================
function saveInitialCiphers() {
- if (cipherListSaved.length == 0) cipherListSaved = [...cipherList] // make a copy of initial ciphers to revert changes
+ if (cipherListSaved.length == 0) cipherListSaved = [...cipherList]; // make a copy of initial ciphers to revert changes
}
-function initCiphers(updDefCiph = true) { // list categories, define default (base) ciphers
- var c = ""
- cCat = [] // clear categories
- for (i = 0; i < cipherList.length; i++) {
- c = cipherList[i].cipherCategory
- if (cCat.indexOf(c) == -1) {
- if ( c !== "Extra" || (c == "Extra" && optShowExtraCiphers) ) cCat.push(c) // list categories (exclude Extra if not allowed)
- }
- if (cipherList[i].enabled && updDefCiph) defaultCipherArray.push(cipherList[i].cipherName) // update default ciphers
- }
- if (defaultCipherArraySaved.length == 0) defaultCipherArraySaved = [...defaultCipherArray] // copy of initial default ciphers
- initColorArrays()
+function initCiphers(updDefCiph = true) {
+ // list categories, define default (base) ciphers
+ var c = "";
+ cCat = []; // clear categories
+ for (i = 0; i < cipherList.length; i++) {
+ c = cipherList[i].cipherCategory;
+ if (cCat.indexOf(c) == -1) {
+ if (c !== "Extra" || (c == "Extra" && optShowExtraCiphers)) cCat.push(c); // list categories (exclude Extra if not allowed)
+ }
+ if (cipherList[i].enabled && updDefCiph)
+ defaultCipherArray.push(cipherList[i].cipherName); // update default ciphers
+ }
+ if (defaultCipherArraySaved.length == 0)
+ defaultCipherArraySaved = [...defaultCipherArray]; // copy of initial default ciphers
+ initColorArrays();
}
function enableDefaultCiphers() {
- var ciphArr = defaultCipherArray
- for (n = 0; n < cipherList.length; n++) {
- cur_chkbox = document.getElementById("cipher_chkbox"+n)
- if (ciphArr.indexOf(cipherList[n].cipherName) == -1) { // disable non-default ciphers
- cipherList[n].enabled = false // disable cipher
- if (cur_chkbox !== null) cur_chkbox.checked = false // update checkbox if present
- } else if (!cipherList[n].enabled) { // enable default cipher (if previously not active)
- cipherList[n].enabled = true // enable cipher
- if (cur_chkbox !== null) cur_chkbox.checked = true // update checkbox if present
- }
- }
- updateTables() // update
+ var ciphArr = defaultCipherArray;
+ for (n = 0; n < cipherList.length; n++) {
+ cur_chkbox = document.getElementById("cipher_chkbox" + n);
+ if (ciphArr.indexOf(cipherList[n].cipherName) == -1) {
+ // disable non-default ciphers
+ cipherList[n].enabled = false; // disable cipher
+ if (cur_chkbox !== null) cur_chkbox.checked = false; // update checkbox if present
+ } else if (!cipherList[n].enabled) {
+ // enable default cipher (if previously not active)
+ cipherList[n].enabled = true; // enable cipher
+ if (cur_chkbox !== null) cur_chkbox.checked = true; // update checkbox if present
+ }
+ }
+ updateTables(); // update
}
function enableAllCiphers() {
- prevCiphIndex = -1 // reset cipher selection
- var cur_chkbox
- for (i = 0; i < cipherList.length; i++) {
- if ( cipherList[i].cipherCategory !== "Extra" || (cipherList[i].cipherCategory == "Extra" && optShowExtraCiphers) ) { // if category is not Extra or is Extra ciphers allowed
- cur_chkbox = document.getElementById("cipher_chkbox"+i)
- cipherList[i].enabled = true
- if (cur_chkbox !== null) cur_chkbox.checked = true
- }
- }
- updateTables() // update
+ prevCiphIndex = -1; // reset cipher selection
+ var cur_chkbox;
+ for (i = 0; i < cipherList.length; i++) {
+ if (
+ cipherList[i].cipherCategory !== "Extra" ||
+ (cipherList[i].cipherCategory == "Extra" && optShowExtraCiphers)
+ ) {
+ // if category is not Extra or is Extra ciphers allowed
+ cur_chkbox = document.getElementById("cipher_chkbox" + i);
+ cipherList[i].enabled = true;
+ if (cur_chkbox !== null) cur_chkbox.checked = true;
+ }
+ }
+ updateTables(); // update
}
function enableAllEnglishCiphers() {
- prevCiphIndex = -1 // reset cipher selection
- var cur_chkbox
- for (i = 0; i < cipherList.length; i++) {
- if (cipherList[i].cipherCategory == "Extra" && optShowExtraCiphers && cipherList[i].cArr.indexOf(97) > -1) { // lowercase "a", "Extra" English ciphers only if allowed
- cur_chkbox = document.getElementById("cipher_chkbox"+i)
- cipherList[i].enabled = true
- if (cur_chkbox !== null) cur_chkbox.checked = true
- } else if (cipherList[i].cipherCategory !== "Extra" && cipherList[i].cArr.indexOf(97) > -1) { // lowercase "a", other cipher categories
- cur_chkbox = document.getElementById("cipher_chkbox"+i)
- cipherList[i].enabled = true
- if (cur_chkbox !== null) cur_chkbox.checked = true
- }
- }
- updateTables() // update
+ prevCiphIndex = -1; // reset cipher selection
+ var cur_chkbox;
+ for (i = 0; i < cipherList.length; i++) {
+ if (
+ cipherList[i].cipherCategory == "Extra" &&
+ optShowExtraCiphers &&
+ cipherList[i].cArr.indexOf(97) > -1
+ ) {
+ // lowercase "a", "Extra" English ciphers only if allowed
+ cur_chkbox = document.getElementById("cipher_chkbox" + i);
+ cipherList[i].enabled = true;
+ if (cur_chkbox !== null) cur_chkbox.checked = true;
+ } else if (
+ cipherList[i].cipherCategory !== "Extra" &&
+ cipherList[i].cArr.indexOf(97) > -1
+ ) {
+ // lowercase "a", other cipher categories
+ cur_chkbox = document.getElementById("cipher_chkbox" + i);
+ cipherList[i].enabled = true;
+ if (cur_chkbox !== null) cur_chkbox.checked = true;
+ }
+ }
+ updateTables(); // update
}
function disableAllCiphers() {
- prevCiphIndex = -1 // reset cipher selection
- var cur_chkbox
- for (i = 0; i < cipherList.length; i++) {
- cur_chkbox = document.getElementById("cipher_chkbox"+i)
- cipherList[i].enabled = false // if checkbox exists toggle state (next line)
- if (cur_chkbox !== null) cur_chkbox.checked = false
- }
- updateTables() // update
+ prevCiphIndex = -1; // reset cipher selection
+ var cur_chkbox;
+ for (i = 0; i < cipherList.length; i++) {
+ cur_chkbox = document.getElementById("cipher_chkbox" + i);
+ cipherList[i].enabled = false; // if checkbox exists toggle state (next line)
+ if (cur_chkbox !== null) cur_chkbox.checked = false;
+ }
+ updateTables(); // update
}
function toggleCipherCategory(ciph_cat) {
- prevCiphIndex = -1 // reset cipher selection
- var on_first = false
- for (i = 0; i < cipherList.length; i++) {
- if (cipherList[i].cipherCategory == ciph_cat && !cipherList[i].enabled) on_first = true // if one cipher is disabled
- }
- var cur_chkbox
- for (i = 0; i < cipherList.length; i++) {
- //console.log(cipherList[i].cipherCategory)
- if (cipherList[i].cipherCategory == ciph_cat) {
- cur_chkbox = document.getElementById("cipher_chkbox"+i)
- if (on_first) { // if one cipher is disabled, first enable all
- cipherList[i].enabled = true
- if (cur_chkbox !== null) cur_chkbox.checked = true
- } else { // if all ciphers are enabled, disable all
- cipherList[i].enabled = false
- if (cur_chkbox !== null) cur_chkbox.checked = false
- }
- }
- }
- updateTables() // update
+ prevCiphIndex = -1; // reset cipher selection
+ var on_first = false;
+ for (i = 0; i < cipherList.length; i++) {
+ if (cipherList[i].cipherCategory == ciph_cat && !cipherList[i].enabled)
+ on_first = true; // if one cipher is disabled
+ }
+ var cur_chkbox;
+ for (i = 0; i < cipherList.length; i++) {
+ //console.log(cipherList[i].cipherCategory)
+ if (cipherList[i].cipherCategory == ciph_cat) {
+ cur_chkbox = document.getElementById("cipher_chkbox" + i);
+ if (on_first) {
+ // if one cipher is disabled, first enable all
+ cipherList[i].enabled = true;
+ if (cur_chkbox !== null) cur_chkbox.checked = true;
+ } else {
+ // if all ciphers are enabled, disable all
+ cipherList[i].enabled = false;
+ if (cur_chkbox !== null) cur_chkbox.checked = false;
+ }
+ }
+ }
+ updateTables(); // update
}
function toggleCipher(c_id, chk = false) {
- prevCiphIndex = -1 // reset cipher selection
- cipherList[c_id].enabled = !cipherList[c_id].enabled // toggle true/false
- if (chk) { // toggle checkbox state
- cur_chkbox = document.getElementById("cipher_chkbox"+c_id);
- if (cur_chkbox !== null) cur_chkbox.checked = !cur_chkbox.checked; // update checkbox if visible
- }
- updateTables() // update
+ prevCiphIndex = -1; // reset cipher selection
+ cipherList[c_id].enabled = !cipherList[c_id].enabled; // toggle true/false
+ if (chk) {
+ // toggle checkbox state
+ cur_chkbox = document.getElementById("cipher_chkbox" + c_id);
+ if (cur_chkbox !== null) cur_chkbox.checked = !cur_chkbox.checked; // update checkbox if visible
+ }
+ updateTables(); // update
}
function updateTables(updColorLayout = true) {
- prevCiphIndex = -1 // reset cipher selection
- for (i = 0; i < cipherList.length; i++) {
- // if previous breakdown cipher is not enabled or if cipher no longer exists
- if ( cipherList[i].cipherName == breakCipher && !cipherList[i].enabled || typeof cipherList.find(o => o.cipherName == breakCipher) == 'undefined' ) {
- for (n = 0; n < cipherList.length; n++) {
- if (cipherList[n].enabled) {
- breakCipher = cipherList[n].cipherName // load first enabled cipher instead
- break
- }
- }
- }
- }
- if (colorControlsMenuOpened && updColorLayout) updColorMenuLayout() // update color controls if menu is opened
- if (encodingMenuOpened) toggleEncodingMenu(true) // update encoding menu
- updateEnabledCipherTable() // update enabled cipher table
- autoHistoryTableLayout() // use Compact History if necessary
- updateHistoryTable() // update history table
- updateWordBreakdown(breakCipher, true) // update word breakdown and choose first enabled cipher
+ prevCiphIndex = -1; // reset cipher selection
+ for (i = 0; i < cipherList.length; i++) {
+ // if previous breakdown cipher is not enabled or if cipher no longer exists
+ if (
+ (cipherList[i].cipherName == breakCipher && !cipherList[i].enabled) ||
+ typeof cipherList.find((o) => o.cipherName == breakCipher) == "undefined"
+ ) {
+ for (n = 0; n < cipherList.length; n++) {
+ if (cipherList[n].enabled) {
+ breakCipher = cipherList[n].cipherName; // load first enabled cipher instead
+ break;
+ }
+ }
+ }
+ }
+ if (colorControlsMenuOpened && updColorLayout) updColorMenuLayout(); // update color controls if menu is opened
+ if (encodingMenuOpened) toggleEncodingMenu(true); // update encoding menu
+ updateEnabledCipherTable(); // update enabled cipher table
+ autoHistoryTableLayout(); // use Compact History if necessary
+ updateHistoryTable(); // update history table
+ updateWordBreakdown(breakCipher, true); // update word breakdown and choose first enabled cipher
}
-function autoHistoryTableLayout() { // use Compact History
- if (enabledCiphCount > optCompactCiphCount) { compactHistoryTable = true } else { compactHistoryTable = false }
+function autoHistoryTableLayout() {
+ // use Compact History
+ if (enabledCiphCount > optCompactCiphCount) {
+ compactHistoryTable = true;
+ } else {
+ compactHistoryTable = false;
+ }
}
function updateEnabledCipherCount() {
- enabledCiphCount = 0 // number of enabled ciphers
- for (i = 0; i < cipherList.length; i++) { // count all enabled ciphers
- if (cipherList[i].enabled) enabledCiphCount++
- }
+ enabledCiphCount = 0; // number of enabled ciphers
+ for (i = 0; i < cipherList.length; i++) {
+ // count all enabled ciphers
+ if (cipherList[i].enabled) enabledCiphCount++;
+ }
}
function sVal() {
- return document.getElementById("phraseBox").value.trim() // get value, remove spaces from both sides
+ return document.getElementById("phraseBox").value.trim(); // get value, remove spaces from both sides
}
function sValNoComments() {
- // get value, remove text inside [...], remove [ and ] (unfinished input), remove spaces from both sides
- return document.getElementById("phraseBox").value.replace(/\[.+\]/g, '').replace(/\[/g, '').replace(/\]/g, '').trim()
+ // get value, remove text inside [...], remove [ and ] (unfinished input), remove spaces from both sides
+ return document
+ .getElementById("phraseBox")
+ .value.replace(/\[.+\]/g, "")
+ .replace(/\[/g, "")
+ .replace(/\]/g, "")
+ .trim();
}
// 100% font size
// var chWidthArr = [["a",8.13],["b",9.28],["c",7.66],["d",9.28],["e",8.32],["f",4.8],["g",9.38],["h",9.26],["i",3.79],["j",3.86],["k",8.38],["l",3.79],["m",14.38],["n",9.26],["o",8.64],["p",9.28],["q",9.28],["r",5.48],["s",6.81],["t",5.46],["u",9.21],["v",7.49],["w",12.12],["x",7.51],["y",7.49],["z",7.09],["A",10.13],["B",10.3],["C",9.63],["D",11.23],["E",9.11],["F",8.64],["G",10.5],["H",11.04],["I",4.22],["J",6.98],["K",9.78],["L",8.08],["M",12.99],["N",11.04],["O",11.42],["P",9.68],["Q",11.42],["R",9.89],["S",8.45],["T",8.12],["U",10.76],["V",9.68],["W",15.31],["X",8.9],["Y",8.76],["Z",8.94],["1",5.03],["2",7.81],["3",7.71],["4",9.1],["5",7.74],["6",8.39],["7",8.13],["8",8.76],["9",8.39],["0",9.07],["-",5.25],["(",4.58],[")",4.6],[" ",3.66]]
// 95% font size
-var chWidthArr = [["a",7.72],["b",8.82],["c",7.27],["d",8.82],["e",7.9],["f",4.57],["g",8.92],["h",8.8],["i",3.6],["j",3.67],["k",7.95],["l",3.6],["m",13.65],["n",8.8],["o",8.2],["p",8.82],["q",8.82],["r",5.2],["s",6.47],["t",5.19],["u",8.75],["v",7.12],["w",11.52],["x",7.13],["y",7.12],["z",6.73],["A",9.62],["B",9.78],["C",9.15],["D",10.67],["E",8.65],["F",8.2],["G",9.97],["H",10.48],["I",4],["J",6.63],["K",9.28],["L",7.67],["M",12.33],["N",10.48],["O",10.85],["P",9.2],["Q",10.85],["R",9.38],["S",8.02],["T",7.72],["U",10.22],["V",9.2],["W",14.55],["X",8.45],["Y",8.32],["Z",8.48],["1",4.78],["2",7.42],["3",7.32],["4",8.63],["5",7.35],["6",7.97],["7",7.72],["8",8.32],["9",7.97],["0",8.62],["-",4.98],["(",4.35],[")",4.37],[" ",3.66]]
-function calcCipherNameWidthPx(str) { // calculate column width inside table based on cipher name length
- var i, n, m
- var tmp = 0; var curChar = ''; var lenArr = [];
- var arr = str.split(' ') // split string by words
- for (i = 0; i < arr.length; i++) { // for each word
- tmp = 0 // reset word width
- for (n = 0; n < arr[i].length; n++) { // for each character in that word
- curChar = arr[i].substring(n,n+1) // current character
- for (m = 0; m < chWidthArr.length; m++) { // for each element in array with widths
- if (chWidthArr[m][0] == curChar) tmp += chWidthArr[m][1] // add width for correspondent character
- }
- }
- lenArr.push(tmp) // save width for current word
- }
- tmp = 0
- for (i = 0; i < lenArr.length; i++) {
- if (lenArr[i] > tmp) tmp = lenArr[i] // find max value
- }
- if (tmp+6 >= 74) return Math.ceil(tmp+6) // 6px padding, 80px for 100% font
- return 74
+var chWidthArr = [
+ ["a", 7.72],
+ ["b", 8.82],
+ ["c", 7.27],
+ ["d", 8.82],
+ ["e", 7.9],
+ ["f", 4.57],
+ ["g", 8.92],
+ ["h", 8.8],
+ ["i", 3.6],
+ ["j", 3.67],
+ ["k", 7.95],
+ ["l", 3.6],
+ ["m", 13.65],
+ ["n", 8.8],
+ ["o", 8.2],
+ ["p", 8.82],
+ ["q", 8.82],
+ ["r", 5.2],
+ ["s", 6.47],
+ ["t", 5.19],
+ ["u", 8.75],
+ ["v", 7.12],
+ ["w", 11.52],
+ ["x", 7.13],
+ ["y", 7.12],
+ ["z", 6.73],
+ ["A", 9.62],
+ ["B", 9.78],
+ ["C", 9.15],
+ ["D", 10.67],
+ ["E", 8.65],
+ ["F", 8.2],
+ ["G", 9.97],
+ ["H", 10.48],
+ ["I", 4],
+ ["J", 6.63],
+ ["K", 9.28],
+ ["L", 7.67],
+ ["M", 12.33],
+ ["N", 10.48],
+ ["O", 10.85],
+ ["P", 9.2],
+ ["Q", 10.85],
+ ["R", 9.38],
+ ["S", 8.02],
+ ["T", 7.72],
+ ["U", 10.22],
+ ["V", 9.2],
+ ["W", 14.55],
+ ["X", 8.45],
+ ["Y", 8.32],
+ ["Z", 8.48],
+ ["1", 4.78],
+ ["2", 7.42],
+ ["3", 7.32],
+ ["4", 8.63],
+ ["5", 7.35],
+ ["6", 7.97],
+ ["7", 7.72],
+ ["8", 8.32],
+ ["9", 7.97],
+ ["0", 8.62],
+ ["-", 4.98],
+ ["(", 4.35],
+ [")", 4.37],
+ [" ", 3.66],
+];
+function calcCipherNameWidthPx(str) {
+ // calculate column width inside table based on cipher name length
+ var i, n, m;
+ var tmp = 0;
+ var curChar = "";
+ var lenArr = [];
+ var arr = str.split(" "); // split string by words
+ for (i = 0; i < arr.length; i++) {
+ // for each word
+ tmp = 0; // reset word width
+ for (n = 0; n < arr[i].length; n++) {
+ // for each character in that word
+ curChar = arr[i].substring(n, n + 1); // current character
+ for (m = 0; m < chWidthArr.length; m++) {
+ // for each element in array with widths
+ if (chWidthArr[m][0] == curChar) tmp += chWidthArr[m][1]; // add width for correspondent character
+ }
+ }
+ lenArr.push(tmp); // save width for current word
+ }
+ tmp = 0;
+ for (i = 0; i < lenArr.length; i++) {
+ if (lenArr[i] > tmp) tmp = lenArr[i]; // find max value
+ }
+ if (tmp + 6 >= 74) return Math.ceil(tmp + 6); // 6px padding, 80px for 100% font
+ return 74;
}
-function calcCipherNameHeightPx(str) { // calculate row height inside compact table based on cipher name length
- var i, n
- var tmp = 0; var curChar = '';
- for (i = 0; i < str.length; i++) { // for each character in string
- curChar = str.substring(i,i+1) // current character
- for (n = 0; n < chWidthArr.length; n++) { // for each element in array with widths
- if (chWidthArr[n][0] == curChar) tmp += chWidthArr[n][1] // add width for correspondent character
- }
- }
- return Math.ceil(tmp+18) // 20px padding for 100% font
+function calcCipherNameHeightPx(str) {
+ // calculate row height inside compact table based on cipher name length
+ var i, n;
+ var tmp = 0;
+ var curChar = "";
+ for (i = 0; i < str.length; i++) {
+ // for each character in string
+ curChar = str.substring(i, i + 1); // current character
+ for (n = 0; n < chWidthArr.length; n++) {
+ // for each element in array with widths
+ if (chWidthArr[n][0] == curChar) tmp += chWidthArr[n][1]; // add width for correspondent character
+ }
+ }
+ return Math.ceil(tmp + 18); // 20px padding for 100% font
}
-function updateEnabledCipherTable() { // draws a table with phrase gematria for enabled ciphers (odd/even)
- document.getElementById("enabledCiphTable").innerHTML = "" // clear previous table
-
- prevCiphIndex = -1 // reset cipher selection
- updateEnabledCipherCount() // get number of enabled ciphers
+function updateEnabledCipherTable() {
+ // draws a table with phrase gematria for enabled ciphers (odd/even)
+ document.getElementById("enabledCiphTable").innerHTML = ""; // clear previous table
- if (enabledCiphCount == 0) return // do not draw the table
-
- phr = sVal() // grab current phrase
- // if (enabledCiphCount == 0 || phr == "") return // no enabled ciphers, empty phraseBox
-
- var result_columns = enabledCiphColumns
- if (enabledCiphCount <= enabledCiphColumns) { result_columns = enabledCiphCount }
- // else if (enabledCiphCount > 6 && enabledCiphCount <= 20) { result_columns = 2 }
- // else { result_columns = 4 }
+ prevCiphIndex = -1; // reset cipher selection
+ updateEnabledCipherCount(); // get number of enabled ciphers
- var cur_ciph_index = 0 // index of current of enabled cipher that will be added to the table (total # of ciphers added so far + 1)
- var new_row_opened = false // condition to open new row inside table
- var odd_col = true // odd = "cipher name - value", even = "value - cipher name", used in each row
- //var n_of_rows = 0 // number of rows inside cipher table
- var last_row_elements = 0 // number of ciphers in the last row
- var ciph_in_row = 0 // count active ciphers in row
- var cur_col = "" // current cipher color
-
- var o = '
'
-
- //n_of_rows = Math.ceil(cipherList.length / result_columns) // 6.0 => 6 rows, 6.25 => 7 rows
- last_row_elements = enabledCiphCount % result_columns
-
- for (i = 0; i < cipherList.length; i++) { // <= to include last row
- if (cipherList[i].enabled) { // for active ciphers
- cur_ciph_index++
- if (!new_row_opened) { // check if new row has to be opened
- o += ''
- odd_col = true // reset on each new row
- new_row_opened = true
- }
- if (ciph_in_row < result_columns) { // until number of ciphers in row equals number of colums
- cur_col = (optColoredCiphers) ? 'color: hsl('+cipherList[i].H+' '+cipherList[i].S+'% '+cipherList[i].L+'% / 1);' : ''
- if (odd_col) { // odd column, "cipher name - value"
- o += '| '+cipherList[i].cipherName+' | '
- // o += ''+cipherList[i].calcGematria(phr)+' | '
- o += ''+cipherList[i].calcGematria(phr)+' | '
- ciph_in_row++
- odd_col = false
- //console.log(cipherList[i].cipherName+": odd")
- } else if (!odd_col) { // even column, "value - cipher name"
- // o += ''+cipherList[i].calcGematria(phr)+' | '
- o += ''+cipherList[i].calcGematria(phr)+' | '
- o += ''+cipherList[i].cipherName+' | '
- ciph_in_row++
- odd_col = true
- //console.log(cipherList[i].cipherName+": even")
- }
- if (cur_ciph_index == enabledCiphCount && last_row_elements !== 0) { // last enabled cipher is added and last row is not fully populated
- for (n = 0; n < result_columns - last_row_elements; n++) { // for remaining empty cells in last row
- if (odd_col) {
- o += ' | '
- o += ' | '
- odd_col = false
- } else if (!odd_col) {
- o += ' | '
- o += ' | '
- odd_col = true
- }
- }
- }
- if (ciph_in_row == result_columns) { // check if row needs to be closed
- o += '
'
- ciph_in_row = 0 // reset cipher count
- new_row_opened = false
- }
- }
- }
- }
- o += '
'
-
- document.getElementById("enabledCiphTable").innerHTML += o
+ if (enabledCiphCount == 0) return; // do not draw the table
+
+ phr = sVal(); // grab current phrase
+ // if (enabledCiphCount == 0 || phr == "") return // no enabled ciphers, empty phraseBox
+
+ var result_columns = enabledCiphColumns;
+ if (enabledCiphCount <= enabledCiphColumns) {
+ result_columns = enabledCiphCount;
+ }
+ // else if (enabledCiphCount > 6 && enabledCiphCount <= 20) { result_columns = 2 }
+ // else { result_columns = 4 }
+
+ var cur_ciph_index = 0; // index of current of enabled cipher that will be added to the table (total # of ciphers added so far + 1)
+ var new_row_opened = false; // condition to open new row inside table
+ var odd_col = true; // odd = "cipher name - value", even = "value - cipher name", used in each row
+ //var n_of_rows = 0 // number of rows inside cipher table
+ var last_row_elements = 0; // number of ciphers in the last row
+ var ciph_in_row = 0; // count active ciphers in row
+ var cur_col = ""; // current cipher color
+
+ var o = '
';
+
+ //n_of_rows = Math.ceil(cipherList.length / result_columns) // 6.0 => 6 rows, 6.25 => 7 rows
+ last_row_elements = enabledCiphCount % result_columns;
+
+ for (i = 0; i < cipherList.length; i++) {
+ // <= to include last row
+ if (cipherList[i].enabled) {
+ // for active ciphers
+ cur_ciph_index++;
+ if (!new_row_opened) {
+ // check if new row has to be opened
+ o += "";
+ odd_col = true; // reset on each new row
+ new_row_opened = true;
+ }
+ if (ciph_in_row < result_columns) {
+ // until number of ciphers in row equals number of colums
+ cur_col = optColoredCiphers
+ ? "color: hsl(" +
+ cipherList[i].H +
+ " " +
+ cipherList[i].S +
+ "% " +
+ cipherList[i].L +
+ "% / 1);"
+ : "";
+ if (odd_col) {
+ // odd column, "cipher name - value"
+ o +=
+ '| ' +
+ cipherList[i].cipherName +
+ " | ";
+ // o += ''+cipherList[i].calcGematria(phr)+' | '
+ o +=
+ '' +
+ cipherList[i].calcGematria(phr) +
+ " | ";
+ ciph_in_row++;
+ odd_col = false;
+ //console.log(cipherList[i].cipherName+": odd")
+ } else if (!odd_col) {
+ // even column, "value - cipher name"
+ // o += ''+cipherList[i].calcGematria(phr)+' | '
+ o +=
+ '' +
+ cipherList[i].calcGematria(phr) +
+ " | ";
+ o +=
+ '' +
+ cipherList[i].cipherName +
+ " | ";
+ ciph_in_row++;
+ odd_col = true;
+ //console.log(cipherList[i].cipherName+": even")
+ }
+ if (cur_ciph_index == enabledCiphCount && last_row_elements !== 0) {
+ // last enabled cipher is added and last row is not fully populated
+ for (n = 0; n < result_columns - last_row_elements; n++) {
+ // for remaining empty cells in last row
+ if (odd_col) {
+ o += ' | ';
+ o += ' | ';
+ odd_col = false;
+ } else if (!odd_col) {
+ o += ' | ';
+ o += ' | ';
+ odd_col = true;
+ }
+ }
+ }
+ if (ciph_in_row == result_columns) {
+ // check if row needs to be closed
+ o += "
";
+ ciph_in_row = 0; // reset cipher count
+ new_row_opened = false;
+ }
+ }
+ }
+ }
+ o += "
";
+
+ document.getElementById("enabledCiphTable").innerHTML += o;
}
// =================== Phrase Box - History Table ===================
-function phraseBoxKeypress(e) { // run on each keystroke inside text box - onkeydown="navHistory(event.keyCode) - from index.html
- var phrPos, pBox
- phr = sVal() // get phrase from SearchField
- pBox = document.getElementById("phraseBox")
+function phraseBoxKeypress(e) {
+ // run on each keystroke inside text box - onkeydown="navHistory(event.keyCode) - from index.html
+ var phrPos, pBox;
+ phr = sVal(); // get phrase from SearchField
+ pBox = document.getElementById("phraseBox");
- phrPos = sHistory.indexOf(phr) // position of phrase in History array
- switch (e) { // keypress event
- case 13: // Enter, Go (Android)
- if (!optNewPhrasesGoFirst) { addPhraseToHistory(phr, true) } // enter as single phrase
- else { addPhraseToHistoryUnshift (phr, true) } // insert in the beginning
- pBox.value = "" // clear textbox on Enter
- break
- case 38: // Up Arrow
- if (sHistory.length > 0) {
- if (phrPos > 0) {phr = sHistory[phrPos - 1]} // load previous phrase
- else if (phrPos <= 0) {phr = sHistory[sHistory.length-1]} // back to last phrase
- pBox.value = phr; updateWordBreakdown(); updateEnabledCipherTable()
- }
- break
- case 40: // Down Arrow
- if (sHistory.length > 0) {
- if (phrPos < sHistory.length-1 && phrPos > -1) {phr = sHistory[phrPos + 1]} // load next phrase
- else if (phrPos == -1 || phrPos == sHistory.length-1) {phr = sHistory[0]} // back to the first phrase
- pBox.value = phr; updateWordBreakdown(); updateEnabledCipherTable()
- }
- break
- case 46: // Delete - remove entries from history
- if (sHistory.length == 1 && phrPos > -1) { // if one entry and matches box contents
- sHistory = [] // reinit
- tArea = document.getElementById("HistoryTableArea")
- tArea.innerHTML = "" // clear table
- }
- if (phrPos > -1) {
- sHistory.splice(phrPos, 1) // if a match is found, delete entry
- }
- pBox.value = "" // empty text box, so the old value is not added again
- updateWordBreakdown() // update breakdown
- updateTables() // update enabled cipher and history table
- break
- case 36: // Home - clear all history
- sHistory = [] // reinitialize
- document.getElementById("HistoryTableArea").innerHTML = "" // clear history table
- break
- case 35: // End - parse sentence as separate words and phrases
- phr = phr.replace(/\t/g, " ") // replace tab with spaces
- phr = phr.replace(/ +/g, " ") // remove double spaces
- // phr = phr.replace(/(\.|,|:|;|\\|)/g, "") // remove special characters, last one is "|"
+ phrPos = sHistory.indexOf(phr); // position of phrase in History array
+ switch (
+ e // keypress event
+ ) {
+ case 13: // Enter, Go (Android)
+ if (!optNewPhrasesGoFirst) {
+ addPhraseToHistory(phr, true);
+ } // enter as single phrase
+ else {
+ addPhraseToHistoryUnshift(phr, true);
+ } // insert in the beginning
+ pBox.value = ""; // clear textbox on Enter
+ break;
+ case 38: // Up Arrow
+ if (sHistory.length > 0) {
+ if (phrPos > 0) {
+ phr = sHistory[phrPos - 1];
+ } // load previous phrase
+ else if (phrPos <= 0) {
+ phr = sHistory[sHistory.length - 1];
+ } // back to last phrase
+ pBox.value = phr;
+ updateWordBreakdown();
+ updateEnabledCipherTable();
+ }
+ break;
+ case 40: // Down Arrow
+ if (sHistory.length > 0) {
+ if (phrPos < sHistory.length - 1 && phrPos > -1) {
+ phr = sHistory[phrPos + 1];
+ } // load next phrase
+ else if (phrPos == -1 || phrPos == sHistory.length - 1) {
+ phr = sHistory[0];
+ } // back to the first phrase
+ pBox.value = phr;
+ updateWordBreakdown();
+ updateEnabledCipherTable();
+ }
+ break;
+ case 46: // Delete - remove entries from history
+ if (sHistory.length == 1 && phrPos > -1) {
+ // if one entry and matches box contents
+ sHistory = []; // reinit
+ tArea = document.getElementById("HistoryTableArea");
+ tArea.innerHTML = ""; // clear table
+ }
+ if (phrPos > -1) {
+ sHistory.splice(phrPos, 1); // if a match is found, delete entry
+ }
+ pBox.value = ""; // empty text box, so the old value is not added again
+ updateWordBreakdown(); // update breakdown
+ updateTables(); // update enabled cipher and history table
+ break;
+ case 36: // Home - clear all history
+ sHistory = []; // reinitialize
+ document.getElementById("HistoryTableArea").innerHTML = ""; // clear history table
+ break;
+ case 35: // End - parse sentence as separate words and phrases
+ phr = phr.replace(/\t/g, " "); // replace tab with spaces
+ phr = phr.replace(/ +/g, " "); // remove double spaces
+ // phr = phr.replace(/(\.|,|:|;|\\|)/g, "") // remove special characters, last one is "|"
- wordArr = phr.split(" ") // split string to array, space delimiter
- phrLimit = optPhraseLimit // max phrase length
- var phrase = ""; var k = 1;
+ wordArr = phr.split(" "); // split string to array, space delimiter
+ phrLimit = optPhraseLimit; // max phrase length
+ var phrase = "";
+ var k = 1;
- // for (i = 0; i < wordArr.length; i++) { // phrases in normal order
- // k = 1 // word count
- // phrase = wordArr[i]
- // addPhraseToHistory(phrase, false)
- // while (k < phrLimit && i+k < wordArr.length) { // add words to a phrase, check it is within array size
- // phrase += " "+wordArr[i+k]
- // addPhraseToHistory(phrase, false)
- // k++
- // }
- // }
+ // for (i = 0; i < wordArr.length; i++) { // phrases in normal order
+ // k = 1 // word count
+ // phrase = wordArr[i]
+ // addPhraseToHistory(phrase, false)
+ // while (k < phrLimit && i+k < wordArr.length) { // add words to a phrase, check it is within array size
+ // phrase += " "+wordArr[i+k]
+ // addPhraseToHistory(phrase, false)
+ // k++
+ // }
+ // }
- var tArr = []; var phrasePos; // temporary history array
- for (i = wordArr.length-1; i > -1; i--) { // add phrases in reverse order, so you don't have to read backwards
- k = 1 // word count
- phrase = wordArr[i]
- if (isNaN(phrase)) { // add first word if not a number
- phrasePos = tArr.indexOf(phrase);
- if (phrasePos > -1) tArr.splice(phrasePos, 1) // remove existing phrase
- tArr.unshift(phrase) // add new phrase in the beginning (since building is in reverse order)
- }
- while (k < phrLimit && i-k > -1) { // add words to a phrase, check it is within wordArr size
- phrase = wordArr[i-k]+" "+phrase
- if (isNaN(phrase)) {
- phrasePos = tArr.indexOf(phrase);
- if (phrasePos > -1) tArr.splice(phrasePos, 1) // remove existing phrase
- tArr.unshift(phrase) // add new phrase in the beginning (since building is in reverse order)
- }
- k++
- }
- }
- for (i = 0; i < tArr.length; i++) sHistory.push(tArr[i]) // add phrases to history table
- updateHistoryTable() // update table only once after all phrases are added
- break
- }
+ var tArr = [];
+ var phrasePos; // temporary history array
+ for (i = wordArr.length - 1; i > -1; i--) {
+ // add phrases in reverse order, so you don't have to read backwards
+ k = 1; // word count
+ phrase = wordArr[i];
+ if (isNaN(phrase)) {
+ // add first word if not a number
+ phrasePos = tArr.indexOf(phrase);
+ if (phrasePos > -1) tArr.splice(phrasePos, 1); // remove existing phrase
+ tArr.unshift(phrase); // add new phrase in the beginning (since building is in reverse order)
+ }
+ while (k < phrLimit && i - k > -1) {
+ // add words to a phrase, check it is within wordArr size
+ phrase = wordArr[i - k] + " " + phrase;
+ if (isNaN(phrase)) {
+ phrasePos = tArr.indexOf(phrase);
+ if (phrasePos > -1) tArr.splice(phrasePos, 1); // remove existing phrase
+ tArr.unshift(phrase); // add new phrase in the beginning (since building is in reverse order)
+ }
+ k++;
+ }
+ }
+ for (i = 0; i < tArr.length; i++) sHistory.push(tArr[i]); // add phrases to history table
+ updateHistoryTable(); // update table only once after all phrases are added
+ break;
+ }
}
-function addPhraseToHistory(phr, upd) { // add new phrase to search history
- var phrPos
- if (phr !== "" && isNaN(phr) || phr == "Infinity") { // if input is not empty and not a number
- phrPos = sHistory.indexOf(phr);
- if (phrPos > -1) { // if phrase is in history
- sHistory.splice(phrPos, 1) // first remove it from array
- }
- sHistory.push(phr) // insert it in the end
- }
- if (upd) updateHistoryTable() // table update condition
+function addPhraseToHistory(phr, upd) {
+ // add new phrase to search history
+ var phrPos;
+ if ((phr !== "" && isNaN(phr)) || phr == "Infinity") {
+ // if input is not empty and not a number
+ phrPos = sHistory.indexOf(phr);
+ if (phrPos > -1) {
+ // if phrase is in history
+ sHistory.splice(phrPos, 1); // first remove it from array
+ }
+ sHistory.push(phr); // insert it in the end
+ }
+ if (upd) updateHistoryTable(); // table update condition
}
-function addPhraseToHistoryUnshift(phr, upd) { // add new phrase to the beginning
- var phrPos
- if (phr !== "" && isNaN(phr) || phr == "Infinity") { // if input is not empty and not a number
- phrPos = sHistory.indexOf(phr);
- if (phrPos > -1) { // if phrase is in history
- sHistory.splice(phrPos, 1) // first remove it from array
- }
- sHistory.unshift(phr) // insert it in the beginning
- }
- if (upd) updateHistoryTable() // table update condition
+function addPhraseToHistoryUnshift(phr, upd) {
+ // add new phrase to the beginning
+ var phrPos;
+ if ((phr !== "" && isNaN(phr)) || phr == "Infinity") {
+ // if input is not empty and not a number
+ phrPos = sHistory.indexOf(phr);
+ if (phrPos > -1) {
+ // if phrase is in history
+ sHistory.splice(phrPos, 1); // first remove it from array
+ }
+ sHistory.unshift(phr); // insert it in the beginning
+ }
+ if (upd) updateHistoryTable(); // table update condition
}
function updateHistoryTable(hltBoolArr) {
- var ms, i, x, y, z, curCiph, curCiphCol, gemVal
- var ciphCount = 0 // count enabled ciphers (for hltBoolArr)
- histTable = document.getElementById("HistoryTableArea")
-
- if (sHistory.length == 0) { return }
+ var ms, i, x, y, z, curCiph, curCiphCol, gemVal;
+ var ciphCount = 0; // count enabled ciphers (for hltBoolArr)
+ histTable = document.getElementById("HistoryTableArea");
- prevPhrID = -1 // reset phrase selection
- ms = '
'
+ if (sHistory.length == 0) {
+ return;
+ }
- highlt = document.getElementById("highlightBox").value.replace(/ +/g," ") // get value of Highlight textbox, remove double spaces
-
- var hltMode = false // highlighting mode
- if (highlt !== "") {
- highlt_num = highlt.split(" "); // create array, space delimited numbers
- highlt_num = highlt_num.map(function (e) { return parseInt(e, 10); }) // parse string array as integer array to exclude quotes
- highlt_num = removeZeroHlt(highlt_num)
- hltMode = true
- }
+ prevPhrID = -1; // reset phrase selection
+ ms = '';
- var dispPhrase = "" // phrase to display inside history table
- var tmpComment = ""; var commentMatch;
- for (x = 0; x < sHistory.length; x++) {
+ highlt = document.getElementById("highlightBox").value.replace(/ +/g, " "); // get value of Highlight textbox, remove double spaces
- if (x % 25 == 0 && enabledCiphCount !== 0) { // show header after each 25 phrases
- ms += ' | '
- for (z = 0; z < cipherList.length; z++) {
- if (cipherList[z].enabled) {
- curCiphCol = (optColoredCiphers) ? 'color: hsl('+cipherList[z].H+' '+cipherList[z].S+'% '+cipherList[z].L+'% / 1);' : ''
- if (compactHistoryTable) {
- ms += ''+cipherList[z].cipherName+' | ' // color of cipher displayed in the table
- } else {
- ms += ''+cipherList[z].cipherName+' | ' // color of cipher displayed in the table
- }
- }
- }
- ms += "
"
- }
+ var hltMode = false; // highlighting mode
+ if (highlt !== "") {
+ highlt_num = highlt.split(" "); // create array, space delimited numbers
+ highlt_num = highlt_num.map(function (e) {
+ return parseInt(e, 10);
+ }); // parse string array as integer array to exclude quotes
+ highlt_num = removeZeroHlt(highlt_num);
+ hltMode = true;
+ }
- ciphCount = 0 // reset enabled cipher count (for hltBoolArr)
+ var dispPhrase = ""; // phrase to display inside history table
+ var tmpComment = "";
+ var commentMatch;
+ for (x = 0; x < sHistory.length; x++) {
+ if (x % 25 == 0 && enabledCiphCount !== 0) {
+ // show header after each 25 phrases
+ ms += ' | ';
+ for (z = 0; z < cipherList.length; z++) {
+ if (cipherList[z].enabled) {
+ curCiphCol = optColoredCiphers
+ ? "color: hsl(" +
+ cipherList[z].H +
+ " " +
+ cipherList[z].S +
+ "% " +
+ cipherList[z].L +
+ "% / 1);"
+ : "";
+ if (compactHistoryTable) {
+ ms +=
+ '' +
+ cipherList[z].cipherName +
+ " | "; // color of cipher displayed in the table
+ } else {
+ ms +=
+ '' +
+ cipherList[z].cipherName +
+ " | "; // color of cipher displayed in the table
+ }
+ }
+ }
+ ms += "
";
+ }
- if (optAllowPhraseComments) {
- tmpComment = "" // reset
- commentMatch = sHistory[x].match(/\[.+\]/g) // find comment
- if (commentMatch !== null) {
- tmpComment = commentMatch[0]
- }
- // comment first, phrase without comment and leading/trailing spaces
- dispPhrase = ''+tmpComment+'' + sHistory[x].replace(/\[.+\]/g, '').trim()
- } else {
- dispPhrase = sHistory[x]
- }
- ms += '| ' + dispPhrase + ' | ' // hP - history phrase, add data index
- var col = "" // value color
+ ciphCount = 0; // reset enabled cipher count (for hltBoolArr)
- for (y = 0; y < cipherList.length; y++) {
- if (cipherList[y].enabled) {
- curCiph = cipherList[y]
- gemVal = curCiph.calcGematria(sHistory[x]) // value only
-
- //phrase x, cipher y
- col = (optColoredCiphers) ? 'hsl('+curCiph.H+' '+curCiph.S+'% '+curCiph.L+'% / 1)' : '' // default value color
+ if (optAllowPhraseComments) {
+ tmpComment = ""; // reset
+ commentMatch = sHistory[x].match(/\[.+\]/g); // find comment
+ if (commentMatch !== null) {
+ tmpComment = commentMatch[0];
+ }
+ // comment first, phrase without comment and leading/trailing spaces
+ dispPhrase =
+ '' +
+ tmpComment +
+ "" +
+ sHistory[x].replace(/\[.+\]/g, "").trim();
+ } else {
+ dispPhrase = sHistory[x];
+ }
+ ms += '
| ' + dispPhrase + " | "; // hP - history phrase, add data index
+ var col = ""; // value color
- // if highlight mode is on
- if (hltMode) {
- // if cross cipher match and highlight box doesn't include number
- if ( optFiltCrossCipherMatch && !highlt_num.includes(gemVal) ) {
- col = (optColoredCiphers) ? 'hsl('+curCiph.H+' '+curCiph.S+'% '+curCiph.L+'% / '+alphaHlt+')' : 'hsl(0 0% 70% / '+alphaHlt+')'
- // hltBoolArr was passed and value inside hltBoolArr is not active (optFiltSameCipherMatch)
- } else if ( typeof hltBoolArr !== 'undefined' && hltBoolArr[x][ciphCount] == false ) {
- col = (optColoredCiphers) ? 'hsl('+curCiph.H+' '+curCiph.S+'% '+curCiph.L+'% / '+alphaHlt+')' : 'hsl(0 0% 70% / '+alphaHlt+')'
- }
- }
- ciphCount++ // next position in hltBoolArr
- ms += ' '+gemVal+' | '
- }
- }
- ms += '
'
- }
+ for (y = 0; y < cipherList.length; y++) {
+ if (cipherList[y].enabled) {
+ curCiph = cipherList[y];
+ gemVal = curCiph.calcGematria(sHistory[x]); // value only
- ms += '
'
- histTable.innerHTML = ms
-}
\ No newline at end of file
+ //phrase x, cipher y
+ col = optColoredCiphers
+ ? "hsl(" + curCiph.H + " " + curCiph.S + "% " + curCiph.L + "% / 1)"
+ : ""; // default value color
+
+ // if highlight mode is on
+ if (hltMode) {
+ // if cross cipher match and highlight box doesn't include number
+ if (optFiltCrossCipherMatch && !highlt_num.includes(gemVal)) {
+ col = optColoredCiphers
+ ? "hsl(" +
+ curCiph.H +
+ " " +
+ curCiph.S +
+ "% " +
+ curCiph.L +
+ "% / " +
+ alphaHlt +
+ ")"
+ : "hsl(0 0% 70% / " + alphaHlt + ")";
+ // hltBoolArr was passed and value inside hltBoolArr is not active (optFiltSameCipherMatch)
+ } else if (
+ typeof hltBoolArr !== "undefined" &&
+ hltBoolArr[x][ciphCount] == false
+ ) {
+ col = optColoredCiphers
+ ? "hsl(" +
+ curCiph.H +
+ " " +
+ curCiph.S +
+ "% " +
+ curCiph.L +
+ "% / " +
+ alphaHlt +
+ ")"
+ : "hsl(0 0% 70% / " + alphaHlt + ")";
+ }
+ }
+ ciphCount++; // next position in hltBoolArr
+ ms +=
+ ' ' +
+ gemVal +
+ " | ";
+ }
+ }
+ ms += "";
+ }
+
+ ms += "
";
+ histTable.innerHTML = ms;
+}