From e36b2bdd631efee6604fb3a4b593ec613ce86339 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Mon, 26 Jun 2017 11:46:02 -0400 Subject: [PATCH] remove similarity plugin #403 --- examples/jspsych-similarity.html | 35 ---- plugins/jspsych-similarity.js | 273 ------------------------------- 2 files changed, 308 deletions(-) delete mode 100644 examples/jspsych-similarity.html delete mode 100644 plugins/jspsych-similarity.js diff --git a/examples/jspsych-similarity.html b/examples/jspsych-similarity.html deleted file mode 100644 index d8180a0a..00000000 --- a/examples/jspsych-similarity.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - -

If you are seeing this message, then you are probably running this example file offline. - Loading the audio files offline requires running your browser in a special mode. - See this Q&A - for examples of how to get this working with Chrome. Other browsers have similar features that you can find more information on via Google.

- - - diff --git a/plugins/jspsych-similarity.js b/plugins/jspsych-similarity.js deleted file mode 100644 index 16ff8bee..00000000 --- a/plugins/jspsych-similarity.js +++ /dev/null @@ -1,273 +0,0 @@ -/** - * jspsych-similarity.js - * Josh de Leeuw - * - * This plugin create a trial where two images are shown sequentially, and the subject rates their similarity using a slider controlled with the mouse. - * - * documentation: docs.jspsych.org - * - */ - - -jsPsych.plugins.similarity = (function() { - - var plugin = {}; - - jsPsych.pluginAPI.registerPreload('similarity', 'stimuli', 'image',function(t){ return !t.is_html || t.is_html == 'undefined'}); - - plugin.info = { - name: 'similarity', - description: '', - parameters: { - stimuli: { - type: [jsPsych.plugins.parameterType.STRING], - default: undefined, - array: true, - no_function: false, - description: '' - }, - is_html: { - type: [jsPsych.plugins.parameterType.BOOL], - default: false, - no_function: false, - description: '' - }, - labels: { - type: [jsPsych.plugins.parameterType.STRING], - array: true, - default: ['Not at all similar', 'Identical'], - no_function: false, - description: '' - }, - intervals: { - type: [jsPsych.plugins.parameterType.INT], - default: 100, - no_function: false, - description: '' - }, - show_ticks: { - type: [jsPsych.plugins.parameterType.BOOL], - default: false, - no_function: false, - description: '' - }, - show_response: { - type: [jsPsych.plugins.parameterType.SELECT], - options: ['FIRST_STIMULUS', 'SECOND_STIMULUS','POST_STIMULUS'], - default: 'SECOND_STIMULUS', - no_function: false, - description: '' - }, - timing_first_stim: { - type: [jsPsych.plugins.parameterType.INT], - default: 1000, - no_function: false, - description: '' - }, - timing_image_gap: { - type: [jsPsych.plugins.parameterType.INT], - default: 1000, - no_function: false, - description: '' - }, - timing_second_stim: { - type: [jsPsych.plugins.parameterType.INT], - default: -1, - no_function: false, - description: '' - }, - prompt: { - type: [jsPsych.plugins.parameterType.STRING], - default: '', - no_function: false, - description: '' - }, - button_label: { - type: [jsPsych.plugins.parameterType.STRING], - default: '', - no_function: false, - description: 'Submit Answers' - } - } - } - - plugin.trial = function(display_element, trial) { - - // default parameters - trial.labels = (typeof trial.labels === 'undefined') ? ["Not at all similar", "Identical"] : trial.labels; - trial.intervals = trial.intervals || 100; - trial.show_ticks = (typeof trial.show_ticks === 'undefined') ? false : trial.show_ticks; - - trial.show_response = trial.show_response || "SECOND_STIMULUS"; - - trial.timing_first_stim = trial.timing_first_stim || 1000; // default 1000ms - trial.timing_second_stim = trial.timing_second_stim || -1; // -1 = inf time; positive numbers = msec to display second image. - trial.timing_image_gap = trial.timing_image_gap || 1000; // default 1000ms - - trial.is_html = (typeof trial.is_html === 'undefined') ? false : trial.is_html; - trial.prompt = (typeof trial.prompt === 'undefined') ? '' : trial.prompt; - - trial.button_label = typeof trial.button_label === 'undefined' ? 'Submit Answers' : trial.button_label; - - // if any trial variables are functions - // this evaluates the function and replaces - // it with the output of the function - trial = jsPsych.pluginAPI.evaluateFunctionParameters(trial); - - display_element.innerHTML = ''; - - // show the images - if (!trial.is_html) { - display_element.innerHTML += ''; - } else { - display_element.innerHTML += '
'+trial.stimuli[0]+'
'; - } - - if (trial.show_response == "FIRST_STIMULUS") { - show_response_slider(display_element, trial); - } - - jsPsych.pluginAPI.setTimeout(function() { - showBlankScreen(); - }, trial.timing_first_stim); - - - function showBlankScreen() { - - display_element.querySelector('#jspsych-sim-stim').style.visibility = 'hidden'; - - jsPsych.pluginAPI.setTimeout(function() { - showSecondStim(); - }, trial.timing_image_gap); - } - - function showSecondStim() { - - if (!trial.is_html) { - display_element.querySelector('#jspsych-sim-stim').src = trial.stimuli[1]; - } else { - display_element.querySelector('#jspsych-sim-stim').innerHTML = trial.stimuli[1]; - } - - display_element.querySelector('#jspsych-sim-stim').style.visibility = 'visible'; - - if (trial.show_response == "SECOND_STIMULUS") { - show_response_slider(display_element, trial); - } - - if (trial.timing_second_stim > 0) { - jsPsych.pluginAPI.setTimeout(function() { - display_element.querySelector("#jspsych-sim-stim").style.visibility = 'hidden'; - if (trial.show_response == "POST_STIMULUS") { - show_response_slider(display_element, trial); - } - }, trial.timing_second_stim); - } - } - - - function show_response_slider(display_element, trial) { - - var startTime = (new Date()).getTime(); - - // create slider - display_element.append($('
', { - "id": 'slider', - "class": 'sim' - })); - - $("#slider").slider({ - value: Math.ceil(trial.intervals / 2), - min: 1, - max: trial.intervals, - step: 1, - }); - - // show tick marks - if (trial.show_ticks) { - for (var j = 1; j < trial.intervals - 1; j++) { - $('#slider').append('
'); - } - - $('#slider .slidertickmark').each(function(index) { - var left = (index + 1) * (100 / (trial.intervals - 1)); - $(this).css({ - 'position': 'absolute', - 'left': left + '%', - 'width': '1px', - 'height': '100%', - 'background-color': '#222222' - }); - }); - } - - // create labels for slider - display_element.append($('