LEAGUES
- < Back
- Wch (IBAF)
- World Baseball Classic
- All
- Wbsc
- Wbsc Premier12
- All
- Usa
- Mlb
- All
- Asian Games
- Asian Games
- All
- Caribbean
- Caribbean Series
- All
- Chinese Taipei
- Cpbl
- All
- Cuba
- Serie Nacional
- All
- Dominican Republic
- Lidom
- All
- Friendly Games
- Friendly Games
- All
- Japan
- Npb
- All
- Mexico
- Lmb
- All
- Olympic Games
- Olympic Games
- All
- Pan Am
- Pan American Games
- All
- South Korea
- Kpb
- All
- Venezuela
- Lvbp
- All
- World Baseball Classic
- World Baseball Classic
- All
Overview
Standings
Matches
"; } function updateMatch(str){ if (str.length > 0) { seq = str.split('\|')[0]; let mId = str.split('\|'); if (mId[3] !== matchId) { xscores.update.seq = mId[0]; setTimeout(initNetty, 100); return; } xscores.update.seq = seq; xscores.update.lastStreamTS = new Date().getTime(); if (str.split('#').length > 1) { let i = 0; let updates = str.split('#'); while (i < updates.length) { if (i > 0) { incomingUpdate('#' + updates[i]); } i++; } } } setTimeout(initNetty, 100); } function errorHandler(statusCode) { console.log("failed with status", statusCode); } function toProperCase(str){ return str.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); } function getBreadcrumbs(data){ let bCrumbsEl = document.getElementsByClassName("breadcrumb-json")[0], countryURL = data.country.replace(/ /g, "-").replace(/_/g, "-").replace(/["'()]/g, "").toLowerCase(), leagueURL, leagueTxt, b_html = ''+toProperCase(data.country)+''; if (data.leagueName === data.parentCompetition){ leagueURL = data.leagueName.replace(/ /g, "-").replace(/_/g, "-").replace(/["'()]/g, "").toLowerCase(); leagueTxt = toProperCase(data.leagueName); }else{ leagueURL = data.parentCompetition.replace(/ /g, "-").replace(/_/g, "-").replace(/["'()]/g, "").toLowerCase(); leagueTxt = toProperCase(data.parentCompetition); } b_html += ''+leagueTxt+''; b_html += data.home+" VS "+data.away; bCrumbsEl.innerHTML = b_html; } function updateMatchObject(data){ if (matchObj.id != 0) return; matchObj.id = matchId; matchObj.status = data.team.status; matchObj.statusType = data.team.statusType; matchObj.score = data.team.rtotalScore; matchObj.htScore = data.team.htScore; matchObj.ftScore = data.team.ftScore; matchObj.etScore = data.team.etScore; matchObj.pnScore = data.team.pnScore; matchObj.note = data.team.note; matchObj.ct = data.team.ct; matchObj.home.id = data.team.homeId; matchObj.home.name = data.team.home; matchObj.away.id = data.team.awayId; matchObj.away.name = data.team.away; matchObj.ko = data.team.ko; matchObj.minute = data.team.minute; matchObj.visible = data.team.visible; if (typeof data.results !== 'undefined' ) { matchObj.events = data.results; for (let a = 0; a < data.results.length; a++) { if (data.results[a].eventType === "c") { if (data.results[a].eventInfo === "Yellow") { if (data.results[a].eventHomeOrAway === "h") { matchObj.home.cards.yellow = matchObj.home.cards.yellow + 1; } else { matchObj.away.cards.yellow = matchObj.away.cards.yellow + 1; } } else if (data.results[a].eventInfo === "Red") { if (data.results[a].eventHomeOrAway === "h") { matchObj.home.cards.red = matchObj.home.cards.red + 1; } else { matchObj.away.cards.red = matchObj.away.cards.red + 1; } } } } } } function createMatchHeader(data) { if (data.team.parentCompetition){ // let titleTxt = data.team.country !== data.team.parentCompetition ? data.team.country + " " + data.team.parentCompetition : data.team.parentCompetition; // document.getElementsByClassName("toolbar_center")[0].textContent = titleTxt; if (data.team.country !== data.team.parentCompetition) { document.getElementsByClassName("toolbar_title")[0].textContent = data.team.country; document.getElementsByClassName("toolbar_subtitle")[0].textContent = data.team.parentCompetition; } else { document.getElementsByClassName("toolbar_title")[0].textContent = data.team.parentCompetition; } } //Breadcrumbs getBreadcrumbs(data.team); //Match header let frag = document.createDocumentFragment(); let teams_wrapper = document.getElementsByClassName("teams_wrapper")[0]; teams_wrapper.innerHTML = ""; //country header// let countryHeader = document.getElementsByClassName("header_country")[0];// let countryFlag = document.createElement("i");// let countryNameEsc = (data.team.country.replace(/[ ()&]/g, "_")).toLowerCase();// countryFlag.setAttribute("class", "flag-icon flag-icon-"+getISOCode(data.team.country.toUpperCase(), 4).toLowerCase());// let countryText = document.createElement("div");// countryText.setAttribute("class", "countryText");// countryText.textContent = data.team.country;// countryHeader.innerHTML = "";// countryHeader.appendChild(countryFlag);// countryHeader.appendChild(countryText); //home team let hTeam = document.createElement("div"); hTeam.setAttribute("class", "hTeam"); let hTeamImg = document.createElement("img"); hTeamImg.setAttribute("class", "match_team_logo backup_picture3 anim_roll-in-left"); hTeamImg.setAttribute("src", imgServer + data.team.homeLogo); hTeamImg.setAttribute("onerror", 'xscores.loadDefaultEmblem(this)'); let hTeamTxt = document.createElement("span"); hTeamTxt.setAttribute("class", "match_team_text wrap"); hTeamTxt.textContent = data.team.home; hTeam.appendChild(hTeamImg); hTeam.appendChild(hTeamTxt); frag.appendChild(hTeam); //match info let match_score = document.createElement("div"); match_score.setAttribute("class", "match_header_score"); let match_details_ko = document.createElement("div"); match_details_ko.setAttribute("class", "match_details_ko"); // match_details_ko.textContent = "K/O: " + data.team.ko; match_details_ko.textContent = data.team.ko; let match_details_score = document.createElement("div"); match_details_score.setAttribute("class", "match_details_score"); match_details_score.textContent = data.team.rtotalScore !== "" ? data.team.rtotalScore.replace("-", " - ") : data.team.rtotalScore = " - "; let match_details_status = document.createElement("div"); match_details_status.setAttribute("class", "match_details_status"); match_details_status.textContent = data.team.status; match_score.appendChild(match_details_ko); match_score.appendChild(match_details_score); // console.log("APPENDING SCORE!!!!!!!"); match_score.appendChild(match_details_status); frag.appendChild(match_score); //away team let aTeam = document.createElement("div"); aTeam.setAttribute("class", "aTeam"); let aTeamImg = document.createElement("img"); aTeamImg.setAttribute("class", "match_team_logo backup_picture3 anim_roll-in-right"); aTeamImg.setAttribute("src", imgServer + data.team.awayLogo); aTeamImg.setAttribute("onerror", 'xscores.loadDefaultEmblem(this)'); let aTeamTxt = document.createElement("span"); aTeamTxt.setAttribute("class", "match_team_text wrap"); aTeamTxt.textContent = data.team.away; aTeam.appendChild(aTeamImg); aTeam.appendChild(aTeamTxt); frag.appendChild(aTeam); teams_wrapper.appendChild(frag); //update x_details variables xscores.sMatch = { leagueCode : data.team.leagueCode, leagueName : data.team.leagueName, leagueNameURL : data.team.parentCompetition.replace(/ /g, "-").toLowerCase(), countryName : data.team.country, leagueShort : data.team.shortName, homeId : data.team.homeId, awayId : data.team.awayId, homeTeam : data.team.home, awayTeam : data.team.away, season: data.team.season }; updateMatchObject(data); getbaseballTimeline1(document.getElementsByClassName("match_timeline")[0], data); showSquareBanner(); } function makeAjaxCall(url, methodType) { let promiseObj = new Promise(function (resolve, reject) { let xhr = new XMLHttpRequest(); xhr.open(methodType, url, true); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('authorization', 'Bearer '+access_token); xhr.send(); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { let respJson = JSON.parse(xhr.responseText); resolve(respJson); } else { reject(xhr.status); console.log("xhr failed"); } } } }); return promiseObj; } function getMatchOdds(odds){ console.log(odds); } function getMatchInfoHTML(infoText, koTime, leagueName, parent){ parent.classList.add("anim_fade-in"); let koTimeSpan = ""; if (koTime) { koTimeSpan = "
Kick Off: " + koTime + "
"; } if (!infoText){ // $("#tab5").html('
No information available
'); if (leagueName) { parent.innerHTML = "
Competition: " + leagueName + "
"; }else{ parent.innerHTML = ""; } return; } let strInfo = infoText.split(". "); let returnTxt = ""; let sideline = false; jQuery.each(strInfo, function(i) { if (strInfo[i].indexOf(":")>0) { let sText = strInfo[i].split(":"); if (sText[0] == "Sidelined Players") { sideline = true; returnTxt += "" + sText[0] + ": "; if (sText[1].indexOf("-")>0){ let sTeam = sText[1].split("-"); returnTxt += sTeam[0]+"
"+sTeam[1]; } }else { returnTxt += "" + sText[0] + ": " + sText[1] + "
"; } }else{ if (sideline == true){ if (strInfo[i].indexOf("-")>0){ let sTeam = strInfo[i].split("-"); returnTxt += "
"+sTeam[0]+"
"+sTeam[1]; } returnTxt += "
"; sideline = false; }else { returnTxt += "" + strInfo[i] + "
"; } } });// let tTxt = "
Match Information
"; let tTxt = ""; if (leagueName) returnTxt = "Competition: " + leagueName + "
" + returnTxt; // $("#tab5").html(tTxt + "
"+returnTxt+"
"); parent.innerHTML = '
' + tTxt + koTimeSpan + "
"+returnTxt+"
"; } function getbaseballTimeline1(parent, obj){ let matchInfo = obj.team; let results = obj.results; let homeTeam = matchInfo.home; let awayTeam = matchInfo.away; let totalRuns = matchInfo.rtotalScore.indexOf("-") > -1 ? matchInfo.rtotalScore.split("-") : ["",""]; let homeR = totalRuns[0]; let awayR = totalRuns[1]; let totalHits = matchInfo.htotalScore.indexOf("-") > -1 ? matchInfo.htotalScore.split("-") : ["",""]; let homeH = totalHits[0]; let awayH = totalHits[1]; let totalErrors = matchInfo.etotalScore.indexOf("-") > -1 ? matchInfo.etotalScore.split("-") : ["",""]; let homeE = totalErrors[0]; let awayE = totalErrors[1]; let homeEX = 0; let awayEX = 0;// let extraInnings = matchInfo.eTotalScore.indexOf("-") > -1 ? matchInfo.eTotalScore.split("-") : ["",""]; let homeEI = ""; let awayEI = ""; let innings = []; for (let ic=1;ic<=parseInt(matchInfo.inningsCount);ic++){ let currentInning = { inningName: ic, inningScore:{ errors: { home: results[0]["p"+ic+"errors"].indexOf("-") > -1 ? results[0]["p"+ic+"errors"].split("-")[0] : "", away: results[0]["p"+ic+"errors"].indexOf("-") > -1 ? results[0]["p"+ic+"errors"].split("-")[1] : "" }, hits: { home: results[0]["p"+ic+"hits"].indexOf("-") > -1 ? results[0]["p"+ic+"hits"].split("-")[0] : "", away: results[0]["p"+ic+"hits"].indexOf("-") > -1 ? results[0]["p"+ic+"hits"].split("-")[1] : "" }, run: { home: results[0]["p"+ic+"run"].indexOf("-") > -1 ? results[0]["p"+ic+"run"].split("-")[0] : "", away: results[0]["p"+ic+"run"].indexOf("-") > -1 ? results[0]["p"+ic+"run"].split("-")[1] : "" } } }; innings.push(currentInning); } var noteInfo = matchInfo.note; var headerHtml = '
R
1
'; headerHtml += '
2
3
4
5
6
'; headerHtml += '
7
8
9
EX
H
E
'; var homeHtml = '
'+homeTeam+'
'+homeR+'
'; let maxIt = innings.length > 9 ? 9 : innings.length; for (let i=0;i
'; } homeHtml += '
'+homeEX+'
'+homeH+'
'+homeE+'