Changed Hex Spinner

Changed Hex Spinner to Sliders

Hex Colours Spinners to be replaced in next update
This commit is contained in:
2024-11-10 00:23:04 +00:00
parent a262cad382
commit 0f7711fbb5
23 changed files with 4505 additions and 72 deletions

394
Export/assets/js/binary.js Normal file
View File

@@ -0,0 +1,394 @@
denary = 0
binary = ""
customBinary = ""
bit1 = false
bit2 = false
bit4 = false
bit8 = false
bit16 = false
bit32 = false
bit64 = false
bit128 = false
bit256 = false
function resetBinarySimulator(){
document.getElementById("blb256").classList.remove('poweredOn');
document.getElementById("blb256").classList.add('poweredOff');
document.getElementById("swt256").classList.remove('btnActive');
bit256 = false;
document.getElementById("blb128").classList.add('poweredOff');
document.getElementById("blb128").classList.remove('poweredOn');
document.getElementById("swt128").classList.remove('btnActive');
bit128 = false;
document.getElementById("blb64").classList.add('poweredOff');
document.getElementById("blb64").classList.remove('poweredOn');
document.getElementById("swt64").classList.remove('btnActive');
bit64 = false;
document.getElementById("blb32").classList.add('poweredOff');
document.getElementById("blb32").classList.remove('poweredOn');
document.getElementById("swt32").classList.remove('btnActive');
bit32 = false;
document.getElementById("blb16").classList.add('poweredOff');
document.getElementById("blb16").classList.remove('poweredOn');
document.getElementById("swt16").classList.remove('btnActive');
bit16 = false;
document.getElementById("blb8").classList.add('poweredOff');
document.getElementById("blb8").classList.remove('poweredOn');
document.getElementById("swt8").classList.remove('btnActive');
bit8 = false;
document.getElementById("blb4").classList.add('poweredOff');
document.getElementById("blb4").classList.remove('poweredOn');
document.getElementById("swt4").classList.remove('btnActive');
bit4 = false;
document.getElementById("blb2").classList.add('poweredOff');
document.getElementById("blb2").classList.remove('poweredOn');
document.getElementById("swt2").classList.remove('btnActive');
bit2 = false;
document.getElementById("blb1").classList.add('poweredOff');
document.getElementById("blb1").classList.remove('poweredOn');
document.getElementById("swt1").classList.remove('btnActive');
bit1 = false;
denary = 0;
updateBinary();
}
function changeClass256(){
if (bit256){
document.getElementById("blb256").classList.add('poweredOff');
document.getElementById("blb256").classList.remove('poweredOn');
document.getElementById("swt256").classList.remove('btnActive');
bit256 = false;
denary = denary - 256;
updateBinary();
}else{
document.getElementById("blb256").classList.add('poweredOn');
document.getElementById("blb256").classList.remove('poweredOff');
document.getElementById("swt256").classList.add('btnActive');
bit256 = true;
denary = denary + 256;
updateBinary();
}
}
function changeClass128(){
if (bit128){
document.getElementById("blb128").classList.add('poweredOff');
document.getElementById("blb128").classList.remove('poweredOn');
document.getElementById("swt128").classList.remove('btnActive');
bit128 = false;
denary = denary - 128;
updateBinary();
}else{
document.getElementById("blb128").classList.add('poweredOn');
document.getElementById("blb128").classList.remove('poweredOff');
document.getElementById("swt128").classList.add('btnActive');
bit128 = true;
denary = denary + 128;
updateBinary();
}
}
function changeClass64(){
if (bit64){
document.getElementById("blb64").classList.add('poweredOff');
document.getElementById("blb64").classList.remove('poweredOn');
document.getElementById("swt64").classList.remove('btnActive');
bit64 = false;
denary = denary - 64;
updateBinary();
}else{
document.getElementById("blb64").classList.add('poweredOn');
document.getElementById("blb64").classList.remove('poweredOff');
document.getElementById("swt64").classList.add('btnActive');
bit64 = true;
denary = denary + 64;
updateBinary();
}
}
function changeClass32(){
if (bit32){
document.getElementById("blb32").classList.add('poweredOff');
document.getElementById("blb32").classList.remove('poweredOn');
document.getElementById("swt32").classList.remove('btnActive');
bit32 = false;
denary = denary - 32;
updateBinary();
}else{
document.getElementById("blb32").classList.add('poweredOn');
document.getElementById("blb32").classList.remove('poweredOff');
document.getElementById("swt32").classList.add('btnActive');
bit32 = true;
denary = denary + 32;
updateBinary();
}
}
function changeClass16(){
if (bit16){
document.getElementById("blb16").classList.add('poweredOff');
document.getElementById("blb16").classList.remove('poweredOn');
document.getElementById("swt16").classList.remove('btnActive');
bit16 = false;
denary = denary - 16;
updateBinary();
}else{
document.getElementById("blb16").classList.add('poweredOn');
document.getElementById("blb16").classList.remove('poweredOff');
document.getElementById("swt16").classList.add('btnActive');
bit16 = true;
denary = denary + 16;
updateBinary();
}
}
function changeClass8(){
if (bit8){
document.getElementById("blb8").classList.add('poweredOff');
document.getElementById("blb8").classList.remove('poweredOn');
document.getElementById("swt8").classList.remove('btnActive');
bit8 = false;
denary = denary - 8;
updateBinary();
}else{
document.getElementById("blb8").classList.add('poweredOn');
document.getElementById("blb8").classList.remove('poweredOff');
document.getElementById("swt8").classList.add('btnActive');
bit8 = true;
denary = denary + 8;
updateBinary();
}
}
function changeClass4(){
if (bit4){
document.getElementById("blb4").classList.add('poweredOff');
document.getElementById("blb4").classList.remove('poweredOn');
document.getElementById("swt4").classList.remove('btnActive');
bit4 = false;
denary = denary - 4;
updateBinary();
}else{
document.getElementById("blb4").classList.add('poweredOn');
document.getElementById("blb4").classList.remove('poweredOff');
document.getElementById("swt4").classList.add('btnActive');
bit4 = true;
denary = denary + 4;
updateBinary();
}
}
function changeClass2(){
if (bit2){
document.getElementById("blb2").classList.add('poweredOff');
document.getElementById("blb2").classList.remove('poweredOn');
document.getElementById("swt2").classList.remove('btnActive');
bit2 = false;
denary = denary - 2;
updateBinary();
}else{
document.getElementById("blb2").classList.add('poweredOn');
document.getElementById("blb2").classList.remove('poweredOff');
document.getElementById("swt2").classList.add('btnActive');
bit2 = true;
denary = denary + 2;
updateBinary();
}
}
function changeClass1(){
if (bit1){
document.getElementById("blb1").classList.add('poweredOff');
document.getElementById("blb1").classList.remove('poweredOn');
document.getElementById("swt1").classList.remove('btnActive');
bit1 = false;
denary = denary - 1;
updateBinary();
}else{
document.getElementById("blb1").classList.add('poweredOn');
document.getElementById("blb1").classList.remove('poweredOff');
document.getElementById("swt1").classList.add('btnActive');
bit1 = true;
denary = denary + 1;
updateBinary();
}
}
function updateBinary(){
binary = ""
if(bit256){
binary = binary + "1"
}else{
binary = binary + "0"
}
if(bit128){
binary = binary + "1"
}else{
binary = binary + "0"
}
if(bit64){
binary = binary + "1"
}else{
binary = binary + "0"
}
if(bit32){
binary = binary + "1"
}else{
binary = binary + "0"
}
if(bit16){
binary = binary + "1"
}else{
binary = binary + "0"
}
if(bit8){
binary = binary + "1"
}else{
binary = binary + "0"
}
if(bit4){
binary = binary + "1"
}else{
binary = binary + "0"
}
if(bit2){
binary = binary + "1"
}else{
binary = binary + "0"
}
if(bit1){
binary = binary + "1"
}else{
binary = binary + "0"
}
document.getElementById("denaryNumber").innerHTML = denary;
document.getElementById("binaryNumber").innerHTML = binary;
}
function convertToBinary(num){
var result = ""
if(num-8>=0){
num = num-8;
result = result + "1";
}else{
result = result + "0";
}
if(num-4>=0){
num = num-4;
result = result + "1";
}else{
result = result + "0";
}
if(num-2>=0){
num = num-2;
result = result + "1";
}else{
result = result + "0";
}
if(num-1>=0){
num = num-1;
result = result + "1";
}else{
result = result + "0";
}
return result
}
function binaryParser(binaryPattern){
for (let i = 0; i < binaryPattern.length; i++) {
if ((binaryPattern[i] == 0) || (binaryPattern[i] == 1)){
validInput = true;
}else{
validInput = false;
alert("Invalid pattern! Digit\n"+ i+" is not a 0 or a 1.\nIt is a "+ binaryPattern[i]);
return validInput
};
};
return validInput;
}
function customBinaryParser(binaryPattern){
resetBinarySimulator();
missingDigits = 9 - binaryPattern.length
for (let j = 0; j < missingDigits; j++){
binaryPattern = 0 + binaryPattern;
};
for (let i = 0; i < binaryPattern.length; i++) {
if (binaryPattern[i] == 1){
if (i == 0){
changeClass256();
}else if (i == 1){
changeClass128();
}else if (i == 2){
changeClass64();
}else if (i == 3){
changeClass32();
}else if (i == 4){
changeClass16();
}else if (i == 5){
changeClass8();
}else if (i == 6){
changeClass4();
}else if (i == 7){
changeClass2();
}else if (i == 8){
changeClass1();
}
}
}
}
function requestBinary(){
do{
customBinary = prompt("Please enter your 9-bit Binary Value");
if (customBinary){
var binaryLength = customBinary.length;
}else{
var binaryLength = 0;
};
do{
if (binaryLength>9){
customBinary = prompt("Too many digits.\n\nPlease enter your 9-bit Binary Value");
if (customBinary){
binaryLength = customBinary.length;
}else{
binaryLength = 0;
};
};
} while (binaryLength > 9);
let validInput = binaryParser(customBinary);
} while (!validInput);
customBinaryParser(customBinary);
}
function customDenaryParser(customDenary){
resetBinarySimulator();
let columnValues = [256,128,64,32,16,8,4,2,1]
for (let i = 0; i < 10; i++) {
if (!(customDenary-columnValues[i] < 0)){
customDenary = customDenary - columnValues[i];
if (i == 0){
changeClass256();
}else if (i == 1){
changeClass128();
}else if (i == 2){
changeClass64();
}else if (i == 3){
changeClass32();
}else if (i == 4){
changeClass16();
}else if (i == 5){
changeClass8();
}else if (i == 6){
changeClass4();
}else if (i == 7){
changeClass2();
}else if (i == 8){
changeClass1();
}
if (customDenary == 0){
break;
}
}
}
}
function requestDenary(){
customDenary = prompt("Please enter your Denary Value\nMax value is 511");
do{
if (customDenary > 511){
customDenary = prompt("Number too large.\n\nPlease enter your Denary Value.\nMax value is 511");
};
} while (customDenary > 511);
customDenaryParser(customDenary);
}

