mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
working example of fullscreen
This commit is contained in:
parent
6f032f189e
commit
d5fd16be7c
44
examples/jspsych-fullscreen.html
Normal file
44
examples/jspsych-fullscreen.html
Normal 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>
|
@ -76,6 +76,7 @@ jsPsych.plugins.fullscreen = (function() {
|
|||||||
} else if (element.msRequestFullscreen) {
|
} else if (element.msRequestFullscreen) {
|
||||||
element.msRequestFullscreen();
|
element.msRequestFullscreen();
|
||||||
}
|
}
|
||||||
|
endTrial();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (document.exitFullscreen) {
|
if (document.exitFullscreen) {
|
||||||
@ -87,14 +88,14 @@ jsPsych.plugins.fullscreen = (function() {
|
|||||||
} else if (document.webkitExitFullscreen) {
|
} else if (document.webkitExitFullscreen) {
|
||||||
document.webkitExitFullscreen();
|
document.webkitExitFullscreen();
|
||||||
}
|
}
|
||||||
|
endTrial();
|
||||||
}
|
}
|
||||||
endTrial();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function endTrial() {
|
function endTrial() {
|
||||||
jsPsych.pluginAPI.setTimeout(function(){
|
display_element.innerHTML = '';
|
||||||
|
|
||||||
display_element.innerHTML = '';
|
jsPsych.pluginAPI.setTimeout(function(){
|
||||||
|
|
||||||
var trial_data = {
|
var trial_data = {
|
||||||
success: !keyboardNotAllowed
|
success: !keyboardNotAllowed
|
||||||
|
Loading…
Reference in New Issue
Block a user