var intervalId; function Countdown(idName) { var gmtNow = Math.floor((new Date()).getTime() / 1000); var matchTime = "1508659200"; var dd = matchTime - gmtNow; if (dd<0) { clearInterval(intervalId); $.ajaxSetup({ cache: true }); LoadScore(idName); setInterval(function() { LoadScore(idName); }, 15000); return; } var dday=Math.floor(dd/(60*60*24)*1); var dayUnit = dday<2 ? " day" : " days"; var dhour=Math.floor((dd%(60*60*24))/(60*60)); var dhour = dhour < 10 ? dhour='0'+dhour : dhour; var dmin=Math.floor(((dd%(60*60*24))%(60*60))/(60)); var dmin = dmin < 10 ? dmin='0'+dmin : dmin; var dsec=Math.floor(((dd%(60*60*24))%(60*60))%(60)); var dsec = dsec < 10 ? dsec='0'+dsec : dsec; var matchName = "South Africa vs Bangladesh - 3rd ODI "; var remainingTime = dday + dayUnit + " "+ dhour + ":" + dmin + ":" + dsec; $("#"+idName).html(""+matchName+ " - " + remainingTime+""); $("#"+idName).css({ "font-family": "Trebuchet MS, Verdana, Arial", "font-size": "10pt", "display": "inline-block" }); } function ProcessLiveScore(data, elementId) { var team1 = '
'+data["team1"]+'
'; var team2 = '
'+data["team2"]+'
'; var score = '
'+data["scoreline"]+'
'; var node = "#"+elementId; $(node).html(team1+" vs "+team2+score); $(".team").css( { "font-size": "12pt", "display": "inline-block" }); } function LoadScore(elementId) { var node = "#"+elementId; $.getJSON({ url: "/alochona/custombc/api/dynamicscore.php?q=ls&matchid=195926", success: function(data) { ProcessLiveScore(data, elementId); } }); } /* $(document).ready(function() { Countdown(); intervalId = setInterval(function() { Countdown(); }, 1000); }); */