View File

@@ -0,0 +1,61 @@
(function() {
"use strict"; // Start of use strict
function initParallax() {
if (!('requestAnimationFrame' in window)) return;
if (/Mobile|Android/.test(navigator.userAgent)) return;
var parallaxItems = document.querySelectorAll('[data-bss-parallax]');
if (!parallaxItems.length) return;
var defaultSpeed = 0.5;
var visible = [];
var scheduled;
window.addEventListener('scroll', scroll);
window.addEventListener('resize', scroll);
scroll();
function scroll() {
visible.length = 0;
for (var i = 0; i < parallaxItems.length; i++) {
var rect = parallaxItems[i].getBoundingClientRect();
var speed = parseFloat(parallaxItems[i].getAttribute('data-bss-parallax-speed'), 10) || defaultSpeed;
if (rect.bottom > 0 && rect.top < window.innerHeight) {
visible.push({
speed: speed,
node: parallaxItems[i]
});
}
}
cancelAnimationFrame(scheduled);
if (visible.length) {
scheduled = requestAnimationFrame(update);
}
}
function update() {
for (var i = 0; i < visible.length; i++) {
var node = visible[i].node;
var speed = visible[i].speed;
node.style.transform = 'translate3d(0, ' + (-window.scrollY * speed) + 'px, 0)';
}
}
}
initParallax();
})(); // End of use strict

