Skip to content

Commit

Permalink
🎨 add favicon and remove imports to user can download local
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendon3578 committed May 2, 2024
1 parent 319b817 commit 7a6a507
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 36 deletions.
Binary file added src/assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sistemas Lineares</title>
<link rel="icon" type="image/png" href="./assets/favicon.png" />
<title>Resolver Sistemas Lineares e Classificação</title>
<link rel="stylesheet" href="./styles/output.css" />
</head>
<body
Expand Down Expand Up @@ -174,6 +175,8 @@ <h4 class="mb-1">Resultado das Determinantes:</h4>
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"
></script>

<script src="./scripts/script.js" type="module" defer></script>
<script src="./scripts/utils.js" defer></script>
<script src="./scripts/classes/MathJaxHTMLWriter.js" defer></script>
<script src="./scripts/script.js" defer></script>
</body>
</html>
54 changes: 52 additions & 2 deletions src/scripts/classes/MathJaxHTMLWriter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { elementExists, isNumber } from "../utils.js";
// import { elementExists, isNumber } from "../utils.js";

/**
* Classe para escrever representações HTML de sistemas lineares usando MathJax.
*/
class MathJaxHTMLWriter {
#matrixIllustrationEl;
#linearSystemIllustrationEl;

/**
* Cria uma instância de MathJaxHTMLWriter.
* @param {HTMLElement} matrixIllustrationEl - O elemento HTML onde a representação da matriz será desenhada.
* @param {HTMLElement} linearSystemIllustrationEl - O elemento HTML onde a representação do sistema linear será desenhada.
* @throws {Error} Se os elementos fornecidos não existirem.
*/
constructor(matrixIllustrationEl, linearSystemIllustrationEl) {
if (
(elementExists(matrixIllustrationEl) &&
Expand All @@ -19,10 +28,17 @@ class MathJaxHTMLWriter {
this.drawInitial2x2MatrixRepresentationAndLinearSystem();
}

/**
* Atualiza o display engine MathJax no HTML.
* @returns {Promise<void>} Uma promessa que é resolvida quando a renderização é concluída.
*/
async updateMathJax() {
await MathJax.typesetPromise();
}

/**
* Desenha a representação inicial de uma matriz 2x2 e um sistema linear.
*/
drawInitial2x2MatrixRepresentationAndLinearSystem() {
const initialCoefficientMatrix = [
["a", "b"],
Expand All @@ -38,6 +54,9 @@ class MathJaxHTMLWriter {
this.drawn2x2LinearSystem(initialCoefficientMatrix, initialConstantMatrix);
}

/**
* Desenha a representação inicial de uma matriz 3x3 e um sistema linear.
*/
drawInitial3x3MatrixRepresentationAndLinearSystem() {
const initialCoefficientMatrix = [
["a", "b", "c"],
Expand Down Expand Up @@ -92,6 +111,11 @@ class MathJaxHTMLWriter {
return modifiedMatrix;
}

/**
* Desenha a representação matricial de uma matriz 2x2.
* @param {Array<Array<number|string>>} coefficientMatrix - A matriz de coeficientes.
* @param {Array<string>} constantMatrix - A matriz de constantes.
*/
drawn2x2MatrixRepresentation(coefficientMatrix, constantMatrix) {
const [a, b] = coefficientMatrix[0];
const [c, d] = coefficientMatrix[1];
Expand All @@ -103,13 +127,24 @@ class MathJaxHTMLWriter {
`;
}

/**
* Escreve a representação de uma matriz 2x2.
* @param {Array<Array<number|string>>} matrix - A matriz a ser representada.
* @returns {string} A representação escrita em MathJax da matriz.
*/
write2x2Matrix(matrix) {
const [a, b] = matrix[0];
const [c, d] = matrix[1];
return `
\\( \\begin{bmatrix} ${a} & ${b}\\\\ ${c} & ${d}\
\\end{bmatrix} \\)`;
}

/**
* Escreve a representação de uma matriz 3x3.
* @param {Array<Array<number|string>>} matrix - A matriz a ser representada.
* @returns {string} A representação escrita em MatJax da matriz.
*/
write3x3Matrix(matrix) {
const [a, b, c] = matrix[0];
const [d, e, f] = matrix[1];
Expand All @@ -119,6 +154,11 @@ class MathJaxHTMLWriter {
\\end{bmatrix} \\)`;
}

/**
* Desenha a representação de uma matriz 3x3.
* @param {Array<Array<number|string>>} coefficientMatrix - A matriz de coeficientes.
* @param {Array<string>} constantMatrix - A matriz de constantes.
*/
drawn3x3MatrixRepresentation(coefficientMatrix, constantMatrix) {
const [a, b, c] = coefficientMatrix[0];
const [d, e, f] = coefficientMatrix[1];
Expand All @@ -131,6 +171,11 @@ class MathJaxHTMLWriter {
`;
}

/**
* Desenha a representação de um sistema linear 2x2.
* @param {Array<Array<number|string>>} coefficientMatrix - A matriz de coeficientes.
* @param {Array<string>} constantMatrix - A matriz de constantes.
*/
drawn2x2LinearSystem(coefficientMatrix, constantMatrix) {
const matrix = this.#stringifyMatrixElements(coefficientMatrix.slice());

Expand All @@ -145,6 +190,11 @@ class MathJaxHTMLWriter {
this.updateMathJax();
}

/**
* Desenha a representação de um sistema linear 3x3.
* @param {Array<Array<number|string>>} coefficientMatrix - A matriz de coeficientes.
* @param {Array<string>} constantMatrix - A matriz de constantes.
*/
drawn3x3LinearSystem(coefficientMatrix, constantMatrix) {
const matrix = this.#stringifyMatrixElements(coefficientMatrix.slice());

Expand All @@ -162,4 +212,4 @@ class MathJaxHTMLWriter {
}
}

export { MathJaxHTMLWriter };
// export { MathJaxHTMLWriter };
Empty file removed src/scripts/classes/Matrix.js
Empty file.
36 changes: 19 additions & 17 deletions src/scripts/script.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { MathJaxHTMLWriter } from "./classes/MathJaxHTMLWriter.js";
import {
areAllDeterminantsZero,
generateRandomNumber,
hasDeterminantsNotEqualsZero,
isDeterminantEqualsZero,
isEquationValid,
isInfinity,
isNumber,
log,
roundToThreeDecimalPlaces,
writeMatrix,
} from "./utils.js";
// import { MathJaxHTMLWriter } from "./classes/MathJaxHTMLWriter.js";
// import {
// areAllDeterminantsZero,
// generateRandomNumber,
// hasDeterminantsNotEqualsZero,
// isDeterminantEqualsZero,
// isEquationValid,
// isInfinity,
// isNumber,
// log,
// roundToThreeDecimalPlaces,
// writeMatrix,
// } from "./utils.js";

/**
* @type { HTMLInputElement }
Expand All @@ -35,13 +35,12 @@ const mathJaxHTMLWriter = new MathJaxHTMLWriter(

function showStatusMessage(status, message) {
statusMessageEl.classList.value = "";
statusMessageEl.innerText = message;
switch (status) {
case "success":
statusMessageEl.innerText = message;
statusMessageEl.classList.value = "text-green-700 font-bold";
break;
case "error":
statusMessageEl.innerText = message;
statusMessageEl.classList.value = "text-red-600 font-bold";
break;
}
Expand Down Expand Up @@ -410,8 +409,11 @@ function solve3x3System(coeffs_eq1, coeffs_eq2, coeffs_eq3) {
}

/**
* @param {string} eq
* @returns
* Extrai os coeficientes de uma equação linear.
* @param {string} eq - A equação linear a ser analisada.
* @param {HTMLElement} [elementToFocusIfError] - O elemento HTML para focar se houver um erro, no qual será focado.
* @returns {Array<number>} Um array contendo os coeficientes da equação.
* @throws {Error} Se houver um erro durante a extração dos coeficientes ou se a equação não estiver formatada corretamente.
*/
function extractCoefficients(eq, elementToFocusIfError) {
let unknowns = ["x", "y"];
Expand Down
30 changes: 15 additions & 15 deletions src/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,18 @@ function generateRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}

export {
isMatrixNxN,
isNumber,
log,
writeMatrix,
elementExists,
roundToThreeDecimalPlaces,
isDeterminantEqualsZero,
isDeterminantNotEqualsZero,
areAllDeterminantsZero,
hasDeterminantsNotEqualsZero,
isInfinity,
isEquationValid,
generateRandomNumber,
};
// export {
// isMatrixNxN,
// isNumber,
// log,
// writeMatrix,
// elementExists,
// roundToThreeDecimalPlaces,
// isDeterminantEqualsZero,
// isDeterminantNotEqualsZero,
// areAllDeterminantsZero,
// hasDeterminantsNotEqualsZero,
// isInfinity,
// isEquationValid,
// generateRandomNumber,
// };

0 comments on commit 7a6a507

Please sign in to comment.