24.09.2026
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
function setSize(varWidth, varHeight){
|
||||
var box = document.getElementById("webBoxSel");
|
||||
var boxHeight = (varHeight / 2);
|
||||
var boxwidth = (varWidth / 2);
|
||||
let box = document.getElementById("webBoxSel");
|
||||
let boxHeight = (varHeight / 2);
|
||||
let boxWidth = (varWidth / 2);
|
||||
|
||||
if(boxHeight >= 300)
|
||||
if((boxHeight >= 300) && (boxWidth >= 300))
|
||||
{
|
||||
box.style.backgroundColor = 'red';
|
||||
}else{
|
||||
box.style.backgroundColor = 'yellow';
|
||||
}
|
||||
|
||||
box.style.width = boxwidth+'px';
|
||||
box.style.width = boxWidth+'px';
|
||||
box.style.height = boxHeight+'px';
|
||||
|
||||
var textInBox = document.getElementById("boxText");
|
||||
let textInBox = document.getElementsByClassName('boxTextClass')[0];
|
||||
|
||||
textInBox.style.color = 'blue';
|
||||
textInBox.style.margin = '25%';
|
||||
@@ -32,5 +32,130 @@ window.addEventListener("resize", function (){
|
||||
const varW = window.outerWidth;
|
||||
const varH = window.outerHeight;
|
||||
setSize(varW, varH);
|
||||
})
|
||||
});
|
||||
|
||||
document.getElementById("textValueBtn").addEventListener('click', function(){
|
||||
let textInBox = document.getElementById("boxTextID");
|
||||
let changeText = document.getElementById("textValue").value;
|
||||
|
||||
|
||||
if(changeText.length == 0)
|
||||
{
|
||||
alert("Text: Not a valid text for this action.")
|
||||
}else{
|
||||
textInBox.innerText = changeText;
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("textSizeBtn").addEventListener('click', function(){
|
||||
let textInBox = document.getElementById("boxTextID");
|
||||
let changeSize = document.getElementById("textSize").value;
|
||||
|
||||
if(!isNaN(changeSize))
|
||||
{
|
||||
alert("Size: Not a valid number for this action.")
|
||||
}else{
|
||||
textInBox.style.fontSize = changeSize+"px";
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("textAngleBtn").addEventListener('click', function(){
|
||||
let textInBox = document.getElementById("boxTextID");
|
||||
let changeAngle = document.getElementById("textAngle").value;
|
||||
|
||||
if(!isNaN(changeAngle))
|
||||
{
|
||||
alert("Angle: Not a valid number for this action.")
|
||||
}else{
|
||||
textInBox.style.transform = "rotate("+changeAngle+"deg)";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
document.getElementById("startBinCalc").addEventListener('click', function(){
|
||||
let dezNumberToBin1 = tryParseInt(document.getElementById("binValue1").value);
|
||||
let dezNumberToBin2 = tryParseInt(document.getElementById("binValue2").value);
|
||||
|
||||
if(isNaN(dezNumberToBin1) || isNaN(dezNumberToBin2))
|
||||
{
|
||||
alert("BinaryNumberAddition: At least one number is not valid for this action.")
|
||||
}else{
|
||||
let bin1 = calcDezToBin(dezNumberToBin1);
|
||||
let bin2 = calcDezToBin(dezNumberToBin2);
|
||||
|
||||
additionTwoBinNumbers(bin1, bin2);
|
||||
|
||||
|
||||
document.getElementById('binCalcResult').innerText = bin1 + " - " + bin2;
|
||||
}
|
||||
});
|
||||
|
||||
function calcDezToBin(dezNumber){
|
||||
|
||||
let tempNumber = dezNumber;
|
||||
let remainderString = "";
|
||||
|
||||
let lastNumber = 0;
|
||||
|
||||
while(tempNumber != 0)
|
||||
{
|
||||
lastNumber = Math.floor(tempNumber/2);
|
||||
remainderString += tempNumber%2;
|
||||
tempNumber = lastNumber;
|
||||
}
|
||||
|
||||
let binaryValue = flipBinString(remainderString);
|
||||
return binaryValue;
|
||||
//document.getElementById('binCalcResult').innerText = binaryValue;
|
||||
}
|
||||
|
||||
function tryParseInt(str) {
|
||||
let retValue = null;
|
||||
if(str !== null) {
|
||||
if(str.length > 0) {
|
||||
if (!isNaN(str)) {
|
||||
retValue = parseInt(str);
|
||||
return retValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function flipBinString(remainderString)
|
||||
{
|
||||
let count = remainderString.length;
|
||||
let remainders = [count];
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
remainders[i] = remainderString[i];
|
||||
}
|
||||
let returnVal = remainders.reverse().join('');
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
function additionTwoBinNumbers(bin1, bin2)
|
||||
{
|
||||
let bin1Array = bin1.split("");
|
||||
let bin2Array = bin2.split("");
|
||||
let tempResult = "";
|
||||
|
||||
if(bin1Array.length < bin2Array.length)
|
||||
for(i = 0; i < bin2Array.length; i++)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
for(i = 0; i < bin1Array.length; i++)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user