javascript
  • countdown
  • repeat
  • 2017-04-08 1 views 0 likes 
    0
    $(function(){ 
        var response = [ 
         {"time":1491656400,"name":"Boss Event","img":"<img style='width:38px;height:38px;' src='http://vignette4.wikia.nocookie.net/tibia/images/f/f4/Hellgorak.gif/revision/latest?cb=20081010165415&path-prefix=en'/>"}, 
         {"time":1491674400,"name":"Paintball Event ","img":"<img style='width:38px;height:38px;' src='http://vignette3.wikia.nocookie.net/tibia/images/3/3d/Snowball.gif/revision/latest?cb=20080124055247&path-prefix=en'/>"} 
        ]; 
        $.each(response, function(i, item, name) { 
         var time = new Date(item.time*1000) ; 
         $('#timer').append('<tr><td valign="middle">'+ item.img +'</td><td style="width: 213px;text-align:center;"><strong>'+ item.name +'</strong><br><span id="t'+ i +'"></span></td></tr>'); 
         $('#t'+i).countdown({ 
          until: time, 
          compact: true, 
          format: 'HMS' 
         }); 
        }); 
    }); 
    

    내 경골 서버의 "이벤트 타이머"로 이것을 사용하고 솔직히 말해서 어떻게 작동하는지 모르겠지만 단지 도움을 요청하고 싶습니다. 예를 들어 3 시간을 설정하는 방법을 알아 냈지만 일단 0에 도달하면 끝납니다. 카운트 다운이 0으로 돌아 가면 다시 시작하는 방법이 있습니까?완료되면이 카운트 다운을 다시 시작하십시오

    감사합니다.

    답변

    0

    나머지 코드를 보지 않고도 "응답 변수"내의 에포크 타임 스탬프가 jquery ".countdown"을 종료하는지 식별하는 것은 어렵습니다. 이 경우 카운트 다운 후 에포크 시간에 추가 된 시간으로 응답 변수를 다시 선언 한 다음 해당 함수를 다시 호출하십시오. 예 -

    function(){ 
          var time1 = currentTime.getTime()+3*60*60*1000; //time+3hrs 
          var time2 = currentTime.getTime()+3*60*60*1000; //time+3hrs 
    //now, declare the new response items 
          var response = [ 
         {"time":time1,"name":"Boss Event","img":"<img style='width:38px;height:38px;'src='http://vignette4.wikia.nocookie.net/tibia/images/f/f4/Hellgorak.gif/revision/latest?cb=20081010165415&path-prefix=en'/>"}, 
         {"time":time2,"name":"Paintball Event ","img":"<img style='width:38px;height:38px;' src='http://vignette3.wikia.nocookie.net/tibia/images/3/3d/Snowball.gif/revision/latest?cb=20080124055247&path-prefix=en'/>"} 
         ]; 
         $.each(response, function(i, item, name) { //loop through the countdown for each of the response items 
         var time = new Date(item.time*1000) ; 
         $('#timer').append('<tr><td valign="middle">'+ item.img +'</td><td style="width: 213px;text-align:center;"><strong>'+ item.name +'</strong><br><span id="t'+ i +'"></span></td></tr>'); 
         $('#t'+i).countdown({ 
          until: time, 
          compact: true, 
          format: 'HMS' 
         }); //end of the countdown 
         }); //end for each of the response items 
    //recall the function here 
        }); 
    
    관련 문제