Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions static/js/decrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,26 @@ form.addEventListener('submit', async function(e) {

resultDiv.appendChild(exportXMLBtn);

const exportHTMLBtn = document.createElement('button');
exportHTMLBtn.textContent = 'Exportar como HTML';
exportHTMLBtn.className = 'btn-secondary';
exportHTMLBtn.style.marginTop = '0.5rem';

exportHTMLBtn.onclick = () => exportDecryptAsHTML(
payload.encoding_matrix,
payload.encrypted_matrix,
result.decrypted_message
);

document.getElementById('result').appendChild(exportHTMLBtn);

} catch (error) {
showError(error.message);
}
});

generateBtn.click();

const json = prettyJson(matrixA, 4);

function exportDecryptAsJSON(encodingMatrix, encryptedMatrix, decryptedMessage) {
const json =
`{
Expand All @@ -92,8 +103,6 @@ function exportDecryptAsJSON(encodingMatrix, encryptedMatrix, decryptedMessage)
URL.revokeObjectURL(url);
}

const xml = prettyXML(matrix, tagName);

function exportDecryptAsXML(encodingMatrix, encryptedMatrix, decryptedMessage) {
const xml =
`<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -111,5 +120,40 @@ function exportDecryptAsXML(encodingMatrix, encryptedMatrix, decryptedMessage) {
a.download = 'desencriptacao.xml';
a.click();

URL.revokeObjectURL(url);
}

function exportDecryptAsHTML(encodingMatrix, encryptedMatrix, decryptedMessage) {
const html =
`<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Desencriptação</title>
</head>
<body>
<h1>Operação: Decrypt</h1>

<h2>Matriz de Codificação</h2>
${prettyHTML(encodingMatrix, 'encodingMatrix')}

<h2>Matriz Encriptada</h2>
${prettyHTML(encryptedMatrix, 'encryptedMatrix')}

<h2>Mensagem Desencriptada</h2>
<p style="font-size:1.2rem; padding:1rem; background:#f8f9fa; border-radius:4px;">
${decryptedMessage}
</p>
</body>
</html>`;

const blob = new Blob([html], { type: 'text/html' });
const url = URL.createObjectURL(blob);

const a = document.createElement('a');
a.href = url;
a.download = 'desencriptacao.html';
a.click();

URL.revokeObjectURL(url);
}
45 changes: 41 additions & 4 deletions static/js/determinant.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,25 @@ form.addEventListener('submit', async function(e) {

resultDiv.appendChild(exportXMLBtn);

const exportHTMLBtn = document.createElement('button');
exportHTMLBtn.textContent = 'Exportar como HTML';
exportHTMLBtn.className = 'btn-secondary';
exportHTMLBtn.style.marginTop = '0.5rem';

exportHTMLBtn.onclick = () => exportDeterminantAsHTML(
payload.matrix,
result.result
);

document.getElementById('result').appendChild(exportHTMLBtn);

} catch (error) {
showError(error.message);
}
});

generateBtn.click();

const json = prettyJson(matrixA, 4);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pq está variable foi apagado?


function exportDeterminantAsJSON(matrix, determinant) {
const json =
`{
Expand All @@ -83,8 +93,6 @@ function exportDeterminantAsJSON(matrix, determinant) {
URL.revokeObjectURL(url);
}

const xml = prettyXML(matrix, tagName);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O JSON e XML ainda funciona certo?


function exportDeterminantAsXML(matrix, determinant) {
const xml =
`<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -103,3 +111,32 @@ function exportDeterminantAsXML(matrix, determinant) {

URL.revokeObjectURL(url);
}

function exportDeterminantAsHTML(matrix, determinant) {
const html =
`<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Determinante</title>
</head>
<body>
<h1>Operação: Determinante</h1>

${prettyHTML(matrix, 'Matriz')}

<h2>Resultado</h2>
<p style="font-size:1.5rem; font-family: monospace;">${determinant}</p>
</body>
</html>`;

const blob = new Blob([html], { type: 'text/html' });
const url = URL.createObjectURL(blob);

const a = document.createElement('a');
a.href = url;
a.download = 'determinante.html';
a.click();

URL.revokeObjectURL(url);
}
50 changes: 45 additions & 5 deletions static/js/encrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,27 @@ form.addEventListener('submit', async function(e) {

document.getElementById('result').appendChild(exportXMLBtn);

const exportHTMLBtn = document.createElement('button');
exportHTMLBtn.textContent = 'Exportar como HTML';
exportHTMLBtn.className = 'btn-secondary';
exportHTMLBtn.style.marginTop = '0.5rem';

exportHTMLBtn.onclick = () => exportEncryptAsHTML(
payload.message,
payload.encoding_matrix,
result.encrypted_matrix
);

document.getElementById('result').appendChild(exportHTMLBtn);


} catch (error) {
showError(error.message);
}
});

generateBtn.click();

const json = prettyJson(matrixA, 4);

