You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.2 KiB
85 lines
2.2 KiB
var outputs = [];
|
|
var simulator = [];
|
|
var graph = [];
|
|
function run() {
|
|
var input1 = document.getElementById("firstInput").value;
|
|
var input2 = document.getElementById("secondInput").value;
|
|
|
|
if (!input1 || !input2) {
|
|
Toastify({
|
|
text: "Input field cannot be empty!",
|
|
duration: 3000,
|
|
close: true,
|
|
gravity: "top",
|
|
}).showToast();
|
|
} else {
|
|
outputFunction(input1, input2);
|
|
simulatorFunction(input1, input2);
|
|
graphFunction(input1, input2);
|
|
|
|
updateTextarea(getActiveTabContent());
|
|
|
|
var input1 = (document.getElementById("firstInput").value = "");
|
|
var input2 = (document.getElementById("secondInput").value = "");
|
|
|
|
// Query for only the checked checkboxes and put the result in an array
|
|
|
|
//Printing values one by one
|
|
// let checked = document.querySelectorAll("input[type='checkbox']:checked");
|
|
// console.clear();
|
|
// checked.forEach(function (cb) {
|
|
// console.log(cb.value);
|
|
// });
|
|
|
|
//Saving values in array
|
|
let checked = document.querySelectorAll("input[type='checkbox']:checked");
|
|
console.clear();
|
|
let checkedValues = Array.from(checked).map((cb) => cb.value);
|
|
console.log(checkedValues);
|
|
}
|
|
}
|
|
|
|
//Functions
|
|
function simulatorFunction(input1, input2) {
|
|
var result = input1 + input2;
|
|
simulator.push(result);
|
|
}
|
|
|
|
function outputFunction(input1, input2) {
|
|
var result = input1 + " " + input2;
|
|
outputs.push(result);
|
|
}
|
|
function graphFunction(input1, input2) {
|
|
var result = input1 + "-" + input2;
|
|
graph.push(result);
|
|
}
|
|
|
|
function getActiveTabContent() {
|
|
var activeTabId = document.querySelector(".rightNav.active").id;
|
|
switch (activeTabId) {
|
|
case "output":
|
|
return outputs;
|
|
case "simulator":
|
|
return simulator;
|
|
case "graph":
|
|
return graph;
|
|
default:
|
|
return [];
|
|
}
|
|
}
|
|
|
|
function updateTextarea(data) {
|
|
scrollableOutput.innerHTML = data.join("\r\n");
|
|
}
|
|
|
|
// Add click event listeners to tab links
|
|
document.querySelectorAll(".rightNav").forEach((navLink) => {
|
|
navLink.addEventListener("click", function (event) {
|
|
event.preventDefault();
|
|
document.querySelectorAll(".rightNav").forEach((navLink) => {
|
|
navLink.classList.remove("active");
|
|
});
|
|
this.classList.add("active");
|
|
updateTextarea(getActiveTabContent());
|
|
});
|
|
});
|