Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adding option to copy output to clipboard. #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
margin: 0;
padding: 0;
}
.copy-output {
cursor:pointer;
}
</style>
</head>
<body>
Expand Down Expand Up @@ -127,6 +130,7 @@ <h1>Himalaya</h1>
<input id='positions' type='checkbox' />
<span>Include positions</span>
</label>
<label class='copy-output' onclick='copyOutput()'>Copy</label>
</div>
<div class='pane pane-output'>
<pre id='output'></pre>
Expand Down Expand Up @@ -177,6 +181,18 @@ <h1>Himalaya</h1>

$('#output').innerText = JSON.stringify(code, null, 2)
}

function copyOutput() {
var output = document.getElementById('output');
var copy = document.createElement('textarea');
copy.setAttribute('id', 'clipboard');
copy.innerHTML = output.innerText;
document.body.appendChild(copy);
copy = document.getElementById('clipboard');
copy.select();
document.execCommand('copy');
document.body.removeChild(copy);
}

$('#source').onkeyup = updateOutput
$('#whitespace').onchange = updateOutput
Expand Down