Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug on positive/negative click behaviour #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

24 changes: 21 additions & 3 deletions assets/js/n-back.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -404,9 +415,16 @@ function loadResults() {
}, null, 4));
$('#action-buttons').children().remove();
$('#action-buttons').append(
$('<div>').addClass('ui fluid large primary copy button').attr('data-clipboard-target', '#results').text('Copy to Clipboard')
$('<div>').addClass('ui two large buttons').append(
$('<div>').addClass('ui fluid large primary copy button')
.text('Copy to Clipboard')
.click(function() => navigator.clipboard.writeText(document.getElementById('results').value))
).append(
$('<div>').addClass('ui fluid large primary button')
.text('Download JSON')
.click(downloadResults)
)
);
const clipboard = new ClipboardJS('.copy.button');
};

function runTask(blocks) {
Expand Down Expand Up @@ -467,4 +485,4 @@ function runTaskWithRest(blocks) {
});
})
);
};
};