From e950ccbb72319378adcd822d3af4dc6457886da3 Mon Sep 17 00:00:00 2001 From: hysz Date: Tue, 25 Jun 2013 02:03:56 +0000 Subject: [PATCH 1/2] Fixed Bug: results not saved to output file. --- core/js/IAT.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/core/js/IAT.js b/core/js/IAT.js index ac07021..1ccae0b 100644 --- a/core/js/IAT.js +++ b/core/js/IAT.js @@ -1,6 +1,6 @@ template = {}; sub = ''; - +results_saved = false; function randomString(length) { var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; @@ -12,7 +12,6 @@ function randomString(length) { // Loads the input file and starts introduction function initialize() { - var tempsubID = randomString(10); // get active template & load data into global variable @@ -337,7 +336,7 @@ function instructionPage() $("#left_cat").html(""); $("#right_cat").html(""); $("#exp_instruct").html(""); - WriteFile(); + if(template.showResult == "show") { calculateIAT(); @@ -348,12 +347,8 @@ function instructionPage() $("#picture_frame").html(resulttext); } - - //crude hack for forwarding by TS - if (template.running == "embedded") - { - window.location.href = template.nextURL + sub; - } + + WriteFile(); } else { @@ -593,8 +588,19 @@ function WriteFile() } } - $.post("core/fileManager.php", { 'op':'writeoutput', 'template':template.name, - 'subject': subject, 'data': str }); + $.post("core/fileManager.php", { 'op':'writeoutput', 'template':template.name, 'subject': subject, 'data': str }, WriteFile_success, "json"); +} + +function WriteFile_success(response) +{ + results_saved = true; + + //crude hack for forwarding by TS + if (template.running == "embedded") + { + window.location.href = template.nextURL + sub; + } + // notify user of success? } From 26b34fe3294df675b6a6b425ede4f5cc4af520cc Mon Sep 17 00:00:00 2001 From: hysz Date: Wed, 26 Jun 2013 01:47:33 +0000 Subject: [PATCH 2/2] fixed bug: embedded version not generating UID --- core/js/IAT.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/js/IAT.js b/core/js/IAT.js index 1ccae0b..33bb1e3 100644 --- a/core/js/IAT.js +++ b/core/js/IAT.js @@ -9,11 +9,16 @@ function randomString(length) { return result; } +function Is_embedded() +{ + return template.hasOwnProperty( "running" ) && template.running == "embedded"; +} + // Loads the input file and starts introduction function initialize() { var tempsubID = randomString(10); - + // get active template & load data into global variable $.getJSON("templates/active.txt", function(input) { document.title = input.active + " IAT"; @@ -24,12 +29,12 @@ function initialize() //takes subID from URL location.search property //expects something like http://www.server.com/IAT/index.php?subID=12345 //if no query is present, or if subID is empty (e.g., ?subID= ), subID defaults to 999+random string - if (template.running == "embedded") + if (Is_embedded()) { tempsubID = getQueryVariable('subID'); - if (tempsubID == "") {tempsubID="99999"+randomString(5)} + if (!tempsubID) {tempsubID="99999"+randomString(5)} } - + //change here to make instruct0 more flexible //to go with standard instruct0.html, just leave running="" $.get("core/instruct0"+template.running+".html", function(data) { @@ -56,7 +61,7 @@ function getQueryVariable(variable) return decodeURIComponent(pair[1]); } } - return(999999); + return null; } function loadInstructions(stage) @@ -596,7 +601,7 @@ function WriteFile_success(response) results_saved = true; //crude hack for forwarding by TS - if (template.running == "embedded") + if (Is_embedded()) { window.location.href = template.nextURL + sub; }