@@ -2,12 +2,119 @@ var spinner = $('#loader');
22const scriptURLC = 'https://script.google.com/macros/s/AKfycbwOfIsJmBwuIP4LF633tpTgrR7GJD9M8b4NN0EZ7fmSueHKXXcr0gMgeCnNzW7n7GFv/exec' ;
33// const scriptURLC ='turd';
44const serverlessForm = document . forms [ 'serverless-form' ] ;
5+ var timerOn = false ;
6+ var bgAnimate = false ;
57
68$ ( "#reset-btn" ) . click ( function ( ) {
79 $ ( "#contactForm" ) . trigger ( "reset" ) ;
810 $ ( ".pulled-detail" ) . html ( "" ) ;
11+ resetTimer ( ) ;
912} ) ;
1013
14+ var countdownDuration = 10 * 60 * 1000 ;
15+
16+ $ ( "#restart-button" ) . click ( function ( ) {
17+
18+ console . log ( "restart button Clicked" ) ;
19+ countdownDuration = 10 * 60 * 1000 ;
20+ $ ( "#stop-timer" ) . html ( "10:00" ) ;
21+ if ( timerOn == false ) {
22+
23+ timerOn = true ;
24+ runTimer ( ) ;
25+
26+ }
27+ bgAnimate = false ;
28+
29+ } )
30+
31+ $ ( "#stop-button" ) . click ( function ( ) {
32+ console . log ( "stop button Clicked" ) ;
33+ resetTimer ( ) ;
34+
35+ } )
36+
37+ function resetTimer ( ) {
38+
39+ timerOn = false ;
40+ bgAnimate = false ;
41+ $ ( "#stop-timer-button" ) . css ( "display" , "inherit" ) ;
42+ $ ( "#stop-timer-div" ) . css ( "display" , "none" ) ;
43+ $ ( "body" ) . css ( "background-color" , "black" ) ;
44+ // clearInterval(timer);
45+ countdownDuration = 10 * 60 * 1000 ;
46+
47+ }
48+
49+ $ ( "#stop-timer-button" ) . click ( function ( ) {
50+
51+ runTimer ( ) ;
52+
53+ } )
54+
55+ function runTimer ( ) {
56+
57+ console . log ( "stop timer button clicked" ) ;
58+ timerOn = true ;
59+ $ ( "#stop-timer-button" ) . css ( "display" , "none" ) ;
60+ $ ( "#stop-timer-div" ) . css ( "display" , "inherit" ) ;
61+ $ ( "#stop-timer" ) . css ( "width" , $ ( "#stop-timer" ) . width ( ) ) ;
62+
63+
64+ var now = new Date ( ) . getTime ( ) ;
65+ var countdownTime = now + countdownDuration ;
66+
67+ console . log ( "Countdown Duration: " + countdownDuration ) ;
68+ console . log ( "current Time: " + now ) ;
69+ console . log ( "Countdown Time: " + countdownTime ) ;
70+
71+ var timer = setInterval ( function ( ) {
72+ console . log ( "Tick" ) ;
73+
74+ var now = new Date ( ) . getTime ( ) ;
75+
76+ var distance = ( now + countdownDuration ) - now ;
77+ console . log ( "countdownTime: " + countdownTime ) ;
78+
79+ var minutes = Math . floor ( ( distance % ( 1000 * 60 * 60 ) ) / ( 1000 * 60 ) ) ;
80+ var seconds = Math . floor ( ( distance % ( 1000 * 60 ) ) / 1000 ) ;
81+ if ( seconds < 10 ) seconds = "0" + seconds ;
82+
83+ $ ( "#stop-timer" ) . html ( minutes + ":" + seconds ) ;
84+
85+ countdownDuration = countdownDuration - 1000 ;
86+
87+ // If the count down is finished, write some text
88+ if ( distance <= 0 ) {
89+ clearInterval ( timer ) ;
90+ countdownDuration = 10 * 60 * 1000 ;
91+ timerOn = false ;
92+ bgAnimate = true ;
93+
94+ var flashRed = setInterval ( function ( ) {
95+
96+ if ( bgAnimate == false ) {
97+ clearInterval ( flashRed ) ;
98+ return ;
99+ }
100+
101+ $ ( "body" ) . animate ( { "background-color" : "rgb(235, 0, 0)" } , 400 )
102+ . delay ( 400 )
103+ . animate ( { "background-color" : "black" } , 400 ) ;
104+
105+ } , 1600 ) ;
106+
107+ }
108+
109+ if ( timerOn == false ) {
110+ clearInterval ( timer ) ;
111+ countdownDuration = 10 * 60 * 1000 ;
112+ }
113+
114+ } , 1000 ) ;
115+
116+ }
117+
11118$ ( "#order-id" ) . change ( function ( ) {
12119
13120 var orderID = $ ( '#order-id' ) . val ( ) ;
@@ -106,6 +213,7 @@ function logTape(e){
106213 if ( result . isConfirmed ) {
107214 // Swal.fire('Saved!', '', 'success')
108215 // $(".resetAble").val("");
216+ resetTimer ( ) ;
109217 $ ( '#order-id' ) . val ( orderID ) ;
110218 $ ( '#stop-time' ) . val ( "" )
111219 $ ( '#tape-num' ) . val ( "" ) ;
0 commit comments