Добавил кнопку копирования как текст

This commit is contained in:
saber-nyan 2019-05-22 11:17:45 +03:00
parent 98870edb1d
commit ba3e3e3b92
No known key found for this signature in database
GPG Key ID: 7B069E9C295E6B4A

View File

@ -2,6 +2,7 @@
<div class="packet" :class="{'packet-incoming': isIncoming}">
<div>#{{id}} at {{new Date(timestamp).toLocaleDateString('ru-RU', {month: '2-digit', day: '2-digit', hour:'2-digit', minute: '2-digit', second: '2-digit'})}}
<button @click.prevent="copyRaw" class="btn btn-link">Copy HEX</button>
<button @click.prevent="copyText" class="btn btn-link">Copy text</button>
<button @click.prevent="copyPythonBytes" class="btn btn-link">Copy as Python bytes </button></div>
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-2 pb-2 mb-3 border-bottom">
<pre>{{ hexdata }}</pre>
@ -47,6 +48,9 @@ export default {
copyRaw() {
this.copyContent(Buffer.from(this.$props.content, 'base64').toString('hex'));
},
copyText() {
this.copyContent(atob(this.$props.content));
},
copyContent(data) {
const tempEl = document.createElement('textarea');
tempEl.value = data; // Chrome