KV-Diagramm Generator
+UND == &&
+ODER == ||
+NICHT == !
+Es dürfen NUR die Variablen a, b, c und d verwendet werden.
+ + + + + + +From 6fe593a196b9ddbcb0a961456730358a312c6ef4 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 10 Mar 2019 22:38:24 +0100 Subject: Added KV template and generator --- assets/js/generator.js | 24 +++++++++++++++ generator.html | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ template.html | 38 +++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 assets/js/generator.js create mode 100644 generator.html create mode 100644 template.html diff --git a/assets/js/generator.js b/assets/js/generator.js new file mode 100644 index 0000000..eabe108 --- /dev/null +++ b/assets/js/generator.js @@ -0,0 +1,24 @@ +document.getElementById('minify').onclick = () => { + let a, b, c, d; + const input = document.getElementById('input').value; + + document.getElementById('log').innerText = ''; + document.getElementById('log').append('LOG\ndcba Z ID\n'); + + try { + for (let i = 0; i < 16; i++) { + const currentBinary = (i >>> 0).toString(2); + // fill binary number with leading zeros until it is 4 digits long + const filledBinary = currentBinary.length >= 4 ? currentBinary : new Array(4 - currentBinary.length + 1).join('0') + currentBinary; + a = filledBinary[3] === '1'; + b = filledBinary[2] === '1'; + c = filledBinary[1] === '1'; + d = filledBinary[0] === '1'; + document.getElementById('log').append(`${filledBinary} ${eval(input) ? '1' : '0'} ${document.getElementById(i + 1).getAttribute('data-id')}\n`); + document.getElementById(i + 1).innerText = eval(input) ? '1' : '0'; + } + } catch (err) { + console.error(err); + alert('Oh, da ist wohl was schiefgelaufen, bitte probieren Sie es noch einmal :)'); + } +}; diff --git a/generator.html b/generator.html new file mode 100644 index 0000000..4b6a40a --- /dev/null +++ b/generator.html @@ -0,0 +1,81 @@ + + +
+ + + + +KV-Diagramm Generator
+UND == &&
+ODER == ||
+NICHT == !
+Es dürfen NUR die Variablen a, b, c und d verwendet werden.
+ + + + + + +