working example of fullscreen

This commit is contained in:
Josh de Leeuw 2017-05-01 16:35:41 -04:00
parent 6f032f189e
commit d5fd16be7c
2 changed files with 48 additions and 3 deletions

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<script src="../jspsych.js"></script>
<script src="../plugins/jspsych-fullscreen.js"></script>
<script src="../plugins/jspsych-single-stim.js"></script>
<link rel="stylesheet" href="../css/jspsych.css"></link>
<style>
img {
width: 300px;
}
</style>
</head>
<script>
var fullscreen_trial = {
type: 'fullscreen',
fullscreen_mode: true
}
var trial_1 = {
type: 'single-stim',
stimulus: 'img/happy_face_1.jpg',
choices: [89, 78], // Y or N
prompt: '<p class="center-content">Have you seen this face before? Y or N.</p>'
}
var fullscreen_trial_exit = {
type: 'fullscreen',
fullscreen_mode: false
}
jsPsych.init({
timeline: [ fullscreen_trial, trial_1, fullscreen_trial_exit ],
on_finish: function() {
jsPsych.data.displayData();
}
});
</script>
</html>

View File

@ -76,6 +76,7 @@ jsPsych.plugins.fullscreen = (function() {
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
endTrial();
});
} else {
if (document.exitFullscreen) {
@ -87,15 +88,15 @@ jsPsych.plugins.fullscreen = (function() {
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
endTrial();
}
}
function endTrial() {
jsPsych.pluginAPI.setTimeout(function(){
display_element.innerHTML = '';
jsPsych.pluginAPI.setTimeout(function(){
var trial_data = {
success: !keyboardNotAllowed
};