From fc95109405cb9a15b90fe666476b363e06bb3910 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 10 Mar 2019 22:37:06 +0100 Subject: Added process of minifying via KV --- assets/js/process.js | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 assets/js/process.js (limited to 'assets/js/process.js') diff --git a/assets/js/process.js b/assets/js/process.js new file mode 100644 index 0000000..988d9bf --- /dev/null +++ b/assets/js/process.js @@ -0,0 +1,84 @@ +/** + * Fill the diagram with 1s and 0s (animated) + */ +document.getElementById('fill').onclick = () => { + document.getElementById('combine').style.display = 'block'; + const elements = document.getElementsByClassName('output'); + + // reset diagram + for (let i = 0; i < elements.length; i++) { + document.getElementById(i + 1).innerText = ''; + } + + // fill diagram + for (let i = 0; i < elements.length; i++) { + ((ind) => { // awesome animation + setTimeout(() => { + document.getElementById(i + 1).innerText = elements[i].classList.contains('true') ? '1' : '0'; + }, 150 * ind) + })(i) + } +}; + +/** + * Combining fields to blocks (animated) + */ +document.getElementById('combine').onclick = () => { + document.getElementById('fill').style.display = 'none'; + document.getElementById('combine').innerText = 'Weiter'; + const steps = document.getElementById('steps'); + const elements = document.getElementsByClassName('grid-child'); + + // mark truthy values + steps.insertAdjacentHTML('beforeend', '
  • Finden von wahren Werten (grün markiert)
  • '); + for (let i = 0; i < elements.length; i++) { + if (elements[i].getAttribute('id') !== null && elements[i].innerText === '1') { + elements[i].style.background = 'lightgreen' + } + } + + // combine fields - stage 1 + document.getElementById('combine').onclick = () => { + steps.insertAdjacentHTML('beforeend', '
  • Felder zu Blöcken zusammenfassen
  • '); + const fieldDnf = document.getElementById('field_dnf'); + + // reset field color + for (let i = 0; i < elements.length; i++) { + elements[i].style.background = 'white' + } + + document.getElementById('3').style.background = 'green'; + document.getElementById('4').style.background = 'green'; + document.getElementById('11').style.background = 'green'; + document.getElementById('12').style.background = 'green'; + + fieldDnf.insertAdjacentHTML('beforeend', '
  • (E2E3)
  • '); + + // combine fields - stage 2 + document.getElementById('combine').onclick = () => { + document.getElementById('11').style.background = 'linear-gradient(to top right, blue, green)'; + document.getElementById('15').style.background = 'blue'; + + fieldDnf.insertAdjacentHTML('beforeend', '
  • (E1∧E2∧E4)
  • '); + + // combine fields - stage 3 + document.getElementById('combine').onclick = () => { + document.getElementById('6').style.background = 'orange'; + + fieldDnf.insertAdjacentHTML('beforeend', + '
  • (E1E2∧E3E4)
  • '); + + document.getElementById('combine').style.display = "none"; + } + }; + }; +}; + +/** + * Scroll up magic + */ +const button = document.getElementById('up'); +const options = {top: 0, left: 0, behavior: 'smooth'}; +button.addEventListener('click', () => { + window.scroll(options) +}); -- cgit v1.2.3