<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<link rel="stylesheet" type="text/css" href="./css/spectatornobordersmassive.css">
<script src="./jquery/jquery-3.5.1.min.js"></script>
<!--<script src="./jquery/jquery.mobile-1.3.0.min.js"></script>
<script src="./jquery/mobiscroll.custom-2.4.4.min.js"></script> -->
<script type="text/javascript">
$(function() {
getStatus();
});
function getStatus() {
$fileName = "score.json?date=" + new Date().toLocaleString(); //ask for the score.json file generated by updateSpectator.php. Include the date to stop the browser caching an old copy
$.getJSON($fileName, function(data) {
//check if the batsman numbers are set, if they are lets show them!
// if (data.batanumber == null)
// {
// document.getElementById("batANumber").className = "batsman_letter";
// document.getElementById("batBNumber").className = "batsman_letter";
// document.getElementById("batANumber").innerHTML="A";
// document.getElementById("batBNumber").innerHTML="B";
// }
// else
{
document.getElementById("batANumber").innerHTML=formatDigits(data.batanumber);
document.getElementById("batBNumber").innerHTML=formatDigits(data.batbnumber);
document.getElementById("batANumber").className = "batsman_digit";
document.getElementById("batBNumber").className = "batsman_digit";
}
document.getElementById("batAScore").innerHTML=formatDigits(data.bata);
document.getElementById("batBScore").innerHTML=formatDigits(data.batb);
document.getElementById("total").innerHTML=formatDigits(data.total);
document.getElementById("overs").innerHTML=formatDigits(data.overs);
document.getElementById("wickets").innerHTML=formatDigits(data.wickets);
document.getElementById("runsreq").innerHTML=formatDigits(data.runsreq);
document.getElementById("lastman").innerHTML=formatDigits(data.lastman);
document.getElementById("lastwkt").innerHTML=formatDigits(data.lastwkt);
document.getElementById("pship").innerHTML=formatDigits(data.pship);
//NEW TR re additional data
//document.getElementById("runsreq").innerHTML=formatDigits(data.runsreq);
//document.getElementById("lastman").innerHTML=formatDigits(data.lastman);
//document.getElementById("lastwkt").innerHTML=formatDigits(data.lastwkt);
//document.getElementById("pship").innerHTML=formatDigits(data.pship);
//END TR re additional data
//check to see if duckworth lewis exists, as this affects the layout.
// if(data.dltarget == null)
// {/
// document.getElementById("target2Heading").className = "noborder";
// document.getElementById("target2Heading").innerHTML="";
// document.getElementById("target2").className = "noborder";
// document.getElementById("target2").innerHTML="";
// document.getElementById("target1").innerHTML=formatDigits(data.target);
// document.getElementById("dl").innerHTML=formatDigits(data.dltarget);
// }
// else
{
document.getElementById("target2Heading").className = "noborder";
document.getElementById("target2Heading").innerHTML="";
document.getElementById("target2").className = "noborder";
document.getElementById("target2").innerHTML="";
document.getElementById("target1").innerHTML=formatDigits(data.target);
document.getElementById("dl").innerHTML=formatDigits(data.dltarget);
}
});
setTimeout("getStatus()",10000); //rerun the function every 10 seconds (including loading the score.json file)
}
function formatDigits(digits) {
var returnStr="";
//split the value into its digit parts, as we want to strip the dashes
digitArray=digits.split("");
for (i=0; i<digitArray.length; i++) {
//ignore this digit if it is a dash
if (digitArray[i] != "-") {
returnStr=returnStr.concat(digitArray[i]);
}
}
// if the input was all dashes, then lets return a 0
if (returnStr==""){
returnStr="0";
}
return returnStr;
}
</script>
</head>