function exportEncryptAsJSON(message, encodingMatrix, encryptedMatrix) {
const json =
`{
Expand All @@ -90,8 +102,6 @@ function exportEncryptAsJSON(message, encodingMatrix, encryptedMatrix) {
URL.revokeObjectURL(url);
}

const xml = prettyXML(matrix, tagName);

function exportEncryptAsXML(message, encodingMatrix, encryptedMatrix) {
const xml =
`<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -110,4 +120,34 @@ function exportEncryptAsXML(message, encodingMatrix, encryptedMatrix) {
a.click();

URL.revokeObjectURL(url);
}
}

function exportEncryptAsHTML(message, encodingMatrix, encryptedMatrix) {
const html =
`<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Encriptação</title>
</head>
<body>
<h1>Operação: Encriptação</h1>

<h2>Mensagem Original</h2>
<p style="font-size:1.2rem; font-family: monospace;">${message}</p>

${prettyHTML(encodingMatrix, 'Matriz de Codificação')}
${prettyHTML(encryptedMatrix, 'Matriz Encriptada')}
</body>
</html>`;

const blob = new Blob([html], { type: 'text/html' });
const url = URL.createObjectURL(blob);

const a = document.createElement('a');
a.href = url;
a.download = 'encriptacao.html';
a.click();

URL.revokeObjectURL(url);
}
45 changes: 41 additions & 4 deletions static/js/inverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@ form.addEventListener('submit', async function(e) {
);

document.getElementById('result').appendChild(exportXMLBtn);


const exportHTMLBtn = document.createElement('button');
exportHTMLBtn.textContent = 'Exportar como HTML';
exportHTMLBtn.className = 'btn-secondary';
exportHTMLBtn.style.marginTop = '0.5rem';

exportHTMLBtn.onclick = () => exportInverseAsHTML(
payload.matrix,
decimalMatrix(result.result, 2)
);

document.getElementById('result').appendChild(exportHTMLBtn);

} catch (error) {
showError(error.message);
}
Expand Down Expand Up @@ -80,8 +92,6 @@ function exportInverseAsJSON(originalMatrix, inverseMatrix) {
URL.revokeObjectURL(url);
}

const xml = prettyXML(matrix, tagName);

function exportInverseAsXML(originalMatrix, inverseMatrix) {
const xml =
`<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -99,4 +109,31 @@ ${prettyXML(inverseMatrix, 'inverseMatrix')}
a.click();

URL.revokeObjectURL(url);
}
}

function exportInverseAsHTML(originalMatrix, inverseMatrix) {
const html =
`<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Matriz Inversa</title>
</head>
<body>
<h1>Operação: Matriz Inversa</h1>

${prettyHTML(originalMatrix, 'Matriz Original')}
${prettyHTML(inverseMatrix, 'Matriz Inversa')}
</body>
</html>`;

const blob = new Blob([html], { type: 'text/html' });
const url = URL.createObjectURL(blob);

const a = document.createElement('a');
a.href = url;
a.download = 'matriz_inversa.html';
a.click();

URL.revokeObjectURL(url);
}
48 changes: 43 additions & 5 deletions static/js/multiply.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,27 @@ form.addEventListener('submit', async function(e) {
);

document.getElementById('result').appendChild(exportXMLBtn);

const exportHTMLBtn = document.createElement('button');
exportHTMLBtn.textContent = 'Exportar como HTML';
exportHTMLBtn.className = 'btn-secondary';
exportHTMLBtn.style.marginTop = '0.5rem';

exportHTMLBtn.onclick = () => exportMultiplyAsHTML(
payload.matrix_a,
payload.matrix_b,
result.result
);

document.getElementById('result').appendChild(exportHTMLBtn);

} catch (error) {
showError(error.message);
}
});

generateBtn.click();

const json = prettyJson(matrixA, 4);

function exportMultiplyAsJSON(matrixA, matrixB, resultMatrix) {
const json =
`{
Expand All @@ -94,8 +106,6 @@ function exportMultiplyAsJSON(matrixA, matrixB, resultMatrix) {
URL.revokeObjectURL(url);
}

const xml = prettyXML(matrix, tagName);

function exportMultiplyAsXML(matrixA, matrixB, resultMatrix) {
const xml =
`<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -114,4 +124,32 @@ ${prettyXML(resultMatrix, 'result')}
a.click();

URL.revokeObjectURL(url);
}
}

function exportMultiplyAsHTML(matrixA, matrixB, resultMatrix) {
const html =
`<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Multiplicação de Matrizes</title>
</head>
<body>
<h1>Operação: Multiplicação de Matrizes (A × B)</h1>

${prettyHTML(matrixA, 'Matriz A')}
${prettyHTML(matrixB, 'Matriz B')}
${prettyHTML(resultMatrix, 'Resultado')}
</body>
</html>`;

const blob = new Blob([html], { type: 'text/html' });
const url = URL.createObjectURL(blob);

const a = document.createElement('a');
a.href = url;
a.download = 'multiplicacao_matrizes.html';
a.click();

URL.revokeObjectURL(url);
}
Loading