Another bug fixinground
This commit is contained in:
@@ -39,7 +39,7 @@ document.getElementById("textValueBtn").addEventListener('click', function(){
|
||||
let changeText = document.getElementById("textValue").value;
|
||||
|
||||
|
||||
if(changeText.length == 0)
|
||||
if(changeText.trim().length === 0)
|
||||
{
|
||||
alert("Text: Not a valid text for this action.")
|
||||
}else{
|
||||
@@ -51,7 +51,7 @@ document.getElementById("textSizeBtn").addEventListener('click', function(){
|
||||
let textInBox = document.getElementById("boxTextID");
|
||||
let changeSize = document.getElementById("textSize").value;
|
||||
|
||||
if(!isNaN(changeSize))
|
||||
if(isNaN(changeSize) || changeSize.trim() === "")
|
||||
{
|
||||
alert("Size: Not a valid number for this action.")
|
||||
}else{
|
||||
@@ -63,7 +63,7 @@ document.getElementById("textAngleBtn").addEventListener('click', function(){
|
||||
let textInBox = document.getElementById("boxTextID");
|
||||
let changeAngle = document.getElementById("textAngle").value;
|
||||
|
||||
if(!isNaN(changeAngle))
|
||||
if(isNaN(changeAngle) || changeAngle.trim() === "")
|
||||
{
|
||||
alert("Angle: Not a valid number for this action.")
|
||||
}else{
|
||||
@@ -76,14 +76,14 @@ 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))
|
||||
if((isNaN(dezNumberToBin1) || isNaN(dezNumberToBin2)) || (dezNumberToBin1 === "" || dezNumberToBin2 === ""))
|
||||
{
|
||||
alert("BinaryNumberAddition: At least one number is not valid for this action.")
|
||||
}else{
|
||||
let bin1 = calcDezToBin(dezNumberToBin1);
|
||||
let bin2 = calcDezToBin(dezNumberToBin2);
|
||||
|
||||
let numbersForText = fillwithZero(bin1.split(''), bin2.split(''));
|
||||
let numbersForText = fillWithZero(bin1.split(''), bin2.split(''));
|
||||
let result = additionTwoBinNumbers(bin1, bin2);
|
||||
|
||||
|
||||
@@ -93,12 +93,17 @@ document.getElementById("startBinCalc").addEventListener('click', function(){
|
||||
|
||||
function calcDezToBin(dezNumber){
|
||||
|
||||
if(dezNumber === 0)
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
|
||||
let tempNumber = dezNumber;
|
||||
let remainderString = "";
|
||||
|
||||
let lastNumber = 0;
|
||||
|
||||
while(tempNumber != 0)
|
||||
while(tempNumber !== 0)
|
||||
{
|
||||
lastNumber = Math.floor(tempNumber/2);
|
||||
remainderString += tempNumber%2;
|
||||
@@ -110,7 +115,7 @@ function calcDezToBin(dezNumber){
|
||||
//document.getElementById('binCalcResult').innerText = binaryValue;
|
||||
}
|
||||
|
||||
function tryParseInt(str) {
|
||||
function tryParseInt(str) { // needs a better solution!
|
||||
let retValue = null;
|
||||
if(str !== null) {
|
||||
if(str.length > 0) {
|
||||
@@ -139,7 +144,7 @@ function flipBinString(remainderString)
|
||||
function additionTwoBinNumbers(bin1, bin2)
|
||||
{
|
||||
|
||||
let binArrays = fillwithZero(bin1.split(''), bin2.split(''));
|
||||
let binArrays = fillWithZero(bin1.split(''), bin2.split(''));
|
||||
let bin1Array = binArrays.first;
|
||||
let bin2Array = binArrays.second;
|
||||
let binOverflow = Array.from({length: bin2Array.length}, (v, k) => '0');
|
||||
@@ -196,11 +201,11 @@ function isLastIndex(index){
|
||||
return index === 0;
|
||||
}
|
||||
|
||||
function fillwithZero(binArray1, binArray2)
|
||||
function fillWithZero(binArray1, binArray2)
|
||||
{
|
||||
let difference = Math.abs(binArray1.length - binArray2.length);
|
||||
|
||||
if(difference != 0)
|
||||
if(difference !== 0)
|
||||
{
|
||||
if(binArray1.length < binArray2.length)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user