View File

@@ -0,0 +1,300 @@
denary = 0
redDenary = 0
greenDenary = 0
blueDenary = 0
redBinary = ""
greenBinary = ""
blueBinary = ""
hexadecimal = ""
placeR1 = 0
placeR16 = 0
placeG1 = 0
placeG16 = 0
placeB1 = 0
placeB16 = 0
function resetColours(){
resetPlaceR16();
resetPlaceR1();
resetPlaceG16();
resetPlaceG1();
resetPlaceB16();
resetPlaceB1();
}
function resetPlaceR16(){
placeR16 = 0
var lightR16 = (100/15 * placeR16) / 100
document.getElementById("blbR2").style.opacity = lightR16;
updateColours();
}
function resetPlaceR1(){
placeR1 = 0
var lightR1 = (100/15 * placeR1) / 100
document.getElementById("blbR1").style.opacity = lightR1;
updateColours();
}
function resetPlaceG16(){
placeG16 = 0
var lightG16 = (100/15 * placeG16) / 100
document.getElementById("blbG2").style.opacity = lightG16;
updateColours();
}
function resetPlaceG1(){
placeG1 = 0
var lightG1 = (100/15 * placeG1) / 100
document.getElementById("blbG1").style.opacity = lightG1;
updateColours();
}
function resetPlaceB16(){
placeB16 = 0
var lightB16 = (100/15 * placeB16) / 100
document.getElementById("blbB2").style.opacity = lightB16;
updateColours();
}
function resetPlaceB1(){
placeB1 = 0
var lightB1 = (100/15 * placeB1) / 100
document.getElementById("blbB1").style.opacity = lightB1;
updateColours();
}
function toggleUpR16(){
if (placeR16 >= 0){
if (placeR16 < 15){
placeR16 = placeR16 + 1;
var lightR16 = (100/15 * placeR16) / 100
document.getElementById("blbR2").style.opacity = lightR16;
updateColours();
}
}
}
function toggleDownR16(){
if (placeR16 > 0){
placeR16 = placeR16 - 1;
var lightR16 = (100/15 * placeR16) / 100
document.getElementById("blbR2").style.opacity = lightR16;
updateColours();
}
}
function toggleUpR1(){
if (place1 >= 0){
if (placeR1 < 15){
placeR1 = placeR1 + 1;
var lightR1 = (100/15 * placeR1) / 100
document.getElementById("blbR1").style.opacity = lightR1;
updateColours();
}
}
}
function toggleDownR1(){
if (placeR1 > 0){
placeR1 = placeR1 - 1;
var lightR1 = (100/15 * placeR1) / 100
document.getElementById("blbR1").style.opacity = lightR1;
updateColours();
}
}
function toggleUpG16(){
if (placeG16 >= 0){
if (placeG16 < 15){
placeG16 = placeG16 + 1;
var lightG16 = (100/15 * placeG16) / 100
document.getElementById("blbG2").style.opacity = lightG16;
updateColours();
}
}
}
function toggleDownG16(){
if (placeG16 > 0){
placeG16 = placeG16 - 1;
var lightG16 = (100/15 * placeG16) / 100
document.getElementById("blbG2").style.opacity = lightG16;
updateColours();
}
}
function toggleUpG1(){
if (placeG1 >= 0){
if (placeG1 < 15){
placeG1 = placeG1 + 1;
var lightG1 = (100/15 * placeG1) / 100
document.getElementById("blbG1").style.opacity = lightG1;
updateColours();
}
}
}
function toggleDownG1(){
if (placeG1 > 0){
placeG1 = placeG1 - 1;
var lightG1 = (100/15 * placeG1) / 100
document.getElementById("blbG1").style.opacity = lightG1;
updateColours();
}
}
function toggleUpB16(){
if (placeB16 >= 0){
if (placeB16 < 15){
placeB16 = placeB16 + 1;
var lightB16 = (100/15 * placeB16) / 100
document.getElementById("blbB2").style.opacity = lightB16;
updateColours();
}
}
}
function toggleDownB16(){
if (placeB16 > 0){
placeB16 = placeB16 - 1;
var lightB16 = (100/15 * placeB16) / 100
document.getElementById("blbB2").style.opacity = lightB16;
updateColours();
}
}
function toggleUpB1(){
if (placeB1 >= 0){
if (placeB1 < 15){
placeB1 = placeB1 + 1;
var lightB1 = (100/15 * placeB1) / 100
document.getElementById("blbB1").style.opacity = lightB1;
updateColours();
}
}
}
function toggleDownB1(){
if (placeB1 > 0){
placeB1 = placeB1 - 1;
var lightB1 = (100/15 * placeB1) / 100
document.getElementById("blbB1").style.opacity = lightB1;
updateColours();
}
}
function updateColours(){
hexadecimal = "";
redDenary = 0
greenDenary = 0
blueDenary = 0
redBinary = ""
greenBinary = ""
blueBinary = ""
denary = ((placeR16*16)+(placeR1))+", "+((placeG16*16)+(placeG1))+", "+((placeB16*16)+(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(){
hexadecimal = "#" + convertToHex((15-placeR16)) + convertToHex((15-placeR1)) + convertToHex((15-placeG16)) + convertToHex((15-placeG1)) + convertToHex((15-placeB16)) + convertToHex((15-placeB1));
return hexadecimal;
}
function convertToHex(num){
var remainder = num - 9
if(remainder<=0){
return num.toString();
}else{
if(remainder==1){
return "A";
}else if(remainder == 2){
return "B";
}else if(remainder == 3){
return "C";
}else if(remainder == 4){
return "D";
}else if(remainder == 5){
return "E";
}else if(remainder == 6){
return "F";
}
}
}
function convertToBinary(num){
var result = ""
if(num-8>=0){
num = num-8;
result = result + "1";
}else{
result = result + "0";
}
if(num-4>=0){
num = num-4;
result = result + "1";
}else{
result = result + "0";
}
if(num-2>=0){
num = num-2;
result = result + "1";
}else{
result = result + "0";
}
if(num-1>=0){
num = num-1;
result = result + "1";
}else{
result = result + "0";
}
return result
}
function updateHex(customHex){
if (customHex == null){
resetColours();
}else{
let char = customHex.charAt(0);
if(char == "#"){
customHex = customHex.substring(1);
}
if (isHex(customHex)){
let hexArray = customHex.split('');
placeR1 = parseInt(hexArray[1], 16);
var lightR1 = (100/15 * placeR1) / 100;
document.getElementById("blbR1").style.opacity = lightR1;
placeR16 = parseInt(hexArray[0], 16);
var lightR16 = (100/15 * placeR16) / 100;
document.getElementById("blbR2").style.opacity = lightR16;
placeG1 = parseInt(hexArray[3], 16);
var lightG1 = (100/15 * placeG1) / 100;
document.getElementById("blbG1").style.opacity = lightG1;
placeG16 = parseInt(hexArray[2], 16);
var lightG16 = (100/15 * placeG16) / 100;
document.getElementById("blbG2").style.opacity = lightG16;
placeB1 = parseInt(hexArray[5], 16);
var lightB1 = (100/15 * placeB1) / 100;
document.getElementById("blbB1").style.opacity = lightB1;
placeB16 = parseInt(hexArray[4], 16);
var lightB16 = (100/15 * placeB16) / 100;
document.getElementById("blbB2").style.opacity = lightB16;
updateColours();
}else{
window.alert("Invalid Entry");
resetColours();
}
}
}
function isHex(str) {
regexp = /^[0-9a-fA-F]+$/;
if (regexp.test(str)){
return true;
}else{
return false;
}
}
function requestHex(){
let customHex = prompt("Please enter your Hex Value");
updateHex(customHex);
}
function invertHex(){
customHex = invertedHex();
updateHex(customHex);
}

View File

@@ -0,0 +1,159 @@
denary = 0
binary = ""
hexadecimal = ""
place1 = 0
place16 = 0
place256 = 0
place4096 = 0
slider4096 = document.getElementById("slider4096");
slider256 = document.getElementById("slider256");
let hexadecimalNumber = document.getElementById("hexadecimalNumber").textContent;
let hexLength = hexadecimalNumber.length
if(hexLength==4){
slider4096.addEventListener("change", update4096);
slider256.addEventListener("change", update256);
}
slider16 = document.getElementById("slider16");
slider1 = document.getElementById("slider1");
slider16.addEventListener("change", update16);
slider1.addEventListener("change", update1);
function resetHexadecimal(){
let hexadecimalNumber = document.getElementById("hexadecimalNumber").textContent;
let hexLength = hexadecimalNumber.length;
if(hexLength==4){
resetPlace4096();
resetPlace256();
}
resetPlace16();
resetPlace1();
}
function resetPlace4096(){
place4096 = 0;
document.getElementById("slider4096").value=0;
var light4096 = (100/15 * place4096) / 100;
document.getElementById("blb4").style.opacity = light4096;
updateNumbers();
}
function resetPlace256(){
place256 = 0;
document.getElementById("slider256").value=0;
var light256 = (100/15 * place256) / 100;
document.getElementById("blb3").style.opacity = light256;
updateNumbers();
}
function resetPlace16(){
place16 = 0;
document.getElementById("slider16").value=0;
var light16 = (100/15 * place16) / 100;
document.getElementById("blb2").style.opacity = light16;
updateNumbers();
}
function resetPlace1(){
place1 = 0;
document.getElementById("slider1").value=0;
var light1 = (100/15 * place1) / 100;
document.getElementById("blb1").style.opacity = light1;
updateNumbers();
}
function update4096(){
place4096 = document.getElementById("slider4096").value;
var light4096 = (100/15 * place4096) / 100;
document.getElementById("blb4").style.opacity = light4096;
updateNumbers();
}
function update256(){
place256 = document.getElementById("slider256").value;
var light256 = (100/15 * place256) / 100;
document.getElementById("blb3").style.opacity = light256;
updateNumbers();
}
function update16(){
place16 = document.getElementById("slider16").value;
var light16 = (100/15 * place16) / 100;
document.getElementById("blb2").style.opacity = light16;
updateNumbers();
}
function update1(){
place1 = document.getElementById("slider1").value;
var light1 = (100/15 * place1) / 100;
document.getElementById("blb1").style.opacity = light1;
updateNumbers();
}
function updateNumbers(){
binary = "";
hexadecimal = "";
let hexadecimalNumber = document.getElementById("hexadecimalNumber").textContent;
let hexLength = hexadecimalNumber.length;
if(hexLength==4){
denary = (place4096*4096)+(place256*256)+(place16*16)+(place1);
hexadecimal = convertToHex(place4096) + convertToHex(place256) + convertToHex(place16) + convertToHex(place1);
binary = convertToBinary(place4096) + convertToBinary(place256) + convertToBinary(place16) + convertToBinary(place1);
}else if(hexLength==2){
denary = (place16*16)+(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(num){
var remainder = num - 9;
if(remainder<=0){
return num.toString();
}else{
if(remainder==1){
return "A";
}else if(remainder == 2){
return "B";
}else if(remainder == 3){
return "C";
}else if(remainder == 4){
return "D";
}else if(remainder == 5){
return "E";
}else if(remainder == 6){
return "F";
}
}
}
function convertToBinary(num){
var result = "";
if(num-8>=0){
num = num-8;
result = result + "1";
}else{
result = result + "0";
}
if(num-4>=0){
num = num-4;
result = result + "1";
}else{
result = result + "0";
}
if(num-2>=0){
num = num-2;
result = result + "1";
}else{
result = result + "0";
}
if(num-1>=0){
num = num-1;
result = result + "1";
}else{
result = result + "0";
}
return result
}
function updateHexNumber(){
let hexadecimalNumber = document.getElementById("hexadecimalNumber").textContent;
let hexLength = hexadecimalNumber.length
if(hexLength==4){
update4096();
update256();
}
update16();
update1();
}

View File

@@ -0,0 +1,100 @@
notValue = true
andValue = false
input1 = false
input2 = false
orValue = false
function notGateToggle(){
if (notValue){
document.getElementById("blbNotGate").classList.remove('poweredOn');
document.getElementById("blbNotGate").classList.add('poweredOff');
document.getElementById("swtNotGate").classList.add('btnActive');
notValue = false;
}else{
document.getElementById("blbNotGate").classList.remove('poweredOff');
document.getElementById("blbNotGate").classList.add('poweredOn');
document.getElementById("swtNotGate").classList.remove('btnActive');
notValue = true;
}
}
function input1Toggle(){
if (input1){
input1 = false;
document.getElementById("swtInput1").classList.remove('btnActive');
}else{
input1 = true;
document.getElementById("swtInput1").classList.add('btnActive');
}
let pageHeading = document.getElementById("pageHeading").textContent;
if(pageHeading=="AND Gate"){
andGateUpdate()
}else if(pageHeading=="OR Gate"){
orGateUpdate()
}
}
function input2Toggle(){
if (input2){
input2 = false;
document.getElementById("swtInput2").classList.remove('btnActive');
}else{
input2 = true;
document.getElementById("swtInput2").classList.add('btnActive');
}
let pageHeading = document.getElementById("pageHeading").textContent;
if(pageHeading=="AND Gate"){
andGateUpdate()
}else if(pageHeading=="OR Gate"){
orGateUpdate()
}
}
function andGateUpdate(){
if (input1 && input2){
document.getElementById("blbAndGate").classList.remove('poweredOff');
document.getElementById("blbAndGate").classList.add('poweredOn');
andValue = true;
}else{
if (andValue){
document.getElementById("blbAndGate").classList.remove('poweredOn');
document.getElementById("blbAndGate").classList.add('poweredOff');
andValue = false;
}
}
}
function orGateUpdate(){
if (input1 || input2){
if (!orValue){
document.getElementById("blbOrGate").classList.remove('poweredOff');
document.getElementById("blbOrGate").classList.add('poweredOn');
orValue = true;
}
}else{
if (orValue){
document.getElementById("blbOrGate").classList.remove('poweredOn');
document.getElementById("blbOrGate").classList.add('poweredOff');
orValue = false;
}
}
}
function resetGate(){
let pageHeading = document.getElementById("pageHeading").textContent;
if(pageHeading=="AND Gate" || pageHeading=="OR Gate"){
input1 = false;
document.getElementById("swtInput1").classList.remove('btnActive');
input2 = false;
document.getElementById("swtInput2").classList.remove('btnActive');
if(pageHeading=="AND Gate"){
andGateUpdate()
}else if(pageHeading=="OR Gate"){
orGateUpdate()
};
}else if(pageHeading=="NOT Gate"){
document.getElementById("blbNotGate").classList.add('poweredOn');
document.getElementById("blbNotGate").classList.remove('poweredOff');
document.getElementById("swtNotGate").classList.remove('btnActive');
notValue = false;
};
}