//var treatment = parseInt(variables["treatment"]); /* * Initialize Game * * Sequence: initialize() -> initializeGame() -> instructionsComplete() -> initializeRound(0) -> { submitChoice() -> initializeRound(r+1) } -> endGame() * */ function initializeGame() { scenario = 0; treatment = 3; console.log("STARTING IDEA CONTEST Treatment " + treatment); $('#ModalTitle').html("Step " + instructionPanel + "/" + totalScreens); $('#instructions').modal({'show':true,'backdrop':"static",'keyboard':false}).on('hidden.bs.modal', function (e) { instructionsComplete(); }); $('#next').click(instructionNext); } // Show instructions of the current page function instructionNext() { switch(instructionPanel) { case 1: $('#ModalTitle').html("Step " + (instructionPanel+1) + "/" + totalScreens); $('#instructions0').fadeOut(400, function() { $('#instructions1').fadeIn(400); }); break; case 2: $('#ModalTitle').html("Step " + (instructionPanel+1) + "/" + totalScreens); $('#instructions1').fadeOut(400, function() { $('#instructions2').fadeIn(400); }); break; case 3: // SELF-REPORT 1 shuffle("selfReport1Container"); //Randomize sequence of self-report questions $('#ModalTitle').html("Step " + (instructionPanel+1) + "/" + totalScreens); $('#instructions2').fadeOut(400, function() { $('#instructions3').fadeIn(400); }); break; case 4: // TREATMENT $('#ModalTitle').html("Step " + (instructionPanel+1) + "/" + totalScreens); // Add text for scenario and treatment $('#scenario').html(scenarios[scenario]); $('#treatment').html(treatmentsLong[treatment]); if(treatment==3) { // choice shuffleExceptFirst("selectPrizeContainer"); //Randomize sequence of prize options } // TODO: submit() to store the random order in which prize options are displayed; this can be just a concatenation of the value attributes // e.g., 'cashnonCashindifferent' or 'indifferentnonCashcash' $('#instructions3').fadeOut(400, function() { $('#instructions4').fadeIn(400); }); break; case 5: // MAIN IDEA ENTRY $('#ModalTitle').html("Step " + (instructionPanel+1) + "/" + totalScreens); ideasEntered++; // increment counter of submitted ideas // TODO: start a timer $('#instructions4').fadeOut(400, function() { $('#instructions5').fadeIn(400); }); break; case 6: // FREE CHOICE $('#ModalTitle').html("Step " + (instructionPanel+1) + "/" + totalScreens); // TODO: The submit() of the idea from previous screen should also submit // * the counter: which n-th idea is this? // * the timer: how many seconds did the user spend typing their idea // * count the length of the idea in characters // TODO: The height of the footer changes when we hide the button and the footer is empty; can we prevent this somehow and keep the height of the footer fixed? $('#next').hide(); $('#freeNo').click(instructionNext); $('#instructions5').fadeOut(400, function() { $('#instructions6').fadeIn(400); }); break; case 7: // SELF-REPORT 2 $('#ModalTitle').html("Step " + (instructionPanel+1) + "/" + totalScreens); $('#next').show(); shuffle("selfReport2Container"); //Randomize sequence of self-report questions // TODO the submit() for the second $('#instructions6').fadeOut(400, function() { $('#instructions7').fadeIn(400); }); break; case 8: // END (ask email) $('#ModalTitle').html("Step " + (instructionPanel+1) + "/" + totalScreens); $('#instructions7').fadeOut(400, function() { $('#instructions8').fadeIn(400); }); break; case 9: // COMPLETE - YOU CAN CLOSE WINDOW $('#ModalTitle').html("Experiment Completed"); $('#next').hide(); $('#instructions8').fadeOut(400, function() { $('#instructions9').fadeIn(400); }); break; } instructionPanel++; }