@@ -2,8 +2,6 @@ var experimentController = (function() {
22
33 var experimentControllerDiv ;
44
5- var config ;
6-
75 var stepOrder ;
86 var stepOrderIterator = 0 ;
97
@@ -12,25 +10,31 @@ var experimentController = (function() {
1210
1311 var stepTime = 0 ;
1412 var stepTextTime = 0 ;
15-
16- function initialize ( controllerConfig ) {
1713
18- var cssLink = document . createElement ( "link" ) ;
14+ var controllerConfig = {
15+ showBackButton : false ,
16+ showSureButton : true ,
17+ showPopup : true ,
18+ } ;
19+
20+
21+ function initialize ( setupConfig ) {
22+
23+ application . transferConfigParams ( setupConfig , controllerConfig ) ;
24+
25+ var cssLink = document . createElement ( "link" ) ;
1926 cssLink . type = "text/css" ;
2027 cssLink . rel = "stylesheet" ;
2128 cssLink . href = "scripts/Experiment/ec.css" ;
2229 document . getElementsByTagName ( "head" ) [ 0 ] . appendChild ( cssLink ) ;
2330
2431 //interactionLogger.logConfig(config.clickConnector, config.clickTransparency, config.taskOrder.toString());
32+
33+ stepOrder = setupConfig . stepOrder ;
34+ steps = setupConfig . steps ;
2535
26- //parse config
27- config = controllerConfig ;
28-
29- stepOrder = controllerConfig . stepOrder ;
30- steps = controllerConfig . steps ;
31-
32- stepTextTime = controllerConfig . taskTextButtonTime ;
33- stepTime = controllerConfig . taskTime ;
36+ stepTextTime = setupConfig . taskTextButtonTime ;
37+ stepTime = setupConfig . taskTime ;
3438
3539 //events
3640 events . marked . on . subscribe ( onEntityMarked ) ;
@@ -51,10 +55,17 @@ var experimentController = (function() {
5155
5256 var taskSolvedButton = document . createElement ( "INPUT" ) ;
5357 taskSolvedButton . id = "taskSolvedButton" ;
54- taskSolvedButton . value = "Done " ;
58+ taskSolvedButton . value = "Next " ;
5559 taskSolvedButton . type = "button" ;
5660 experimentHeaderDiv . appendChild ( taskSolvedButton ) ;
57-
61+
62+ if ( controllerConfig . showBackButton ) {
63+ var backButton = document . createElement ( 'INPUT' ) ;
64+ backButton . id = 'backButton' ;
65+ backButton . value = 'Back' ;
66+ backButton . type = 'button' ;
67+ experimentHeaderDiv . appendChild ( backButton ) ;
68+ }
5869
5970 //taskdialog
6071 var taskDialogDiv = document . createElement ( "DIV" ) ;
@@ -88,8 +99,13 @@ var experimentController = (function() {
8899 parent . appendChild ( experimentControllerDiv ) ;
89100
90101 //taskFieldText and solvedButton
91- $ ( "#taskSolvedButton" ) . jqxButton ( { theme : "metro" } ) ;
92- $ ( "#taskSolvedButton" ) . click ( taskSolvedButtonClick ) ;
102+ $ ( '#taskSolvedButton' ) . jqxButton ( { theme : 'metro' } ) ;
103+ $ ( '#taskSolvedButton' ) . click ( taskSolvedButtonClick ) ;
104+
105+ if ( controllerConfig . showBackButton ) {
106+ $ ( '#backButton' ) . jqxButton ( { theme : 'metro' } ) ;
107+ $ ( '#backButton' ) . click ( backButtonClick ) ;
108+ }
93109
94110 //taskdialog
95111 $ ( "#taskDialog" ) . jqxWindow ( { height : 1000 , width : 700 , theme : 'metro' , isModal : true , autoOpen : false , resizable : false , showCloseButton : false , okButton : $ ( '#button_ok' ) } ) ;
@@ -109,14 +125,23 @@ var experimentController = (function() {
109125 }
110126
111127
112- function taskSolvedButtonClick ( event ) {
113-
114- if ( $ ( "#taskSolvedButton" ) [ 0 ] . value == "Done" ) {
115- $ ( "#taskSolvedButton" ) [ 0 ] . value = "Sure?"
116- setTimeout ( resetSolvedButton , 3000 ) ;
117- } else {
118- nextStep ( ) ;
119- }
128+ function taskSolvedButtonClick ( event ) {
129+
130+ if ( $ ( "#taskSolvedButton" ) [ 0 ] . value == "Next" && controllerConfig . showSureButton ) {
131+ $ ( "#taskSolvedButton" ) [ 0 ] . value = "Sure?"
132+ setTimeout ( resetSolvedButton , 3000 ) ;
133+ } else {
134+
135+ nextStep ( ) ;
136+ }
137+ }
138+
139+ function backButtonClick ( event ) {
140+ previousStep ( ) ;
141+ }
142+
143+ function resetSolvedButton ( ) {
144+ if ( $ ( '#taskSolvedButton' ) [ 0 ] . value !== 'Next' ) $ ( '#taskSolvedButton' ) [ 0 ] . value = 'Next' ;
120145 }
121146
122147 function nextStep ( ) {
@@ -126,8 +151,14 @@ var experimentController = (function() {
126151 setNextStep ( ) ;
127152
128153 setStepTexts ( currentStep . text , 100 , 100 , 1000 , 300 , stepTextTime ) ;
154+ }
129155
130- application . loadUIConfig ( currentStep . ui ) ;
156+ function previousStep ( ) {
157+ stopTaskTimer ( ) ;
158+
159+ setPreviousStep ( ) ;
160+
161+ setStepTexts ( currentStep . text , 100 , 100 , 1000 , 300 , stepTextTime ) ;
131162 }
132163
133164 function setNextStep ( ) {
@@ -144,6 +175,20 @@ var experimentController = (function() {
144175 } ) ;
145176 }
146177
178+ function setPreviousStep ( ) {
179+ if ( stepOrderIterator > 1 ) {
180+ stepOrderIterator = stepOrderIterator - 1 ;
181+
182+ var nextStepByStepOrder = stepOrder [ stepOrderIterator - 1 ] ;
183+
184+ steps . forEach ( function ( step ) {
185+ if ( step . number == nextStepByStepOrder ) {
186+ currentStep = step ;
187+ return ;
188+ }
189+ } ) ;
190+ }
191+ }
147192
148193 function setStepTexts ( textArray , posx , posy , width , height , time ) {
149194
@@ -152,8 +197,9 @@ var experimentController = (function() {
152197 textArray . forEach ( function ( text ) {
153198 fullText = fullText + text + "<br/>" ;
154199 } ) ;
155-
156- showPopup ( fullText , posx , posy , width , height , time ) ;
200+ if ( controllerConfig . showPopup ) {
201+ showPopup ( fullText , posx , posy , width , height , time ) ;
202+ }
157203 setText ( fullText ) ;
158204 }
159205
@@ -193,9 +239,9 @@ var experimentController = (function() {
193239 }
194240
195241
196- function resetSolvedButton ( ) {
197- $ ( "#taskSolvedButton" ) [ 0 ] . value = "Done " ;
198- }
242+ // function resetSolvedButton(){
243+ // $("#taskSolvedButton")[0].value = "Next ";
244+ // }
199245
200246
201247
@@ -285,6 +331,7 @@ var experimentController = (function() {
285331 initialize : initialize ,
286332 activate : activate
287333 } ;
288- } ) ( ) ;
334+ }
335+ ) ( ) ;
289336
290337
0 commit comments