Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var interval = setInterval(function() {
- $.ajax({
- url: "conf/checktime.php",
- type: 'GET',
- data: '',
- async: false,
- dataType: "json",
- success: function (data) {
- console.log(data);
- var timer2 = localStorage.getItem('timer');
- if(data.status == 'Ada'){
- if(timer2 === null) timer2 = "02:00";
- $('.countdown').html(timer2);
- var interval = setInterval(function() {
- var timer = timer2.split(':');
- var minutes = parseInt(timer[0], 10);
- var seconds = parseInt(timer[1], 10);
- --seconds;
- minutes = (seconds < 0) ? --minutes : minutes;
- if (minutes < 0){
- clearInterval(interval);
- localStorage.removeItem('timer');
- $('.countdown').html('');
- $.ajax({
- url: "conf/checktimeupdate.php",
- type: 'GET',
- data: '',
- async: false,
- dataType: "json",
- success: function (data) {
- },
- cache: false,
- contentType: false,
- });
- }else{
- seconds = (seconds < 0) ? 59 : seconds;
- seconds = (seconds < 10) ? '0' + seconds : seconds;
- $('.countdown').html(minutes + ':' + seconds);
- timer2 = minutes + ':' + seconds;
- localStorage.setItem('timer',timer2);
- }
- }, 1000);
- }else if(data.status == 'Tidak'){
- console.log("B");
- // clearInterval(interval);
- $('.countdown').html('');
- localStorage.removeItem('timer');
- }
- },
- cache: false,
- contentType: false,
- });
- }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment