Skip to content

Commit

Permalink
add copy to clipboard function
Browse files Browse the repository at this point in the history
  • Loading branch information
ycanas committed Mar 27, 2024
1 parent c8f9e32 commit bd90296
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
6 changes: 6 additions & 0 deletions css/bootstrap.min.css

Large diffs are not rendered by default.

File renamed without changes.
17 changes: 14 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- estilos -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="./styles.css">
<link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="./css/styles.css">
<link rel="icon" type="image/png" href="./img/favicon.png">
<title>Traductor Binario</title>
</head>
Expand All @@ -37,6 +37,16 @@
<!-- JavaScript -->
</div>

<!-- Toast -->
<div class="toast align-items-center position-fixed bottom-0 end-0 border-0 border-bottom border-success m-4 p-1" id="toast" role="alert" aria-live="assertive" aria-atomic="true" data-bs-delay="3000">
<div class="d-flex">
<div class="toast-body fw-medium fs-6">
Resultado Copiado
</div>
<button type="button" class="btn-close btn-close-dark me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>

<!-- infromación -->
<div class="px-5 pt-5 mt-5" style="font-size: 18px;">
<p>
Expand Down Expand Up @@ -91,6 +101,7 @@ <h5>Ejemplo: </h5> <br>
</footer>

<!-- script -->
<script src="./main.js"></script>
<script src="./js/bootstrap.min.js" type="module"></script>
<script src="./js/main.js" type="module"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions js/bootstrap.min.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions main.js → js/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import "./bootstrap.min.js"

const toast = document.getElementById('toast');
const bootstrapToast = bootstrap.Toast.getOrCreateInstance(toast);
const buttonBinary = document.getElementById('buttonBinary');
const buttonText = document.getElementById('buttonText');

Expand All @@ -21,6 +25,8 @@ buttonBinary.onclick = function() {
document.getElementById('inputText').value = "";
divOutput.className = "w-75 mt-1 alert alert-success mx-auto";
divOutput.innerHTML = `${output.trim()}`;
navigator.clipboard.writeText(output.trim());
bootstrapToast.show();
}


Expand Down Expand Up @@ -56,4 +62,6 @@ buttonText.onclick = function() {
document.getElementById('inputText').value = "";
divOutput.className = "w-75 mt-1 alert alert-success mx-auto";
divOutput.innerHTML = `${output.trim()}`;
navigator.clipboard.writeText(output.trim());
bootstrapToast.show();
}

0 comments on commit bd90296

Please sign in to comment.