function resetBinarySimulator(){document.getElementById("blb256").classList.remove("poweredOn"),document.getElementById("blb256").classList.add("poweredOff"),document.getElementById("swt256").classList.remove("btnActive"),bit256=!1,document.getElementById("blb128").classList.add("poweredOff"),document.getElementById("blb128").classList.remove("poweredOn"),document.getElementById("swt128").classList.remove("btnActive"),bit128=!1,document.getElementById("blb64").classList.add("poweredOff"),document.getElementById("blb64").classList.remove("poweredOn"),document.getElementById("swt64").classList.remove("btnActive"),bit64=!1,document.getElementById("blb32").classList.add("poweredOff"),document.getElementById("blb32").classList.remove("poweredOn"),document.getElementById("swt32").classList.remove("btnActive"),bit32=!1,document.getElementById("blb16").classList.add("poweredOff"),document.getElementById("blb16").classList.remove("poweredOn"),document.getElementById("swt16").classList.remove("btnActive"),bit16=!1,document.getElementById("blb8").classList.add("poweredOff"),document.getElementById("blb8").classList.remove("poweredOn"),document.getElementById("swt8").classList.remove("btnActive"),bit8=!1,document.getElementById("blb4").classList.add("poweredOff"),document.getElementById("blb4").classList.remove("poweredOn"),document.getElementById("swt4").classList.remove("btnActive"),bit4=!1,document.getElementById("blb2").classList.add("poweredOff"),document.getElementById("blb2").classList.remove("poweredOn"),document.getElementById("swt2").classList.remove("btnActive"),bit2=!1,document.getElementById("blb1").classList.add("poweredOff"),document.getElementById("blb1").classList.remove("poweredOn"),document.getElementById("swt1").classList.remove("btnActive"),bit1=!1,denary=0,updateBinary()}function changeClass256(){bit256?(document.getElementById("blb256").classList.add("poweredOff"),document.getElementById("blb256").classList.remove("poweredOn"),document.getElementById("swt256").classList.remove("btnActive"),bit256=!1,denary-=256,updateBinary()):(document.getElementById("blb256").classList.add("poweredOn"),document.getElementById("blb256").classList.remove("poweredOff"),document.getElementById("swt256").classList.add("btnActive"),bit256=!0,denary+=256,updateBinary())}function changeClass128(){bit128?(document.getElementById("blb128").classList.add("poweredOff"),document.getElementById("blb128").classList.remove("poweredOn"),document.getElementById("swt128").classList.remove("btnActive"),bit128=!1,denary-=128,updateBinary()):(document.getElementById("blb128").classList.add("poweredOn"),document.getElementById("blb128").classList.remove("poweredOff"),document.getElementById("swt128").classList.add("btnActive"),bit128=!0,denary+=128,updateBinary())}function changeClass64(){bit64?(document.getElementById("blb64").classList.add("poweredOff"),document.getElementById("blb64").classList.remove("poweredOn"),document.getElementById("swt64").classList.remove("btnActive"),bit64=!1,denary-=64,updateBinary()):(document.getElementById("blb64").classList.add("poweredOn"),document.getElementById("blb64").classList.remove("poweredOff"),document.getElementById("swt64").classList.add("btnActive"),bit64=!0,denary+=64,updateBinary())}function changeClass32(){bit32?(document.getElementById("blb32").classList.add("poweredOff"),document.getElementById("blb32").classList.remove("poweredOn"),document.getElementById("swt32").classList.remove("btnActive"),bit32=!1,denary-=32,updateBinary()):(document.getElementById("blb32").classList.add("poweredOn"),document.getElementById("blb32").classList.remove("poweredOff"),document.getElementById("swt32").classList.add("btnActive"),bit32=!0,denary+=32,updateBinary())}function changeClass16(){bit16?(document.getElementById("blb16").classList.add("poweredOff"),document.getElementById("blb16").classList.remove("poweredOn"),document.getElementById("swt16").classList.remove("btnActive"),bit16=!1,denary-=16,updateBinary()):(document.getElementById("blb16").classList.add("poweredOn"),document.getElementById("blb16").classList.remove("poweredOff"),document.getElementById("swt16").classList.add("btnActive"),bit16=!0,denary+=16,updateBinary())}function changeClass8(){bit8?(document.getElementById("blb8").classList.add("poweredOff"),document.getElementById("blb8").classList.remove("poweredOn"),document.getElementById("swt8").classList.remove("btnActive"),bit8=!1,denary-=8,updateBinary()):(document.getElementById("blb8").classList.add("poweredOn"),document.getElementById("blb8").classList.remove("poweredOff"),document.getElementById("swt8").classList.add("btnActive"),bit8=!0,denary+=8,updateBinary())}function changeClass4(){bit4?(document.getElementById("blb4").classList.add("poweredOff"),document.getElementById("blb4").classList.remove("poweredOn"),document.getElementById("swt4").classList.remove("btnActive"),bit4=!1,denary-=4,updateBinary()):(document.getElementById("blb4").classList.add("poweredOn"),document.getElementById("blb4").classList.remove("poweredOff"),document.getElementById("swt4").classList.add("btnActive"),bit4=!0,denary+=4,updateBinary())}function changeClass2(){bit2?(document.getElementById("blb2").classList.add("poweredOff"),document.getElementById("blb2").classList.remove("poweredOn"),document.getElementById("swt2").classList.remove("btnActive"),bit2=!1,denary-=2,updateBinary()):(document.getElementById("blb2").classList.add("poweredOn"),document.getElementById("blb2").classList.remove("poweredOff"),document.getElementById("swt2").classList.add("btnActive"),bit2=!0,denary+=2,updateBinary())}function changeClass1(){bit1?(document.getElementById("blb1").classList.add("poweredOff"),document.getElementById("blb1").classList.remove("poweredOn"),document.getElementById("swt1").classList.remove("btnActive"),bit1=!1,denary-=1,updateBinary()):(document.getElementById("blb1").classList.add("poweredOn"),document.getElementById("blb1").classList.remove("poweredOff"),document.getElementById("swt1").classList.add("btnActive"),bit1=!0,denary+=1,updateBinary())}function updateBinary(){binary="",bit256?binary+="1":binary+="0",bit128?binary+="1":binary+="0",bit64?binary+="1":binary+="0",bit32?binary+="1":binary+="0",bit16?binary+="1":binary+="0",bit8?binary+="1":binary+="0",bit4?binary+="1":binary+="0",bit2?binary+="1":binary+="0",bit1?binary+="1":binary+="0",document.getElementById("denaryNumber").innerHTML=denary,document.getElementById("binaryNumber").innerHTML=binary}function convertToBinary(e){var t="";return e-8>=0?(e-=8,t+="1"):t+="0",e-4>=0?(e-=4,t+="1"):t+="0",e-2>=0?(e-=2,t+="1"):t+="0",e-1>=0?(e-=1,t+="1"):t+="0",t}function binaryParser(e){for(let t=0;t9&&(customBinary=prompt("Too many digits.\n\nPlease enter your 9-bit Binary Value"),e=customBinary?customBinary.length:0)}while(e>9);binaryParser(customBinary)}while(!validInput);customBinaryParser(customBinary)}function customDenaryParser(e){resetBinarySimulator();let t=[256,128,64,32,16,8,4,2,1];for(let n=0;n<10&&(e-t[n]<0||(e-=t[n],0==n?changeClass256():1==n?changeClass128():2==n?changeClass64():3==n?changeClass32():4==n?changeClass16():5==n?changeClass8():6==n?changeClass4():7==n?changeClass2():8==n&&changeClass1(),0!=e));n++);}function requestDenary(){customDenary=prompt("Please enter your Denary Value\nMax value is 511");do{customDenary>511&&(customDenary=prompt("Number too large.\n\nPlease enter your Denary Value.\nMax value is 511"))}while(customDenary>511);customDenaryParser(customDenary)}function resetHexadecimal(){4==document.getElementById("hexadecimalNumber").textContent.length&&(resetPlace4096(),resetPlace256()),resetPlace16(),resetPlace1()}function resetPlace4096(){place4096=0;var e=100/15*place4096/100;document.getElementById("blb4").style.opacity=e,updateNumbers()}function resetPlace256(){place256=0;var e=100/15*place256/100;document.getElementById("blb3").style.opacity=e,updateNumbers()}function resetPlace16(){place16=0;var e=100/15*place16/100;document.getElementById("blb2").style.opacity=e,updateNumbers()}function resetPlace1(){place1=0;var e=100/15*place1/100;document.getElementById("blb1").style.opacity=e,updateNumbers()}function toggleUp4096(){if(place4096>=0&&place4096<15){place4096+=1;var e=100/15*place4096/100;document.getElementById("blb4").style.opacity=e,updateNumbers()}}function toggleDown4096(){if(place4096>0){place4096-=1;var e=100/15*place4096/100;document.getElementById("blb4").style.opacity=e,updateNumbers()}}function toggleUp256(){if(place256>=0&&place256<15){place256+=1;var e=100/15*place256/100;document.getElementById("blb3").style.opacity=e,updateNumbers()}}function toggleDown256(){if(place256>0){place256-=1;var e=100/15*place256/100;document.getElementById("blb3").style.opacity=e,updateNumbers()}}function toggleUp16(){if(place16>=0&&place16<15){place16+=1;var e=100/15*place16/100;document.getElementById("blb2").style.opacity=e,updateNumbers()}}function toggleDown16(){if(place16>0){place16-=1;var e=100/15*place16/100;document.getElementById("blb2").style.opacity=e,updateNumbers()}}function toggleUp1(){if(place1>=0&&place1<15){place1+=1;var e=100/15*place1/100;document.getElementById("blb1").style.opacity=e,updateNumbers()}}function toggleDown1(){if(place1>0){place1-=1;var e=100/15*place1/100;document.getElementById("blb1").style.opacity=e,updateNumbers()}}function updateNumbers(){binary="",hexadecimal="";let e=document.getElementById("hexadecimalNumber").textContent.length;4==e?(denary=4096*place4096+256*place256+16*place16+place1,hexadecimal=convertToHex(place4096)+convertToHex(place256)+convertToHex(place16)+convertToHex(place1),binary=convertToBinary(place4096)+convertToBinary(place256)+convertToBinary(place16)+convertToBinary(place1)):2==e&&(denary=16*place16+place1,hexadecimal=convertToHex(place16)+convertToHex(place1),binary=convertToBinary(place16)+convertToBinary(place1)),document.getElementById("denaryNumber").innerHTML=denary,document.getElementById("hexadecimalNumber").innerHTML=hexadecimal,document.getElementById("binaryNumber").innerHTML=binary}function convertToHex(e){var t=e-9;return t<=0?e.toString():1==t?"A":2==t?"B":3==t?"C":4==t?"D":5==t?"E":6==t?"F":void 0}function convertToBinary(e){var t="";return e-8>=0?(e-=8,t+="1"):t+="0",e-4>=0?(e-=4,t+="1"):t+="0",e-2>=0?(e-=2,t+="1"):t+="0",e-1>=0?(e-=1,t+="1"):t+="0",t}function resetColours(){resetPlaceR16(),resetPlaceR1(),resetPlaceG16(),resetPlaceG1(),resetPlaceB16(),resetPlaceB1()}function resetPlaceR16(){placeR16=0;var e=100/15*placeR16/100;document.getElementById("blbR2").style.opacity=e,updateColours()}function resetPlaceR1(){placeR1=0;var e=100/15*placeR1/100;document.getElementById("blbR1").style.opacity=e,updateColours()}function resetPlaceG16(){placeG16=0;var e=100/15*placeG16/100;document.getElementById("blbG2").style.opacity=e,updateColours()}function resetPlaceG1(){placeG1=0;var e=100/15*placeG1/100;document.getElementById("blbG1").style.opacity=e,updateColours()}function resetPlaceB16(){placeB16=0;var e=100/15*placeB16/100;document.getElementById("blbB2").style.opacity=e,updateColours()}function resetPlaceB1(){placeB1=0;var e=100/15*placeB1/100;document.getElementById("blbB1").style.opacity=e,updateColours()}function toggleUpR16(){if(placeR16>=0&&placeR16<15){placeR16+=1;var e=100/15*placeR16/100;document.getElementById("blbR2").style.opacity=e,updateColours()}}function toggleDownR16(){if(placeR16>0){placeR16-=1;var e=100/15*placeR16/100;document.getElementById("blbR2").style.opacity=e,updateColours()}}function toggleUpR1(){if(place1>=0&&placeR1<15){placeR1+=1;var e=100/15*placeR1/100;document.getElementById("blbR1").style.opacity=e,updateColours()}}function toggleDownR1(){if(placeR1>0){placeR1-=1;var e=100/15*placeR1/100;document.getElementById("blbR1").style.opacity=e,updateColours()}}function toggleUpG16(){if(placeG16>=0&&placeG16<15){placeG16+=1;var e=100/15*placeG16/100;document.getElementById("blbG2").style.opacity=e,updateColours()}}function toggleDownG16(){if(placeG16>0){placeG16-=1;var e=100/15*placeG16/100;document.getElementById("blbG2").style.opacity=e,updateColours()}}function toggleUpG1(){if(placeG1>=0&&placeG1<15){placeG1+=1;var e=100/15*placeG1/100;document.getElementById("blbG1").style.opacity=e,updateColours()}}function toggleDownG1(){if(placeG1>0){placeG1-=1;var e=100/15*placeG1/100;document.getElementById("blbG1").style.opacity=e,updateColours()}}function toggleUpB16(){if(placeB16>=0&&placeB16<15){placeB16+=1;var e=100/15*placeB16/100;document.getElementById("blbB2").style.opacity=e,updateColours()}}function toggleDownB16(){if(placeB16>0){placeB16-=1;var e=100/15*placeB16/100;document.getElementById("blbB2").style.opacity=e,updateColours()}}function toggleUpB1(){if(placeB1>=0&&placeB1<15){placeB1+=1;var e=100/15*placeB1/100;document.getElementById("blbB1").style.opacity=e,updateColours()}}function toggleDownB1(){if(placeB1>0){placeB1-=1;var e=100/15*placeB1/100;document.getElementById("blbB1").style.opacity=e,updateColours()}}function updateColours(){hexadecimal="",redDenary=0,greenDenary=0,blueDenary=0,redBinary="",greenBinary="",blueBinary="",denary=16*placeR16+placeR1+", "+(16*placeG16+placeG1)+", "+(16*placeB16+placeB1),hexadecimal="#"+convertToHex(placeR16)+convertToHex(placeR1)+convertToHex(placeG16)+convertToHex(placeG1)+convertToHex(placeB16)+convertToHex(placeB1),redBinary=convertToBinary(placeR16)+convertToBinary(placeR1),greenBinary=convertToBinary(placeG16)+convertToBinary(placeG1),blueBinary=convertToBinary(placeB16)+convertToBinary(placeB1),document.getElementById("denaryNumber").innerHTML=denary,document.getElementById("hexadecimalNumber").innerHTML=hexadecimal,document.getElementById("colouredHex").style.backgroundColor=hexadecimal,document.getElementById("invertedHex").style.backgroundColor=invertedHex(),document.getElementById("redBinaryNumber").innerHTML=redBinary,document.getElementById("blueBinaryNumber").innerHTML=blueBinary,document.getElementById("greenBinaryNumber").innerHTML=greenBinary}function invertedHex(){return hexadecimal="#"+convertToHex(15-placeR16)+convertToHex(15-placeR1)+convertToHex(15-placeG16)+convertToHex(15-placeG1)+convertToHex(15-placeB16)+convertToHex(15-placeB1),hexadecimal}function convertToHex(e){var t=e-9;return t<=0?e.toString():1==t?"A":2==t?"B":3==t?"C":4==t?"D":5==t?"E":6==t?"F":void 0}function convertToBinary(e){var t="";return e-8>=0?(e-=8,t+="1"):t+="0",e-4>=0?(e-=4,t+="1"):t+="0",e-2>=0?(e-=2,t+="1"):t+="0",e-1>=0?(e-=1,t+="1"):t+="0",t}function updateHex(e){if(null==e)resetColours();else{if("#"==e.charAt(0)&&(e=e.substring(1)),isHex(e)){let d=e.split("");placeR1=parseInt(d[1],16);var t=100/15*placeR1/100;document.getElementById("blbR1").style.opacity=t,placeR16=parseInt(d[0],16);var n=100/15*placeR16/100;document.getElementById("blbR2").style.opacity=n,placeG1=parseInt(d[3],16);var a=100/15*placeG1/100;document.getElementById("blbG1").style.opacity=a,placeG16=parseInt(d[2],16);var l=100/15*placeG16/100;document.getElementById("blbG2").style.opacity=l,placeB1=parseInt(d[5],16);var c=100/15*placeB1/100;document.getElementById("blbB1").style.opacity=c,placeB16=parseInt(d[4],16);var o=100/15*placeB16/100;document.getElementById("blbB2").style.opacity=o,updateColours()}else window.alert("Invalid Entry"),resetColours()}}function isHex(e){return regexp=/^[0-9a-fA-F]+$/,!!regexp.test(e)}function requestHex(){updateHex(prompt("Please enter your Hex Value"))}function invertHex(){customHex=invertedHex(),updateHex(customHex)}function notGateToggle(){notValue?(document.getElementById("blbNotGate").classList.remove("poweredOn"),document.getElementById("blbNotGate").classList.add("poweredOff"),document.getElementById("swtNotGate").classList.add("btnActive"),notValue=!1):(document.getElementById("blbNotGate").classList.remove("poweredOff"),document.getElementById("blbNotGate").classList.add("poweredOn"),document.getElementById("swtNotGate").classList.remove("btnActive"),notValue=!0)}function input1Toggle(){input1?(input1=!1,document.getElementById("swtInput1").classList.remove("btnActive")):(input1=!0,document.getElementById("swtInput1").classList.add("btnActive"));let e=document.getElementById("pageHeading").textContent;"AND Gate"==e?andGateUpdate():"OR Gate"==e&&orGateUpdate()}function input2Toggle(){input2?(input2=!1,document.getElementById("swtInput2").classList.remove("btnActive")):(input2=!0,document.getElementById("swtInput2").classList.add("btnActive"));let e=document.getElementById("pageHeading").textContent;"AND Gate"==e?andGateUpdate():"OR Gate"==e&&orGateUpdate()}function andGateUpdate(){input1&&input2?(document.getElementById("blbAndGate").classList.remove("poweredOff"),document.getElementById("blbAndGate").classList.add("poweredOn"),andValue=!0):andValue&&(document.getElementById("blbAndGate").classList.remove("poweredOn"),document.getElementById("blbAndGate").classList.add("poweredOff"),andValue=!1)}function orGateUpdate(){input1||input2?orValue||(document.getElementById("blbOrGate").classList.remove("poweredOff"),document.getElementById("blbOrGate").classList.add("poweredOn"),orValue=!0):orValue&&(document.getElementById("blbOrGate").classList.remove("poweredOn"),document.getElementById("blbOrGate").classList.add("poweredOff"),orValue=!1)}denary=0,binary="",customBinary="",bit1=!1,bit2=!1,bit4=!1,bit8=!1,bit16=!1,bit32=!1,bit64=!1,bit128=!1,bit256=!1,function(){"use strict";!function(){if("requestAnimationFrame"in window&&!/Mobile|Android/.test(navigator.userAgent)){var e=document.querySelectorAll("[data-bss-parallax]");if(e.length){var t,n=[];window.addEventListener("scroll",a),window.addEventListener("resize",a),a()}}function a(){n.length=0;for(var a=0;a0&&c.top