Skip to content

Commit

Permalink
cleaned up console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
RobAWilkinson committed Jan 14, 2017
1 parent e78fa7f commit 15016fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
8 changes: 6 additions & 2 deletions jspsych.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ window.jsPsych = (function() {
opts.display_element = document.querySelector('body');
} else {
// make sure that the display element exists on the page
var display = opts.display_element;
var display;
if (opts.display_element instanceof Element) {
var display = opts.display_element;
} else {
var display = document.querySelector('#' + opts.display_element);
}
if(display === null) {
console.error('The display_element specified in jsPsych.init() does not exist in the DOM.');
} else {
Expand Down Expand Up @@ -186,7 +191,6 @@ window.jsPsych = (function() {
};

core.getDisplayElement = function() {
console.log("yo in getDisplayElement", DOM_target);
return DOM_target;
};

Expand Down
18 changes: 5 additions & 13 deletions plugins/jspsych-survey-multi-choice.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ jsPsych.plugins['survey-multi-choice'] = (function() {

// form element
var trial_form_id = _join(plugin_id_name, "form");
console.log("trial_form_id", trial_form_id)
display_element.innerHTML += '<form id="'+trial_form_id+'"></form>';
var trial_form = display_element.querySelector("#" + trial_form_id);
console.log("trial_form", trial_form)
// show preamble text
var preamble_id_name = _join(plugin_id_name, 'preamble');
trial_form.innerHTML += '<div id="'+preamble_id_name+'" class="'+preamble_id_name+'">'+trial.preamble+'</div>';
Expand Down Expand Up @@ -120,7 +118,7 @@ jsPsych.plugins['survey-multi-choice'] = (function() {
// create radio button
var input_id_name = _join(plugin_id_name, 'response', i);
display_element.querySelector(option_id_selector + " label").innerHTML =
'<input type="radio" name="'+ input_id_name + '" value="' + trial.options[i][j] + '">' +
'<input type="radio" name="' + input_id_name + '" value="' + trial.options[i][j] + '">' +
display_element.querySelector(option_id_selector + " label").innerHTML;
}

Expand All @@ -129,7 +127,7 @@ jsPsych.plugins['survey-multi-choice'] = (function() {
display_element.querySelector(question_selector + " p").innerHMTL += "<span class='required'>*</span>";

// add required property
display_element.querySelector(question_selector + " input").required = true;
display_element.querySelector(question_selector + " input[type=radio]").required = true;
}
}
// add submit button
Expand All @@ -146,17 +144,11 @@ jsPsych.plugins['survey-multi-choice'] = (function() {
// create object to hold responses
var question_data = {};
var matches = display_element.querySelectorAll("div." + plugin_id_name + "-question");
var inputs = document.getElementsByTagName('input');
var radios = []
for(var i = 0; i < inputs.length; i++){
if(inputs[i].checked){
radios.push(inputs[i].value)
}
}
matches.forEach(function(currentEl ,index){
matches.forEach(function(match, index) {
var id = "Q" + index;
var val = match.querySelector("input[type=radio]:checked").value;
var obje = {};
obje[id] = radios[index];
obje[id] = val;
Object.assign(question_data, obje);
})
// save data
Expand Down

0 comments on commit 15016fe

Please sign in to comment.