summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--static/img/glyphicons-512-copy.pngbin0 -> 1356 bytes
-rw-r--r--static/js/app.js23
2 files changed, 23 insertions, 0 deletions
diff --git a/static/img/glyphicons-512-copy.png b/static/img/glyphicons-512-copy.png
new file mode 100644
index 0000000..4e293dc
--- /dev/null
+++ b/static/img/glyphicons-512-copy.png
Binary files differ
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');
+
+
});