Commit 82f1983d authored by Dominik Schuhmann's avatar Dominik Schuhmann
Browse files

Update main.js to can switch exercises

parent 040c0b0d
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -47,70 +47,16 @@
<div style="text-align: center">
<input type="checkbox" id="pir" class="checkboxunit" name="horns" style onclick="myfunction()">
</div>
<div>
<!--<div>
<h1>Resultar.</h1>
<p id="result"></p>
</div>-->
<div>
<h1>Mögliche Aufgaben</h1>
<h3 id="aufgaben"></h3>
</div>
<script>
function myfunction() {
var check1 = document.getElementById('stack');
var check2 = document.getElementById('unit');
var check3 = document.getElementById('rgbUnit');
var check4 = document.getElementById('hub');
var check5 = document.getElementById('dual-B');
var check6 = document.getElementById('pir');
var result = document.getElementById("result");
var checkboxes = {check2,check3,check4,check5,check6};
var array = [];
if (check1.checked == false) {
result.innerHTML = "Leider kann ohne Stack keine Aufgabe gemacht werden!"
} else {
array.push(check1.id);
if (check2.checked == true) {
array.push(check2.id);
}
if (check3.checked == true) {
array.push(check3.id);
}
if (check4.checked == true) {
array.push(check4.id);
}
if (check5.checked == true) {
array.push(check5.id);
}
if (check6.checked == true) {
array.push(check6.id);
}
document.getElementById("result").innerHTML = array.join();
}
}
</script>
<!--<script>
var test = document.getElementById('testButton');
var button2 = document.getElementById('button2');
button2.addEventListener("click", pressed2);
test.addEventListener("click", pressed);
var ary = ["Buttons clicked: "];
function pressed (){
ary.push("Button1");
console.log("Hello world!");
document.getElementById('testString').innerHTML = "Es wurde der Button ganz oben geklickt";
document.getElementById('testString').style.color = 'red';
var text = ary.join();
document.getElementById('Buttons').innerHTML = text;
}
function pressed2 () {
ary.push("Button2");
console.log("2ter Button");
document.getElementById('testString').innerHTML = "Es wurde der Butten in Reihe zwei geklickt";
document.getElementById('testString').style.color = 'blue';
var text = ary.join();
document.getElementById('Buttons').innerHTML = text;
}
</script>-->
<script src="C:\Users\Dominik\Documents\PhpStorm_Workspace\Nerdtree\js\main.js"></script>
</body>
</html>
function myfunction() {
var check1 = document.getElementById('stack');
var check2 = document.getElementById('unit');
var check3 = document.getElementById('rgbUnit');
var check4 = document.getElementById('hub');
var check5 = document.getElementById('dual-B');
var check6 = document.getElementById('pir');
var array = [];
if (check1.checked == true) {
array.push(check1.id);
}
if (check2.checked == true) {
array.push(check2.id);
}
if (check3.checked == true) {
array.push(check3.id);
}
if (check4.checked == true) {
array.push(check4.id);
}
if (check5.checked == true) {
array.push(check5.id);
}
if (check6.checked == true) {
array.push(check6.id);
}
getmoeglicheAufgaben(array);
}
function getmoeglicheAufgaben(array){
//deklaration Aufgaben
var aufledsleucht = ["rgbUnit","http://nerd40.ce.jku.at/?page_id=493", "Aufgabe: LEDs zum Leuchten bringen"];
var ledsbewegungssensor =[["rgbUnit","pir"], "http://nerd40.ce.jku.at/?page_id=940", "Aufgabe: LEDs leuchten lassen mithilfe eines Bewegungssensors"];
//Ausgabe
var aufgaben = document.getElementById("aufgaben");
var text= "<ul>";
//prüfung der Aufgaben
if(array.includes("stack")) {
if (array.includes(aufledsleucht[0])){
print(aufledsleucht);
}
var all = true;
for (i =0; i <ledsbewegungssensor[0].length && all;i++){
if (!array.includes(ledsbewegungssensor[0][i])){
all = false;
}
}
if(all){
print(ledsbewegungssensor);
}
text += "</ul>";
aufgaben.innerHTML = text;
}else {
alert("Leider kann ohne Stack keine Aufgabe gemacht werden!");
aufgaben.innerHTML = "Leider kann ohne Stack keine Aufgabe gemacht werden!"
}
//ausgabe function
function print (x){
text += "<li>"+"<a href="+x[1] +">"+x[2]+"</a>"+"</li>";
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment