2016-11-23 8 views
0

したがって、countDown.jsプラグインを使用して次のコールスケジュールを表示しています。CountDown.jsのコールバックで現在のcountdwon時間を取得する方法

endTimeの5分前、2分前、1秒前にpoupを作成したいと思います。

今のところ、終了時刻の1秒前にポップアップを表示することができます。私のコードは以下の通りです。

<script type="text/javascript"> 
      $(function() { 
       var austDay = new Date(<?php echo strtotime(Date::Add($next_scheduled_call->next_call_time))*1000; ?>); 
       $('#defaultCountdown').countdown({until: austDay,onExpiry: callDue}); 
      }); 

      function callDue(){ 
       @if($isSalesManagerGroup == 'no') 
        alert('Your Call is Get to Due , Please Update Soon.'); 
        location.href= "{{ URL::to('/home/leads/history/'.$next_scheduled_call->leads_id.'')}}"; 
       @endif  
      } 
     </script> 

どのように私はいくつかのDate機能により上記の要件

答えて

0

を取得するには、次のようにsetTimeoutの助けを借りて、あなたがこれを達成することができ、このコードを変更することができます。

<script type="text/javascript"> 
    $(function() { 
     var austDay = new Date(<?php echo strtotime(Date::Add($next_scheduled_call->next_call_time))*1000; ?>); 
     var currentDate = new Date(); //current Date 
     var diff_in_sec = (austDay.getTime() - currentDate.getTime())/ 1000; 

     var Seconds_Between_Dates = Math.ceil(diff_in_sec); 

     var timeBefore5Min = Seconds_Between_Dates - (5 * 60); 
     var timeBefore2Min = Seconds_Between_Dates - (2 * 60); 

     $('#defaultCountdown').countdown({until: austDay,onExpiry: callDue}); 

     setTimeout(function(){ 
      callDue(); //calling function before 5 min 
     },timeBefore5Min * 1000); 

     setTimeout(function(){ 
      callDue(); //calling function before 2 min 
     },timeBefore2Min * 1000); 
    }); 

    function callDue(){ 
     @if($isSalesManagerGroup == 'no') 
      alert('Your Call is Get to Due , Please Update Soon.'); 
      location.href= "{{ URL::to('/home/leads/history/'.$next_scheduled_call->leads_id.'')}}"; 
     @endif  
    } 
</script> 
関連する問題