Skip to content

Commit

Permalink
display the the experiment's JSON data in a new window
Browse files Browse the repository at this point in the history
  • Loading branch information
bbonf committed May 17, 2024
1 parent 951814f commit 8cf168f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions jspsych-uil-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,13 @@ function saveJson (json, access_key, acc_server = undefined) {
else {
// show the data in prettyfied format
json = JSON.stringify(JSON.parse(json), null, 4);
// clear the body
document.body.innerHTML= '';
// Add preformatted json content.
let pre_element = document.createElement("pre");
pre_element.innerText = json;
document.body.append(pre_element);

let content = `<!doctype html><html><body><h1>Experiment Data (debug version)</h1>${pre_element.outerHTML}</body></html>`;
let url = URL.createObjectURL(new Blob([content], {type: 'text/html;charset=utf-8'}));
window.open(url);
}
}

Expand Down

0 comments on commit 8cf168f

Please sign in to comment.