1
1
/* global alertify, $ */
2
2
3
- define ( [ 'jquery' , 'controllers/tableController' , 'helper/mpc' , 'alertify' , 'alertify_defaults' ] , function ( $ , tableController , mpc , alertify ) {
3
+ define ( [ 'jquery' , 'controllers/tableController' , 'helper/mpc' , 'alertify' , 'alertify_defaults' , 'controllers/confirmationCodes' ] , function ( $ , tableController , mpc , alertify , _ , confirmationCodes ) {
4
4
5
+ console . log ( confirmationCodes ) ;
6
+ console . log ( confirmationCodes . get_confirmation_code ( ) ) ;
5
7
6
8
var client = ( function ( ) {
7
9
var SESSION_KEY_ERROR = 'Invalid session number' ;
@@ -46,6 +48,7 @@ define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'aler
46
48
SEMANTIC_CELLS : 0 ,
47
49
} ,
48
50
mouse_positions : [ ] ,
51
+ mouse_clicks : [ ] ,
49
52
time_ms : 0 ,
50
53
} ;
51
54
/*
@@ -59,12 +62,15 @@ define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'aler
59
62
// define mouse_positions as 100x1000 array
60
63
for ( var i = 0 ; i < MOUSE_PRECISION_WIDTH ; i ++ ) {
61
64
analytics . mouse_positions . push ( [ ] ) ;
65
+ analytics . mouse_clicks . push ( [ ] ) ;
62
66
for ( var k = 0 ; k < MOUSE_PRECISION_HEIGHT ; k ++ ) {
63
67
analytics . mouse_positions [ i ] . push ( 0 )
68
+ analytics . mouse_clicks [ i ] . push ( 0 )
64
69
}
65
70
}
66
71
67
72
document . addEventListener ( 'mousemove' , handleMouseMove , false ) ;
73
+ document . addEventListener ( 'click' , handleMouseClick , false ) ;
68
74
function getPos ( event ) {
69
75
70
76
// TODO: make sure this is consistent across browsers
@@ -90,6 +96,16 @@ define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'aler
90
96
return [ event . pageX / width , event . pageY / height ] ;
91
97
}
92
98
99
+ function handleMouseClick ( event ) {
100
+ // y coord should potentially be mult. by 100
101
+ // to account for difference in x, y page size
102
+
103
+ var pos = getPos ( event ) ;
104
+ var x = Math . floor ( pos [ 0 ] * MOUSE_PRECISION_WIDTH ) ;
105
+ var y = Math . floor ( pos [ 1 ] * MOUSE_PRECISION_HEIGHT ) ;
106
+ //each array stores # of hits at this area
107
+ analytics . mouse_clicks [ x ] [ y ] ++ ;
108
+ }
93
109
function handleMouseMove ( event ) {
94
110
// y coord should potentially be mult. by 100
95
111
// to account for difference in x, y page size
@@ -492,6 +508,8 @@ define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'aler
492
508
493
509
success ( 'Submitted data.' ) ;
494
510
convertToHTML ( submitEntries ) ;
511
+ // post confirmation or completion code for mturk users to submit to in aws/mturk site
512
+ alert ( confirmationCodes . get_confirmation_code ( ) ) ;
495
513
496
514
// Stop loading animation
497
515
la . stop ( ) ;
@@ -587,6 +605,7 @@ define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'aler
587
605
callback ( true ) ;
588
606
}
589
607
608
+
590
609
return {
591
610
errors : errors ,
592
611
submitEntries : submitEntries ,
0 commit comments