diff options
| author | Eliot Whalan <ewhal@pantsu.cat> | 2016-07-01 00:23:59 +0200 |
|---|---|---|
| committer | Eliot Whalan <ewhal@pantsu.cat> | 2016-07-01 00:23:59 +0200 |
| commit | 79963d160586be2fa13869406d2aeda3c540142c (patch) | |
| tree | 1d2f63d580c026c11bbbd4e763e8c9b676e25dfb /static/js/app.js | |
| parent | 928f7366be8e833ce732dcd8d981eba2f05ece36 (diff) | |
| parent | 2e2708c050e7fd3de7fe2008c6ddf5e0d03454fd (diff) | |
Merge branch 'master' of https://github.com/pomf/pomf
Diffstat (limited to 'static/js/app.js')
| -rw-r--r-- | static/js/app.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/static/js/app.js b/static/js/app.js index e9e755a..27a9353 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -81,6 +81,26 @@ document.addEventListener('DOMContentLoaded', function () { link.textContent = response.files[0].url.replace(/.*?:\/\//g, ''); link.href = response.files[0].url; url.appendChild(link); + var copy = document.createElement('button'); + copy.className = 'upload-clipboard-btn'; + var glyph = document.createElement('img'); + glyph.src = 'img/glyphicons-512-copy.png'; + copy.appendChild(glyph); + url.appendChild(copy); + copy.addEventListener("click", function(event) { + /*why create element? text needs to be on screen to be selected + and thus copied. only text we have on screen is the link without + the http[s]:// part. so this creates an element with the full link + for a moment and then deletes. */ + var element = document.createElement('a'); + element.textContent = response.files[0].url; + link.appendChild(element); + var range = document.createRange(); + range.selectNode(element); + window.getSelection().addRange(range); + document.execCommand("copy"); + link.removeChild(element); + }); } else { bar.innerHTML = 'Error: ' + response.description; } @@ -172,4 +192,6 @@ document.addEventListener('DOMContentLoaded', function () { uploadButton.addEventListener('click', selectFiles.bind(this, uploadInput)); uploadButton.addEventListener('drop', handleDragDrop.bind(this, state, uploadButton), false); document.getElementById('upload-form').classList.add('js'); + + }); |
