473,326 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

show a div when timer count down reaches < 00:00

I have a scenario where i need to show a div when the timer total value is < 0 Here is the directive code:
Expand|Select|Wrap|Line Numbers
  1. angular.module('iSourcingApp.tpModule')
  2. .directive('stopWatch', function($state) {
  3.     return {
  4.         restrict: 'A',
  5.         replace: false,
  6.         scope: {
  7.             name: "=",
  8.             timeOfInterview: "=",
  9.             onSend: '&',
  10.             startInterview: '&',
  11.             viewPage: "="
  12.         },
  13.         controller: function($scope, $rootScope, $interval) {
  14.             debugger
  15.             $rootScope.showDiv = {};
  16.             $scope.getTimeRemaining = function(endtime) {
  17.                 $scope.t[$scope.name].total = Date.parse(endtime) - Date.parse(new Date());
  18.                 $scope.t[$scope.name].seconds = Math.floor(($scope.t[$scope.name].total / 1000) % 60);
  19.                 $scope.t[$scope.name].minutes = Math.floor(($scope.t[$scope.name].total / 1000 / 60) % 60);
  20.                 $scope.t[$scope.name].hours = Math.floor(($scope.t[$scope.name].total / (1000 * 60 * 60)) % 24);
  21.                 $scope.t[$scope.name].days = Math.floor($scope.t[$scope.name].total / (1000 * 60 * 60 * 24));
  22.             }
  23.             $scope.initializeClock = function(endtime) {
  24.                 debugger
  25.                 $scope.t = {};
  26.                 $scope.t[$scope.name] = {};
  27.                 $scope.updateClock = function() {
  28.                     debugger
  29.                     $scope.getTimeRemaining(endtime);
  30.                     $scope.t[$scope.name].hours = ('0' + $scope.t[$scope.name].hours).slice(-2);
  31.                     $scope.t[$scope.name].minutes = ('0' + $scope.t[$scope.name].minutes).slice(-2);
  32.                     $scope.t[$scope.name].seconds = ('0' + $scope.t[$scope.name].seconds).slice(-2);
  33.                     if ($scope.t[$scope.name].total == 0) {
  34.                         console.log($scope.t[$scope.name].total);
  35.                         $interval.cancel($scope.timeinterval);
  36.                         $rootScope.showDiv[$scope.name] = true;
  37.                         alert("Start interview for " + $scope.name);
  38.                     } else {
  39.                         if ($scope.t[$scope.name].total < 0) {
  40.                             $interval.cancel($scope.timeinterval);
  41.                             $rootScope.showDiv[$scope.name] = true;
  42.                         }
  43.                     }
  44.                 }
  45.                 $scope.updateClock();
  46.                 $scope.timeinterval = $interval($scope.updateClock, 1000);
  47.             }
  48.             $scope.initializeClock($scope.timeOfInterview);
  49.         },
  50.         templateUrl: function() {
  51.             var tpl = $state.current.name;
  52.             return './tpModule/views/' + tpl + '.html';
  53.         }
  54.     };
  55. });
  56.  
Here if $scope.t[$scope.name].total < 0then i am setting showDiv to true and when it is true i m showing a div

Expand|Select|Wrap|Line Numbers
  1. <div ng-show="showDiv[candidateInfo.name]" class="col-xs-offset-4 showDiv">
  2.             <p class="timer-text">The interview for {{candidateInfo.name}} has crossed scheduled time</p>
  3.             <div class="row showDiv" >
  4.                 <a class="timer-text col-xs-3" style="cursor:pointer" ng-click="fnReschedule(candidateInfo.name, candidateInfo.recruiter)"><i >reschedule</i></a>
  5.                 <a class="timer-text col-xs-3" style="cursor:pointer" ng-click="fnStartInterview(candidateInfo.name,candidateInfo.presentRound,candidateInfo.askedQuestions,candidateInfo._id,candidateInfo.dateOfInterview)"><i class="text-center">start interview</i></a>
  6.             </div>
  7.         </div>
  8.  
So,what is happening here is initially some template is shown and after a sec or so the div is shown but i need not show the template initially if the timer is < 0

and the timer is different for different candidates

Any help would be appreciated.
Aug 5 '16 #1
0 1256

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Trint Smith | last post by:
I need to display a timer ticking down. Example: 11h:52m:39s to 00h:00m:00s How can I do this? Thanks, Trint .Net programmer trintsmith@hotmail.com
2
by: HeroinNO.4 | last post by:
Copy the code below and save in a .htm file, for example : 1.htm, then run it in browser, you'll see a cool count down timer ! If it doesn't work, you may open http://www.fillweb.com in IE and...
1
by: HeroinNO.4 | last post by:
Hello guys, sorry for my last version has a little "feature"(MS always call his bug "feature"), and now I fixed it and show the source to you all ! Just as the last version, copy the code below and...
2
by: HeroinNO.4 | last post by:
Hello guys, now the source code updated to November 06, 2006 00:00 GMT,and now I fixed it and show the source to you all ! Just as the last version, copy the code below and save in a .htm file, fox...
1
by: HeroinNO.4 | last post by:
You can open http://www.fillweb.com in IE and View->Source to see the latest version full featured count down timer source code, or you may also copy the code below and save in a "*.htm" file, for...
2
by: HeroinNO.4 | last post by:
Hello everyone! Now the latest version of free count down timer source code is available in http://www.fillweb.com/countdown.htm, you can open it in IE and View->Source to see the latest version...
7
by: HeroinNO.4 | last post by:
Hello guys, free count down timer source code has updated to 06/11/27, you can copy the code below and save in a ".htm" file and run it in a browser support javascript 1.1 or later, or you can open...
2
by: KMEscherich | last post by:
Am using Access '97 This is going on a form. Hi there, would like to know if there is a way to count down the days from when a user enters a date in a specific date field. If so, can someone...
3
missshaikh
by: missshaikh | last post by:
Hi all, i need the count down timer when button click the timer start and count down work on ASP.net :( i have one timer which is on JavaScript that run page onload . but i need the Button...
0
by: pratk | last post by:
how to postback gridview when timer counts 0.radio buttons inside gv should be disabled when timer counts......any help would save my life......
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.