AndrewPaglusch / FlashPaper

One-time encrypted password/secret sharing
MIT License
377 stars 60 forks source link

Copy Button #56

Closed Zurd closed 2 years ago

Zurd commented 2 years ago

Greetings from reddit :)

I added a Copy button in 2 pages (view_code and view_secret) in case you are interested.

First, in html/view_code.php, doesn't make sense to have a textarea for a URL so here it is in input text: <input type="text" readonly class="form-control" name="secret" style="resize: vertical;" value="<?php echo $message ?>" />

html/header.html

<script>
function copyText() {
     var textToCopy = document.getElementById("copy");
     textToCopy.select();
     document.execCommand("copy");
}
</script>

html/view_secret.php

<div class="col">
<button class="btn btn-primary" type="button" onclick="copyText()">Copy</button>
</div>

Also, you need to add id="copy" in the textarea

html/view_code.php

<div class="col">
<button class="btn btn-primary" type="button" onclick="copyText()">Copy</button>
</div>

Would be a nice feature with multi-languages like with gettext. Code would automatically detects the browser language and translate the text accordingly.

AndrewPaglusch commented 2 years ago

Thank you for the suggestions! Would you be open to submitting a pull request with your changes? If not, I will look into implementing them myself.

Zurd commented 2 years ago

I really don't have much experience with github, pull requests and patch file, would take me like 45 minutes to make it and the changes only take 3 minutes to copy/paste :)

AndrewPaglusch commented 2 years ago

@Zurd I've started work on this. Can you please take a look at #57 and let me know if you have any recommendations? Thanks!

Zurd commented 2 years ago

Just tested it and it worked perfectly well!

AndrewPaglusch commented 2 years ago

57 merged