JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<table class="table_main">
<thead>
<tr>
<td class="cell_header" colspan="2">Szyfrator v1.1</td>
</tr>
</thead>
<tbody>
<!-- POCZĄTEK MODUŁU SZYFRUJĄCEGO -->
<tr class="module_encryption">
<td colspan="2" class="module_header">
MODUŁ SZYFRUJĄCY
</td>
</tr>
<tr class="module_encryption">
<td class="cell_buttons">
<input type="button" class="button" id="encode_button_reveal" value="Ujawnij wynik">
<input type="button" class="button" id="encode_button_hide" value="Ponownie ukryj wynik">
<hr style="visibility:hidden;">
<input type="button" class="button button_copy" id="encode_button_copy" disabled value="Skopiuj wynik do schowka">
<hr>
<input type="button" class="button" id="encode_button_clear" value="Wyczyść">
</td>
<td class="cell_textareas">
<textarea class="area" id="encode_input" autofocus></textarea>
<textarea class="area" id="encode_output" readonly></textarea>
</td>
</tr>
<tr class="module_encryption">
<td class="cell_status" colspan="2"></td>
</tr>
<!-- KONIEC MODUŁU SZYFRUJĄCEGO -->
<tr><td class="cell_spacer" colspan="2"></td></tr>
<!-- POCZĄTEK MODUŁU DESZYFRUJĄCEGO -->
<tr class="module_decryption">
<td colspan="2" class="module_header">
MODUŁ DESZYFRUJĄCY
</td>
</tr>
<tr class="module_decryption">
<td class="cell_buttons">
<input type="button" class="button button_copy" id="decode_button_copy" disabled value="Skopiuj wynik do schowka">
<hr>
<input type="button" class="button" id="decode_button_clear" value="Wyczyść">
</td>
<td class="cell_textareas">
<textarea class="area" id="decode_input" autofocus></textarea>
<textarea class="area" id="decode_output" readonly></textarea>
</td>
</tr>
<tr class="module_decryption">
<td class="cell_status" colspan="2"></td>
</tr>
<!-- KONIEC MODUŁU SZYFRUJĄCEGO -->
</tbody>
</table>
</body>
CSS
.table_main {
width: 640px;
border: none;
margin: 0 auto;
border-collapse: collapse;
}
.module_encryption td {
margin: 0;
background-color: lightgreen;
}
.module_decryption td {
margin: 0;
background-color: lightblue;
}
.module_header {
text-align: center;
}
.cell_header {
text-align: center;
font-weight: bold;
padding-bottom: 20px;
}
.cell_buttons {
width: 200px;
text-align: center;
}
.cell_textareas {
text-align: center;
}
.cell_status {
height: 20px;
}
.cell_spacer {
height: 10px;
}
.button {
width: 190px;
border: 1px solid black;
}
.button_copy {
background-color: #FF5510;
}
.button_paste {
background-color: #00FF10;
}
.area {
width: 200px;
height: 200px;
resize: none;
}
#encode_input {
border: none !important;
background:
...
JavaScript
var event_input = new Event("input", {
view: window,
bubbles: true,
cancelable: true
});
{
document.addEventListener(
"DOMContentLoaded",
function() {
document.getElementById("encode_input").value = "";
document.getElementById("encode_output").value = "";
document.getElementById("decode_input").value = "";
document.getElementById("decode_output").value = "";
document.getElementById("encode_input").dispatchEvent(event_input);
document.getElementById("decode_input").dispatchEvent(event_input);
}
);
}
//Encryption logic for textareas
{
let encode_input = document.getElementById("encode_input");
let encode_output = document.getElementById("encode_output");
let encode_input_handler = function(e) {
encode_output.value = encode(e.target.value);
if(encode_output.value.length) {
document.getElementById("encode_button_copy").removeAttribute("disabled");
encode_output.style["outline"] = "4px solid yellow";
} else {
document.getElementById("encode_button_copy").setAttribute("disabled", "");
encode_output.style["outline"] = "none";
}
}
encode_input.addEventListener("input", encode_input_handler );
}
//Encryption logic for buttons
{
document.getElementById("encode_button_clear").addEventListener(
"click",
function() {
let encode_input = document.getElementById("encode_input");
document.getElementById("encode_input").value = "";
encode_input.dispatchEvent(event_input);
encode_input.focus();
}
);
document.getElementById("encode_button_reveal").addEventListener(
"click",
function() {
let encode_output = document.getElementById("encode_output");
encode_output.value = reveal(encode_output.value);
document.getElementById("encode_input").focus();
}
);
document.getElementById("encode_button_hide").addEventListener(
"click",
function() {
let encode_output = document.getElementById("encode_output");
encode_output.value =...