summaryrefslogtreecommitdiff
path: root/static/js/app.js
diff options
context:
space:
mode:
authorAustin <austi_gillm935@ahapps.anoka.k12.mn.us>2016-06-29 03:34:18 +0200
committerGitHub <noreply@github.com>2016-06-29 03:34:18 +0200
commit4a869e4e0e1368baf5aa4e1a4144e0d31f633782 (patch)
tree1e7854825abdf06ccf402256acac62a91b68059d /static/js/app.js
parent186b9bf0aed3638845544c1dad9f54297cc23413 (diff)
parent0a546f1082755fdd39c984542c2e4e63874d30fd (diff)
Merge pull request #43 from ileyd/patch-1
Implemented clipboard
Diffstat (limited to 'static/js/app.js')
-rw-r--r--static/js/app.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/static/js/app.js b/static/js/app.js
index e9e755a..44c8453 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -81,6 +81,27 @@ 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';
+ glyph.style = 'height:16px';
+ 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 +193,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');
+
+
});