diff --git a/javascript/src/Clipboard.js b/javascript/src/Clipboard.js index 7e5d7ca33f950b622a3eb9912d476da63572083a..1c48a9cfe909608348d44f5c8ceaea1bb2852fa1 100644 --- a/javascript/src/Clipboard.js +++ b/javascript/src/Clipboard.js @@ -11,7 +11,24 @@ var QfqNS = QfqNs || {}; (function (n) { n.Clipboard = function (data) { - this.copyTextToClipboardAsync(data.text); + if(data.text) { + this.copyTextToClipboardAsync(data.text); + return; + } + if(data.url) { + this.getDataFromUri(data.uri); + } + }; + + n.Clipboard.prototype.getDataFromUri = function(uri) { + var that = this; + $.getJSON(uri, function(data) { + if (data.text) { + that.copyTextToClipboardAsync(data.text); + } else { + that.buildError("JSON Response didn't include a variable called 'text'"); + } + }); }; n.Clipboard.prototype.copyTextToClipboard = function(text) { @@ -39,7 +56,7 @@ var QfqNS = QfqNs || {}; */ n.Clipboard.prototype.copyTextToClipboardAsync = function(text) { if (!navigator.clipboard) { - this.fallbackCopyTextToClipboard(text); + this.copyTextToClipboard(text); return; }