Commit bc722ff5 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #781 from ethereum/copyBtninDetails

Copy to clipboard on log details
parents b454a9a0 ef454048
'use strict' 'use strict'
var yo = require('yo-yo') var yo = require('yo-yo')
const copy = require('clipboard-copy')
// -------------- styling ---------------------- // -------------- styling ----------------------
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
...@@ -58,7 +59,10 @@ var css = csjs` ...@@ -58,7 +59,10 @@ var css = csjs`
.details { .details {
background-color: ${styles.colors.lightGrey}; background-color: ${styles.colors.lightGrey};
} }
` .clipboardCopy {
margin-right: 0.5em;
cursor: pointer;
}`
/** /**
* This just export a function that register to `newTransaction` and forward them to the logger. * This just export a function that register to `newTransaction` and forward them to the logger.
* Emit debugRequested * Emit debugRequested
...@@ -253,7 +257,7 @@ function createTable (opts) { ...@@ -253,7 +257,7 @@ function createTable (opts) {
var contractAddress = yo` var contractAddress = yo`
<tr class="${css.tr}"> <tr class="${css.tr}">
<td class="${css.td}"> contractAddress </td> <td class="${css.td}"> contractAddress </td>
<td class="${css.td}">${opts.contractAddress}</td> <td class="${css.td}"><i class="fa fa-clipboard ${css.clipboardCopy}" aria-hidden="true" onclick=${function () { copy(opts.contractAddress) }} title='Copy to clipboard'></i>${opts.contractAddress}</td>
</tr class="${css.tr}"> </tr class="${css.tr}">
` `
if (opts.contractAddress) table.appendChild(contractAddress) if (opts.contractAddress) table.appendChild(contractAddress)
...@@ -261,7 +265,7 @@ function createTable (opts) { ...@@ -261,7 +265,7 @@ function createTable (opts) {
var from = yo` var from = yo`
<tr class="${css.tr}"> <tr class="${css.tr}">
<td class="${css.td} ${css.tableTitle}"> from </td> <td class="${css.td} ${css.tableTitle}"> from </td>
<td class="${css.td}">${opts.from}</td> <td class="${css.td}"><i class="fa fa-clipboard ${css.clipboardCopy}" aria-hidden="true" onclick=${function () { copy(opts.from) }} title='Copy to clipboard'></i>${opts.from}</td>
</tr class="${css.tr}"> </tr class="${css.tr}">
` `
if (opts.from) table.appendChild(from) if (opts.from) table.appendChild(from)
...@@ -276,7 +280,7 @@ function createTable (opts) { ...@@ -276,7 +280,7 @@ function createTable (opts) {
var to = yo` var to = yo`
<tr class="${css.tr}"> <tr class="${css.tr}">
<td class="${css.td}"> to </td> <td class="${css.td}"> to </td>
<td class="${css.td}">${toHash}</td> <td class="${css.td}"><i class="fa fa-clipboard ${css.clipboardCopy}" aria-hidden="true" onclick=${function () { copy(opts.toHash) }} title='Copy to clipboard'></i>${toHash}</td>
</tr class="${css.tr}"> </tr class="${css.tr}">
` `
if (opts.to) table.appendChild(to) if (opts.to) table.appendChild(to)
...@@ -284,7 +288,7 @@ function createTable (opts) { ...@@ -284,7 +288,7 @@ function createTable (opts) {
var gas = yo` var gas = yo`
<tr class="${css.tr}"> <tr class="${css.tr}">
<td class="${css.td}"> gas </td> <td class="${css.td}"> gas </td>
<td class="${css.td}">${opts.gas}</td> <td class="${css.td}"><i class="fa fa-clipboard ${css.clipboardCopy}" aria-hidden="true" onclick=${function () { copy(opts.gas) }} title='Copy to clipboard'></i>${opts.gas}</td>
</tr class="${css.tr}"> </tr class="${css.tr}">
` `
if (opts.gas) table.appendChild(gas) if (opts.gas) table.appendChild(gas)
...@@ -292,7 +296,7 @@ function createTable (opts) { ...@@ -292,7 +296,7 @@ function createTable (opts) {
var hash = yo` var hash = yo`
<tr class="${css.tr}"> <tr class="${css.tr}">
<td class="${css.td}"> hash </td> <td class="${css.td}"> hash </td>
<td class="${css.td}">${opts.hash}</td> <td class="${css.td}"><i class="fa fa-clipboard ${css.clipboardCopy}" aria-hidden="true" onclick=${function () { copy(opts.hash) }} title='Copy to clipboard'></i>${opts.hash}</td>
</tr class="${css.tr}"> </tr class="${css.tr}">
` `
if (opts.hash) table.appendChild(hash) if (opts.hash) table.appendChild(hash)
...@@ -300,7 +304,7 @@ function createTable (opts) { ...@@ -300,7 +304,7 @@ function createTable (opts) {
var input = yo` var input = yo`
<tr class="${css.tr}"> <tr class="${css.tr}">
<td class="${css.td}"> input </td> <td class="${css.td}"> input </td>
<td class="${css.td}">${opts.input}</td> <td class="${css.td}"><i class="fa fa-clipboard ${css.clipboardCopy}" aria-hidden="true" onclick=${function () { copy(opts.input) }} title='Copy to clipboard'></i>${opts.input}</td>
</tr class="${css.tr}"> </tr class="${css.tr}">
` `
if (opts.input) table.appendChild(input) if (opts.input) table.appendChild(input)
...@@ -309,7 +313,7 @@ function createTable (opts) { ...@@ -309,7 +313,7 @@ function createTable (opts) {
var inputDecoded = yo` var inputDecoded = yo`
<tr class="${css.tr}"> <tr class="${css.tr}">
<td class="${css.td}"> decoded input </td> <td class="${css.td}"> decoded input </td>
<td class="${css.td}">${opts['decoded input']}</td> <td class="${css.td}"><i class="fa fa-clipboard ${css.clipboardCopy}" aria-hidden="true" onclick=${function () { copy(opts['decoded input']) }} title='Copy to clipboard'></i>${opts['decoded input']}</td>
</tr class="${css.tr}">` </tr class="${css.tr}">`
table.appendChild(inputDecoded) table.appendChild(inputDecoded)
} }
...@@ -317,7 +321,7 @@ function createTable (opts) { ...@@ -317,7 +321,7 @@ function createTable (opts) {
var logs = yo` var logs = yo`
<tr class="${css.tr}"> <tr class="${css.tr}">
<td class="${css.td}"> logs </td> <td class="${css.td}"> logs </td>
<td class="${css.td}">${opts.logs || '0'}</td> <td class="${css.td}"><i class="fa fa-clipboard ${css.clipboardCopy}" aria-hidden="true" onclick=${function () { copy(opts.logs || '0') }} title='Copy to clipboard'></i>${opts.logs || '0'}</td>
</tr class="${css.tr}"> </tr class="${css.tr}">
` `
if (opts.logs) table.appendChild(logs) if (opts.logs) table.appendChild(logs)
...@@ -326,7 +330,7 @@ function createTable (opts) { ...@@ -326,7 +330,7 @@ function createTable (opts) {
val = yo` val = yo`
<tr class="${css.tr}"> <tr class="${css.tr}">
<td class="${css.td}"> value </td> <td class="${css.td}"> value </td>
<td class="${css.td}">${val} wei</td> <td class="${css.td}"><i class="fa fa-clipboard ${css.clipboardCopy}" aria-hidden="true" onclick=${function () { copy(`${val} wei`) }} title='Copy to clipboard'></i>${val} wei</td>
</tr class="${css.tr}"> </tr class="${css.tr}">
` `
if (opts.val) table.appendChild(val) if (opts.val) table.appendChild(val)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment