From 68b8c7c21493e1d328b09acc5b461cf08ef1a826 Mon Sep 17 00:00:00 2001 From: Waescheklammer <33402322+Waescheklammer@users.noreply.github.com> Date: Tue, 9 Apr 2019 18:53:02 +0200 Subject: [PATCH 1/4] Update index.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Module switch patched Bug: nach 2. ausführen springt die Fragenschleife nach 0 sofort auf 3, später direkt auf 3 & Correct zähler funktioniert beim 2. Durchlauf nicht mehr --- index.js | 57 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index 0861356..65fc7c8 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,9 @@ *Button LösungenText *Noten anzeigen/Mit Lösungen verbinden *Desktop CSS Layout + *ASYNC Event listeners -> nicht synchron mit fetch + -> Hat keine daten, feuert bevor fetch geladen wird + *BUG:bei zweitem durchlauf komisches verhalten */ let menu = document.getElementById("main__menu"); @@ -39,13 +42,15 @@ function fetchRequest(addr){ }).then(data => { localStorage.setItem("notes", JSON.stringify(data.notes)); localStorage.setItem("solution", JSON.stringify(data.solution)); + insertFirstPage(); + responseButtons(); }).catch(err => { // Do something for an error here }); } -fetchRequest(fetchAddr); +//fetchRequest(fetchAddr); //--------------------------- // Render Buttons @@ -74,7 +79,6 @@ function randomizeChoiceButtons(buttons, randomDec){ } } -randomizeChoiceButtons(buttons, randomChoice); @@ -89,8 +93,7 @@ function renderRenderbody(solutionIndex){ let textArr=JSON.parse(localStorage.getItem("notes")); document.getElementById("renderParagraph").innerHTML= textArr[solutionIndex]; } - -renderRenderbody(solutionIndex); +//Überspring 2 und 3 //--------------------------- @@ -102,7 +105,7 @@ let solutionValue = JSON.parse(localStorage.getItem("solution")); //Setzt nächsten Rendering Content zusammen/ wechselt zur nächsten Seite & summiert richtige Antworten function handleButton(event){ let h = JSON.parse(localStorage.getItem("solution")); - + console.log(solutionIndex); let lastPage = () => { jP.innerHTML = Correct +"/4"; quiz.classList.add("hidden"); @@ -117,11 +120,11 @@ function handleButton(event){ renderRenderbody(solutionIndex); } - if (event === solutionValue[solutionIndex]) { if(solutionIndex === 3){ Correct+=1; - lastPage(); + lastPage(); + solutionIndex=0; } else { @@ -130,25 +133,43 @@ function handleButton(event){ } } else{ - if(solutionIndex === 3){lastPage();} + if(solutionIndex === 3){lastPage(); + solutionIndex=0; + } else - {nextPage();} + { + nextPage(); + } } } +function insertFirstPage(){ + menu.classList.add("hidden"); + quiz.classList.remove("hidden"); + renderRenderbody(solutionIndex); + randomizeChoiceButtons(buttons, randomChoice); +} + +//fect('http://192.168.0.108:8000/Modul2.json'); //Start Button document.getElementById("form_button").addEventListener('click', () =>{ var sel = document.getElementById("menuform").value; - if (sel !== 'Modul') { - menu.classList.add("hidden"); - quiz.classList.remove("hidden"); - renderRenderbody(solutionIndex); + const mod2Addr= 'http://192.168.0.108:8000/Modul2.json'; + const mod1Addr= 'http://192.168.0.108:8000/Modul1.json'; + + if(sel === 'Bassschlüssel'){ + localStorage.clear(); + fetchRequest(mod2Addr); } - else - { + if(sel === 'Violinschlüssel'){ + localStorage.clear(); + fetchRequest(mod1Addr); + } + if (sel !== 'Modul') { form.classList.add("main__choicebox--redLine"); } -}) + +}); //Restart Button document.getElementById("statistic__button").addEventListener('click', () =>{ @@ -162,7 +183,8 @@ document.getElementById("statistic__button").addEventListener('click', () =>{ }); // Quiz Buttons -document.getElementById("main__choicebox").addEventListener('click', function(event){ +function responseButtons(){ + document.getElementById("main__choicebox").addEventListener('click', function(event){ let elem = event.target.id; if(elem === buttons[0]){ @@ -182,3 +204,4 @@ document.getElementById("main__choicebox").addEventListener('click', function(ev handleButton(buttonText); } }); +} From 01974c73f7d75c118a57440364f1ef40d283c44d Mon Sep 17 00:00:00 2001 From: Waescheklammer <33402322+Waescheklammer@users.noreply.github.com> Date: Sun, 14 Apr 2019 16:12:54 +0200 Subject: [PATCH 2/4] Update style.css responsive swap --- style.css | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/style.css b/style.css index 568b157..873ad7f 100644 --- a/style.css +++ b/style.css @@ -13,17 +13,7 @@ h2{ text-align: center; font-size: 2.5rem; } -@media only screen and (min-width: 990px){ - #container{ - grid-template-areas: - 'header' - 'ad' - 'ad' - 'footer footer'; - grid-template-columns: auto; - grid-template-rows: 10% auto auto 10%; - } -} + #container{ height: 100%; display: grid; @@ -211,3 +201,16 @@ progress[value]::-webkit-progress-value { padding: 10%; } .hidden{display: none;} + + +@media only screen and (min-width: 1000px){ + #container{ + background-color: white; + grid-template-areas: + 'header header' + 'main ad' + 'footer footer'; + grid-template-columns: auto 30%; + grid-template-rows: 10% auto 10%; + } +} From 5a1ff00e2f1c95e602411f9520b5e542f2dee858 Mon Sep 17 00:00:00 2001 From: Waescheklammer <33402322+Waescheklammer@users.noreply.github.com> Date: Tue, 16 Apr 2019 11:27:52 +0200 Subject: [PATCH 3/4] Add files via upload --- index.html | 11 +++---- index.js | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++--- style.css | 6 ++-- 3 files changed, 98 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 8dfce33..b69370b 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,7 @@ +