@@ -26,59 +26,7 @@ function pageStartup() {
2626 initConfig ( ) ;
2727 }
2828
29- if ( typeof ( macgap ) != "undefined" ) {
30- // Add some handlers if using MacGap binary
31- macgap . menu . getItem ( "Help" ) . submenu ( ) . getItem ( "JS Timer Help" ) . setCallback (
32- function ( ) { goHelp ( ) ; } ) ;
33- macgap . menu . getItem ( "Run" ) . submenu ( ) . getItem ( 'Preset 1' ) . setCallback (
34- function ( ) { document . getElementById ( 'preset0' ) . click ( ) ; } ) ;
35- macgap . menu . getItem ( "Run" ) . submenu ( ) . getItem ( 'Preset 2' ) . setCallback (
36- function ( ) { document . getElementById ( 'preset1' ) . click ( ) ; } ) ;
37- macgap . menu . getItem ( "Run" ) . submenu ( ) . getItem ( 'Preset 3' ) . setCallback (
38- function ( ) { document . getElementById ( 'preset2' ) . click ( ) ; } ) ;
39- macgap . menu . getItem ( "Run" ) . submenu ( ) . getItem ( 'Demo' ) . setCallback (
40- function ( ) { document . getElementById ( 'demo' ) . click ( ) ; } ) ;
41- macgap . menu . getItem ( "Run" ) . submenu ( ) . getItem ( 'Clock' ) . setCallback (
42- function ( ) { showClock ( ) ; } ) ;
43- } // End macgap setup
44- var isNode = ( typeof process !== "undefined" && typeof require !== "undefined" ) ;
45- if ( isNode ) {
46- // GUI handler options for running in node-webkit
47- var gui = require ( 'nw.gui' ) ;
48- var win = gui . Window . get ( ) ;
49- var menubar = new gui . Menu ( { type : 'menubar' } ) ;
50- var mrun = new gui . Menu ( ) ;
51- menubar . append ( new gui . MenuItem ( { label : 'Run...' , submenu : mrun } ) ) ;
52-
53- mrun . append ( new gui . MenuItem ( {
54- label : 'Preset 1' ,
55- click : function ( ) { document . getElementById ( 'preset0' ) . click ( ) ; } ,
56- key : 'F1'
57- } ) ) ;
58- mrun . append ( new gui . MenuItem ( {
59- label : 'Preset 2' ,
60- click : function ( ) { document . getElementById ( 'preset1' ) . click ( ) ; } ,
61- key : 'F2'
62- } ) ) ;
63- mrun . append ( new gui . MenuItem ( {
64- label : 'Preset 3' ,
65- click : function ( ) { document . getElementById ( 'preset2' ) . click ( ) ; } ,
66- key : 'F3'
67- } ) ) ;
68- mrun . append ( new gui . MenuItem ( {
69- label : 'Demo' ,
70- click : function ( ) { document . getElementById ( 'demo' ) . click ( ) ; } ,
71- key : 'F4'
72- } ) ) ;
73- mrun . append ( new gui . MenuItem ( {
74- label : 'Clock' ,
75- click : function ( ) { showClock ( ) ; } ,
76- key : 'c'
77- } ) ) ;
78-
79- win . menu = menubar ;
80- } // End node setup
81- // Load the sound clip
29+ // Load the sound clip
8230 $ ( "#timeupsnd" ) . trigger ( 'load' ) ;
8331 setupGui ( ) ;
8432 updateDisplay ( ) ;
@@ -88,15 +36,15 @@ function userTimer(F) {
8836 startTimer ( F . userTalk . value * 60 , F . userQA . value * 60 ) ;
8937}
9038function startTimer ( talkSecs , qaSecs ) {
39+ elapsed = 0 ;
40+ qaTime = 0 ;
9141 if ( talkSecs > 0 ) {
92- elapsed = 0 ;
9342 $ ( "#mode" ) . html ( jstConfig [ "presVocab" ] ) ;
9443 ticks = talkSecs ;
9544 talkPart = 1 ;
9645 qaTime = qaSecs ;
9746 } else {
9847 if ( qaSecs > 0 ) {
99- elapsed = 0 ;
10048 $ ( "#mode" ) . html ( jstConfig [ "qaVocab" ] ) ;
10149 talkPart = 2 ;
10250 ticks = qaSecs ;
@@ -133,15 +81,20 @@ function updateDisplay() {
13381 pieChart . update ( ) ;
13482 }
13583}
84+
85+ // timerFunc is the main tick handler
13686function timerFunc ( ) {
13787 ticks = ticks - 1 ;
13888 elapsed = elapsed + 1 ;
13989 if ( ticks <= 0 ) {
14090 var x = document . getElementById ( 'autoQA' ) ;
141- if ( talkPart == 1 && x . checked ) {
91+ if ( talkPart == 1 && x . checked && qaTime > 0 ) {
14292 talkPart = 2 ;
14393 ticks = qaTime ;
14494 updateDisplay ( ) ;
95+ if ( jstConfig . qasoundOn ) {
96+ $ ( "#qasnd" ) . trigger ( 'play' ) ;
97+ }
14598 $ ( "#mode" ) . html ( "Question / Answer" ) ;
14699 } else {
147100 updateDisplay ( ) ;
@@ -221,8 +174,9 @@ function goHelp() {
221174}
222175
223176function handleKey ( evt ) {
224- var theKey = ( evt . which ) ? evt . which : evt . keyCode ;
225- if ( theKey > 111 && theKey < 119 ) {
177+ var theKey = evt . which ;
178+ // Disabled for now
179+ if ( false && theKey > 111 && theKey < 119 ) {
226180 // F1-F8 keys, - Activate presets
227181 evt . preventDefault ( ) ;
228182 var presetNum = theKey - 112 ;
0 commit comments