11/* global alertify, $ */
22
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 ) {
44
5+ console . log ( confirmationCodes ) ;
6+ console . log ( confirmationCodes . get_confirmation_code ( ) ) ;
57
68 var client = ( function ( ) {
79 var SESSION_KEY_ERROR = 'Invalid session number' ;
@@ -46,6 +48,7 @@ define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'aler
4648 SEMANTIC_CELLS : 0 ,
4749 } ,
4850 mouse_positions : [ ] ,
51+ mouse_clicks : [ ] ,
4952 time_ms : 0 ,
5053 } ;
5154 /*
@@ -59,12 +62,15 @@ define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'aler
5962 // define mouse_positions as 100x1000 array
6063 for ( var i = 0 ; i < MOUSE_PRECISION_WIDTH ; i ++ ) {
6164 analytics . mouse_positions . push ( [ ] ) ;
65+ analytics . mouse_clicks . push ( [ ] ) ;
6266 for ( var k = 0 ; k < MOUSE_PRECISION_HEIGHT ; k ++ ) {
6367 analytics . mouse_positions [ i ] . push ( 0 )
68+ analytics . mouse_clicks [ i ] . push ( 0 )
6469 }
6570 }
6671
6772 document . addEventListener ( 'mousemove' , handleMouseMove , false ) ;
73+ document . addEventListener ( 'click' , handleMouseClick , false ) ;
6874 function getPos ( event ) {
6975
7076 // TODO: make sure this is consistent across browsers
@@ -90,6 +96,16 @@ define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'aler
9096 return [ event . pageX / width , event . pageY / height ] ;
9197 }
9298
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+ }
93109 function handleMouseMove ( event ) {
94110 // y coord should potentially be mult. by 100
95111 // to account for difference in x, y page size
@@ -492,6 +508,8 @@ define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'aler
492508
493509 success ( 'Submitted data.' ) ;
494510 convertToHTML ( submitEntries ) ;
511+ // post confirmation or completion code for mturk users to submit to in aws/mturk site
512+ alert ( confirmationCodes . get_confirmation_code ( ) ) ;
495513
496514 // Stop loading animation
497515 la . stop ( ) ;
@@ -587,6 +605,7 @@ define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'aler
587605 callback ( true ) ;
588606 }
589607
608+
590609 return {
591610 errors : errors ,
592611 submitEntries : submitEntries ,
0 commit comments