Professional Documents
Culture Documents
Calculation
Suite
by
Christopher Topalian
All Rights Reserved
Copyright 2000-2023
Dedicated
to
God the Father
<!-- Dedicated to God the Father -->
<html>
<head>
<title> Topalian Calculation Suite </title>
function sortByCategoryAndType(whichArray,
whichDirection)
{
// ascending
if (whichDirection == "up")
{
whichArray.sort(function(a, b)
{
return
a.category.localeCompare(b.category) ||
a.type.localeCompare(b.type)
});
}
// descending
else if (whichDirection == "down")
{
whichArray.sort(function(b, a)
{
return
a.category.localeCompare(b.category) ||
a.type.localeCompare(b.type)
});
}
}
function createCalculator(whichItem,
whichAmount)
{
if (document.getElementById("mainDiv"))
{
document.getElementById("mainDiv").remove();
}
//----//
whichAmount =
calculationData[whichItem].amountOfTextBoxes;
//----//
mainDiv.className = "mainDivStyle";
mainDiv.id = "mainDiv";
document.body.append(mainDiv);
//----//
let titleOfCalculator =
document.createElement("div");
titleOfCalculator.className =
"titleOfCalculatorStyle";
titleOfCalculator.innerHTML = '<center>
'+calculationData[whichItem].name+' </center>';
titleOfCalculator.innerHTML += "<br>";
mainDiv.append(titleOfCalculator);
//----//
textBox.id = x;
if (whichAmount == 1)
{
textBox.onkeyup = function()
{
let a =
document.getElementById(0).value;
document.getElementById("textBoxResult").valu
e = eval(calculationData[whichItem].expression);
};
}
if (whichAmount == 2)
{
textBox.onkeyup = function()
{
let a =
document.getElementById(0).value;
let b =
document.getElementById(1).value;
document.getElementById("textBoxResult").valu
e = eval(calculationData[whichItem].expression);
};
}
if (whichAmount == 3)
{
textBox.onkeyup = function()
{
let a =
document.getElementById(0).value;
let b =
document.getElementById(1).value;
let c =
document.getElementById(2).value;
document.getElementById("textBoxResult").valu
e = eval(calculationData[whichItem].expression);
};
}
mainDiv.append(textBox);
}
//----//
if (whichAmount == 1)
{
let titleTextBox =
document.createElement("div");
titleTextBox.innerHTML =
calculationData[whichItem].textBoxOne;
mainDiv.insertBefore(titleTextBox,
document.getElementById(0));
}
if (whichAmount == 2)
{
let titleTextBox =
document.createElement("div");
titleTextBox.innerHTML =
calculationData[whichItem].textBoxOne;
mainDiv.insertBefore(titleTextBox,
document.getElementById(1));
//----//
let titleTextBox2 =
document.createElement("div");
titleTextBox2.innerHTML =
calculationData[whichItem].textBoxTwo;
mainDiv.insertBefore(titleTextBox2,
document.getElementById(2));
}
if (whichAmount == 3)
{
let titleTextBox =
document.createElement("div");
titleTextBox.innerHTML =
calculationData[whichItem].textBoxOne;
mainDiv.insertBefore(titleTextBox,
document.getElementById(1));
//----//
let titleTextBox2 =
document.createElement("div");
titleTextBox2.innerHTML =
calculationData[whichItem].textBoxTwo;
mainDiv.insertBefore(titleTextBox2,
document.getElementById(2));
//----//
let titleTextBox3 =
document.createElement("div");
titleTextBox3.innerHTML =
calculationData[whichItem].textBoxThree;
mainDiv.insertBefore(titleTextBox3,
document.getElementById(4));
}
//----//
let textBoxResult =
document.createElement("textarea");
textBoxResult.id = "textBoxResult";
textBoxResult.placeholder = "Result";
window.onkeyup = function()
{
if
(document.getElementById("textBoxResult").val
ue == "NaN" ||
document.getElementById("textBoxResult").valu
e == "Infinity")
{
document.getElementById("textBoxResult").valu
e = "";
}
else if
(document.getElementById("textBoxResult").val
ue != "NaN" ||
document.getElementById("textBoxResult").valu
e != "Infinity")
{
textResult.innerHTML = '
'+calculationData[whichItem].textBoxResult+' ';
}
}
mainDiv.append(textBoxResult);
//----//
let textResult =
document.createElement("div");
textResult.innerHTML = '
'+calculationData[whichItem].textBoxResult+' ';
mainDiv.append(textResult);
//----//
if (document.getElementById("formulaText"))
{
document.getElementById("formulaText").remov
e();
}
let formulaText =
document.createElement("div");
formulaText.className = "formulaTextStyle";
formulaText.id = "formulaText";
formulaText.innerHTML =
calculationData[whichItem].formula;
document.body.append(formulaText);
//----//
let expressionText =
document.createElement("div");
expressionText.className =
"expressionTextStyle";
expressionText.innerHTML =
calculationData[whichItem].expression;
mainDiv.append(expressionText);
}
//----//
function createMenu()
{
if
(document.getElementById("menuMainDiv"))
{
document.getElementById("menuMainDiv").rem
ove();
}
mainDiv.className = "menuMainDivStyle";
mainDiv.id = "menuMainDiv";
document.body.append(mainDiv);
//----//
let minimizeButton =
document.createElement("button");
minimizeButton.className =
"menuButtonStyle";
minimizeButton.style.position = "absolute";
minimizeButton.style.left = 0 + "px";
minimizeButton.innerHTML = "_";
minimizeButton.onclick = function()
{
// minimize the height of the div to show
only _ □
document.getElementById("menuSubDiv").style.
height = 0 + "px";
};
mainDiv.append(minimizeButton);
//----//
let maximizeButton =
document.createElement("button");
maximizeButton.className =
"menuButtonStyle";
maximizeButton.style.position = "absolute";
maximizeButton.style.left = 30 + "px";
maximizeButton.innerHTML = "□";
maximizeButton.onclick = function()
{
document.getElementById("menuSubDiv").style.
height = 300 + "px";
};
mainDiv.append(maximizeButton);
//----//
subDiv.className = "menuSubDivStyle";
subDiv.id = "menuSubDiv";
subDiv.innerHTML = "<br>";
mainDiv.append(subDiv);
//----//
functionButton.className =
"menuButtonStyle";
functionButton.style.display = "flex";
functionButton.style.flexDirection = "row";
functionButton.innerHTML =
calculationData[x].name;
functionButton.id =
calculationData[x].name;
functionButton.onclick = function()
{
eval(""+calculationData[x].calculatorFunction+""
+ ";");
console.log(""+calculationData[x].calculatorFun
ction+"");
document.getElementById(calculationData[x].na
me).style.borderColor = "rgb(0, 255, 255)";
};
subDiv.append(functionButton);
document.getElementById("menuSubDiv").style.
height = 0 + "px";
}
}
function findIndexByName(whichArray,
whichName)
{
let index = whichArray.findIndex(function(a)
{
return a.name === whichName
});
return index;
}
function createTitleOfApplication()
{
let titleOfApplication =
document.createElement("div");
titleOfApplication.className =
"titleOfApplicationStyle";
titleOfApplication.innerHTML = "<a href =
'https://github.com/christophertopalian' target =
'_blank'> Topalian Calculation Suite </a>";
document.body.append(titleOfApplication);
}
//----//
function whenLoaded()
{
sortByCategoryAndType(calculationData,
"up");
createMenu();
createCalculator(findIndexByName(calculationD
ata, "Addition"), 2);
createTitleOfApplication();
}
</script>
</head>
</body>
</html>
/* Dedicated to God the Father */
/* https://github.com/ChristopherTopalian */
/* style001.css */
body
{
background-color: rgb(40, 40, 40);
font-family: arial;
font-size: 25px;
color: rgb(255, 255, 255);
}
textarea
{
width: 100%;
height: 40px;
padding-left: 10px;
border-radius: 4px;
background-color: rgb(40, 40, 40);
font-size: 20px;
color: rgb(255, 255, 255);
line-height: 30px;
overflow: hidden;
resize: none;
}
br
{
margin-top: 3px;
margin-bottom: 3px;
display: block;
}
a
{
text-decoration: none;
}
a:link
{
color: rgb(255, 255, 255);
}
a:hover
{
color: rgb(0, 255, 255);
}
a:active
{
color: rgb(150, 200, 255);
}
a:visited
{
color: rgb(255, 255, 255);
}
.mainDivStyle
{
position: relative;
top: 10vh;
width: 25vw;
padding-left: 12px;
padding-right: 12px;
padding-top: 12px;
padding-bottom: 12px;
border-style: solid;
border-width: 2px;
border-radius: 5px;
border-color: rgb(255, 255, 255);
display: flex;
flex-direction: column;
align-items: center;
margin: auto;
}
.titleOfCalculatorStyle
{
font-size: 24px;
font-weight: bold;
}
.formulaTextStyle
{
position: absolute;
top: 4vh;
width: 99.5vw;
display: flex;
flex-direction: column;
align-items: center;
margin: auto;
font-size: 25px;
font-weight: bold;
}
.expressionTextStyle
{
position: absolute;
top: 60vh;
width: 70vw;
display: flex;
flex-direction: column;
align-items: center;
margin: auto;
font-size: 30px;
font-weight: bold;
}
.menuButtonStyle
{
padding: 9px;
margin: 1px;
border-style: solid;
border-width: 1px;
border-color: rgb(100, 100, 100);
border-radius: 3px;
background-color: rgb(0, 0, 0);
font-family: arial;
font-size: 14.5px;
font-weight: bold;
color: rgb(247, 247, 247);
text-align: center;
line-height: 0px;
}
.menuButtonStyle:hover
{
border-color: rgb(255, 255, 255);
background: rgb(0, 0, 0);
}
.menuButtonStyle:active
{
position: relative;
top: 1px;
border-color: rgb(0, 255, 255);
}
.menuMainDivStyle
{
position: fixed;
left: 0px;
top: 22px;
z-index: 1000;
background-color: rgba(0, 0, 0, 0.4);
}
.menuSubDivStyle
{
min-width: 290px;
margin-left: auto;
margin-right: auto;
float: left;
overflow-y: auto;
resize: both;
}
.titleOfApplicationStyle
{
position: fixed;
right: 15px;
top: 5px;
font-size: 18px;
font-weight: bold;
}
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
// data001.js
let calculationData = [
{
name: "Addition",
formula: "Sum = a + b",
expression: "parseFloat(a) + parseFloat(b)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Addition'));",
textBoxOne: "plus",
textBoxTwo: "equals",
textBoxResult: "Result",
amountOfTextBoxes: 2,
category: "arithmetic",
type: "simple"
},
{
name: "Addition of 3",
formula: "Sum = a + b + c",
expression: "parseFloat(a) + parseFloat(b) +
parseFloat(c)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Addition of 3'));",
textBoxOne: "plus",
textBoxTwo: "plus",
textBoxThree: "equals",
textBoxResult: "Result",
amountOfTextBoxes: 3,
category: "arithmetic",
type: "simple"
},
{
name: "Subtraction",
formula: "Difference = a - b",
expression: "a - b",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Subtraction'));",
textBoxOne: "minus",
textBoxTwo: "equals",
textBoxResult: "Result",
amountOfTextBoxes: 2,
category: "arithmetic",
type: "simple"
},
{
name: "Multiplication",
formula: "Product = a * b",
expression: "a * b",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Multiplication'));",
textBoxOne: "multiplied by",
textBoxTwo: "equals",
textBoxResult: "Result",
amountOfTextBoxes: 2,
category: "arithmetic",
type: "simple"
},
{
name: "Division",
formula: "Quotient = a / b",
expression: "a / b",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Division'));",
textBoxOne: "divided by",
textBoxTwo: "equals",
textBoxResult: "Result",
amountOfTextBoxes: 2,
category: "arithmetic",
type: "simple"
},
{
name: "Modulo",
formula: "Remainder = a % b",
expression: "a % b",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Modulo'));",
textBoxOne: "Dividend",
textBoxTwo: "Divisor",
textBoxResult: "Result Remainder",
amountOfTextBoxes: 2,
category: "arithmetic",
type: "simple"
},
{
name: "Percent",
formula: "Percent = (a / b) * 100",
expression: "(a / b) * 100",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Percent'));",
textBoxOne: "is what % of",
textBoxTwo: "Total Value",
textBoxResult: "Result %",
amountOfTextBoxes: 2,
category: "percent",
type: "simple"
},
{
name: "Rectangle Area",
formula: "Area = width * length",
expression: "a * b",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Rectangle Area'));",
textBoxOne: "Width",
textBoxTwo: "Length",
textBoxResult: "Result Area",
amountOfTextBoxes: 2,
category: "geometry",
type: "rectangle"
},
{
name: "Square Area",
formula: "Area = a * a",
expression: "a * a",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Square Area'));",
textBoxOne: "Side",
textBoxResult: "Result Area",
amountOfTextBoxes: 1,
category: "geometry",
type: "square"
},
{
name: "Circle Area from Radius",
formula: "Area = PI * radius^2",
expression: "Math.PI * Math.pow(a, 2)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Circle Area from Radius'));",
textBoxOne: "Radius",
textBoxResult: "Result Area",
amountOfTextBoxes: 1,
category: "geometry",
type: "circle"
},
{
name: "Circle Area from Diameter",
formula: "Area = PI * (diameter / 2)^2",
expression: "Math.PI * Math.pow((a / 2), 2)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Circle Area from Diameter'));",
textBoxOne: "Diameter",
textBoxResult: "Result Area",
amountOfTextBoxes: 1,
category: "geometry",
type: "circle"
},
{
name: "Circle Area from Circumference",
formula: "Area = (circumference^2) / (4 * PI)",
expression: "Math.pow(a, 2) / (4 * Math.PI)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Circle Area from Circumference'));",
textBoxOne: "Circumference",
textBoxResult: "Result Area",
amountOfTextBoxes: 1,
category: "geometry",
type: "circle"
},
{
name: "Circle Circumference from Diameter",
formula: "Circumference = PI * diameter",
expression: "Math.PI * a",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Circle Circumference from Diameter'));",
textBoxOne: "Diameter",
textBoxResult: "Result Circumference",
amountOfTextBoxes: 1,
category: "geometry",
type: "circle"
},
{
name: "Circle Circumference from Radius",
formula: "Circumference = (2 * PI) * radius",
expression: "(2 * Math.PI) * a",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Circle Circumference from Radius'));",
textBoxOne: "Radius",
textBoxResult: "Result Circumference",
amountOfTextBoxes: 1,
category: "geometry",
type: "circle"
},
{
name: "Circle Circumference from Area",
formula: "Circumference = 2 * Square Root PI
* area",
expression: "2 * (Math.sqrt(Math.PI * a))",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Circle Circumference from Area'));",
textBoxOne: "Area",
textBoxResult: "Result Circumference",
amountOfTextBoxes: 1,
category: "geometry",
type: "circle"
},
{
name: "Distance",
// distance = speed * time
formula: "Distance = (mph * minutes) / 60",
expression: "(a * b) / 60",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Distance'));",
textBoxOne: "Mph",
textBoxTwo: "Minutes",
textBoxResult: "Result Miles",
amountOfTextBoxes: 2,
category: "speed time distance",
type: "distance"
},
{
name: "Speed",
// speed = distance / time
// feet to miles is feet * 0.000189394
// minutes to hours is minutes * 0.166667
formula: "Speed = (feet * 0.000189394) /
(minutes * 0.166667)",
expression: "(a * 0.000189394) / (b *
0.0166667)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Speed'));",
textBoxOne: "Feet",
textBoxTwo: "Minutes",
textBoxResult: "Result Mph",
amountOfTextBoxes: 2,
category: "speed time distance",
type: "speed"
},
{
name: "Time",
// time = distance / time
// feet to miles is feet * 000189394
// mph to mpm is mph * 0.0166667
formula: "Time = (feet * 0.000189394) / (b *
0.0166667)",
expression: "(a * 0.000189394) / (b *
0.0166667)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Time'));",
textBoxOne: "Feet",
textBoxTwo: "MPH",
textBoxResult: "Result Minutes",
amountOfTextBoxes: 2,
category: "speed time distance",
type: "time"
},
{
name: "Recatangle Perimeter",
formula: "Perimeter = (2 * a) + (2 * b);",
expression: "(2 * a) + (2 * b)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Recatangle Perimeter'));",
textBoxOne: "Width",
textBoxTwo: "Length",
textBoxResult: "Result Perimeter",
amountOfTextBoxes: 2,
category: "geometry",
type: "rectangle"
},
{
name: "Square Perimeter",
formula: "Perimeter = 4 * side",
expression: "4 * a",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Square Perimeter'));",
textBoxOne: "Side",
textBoxResult: "Result Perimeter",
amountOfTextBoxes: 1,
category: "geometry",
type: "square"
},
{
name: "Triangle Equilateral Perimeter",
formula: "Perimeter = 3 * side",
expression: "3 * a",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Triangle Equilateral Perimeter'));",
textBoxOne: "Side",
textBoxResult: "Result Perimeter",
amountOfTextBoxes: 1,
category: "geometry",
type: "triangle"
},
{
name: "Triangle Isosceles Perimeter",
formula: "Perimeter = (2 * a) + b",
expression: "(2 * parseFloat(a)) +
parseFloat(b)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Triangle Isosceles Perimeter'));",
textBoxOne: "Leg",
textBoxTwo: "Base",
textBoxResult: "Result Perimeter",
amountOfTextBoxes: 2,
category: "geometry",
type: "triangle"
},
{
name: "Sphere Area from Radius",
formula: "Area = 4 * PI * radius^2",
expression: "4 * Math.PI * Math.pow(a, 2)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Sphere Area from Radius'));",
textBoxOne: "Radius",
textBoxResult: "Result Area",
amountOfTextBoxes: 1,
category: "geometry",
type: "sphere"
},
{
name: "Sphere Radius from Diameter",
formula: "Radius = diameter / 2",
expression: "a / 2",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Sphere Radius from Diameter'));",
textBoxOne: "Diameter",
textBoxResult: "Result Radius",
amountOfTextBoxes: 1,
category: "geometry",
type: "sphere"
},
{
name: "Sphere Volume from Radius",
formula: "Volume = (4 / 3 * Math.PI) *
Math.pow(radius, 3.0)",
expression: "(4 / 3 * Math.PI) * Math.pow(a,
3.0)",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Sphere Volume from Radius'));",
textBoxOne: "Radius",
textBoxResult: "Result Volume",
amountOfTextBoxes: 1,
category: "geometry",
type: "sphere"
},
{
name: "Celsius to Fahrenheit",
formula: "Fahrenheit = (celsius * 1.8) + 32",
expression: "(a * 1.8) + 32",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Celsius to Fahrenheit'));",
textBoxOne: "Celsius",
textBoxResult: "Result Fahrenheit",
amountOfTextBoxes: 1,
category: "conversion",
type: "temperature"
},
{
name: "Fahrenheit to Celsius",
formula: "Celsius = 5 * (fahrenheit - 32) / 9;",
expression: "5 * (a - 32) / 9",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Fahrenheit to Celsius'));",
textBoxOne: "Fahrenheit",
textBoxResult: "Result Celsius",
amountOfTextBoxes: 1,
category: "conversion",
type: "temperature"
},
{
name: "Decimal to Percent",
formula: "Percent = decimal * 100",
expression: "a * 100",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Decimal to Percent'));",
textBoxOne: "Decimal",
textBoxResult: "Result Percent",
amountOfTextBoxes: 1,
category: "conversion",
type: "percent"
},
{
name: "Percent to Decimal",
formula: "Decimal = percent / 100",
expression: "a / 100",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Percent to Decimal'));",
textBoxOne: "Percent",
textBoxResult: "Result Decimal",
amountOfTextBoxes: 1,
category: "conversion",
type: "percent"
},
{
name: "Mph to Kph",
formula: "Kph = mph * 1.60934",
expression: "a * 1.60934",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Mph to Kph'));",
textBoxOne: "Mph",
textBoxResult: "Result Kph",
amountOfTextBoxes: 1,
category: "conversion",
type: "speed"
},
{
name: "Kph to Mph",
formula: "Mph = kph * 0.621371",
expression: "a * 0.621371",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Kph to Mph'));",
textBoxOne: "Kph",
textBoxResult: "Result Mph",
amountOfTextBoxes: 1,
category: "conversion",
type: "speed"
},
{
name: "Feet to Meter",
formula: "Meter = feet * 0.3048",
expression: "a * 0.3048",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Feet to Meter'));",
textBoxOne: "Feet",
textBoxResult: "Result Meter",
amountOfTextBoxes: 1,
category: "conversion",
type: "distance"
},
{
name: "Meter to Feet",
formula: "Feet = meters * 3.28084",
expression: "a * 3.28084",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Meter to Feet'));",
textBoxOne: "Meter",
textBoxResult: "Result Feet",
amountOfTextBoxes: 1,
category: "conversion",
type: "distance"
},
{
name: "Percent of Hour",
formula: "PercentOfHour = (minute * 100) /
60",
expression: "(a * 100) / 60",
calculatorFunction:
"createCalculator(findIndexByName(calculation
Data, 'Percent of Hour'));",
textBoxOne: "Minutes",
textBoxResult: "Result Percent of Hour",
amountOfTextBoxes: 1,
category: "percent",
type: "time"
}
];
For More Tutorials:
CollegeOfScripting.weebly.com
CollegeOfScripting.wordpress.com
GitHub.com/ChristopherTopalian
Youtube.com/ScriptingCollege
Twitter.com/CollegeOfScript
Sites.google.com/view/
CollegeOfScripting
Dedicated to God the Father
This book is created by the
College of Scripting Music & Science.
Always remember, that each time you write a script with
a pencil and paper, it becomes imprinted so deeply in
memory that the material and methods are learned
extremely well.
When you Type the scripts, the same is true. The more
you type and write out the scripts by keyboard or pencil
and paper, the more you will learn programming!