diff --git a/CNAME b/CNAME deleted file mode 100644 index be4bb28..0000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -n-back.irockbunnylab.com \ No newline at end of file diff --git a/assets/js/n-back.js b/assets/js/n-back.js index 6525552..891467f 100644 --- a/assets/js/n-back.js +++ b/assets/js/n-back.js @@ -385,6 +385,17 @@ function loadRSME() { }); }; +function downloadResults() { + var dataStr = 'data:text/json;charset=utf-8,' + document.getElementById('results').value; + var filename = 'n-back_result_' + (new Date().toISOString()) + '.json' + var downloadAnchorNode = document.createElement('a'); + downloadAnchorNode.setAttribute("href", dataStr); + downloadAnchorNode.setAttribute("download", filename); + document.body.appendChild(downloadAnchorNode); // required for firefox + downloadAnchorNode.click(); + downloadAnchorNode.remove(); +}; + function loadResults() { $('#task-header .image').attr({ src: '/images/logo.png', @@ -404,9 +415,16 @@ function loadResults() { }, null, 4)); $('#action-buttons').children().remove(); $('#action-buttons').append( - $('
').addClass('ui fluid large primary copy button').attr('data-clipboard-target', '#results').text('Copy to Clipboard') + $('
').addClass('ui two large buttons').append( + $('
').addClass('ui fluid large primary copy button') + .text('Copy to Clipboard') + .click(function() => navigator.clipboard.writeText(document.getElementById('results').value)) + ).append( + $('
').addClass('ui fluid large primary button') + .text('Download JSON') + .click(downloadResults) + ) ); - const clipboard = new ClipboardJS('.copy.button'); }; function runTask(blocks) { @@ -467,4 +485,4 @@ function runTaskWithRest(blocks) { }); }) ); -}; \ No newline at end of file +};