$(document).ready(function() { reloadPageContent(); refreshContent();}); refreshContent(); // function to refresh content every 1 second function reloadPageContent() { var timeInterval = 12000; // set interval for the refresh setInterval(function() { refreshContent() }, timeInterval); } function refreshstarter() { var vrecno = 0; // Get the vrecno value from URL var sPageURL = window.location.search.substring(1); var sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == 'vrecno') { vrecno = sParameterName[1]; break; } } var xmlPath = "endata.php"; var starterlist = "starterlist"; ajaxGetXml(xmlPath, starterlist, vrecno, false); } function refreshContent() { var vrecno = 0; // Get the vrecno value from URL var sPageURL = window.location.search.substring(1); var sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == 'vrecno') { vrecno = sParameterName[1]; break; } } var xmlPath = "endata.php"; var xmlPathLastnight = "http://www.hksoccerdb.com/hksoccerdb.com"; var starterlist = "starterlist"; var win = "win"; var sectionmark = "sectionmark"; var pla = "pla"; var qin = "qin"; var pqin = "pqin"; var cc = "cc"; var ccp= "ccp"; var ccqin = "ccqin"; var ccpqin = "ccpqin"; ajaxGetXml(xmlPath, win, vrecno, 0); ajaxGetXml(xmlPath, pla, vrecno, 0); } function ajaxGettimeXml(xmlPath, xmlName, vrecno, isLastnight) { $.ajax({ type: "GET", cache: false, url: xmlPath + "?vtype=" + xmlName +"&vrno="+ vrecno+"&tttt=2912250429&t=0" , success: function(result) { var xmlDoc = result; $.ajax({ type: "GET", cache: false, url: xmlPath + "?vtype=" + xmlName +"&vrno="+ vrecno+"&tttt=2912250429&t=" + isLastnight , success: function(result) { var xmlDoc1 = result; fillinXML(xmlDoc, vrecno, xmlName, isLastnight,xmlDoc1); } }); } }); } function ajaxGetXml(xmlPath, xmlName, vrecno, isLastnight) { $.ajax({ type: "GET", cache: false, url: xmlPath + "?vtype=" + xmlName +"&vrno="+ vrecno+"&tttt=2912250429&t=0" + isLastnight , success: function(result) { var xmlDoc = result; fillinXML(xmlDoc, vrecno, xmlName, isLastnight); } }); } function fillinXML(xmlDoc, vrecno, type, isLastnight,xmlDoc1) { if(type == "starterlist") { // Parse xml doc, and fill nodes values to table rows var horseList = xmlDoc.getElementsByTagName("HORSE"); var horseNameCList = xmlDoc.getElementsByTagName("HORSE_NAME_C"); for(i=0; i 0) { document.getElementById("horsename"+ix).innerHTML = horseNameCList[i].childNodes[0].nodeValue; } } } var pvalue = ''; var pbackgroup = 'GridData2'; if (isLastnight != 0) { pvalue = 'P'; pbackgroup = 'GridData2'; } if(type == "win" ) { var horseList = xmlDoc.getElementsByTagName("HORSE"); var WinTime = xmlDoc.getElementsByTagName("RACE"); document.getElementById(pvalue+"WINTIME").innerHTML = WinTime[0].getAttribute("TIME").substr(6, 2)+":"+WinTime[0].getAttribute("TIME").substr(8, 2); for(i=0; i 19) {document.getElementById("WDROP"+ix).className = "GridDatafontdrop20";}if (horseList[i].getAttribute("ODDSDROP") > 49) {document.getElementById("WDROP"+ix).className = "GridDatafontdrop50";} if(horseList[i].getAttribute("HOT") == "1") { document.getElementById(pvalue+"WIN"+ix).className = "GridDatafav"; } else { document.getElementById(pvalue+"WIN"+ix).className = pbackgroup; } } } if(type == "pla") { var horseList = xmlDoc.getElementsByTagName("HORSE"); for(i=0; i 19) { document.getElementById("PDROP"+ix).className = "GridDatafontdrop20"; } if (horseList[i].getAttribute("ODDSDROP") > 49) { document.getElementById("PDROP"+ix).className = "GridDatafontdrop50"; } if (horseList[i].childNodes[0].nodeValue.substring(0,1)=='T') { document.getElementById(pvalue+"PLA"+ix).innerHTML = atob(horseList[i].childNodes[0].nodeValue.replace('T','')); } else { document.getElementById(pvalue+"PLA"+ix).innerHTML =horseList[i].childNodes[0].nodeValue; } if(horseList[i].getAttribute("HOT") == "1") { document.getElementById(pvalue+"PLA"+ix).className = "GridDatafav"; } else { document.getElementById(pvalue+"PLA"+ix).className = pbackgroup; } } } if(type == "cc") { var horseList = xmlDoc.getElementsByTagName("HORSE"); var WinTime = xmlDoc.getElementsByTagName("RACE"); document.getElementById("WINTIME").innerHTML = WinTime[0].getAttribute("CCTIME") for(i=0; i
" + horseList[i].getAttribute("PRICE"); if (horseList[i].getAttribute("WATE") > 79) { document.getElementById("cce"+horseList[i].getAttribute("NO")).className = "Header10" } else { document.getElementById("cce"+horseList[i].getAttribute("NO")).className = "Header1" } } } if(type == "ccp") { var horseList = xmlDoc.getElementsByTagName("HORSE"); for(i=0; i
" + horseList[i].getAttribute("PRICE"); if (horseList[i].getAttribute("WATE") > 79) { document.getElementById("ccpe"+horseList[i].getAttribute("NO")).className = "Header10" } else { document.getElementById("ccpe"+horseList[i].getAttribute("NO")).className = "Header1" } } } if(type == "ccqin") { var horseList = xmlDoc.getElementsByTagName("HORSE"); for(i=0; i
" + Math.round((horseList[i].getAttribute("PRICE"))/100); if (horseList[i].getAttribute("WATE") > 81 && horseList[i].getAttribute("WATE") < 84.9) { document.getElementById("CCQIN"+horseList[i].getAttribute("NO")).className = "GridDatah3" } if (horseList[i].getAttribute("WATE") >= 85 && horseList[i].getAttribute("WATE") < 89.9) { document.getElementById("CCQIN"+horseList[i].getAttribute("NO")).className = "GridDatah1" } if (horseList[i].getAttribute("WATE") >= 90) { document.getElementById("CCQIN"+horseList[i].getAttribute("NO")).className = "GridDatah2" } if (horseList[i].getAttribute("WATE") < 82) { document.getElementById("CCQIN"+horseList[i].getAttribute("NO")).className = "GridData" } } } if(type == "ccpqin") { var horseList = xmlDoc.getElementsByTagName("HORSE"); for(i=0; i
" + Math.round((horseList[i].getAttribute("PRICE"))/100); if (horseList[i].getAttribute("WATE") > 81 && horseList[i].getAttribute("WATE") < 84.9) { document.getElementById("CCPQIN"+horseList[i].getAttribute("NO")).className = "GridDatah3" } if (horseList[i].getAttribute("WATE") >= 85 && horseList[i].getAttribute("WATE") < 89.9) { document.getElementById("CCPQIN"+horseList[i].getAttribute("NO")).className = "GridDatah1" } if (horseList[i].getAttribute("WATE") >= 90) { document.getElementById("CCPQIN"+horseList[i].getAttribute("NO")).className = "GridDatah2" } if (horseList[i].getAttribute("WATE") < 82) { document.getElementById("CCPQIN"+horseList[i].getAttribute("NO")).className = "GridData" } } } if(type == "qin") { if (isLastnight != 0 ) { var horseList1 = xmlDoc1.getElementsByTagName("HORSE"); var QinPool1 = xmlDoc1.getElementsByTagName("QINPOOL"); document.getElementById("QINPOOL1").innerHTML = "Q:"+formatNumber(QinPool1[0].childNodes[0].nodeValue); } var horseList = xmlDoc.getElementsByTagName("HORSE"); var QinPool = xmlDoc.getElementsByTagName("QINPOOL"); document.getElementById("QINPOOL").innerHTML = "Q:"+formatNumber(QinPool[0].childNodes[0].nodeValue); for(i=0; i 19) { vgrid = "GridDatadrop20"; } if (horseList[i].getAttribute("ODDSDROP") > 49) { vgrid = "GridDatadrop50"; } } if (horseList[i].getAttribute("HOT") == '1') { vfont1 = ''; } if (isLastnight != 0 ) { if (horseList1[i].getAttribute("HOT") == '1') { vfont = ''; } document.getElementById("QIN"+horseList[i].getAttribute("NO")).innerHTML = vfont+horseList1[i].childNodes[0].nodeValue+"
"+vfont1+horseList[i].childNodes[0].nodeValue+"
"; } else { document.getElementById("QIN"+horseList[i].getAttribute("NO")).innerHTML = vfont1+horseList[i].childNodes[0].nodeValue+"
"; } // document.getElementById("QIN"+horseList[i].getAttribute("NO")).className = "GridData" if (isLastnight != 0 ) { document.getElementById("QIN"+horseList[i].getAttribute("NO")).className = favbgcolor(horseList[i].childNodes[0].nodeValue,horseList1[i].childNodes[0].nodeValue,isLastnight) } else { document.getElementById("QIN"+horseList[i].getAttribute("NO")).className = vgrid } } } if(type == "pqin") { if (isLastnight != 0 ) { var horseList1 = xmlDoc1.getElementsByTagName("HORSE"); var PQinPool1 = xmlDoc1.getElementsByTagName("PQINPOOL"); document.getElementById("PQINPOOL1").innerHTML = "PQ:"+formatNumber(PQinPool1[0].childNodes[0].nodeValue); } var horseList = xmlDoc.getElementsByTagName("HORSE"); var PQinPool = xmlDoc.getElementsByTagName("PQINPOOL"); document.getElementById("PQINPOOL").innerHTML = "PQ:"+formatNumber(PQinPool[0].childNodes[0].nodeValue); for(i=0; i 19) { vgrid = "GridDatadrop20"; } if (horseList[i].getAttribute("ODDSDROP") > 49) { vgrid = "GridDatadrop50"; } } if (horseList[i].getAttribute("HOT") == '1') { vfont1 = ''; } if (isLastnight != 0 ) { if (horseList1[i].getAttribute("HOT") == '1') { vfont = ''; } document.getElementById("PQIN"+horseList[i].getAttribute("NO")).innerHTML = vfont+horseList1[i].childNodes[0].nodeValue+"
"+vfont1+horseList[i].childNodes[0].nodeValue+"
"; } else { document.getElementById("PQIN"+horseList[i].getAttribute("NO")).innerHTML = vfont1+horseList[i].childNodes[0].nodeValue+"
"; } if (isLastnight != 0 ) { document.getElementById("PQIN"+horseList[i].getAttribute("NO")).className = favbgcolor(horseList[i].childNodes[0].nodeValue,horseList1[i].childNodes[0].nodeValue,isLastnight) } else { document.getElementById("PQIN"+horseList[i].getAttribute("NO")).className = vgrid } } } if(type == "fct") { if (isLastnight != 0 ) { var horseList1 = xmlDoc1.getElementsByTagName("HORSE"); var QinPool1 = xmlDoc1.getElementsByTagName("FCTPOOL"); } var horseList = xmlDoc.getElementsByTagName("HORSE"); var QinPool = xmlDoc.getElementsByTagName("FCTPOOL"); for(i=0; i 19) { vgrid = "GridDatadrop20"; } if (horseList[i].getAttribute("ODDSDROP") > 49) { vgrid = "GridDatadrop50"; } } if (horseList[i].getAttribute("HOT") == '1') { vfont1 = ''; } if (isLastnight != 0 ) { if (horseList1[i].getAttribute("HOT") == '1') { vfont = ''; } document.getElementById("QIN"+horseList[i].getAttribute("NO")).innerHTML = vfont+horseList1[i].childNodes[0].nodeValue+"
"+vfont1+horseList[i].childNodes[0].nodeValue+"
"; } else { document.getElementById("QIN"+horseList[i].getAttribute("NO")).innerHTML = vfont1+horseList[i].childNodes[0].nodeValue+"
"; } // document.getElementById("QIN"+horseList[i].getAttribute("NO")).className = "GridData" if (isLastnight != 0 ) { document.getElementById("QIN"+horseList[i].getAttribute("NO")).className = favbgcolor(horseList[i].childNodes[0].nodeValue,horseList1[i].childNodes[0].nodeValue,isLastnight) } else { document.getElementById("QIN"+horseList[i].getAttribute("NO")).className = vgrid } } } if (type == 'sectionmark'){ var horseList = xmlDoc.getElementsByTagName("RACE"+vrecno); if (horseList[0].getAttribute("T1") != 0){ vtxt = '隔夜'; vtxtclass = 'Header1'; } else { vtxt = '隔夜'; vtxtclass = 'Header2'; } document.getElementById("SEC1").innerHTML = vtxt; document.getElementById("SEC1").className = vtxtclass; if (horseList[0].getAttribute("T2") != 0){ vtxt = '賽日12:00'; vtxtclass = 'Header1'; } else { vtxt = '賽日12:00'; vtxtclass = 'Header2'; } document.getElementById("SEC2").innerHTML = vtxt; document.getElementById("SEC2").className = vtxtclass; if (horseList[0].getAttribute("T3") != 0){ vtxt = '頭場前2小時'; vtxtclass = 'Header1'; } else { vtxt = '頭場前2小時'; vtxtclass = 'Header2'; } document.getElementById("SEC3").innerHTML = vtxt; document.getElementById("SEC3").className = vtxtclass; if (horseList[0].getAttribute("T4") != 0){ vtxt = '30'; vtxtclass = 'Header1'; } else { vtxt = '30'; vtxtclass = 'Header2'; } document.getElementById("SEC4").innerHTML = vtxt; document.getElementById("SEC4").className = vtxtclass; if (horseList[0].getAttribute("T5") != 0){ vtxt = '25'; vtxtclass = 'Header1'; } else { vtxt = '25'; vtxtclass = 'Header2'; } document.getElementById("SEC5").innerHTML = vtxt; document.getElementById("SEC5").className = vtxtclass; if (horseList[0].getAttribute("T6") != 0){ vtxt = '20'; vtxtclass = 'Header1'; } else { vtxt = '20'; vtxtclass = 'Header2'; } document.getElementById("SEC6").innerHTML = vtxt; document.getElementById("SEC6").className = vtxtclass; if (horseList[0].getAttribute("T7") != 0){ vtxt = '15'; vtxtclass = 'Header1'; } else { vtxt = '15'; vtxtclass = 'Header2'; } document.getElementById("SEC7").innerHTML = vtxt; document.getElementById("SEC7").className = vtxtclass; if (horseList[0].getAttribute("T8") != 0){ vtxt = '10'; vtxtclass = 'Header1'; } else { vtxt = '10'; vtxtclass = 'Header2'; } document.getElementById("SEC8").innerHTML = vtxt; document.getElementById("SEC8").className = vtxtclass; if (horseList[0].getAttribute("T9") != 0){ vtxt = '5'; vtxtclass = 'Header1'; } else { vtxt = '5'; vtxtclass = 'Header2'; } document.getElementById("SEC9").innerHTML = vtxt; document.getElementById("SEC9").className = vtxtclass; if (horseList[0].getAttribute("T10") != 0){ vtxt = '2'; vtxtclass = 'Header1'; } else { vtxt = '2'; vtxtclass = 'Header2'; } document.getElementById("SEC10").innerHTML = vtxt; document.getElementById("SEC10").className = vtxtclass; } } function formatNumber(str, glue) { if(isNaN(str)) { return NaN; } var glue= (typeof glue== 'string') ? glue: ','; var digits = str.toString().split('.'); var integerDigits = digits[0].split(""); var threeDigits = []; while (integerDigits.length > 3) { threeDigits.unshift(integerDigits.splice(integerDigits.length - 3, 3).join("")); } threeDigits.unshift(integerDigits.join("")); digits[0] = threeDigits.join(glue); return digits.join("."); } function favbgcolor(str1,str2,ptime) { var bgcolor = ''; if ( str2-str1 > (str1/100)*5 ) { bgcolor = 'GridDatah3'; } else { bgcolor = 'GridData'; } if ( str2-str1 > (str1/10)*1 ) { bgcolor = 'GridDatah'; } if ( str2-str1 > (str1/10)*2 ) { bgcolor = 'GridDatah1'; } if ( str2-str1 > (str1/10)*3 ) { bgcolor = 'GridDatah2'; } return bgcolor; } var Base64 = { // private property _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode : function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, // public method for decoding decode : function (input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = Base64._utf8_decode(output); return output; }, // private method for UTF-8 encoding _utf8_encode : function (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // private method for UTF-8 decoding _utf8_decode : function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } }