Skip to content
Snippets Groups Projects
Commit 5b9c1946 authored by bbaer's avatar bbaer
Browse files

added a JSON request for a text variable

parent 6e6abbc8
No related branches found
No related tags found
1 merge request!47Copy cat
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment