Skip to content

Commit

Permalink
Add copy message to web page
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed Jan 12, 2025
1 parent 98db077 commit 5679ae1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
padding-bottom: 3px;
padding-left: 14px;
padding-right: 14px;
cursor: pointer;
}
.textRow {
display: flex;
Expand Down Expand Up @@ -96,6 +97,11 @@
margin-top: 0px;
margin-bottom: 0px;
}
.copyMessage {
color: var(--col-light);
margin-left: 12px;
font-size: 18px;
}
@media (max-width: 800px) {
.logo {
display: none;
Expand All @@ -115,6 +121,7 @@ <h2> An extremely fast LaTeX formatter </h2>
<div>
<button id="formatButton">Format</button>
<button id="copyButton">Copy output to clipboard</button>
<span class=copyMessage id="copyMessage"></span>
</div>
</div>

Expand Down
6 changes: 5 additions & 1 deletion web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import init, { main } from './pkg/tex_fmt.js';
// Submit button logic
document.getElementById('formatButton').addEventListener(
'click', async () => {
const copyMessage = document.getElementById('copyMessage');
copyMessage.innerText = ""
const inputText = document.getElementById('inputText').value;
const outputText = document.getElementById('outputText');
const logText = document.getElementById('logText');
Expand All @@ -38,7 +40,9 @@ document.getElementById('copyButton').addEventListener(
outputText.setSelectionRange(0, 99999);
try {
document.execCommand('copy');
alert('Copied to clipboard:\n\n' + outputText.value);
const copyMessage = document.getElementById('copyMessage');
copyMessage.innerText = "Copied!"
outputText.blur();
} catch (err) {
console.error('Failed to copy text: ', err);
}
Expand Down

0 comments on commit 5679ae1

Please sign in to comment.