|
| 1 | +var nought1 = 0; |
| 2 | +var nought2 = 0; |
| 3 | +var nought3 = 0; |
| 4 | +var nought4 = 0; |
| 5 | +var nought5 = 0; |
| 6 | +var nought6 = 0; |
| 7 | +var nought7 = 0; |
| 8 | +var nought8 = 0; |
| 9 | + |
| 10 | +function changeLeverOne() { |
| 11 | + if (nought1 == 0) { |
| 12 | + document.getElementById('firstLever').src = 'assets/img/lever_down.png'; |
| 13 | + nought1 = 1; |
| 14 | + } |
| 15 | + else { |
| 16 | + document.getElementById("firstLever").src = 'assets/img/lever_up.png'; |
| 17 | + nought1 = 0; |
| 18 | + } |
| 19 | + workOut() |
| 20 | +} |
| 21 | +function changeLeverTwo() { |
| 22 | + if (nought2 == 0) { |
| 23 | + document.getElementById('secondLever').src = 'assets/img/lever_down.png'; |
| 24 | + nought2 = 1; |
| 25 | + } |
| 26 | + else { |
| 27 | + document.getElementById("secondLever").src = 'assets/img/lever_up.png'; |
| 28 | + nought2 = 0; |
| 29 | + } |
| 30 | + workOut() |
| 31 | +} |
| 32 | +function changeLeverThree() { |
| 33 | + if (nought3 == 0) { |
| 34 | + document.getElementById('thirdLever').src = 'assets/img/lever_down.png'; |
| 35 | + nought3 = 1; |
| 36 | + } |
| 37 | + else { |
| 38 | + document.getElementById("thirdLever").src = 'assets/img/lever_up.png'; |
| 39 | + nought3 = 0; |
| 40 | + } |
| 41 | + workOut() |
| 42 | +} |
| 43 | +function changeLeverFour() { |
| 44 | + if (nought4 == 0) { |
| 45 | + document.getElementById('fourthLever').src = 'assets/img/lever_down.png'; |
| 46 | + nought4 = 1; |
| 47 | + } |
| 48 | + else { |
| 49 | + document.getElementById("fourthLever").src = 'assets/img/lever_up.png'; |
| 50 | + nought4 = 0; |
| 51 | + } |
| 52 | + workOut() |
| 53 | +} |
| 54 | +function changeLeverFive() { |
| 55 | + if (nought5 == 0) { |
| 56 | + document.getElementById('fifthLever').src = 'assets/img/lever_down.png'; |
| 57 | + nought5 = 1; |
| 58 | + } |
| 59 | + else { |
| 60 | + document.getElementById("fifthLever").src = 'assets/img/lever_up.png'; |
| 61 | + nought5 = 0; |
| 62 | + } |
| 63 | + workOut() |
| 64 | +} |
| 65 | +function changeLeverSix() { |
| 66 | + if (nought6 == 0) { |
| 67 | + document.getElementById('sixthLever').src = 'assets/img/lever_down.png'; |
| 68 | + nought6 = 1; |
| 69 | + } |
| 70 | + else { |
| 71 | + document.getElementById("sixthLever").src = 'assets/img/lever_up.png'; |
| 72 | + nought6 = 0; |
| 73 | + } |
| 74 | + workOut() |
| 75 | +} |
| 76 | +function changeLeverSeven() { |
| 77 | + if (nought7 == 0) { |
| 78 | + document.getElementById('seventhLever').src = 'assets/img/lever_down.png'; |
| 79 | + nought7 = 1; |
| 80 | + } |
| 81 | + else { |
| 82 | + document.getElementById("seventhLever").src = 'assets/img/lever_up.png'; |
| 83 | + nought7 = 0; |
| 84 | + } |
| 85 | + workOut() |
| 86 | +} |
| 87 | +function changeLeverEight() { |
| 88 | + if (nought8 == 0) { |
| 89 | + document.getElementById('eighthLever').src = 'assets/img/lever_down.png'; |
| 90 | + nought8 = 1; |
| 91 | + } |
| 92 | + else { |
| 93 | + document.getElementById("eighthLever").src = 'assets/img/lever_up.png'; |
| 94 | + nought8 = 0; |
| 95 | + } |
| 96 | + workOut() |
| 97 | +} |
| 98 | +function workOut() { |
| 99 | + document.getElementById('binary').innerHTML = nought1.toString()+nought2.toString()+nought3.toString()+nought4.toString(); |
| 100 | + document.getElementById('binary2').innerHTML = nought5.toString()+nought6.toString()+nought7.toString()+nought8.toString(); |
| 101 | + document.getElementById('hexidecimal').innerHTML = ((nought1*8+nought2*4+nought3*2+nought4*1).toString(16)).toUpperCase(); |
| 102 | + document.getElementById('hexidecimal2').innerHTML = ((nought5*8+nought6*4+nought7*2+nought8*1).toString(16)).toUpperCase(); |
| 103 | + document.getElementById('decimal').innerHTML = (nought1*128+nought2*64+nought3*32+nought4*16+nought5*8+nought6*4+nought7*2+nought8*1).toString() |
| 104 | + // Add octal at one point??? |
| 105 | +} |
0 commit comments