Function updateScoreboard
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
function updateScoreboard(obj) {
try { document.querySelector("div.teamScore#home").innerHTML = obj.Teams.Home.Score; } catch (error) { console.error(error); }
try { document.querySelector("div.teamScore#away").innerHTML = obj.Teams.Away.Score; } catch (error) { console.error(error); }
updateNumber(obj?.Ball, "ball");
Function updateSettings
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
function updateSettings(obj){
const oldMaxInning = parseInt(localStorage.getItem("MaxInning"));
localStorage.setItem("MaxInning",obj.MaxInning);
localStorage.setItem("BlackenLastInning",obj.BlackenLastInning);
Function maxInning
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
function maxInning(obj, extraInningScoreAway, extraInningScoreHome) {
if( obj.Inning <= parseInt(localStorage.getItem("MaxInning"))){
document.documentElement.style.setProperty('--i-inning', localStorage.getItem("MaxInning"));
try{document.querySelector("div.container > div#iex").remove();}catch(error){console.log(error);}
}else if (obj.Inning > parseInt(localStorage.getItem("MaxInning")) + 1 || (obj.Arrow == 2 && obj.Inning == parseInt(localStorage.getItem("MaxInning"))+1) || extraInningScoreAway != 0 || extraInningScoreHome != 0) {
Function updateBase
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
function updateBase(base,id) {
if (base !== undefined) {
if (base) {
try { document.querySelector("div#"+id).classList.remove("disabled"); } catch (error) { console.error(error); }
} else {
Function updateInning
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
function updateInning(obj) {
let { extraInningScoreAway, extraInningScoreHome } = updateGeneralInning(obj);
for (let i = 1; i <= obj.Inning; i++) {
if (i > localStorage.getItem("MaxInning")) {
extraInningScoreAway += obj.Int[i].A;
Function updateTeams
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
function updateTeams(data,team) {
setName(data?.Name, team, ["pregame","postgame"]);
setName(data?.Short, team, ["scoreboard","inning"]);
if (data?.Color !== undefined) {
document.documentElement.style.setProperty('--c-' + team, data.Color);
Function connectSettings
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
function connectSettings(obj) {
localStorage.setItem("MaxInning",obj.MaxInning);
localStorage.setItem("BlackenLastInning",obj.BlackenLastInning);
Function activeDeactiveInning
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
function activeDeactiveInning(i,team,active,score){
if(active){
try{
document.querySelector("#i" + i + " > #"+team).classList.remove("disabledinng");
document.querySelector("#i" + i + " > #"+team).innerHTML = score;
Similar blocks of code found in 2 locations. Consider refactoring.
if (obj.Arrow == 1) {
try { document.querySelector(".inning > span#up").classList.remove("disabled"); } catch (error) { console.error(error); }
try { document.querySelector(".inning > span#down").classList.add("disabled"); } catch (error) { console.error(error); }
} else {
Similar blocks of code found in 2 locations. Consider refactoring.
} else {
try { document.querySelector(".inning > span#up").classList.add("disabled"); } catch (error) { console.error(error); }
try { document.querySelector(".inning > span#down").classList.remove("disabled"); } catch (error) { console.error(error); }
}
Identical blocks of code found in 2 locations. Consider refactoring.
function activeDeactiveScoreboard(data,url){
if (data !== undefined && document.URL.includes(url)) {
if (data) {
document.querySelector("div.scoreboard").classList.remove("disabled");
} else {
Similar blocks of code found in 2 locations. Consider refactoring.
if( obj.Inning <= parseInt(localStorage.getItem("MaxInning"))){
document.documentElement.style.setProperty('--i-inning', localStorage.getItem("MaxInning"));
try{document.querySelector("div.container > div#iex").remove();}catch(error){console.log(error);}
}else if (obj.Inning > parseInt(localStorage.getItem("MaxInning")) + 1 || (obj.Arrow == 2 && obj.Inning == parseInt(localStorage.getItem("MaxInning"))+1) || extraInningScoreAway != 0 || extraInningScoreHome != 0) {
let inning = getComputedStyle(document.documentElement).getPropertyValue('--i-inning');
Similar blocks of code found in 2 locations. Consider refactoring.
} else if (getComputedStyle(document.documentElement).getPropertyValue('--i-inning') != localStorage.getItem("MaxInning")) {
document.documentElement.style.setProperty('--i-inning', localStorage.getItem("MaxInning"));
try { document.querySelector("div.container > #iex.inning").remove(); } catch (error) { console.error(error); }
}
Similar blocks of code found in 2 locations. Consider refactoring.
function updateActive(json){
const obj = JSON.parse(json);
activeDeactiveScoreboard(obj?.main, 'scoreboard.html');
activeDeactiveScoreboard(obj?.pre, 'pregame.html');
activeDeactiveScoreboard(obj?.post, 'postgame.html');
Similar blocks of code found in 2 locations. Consider refactoring.
function updateNumber(data, id) {
if(data !== undefined)
try { document.querySelector("span#" + id).innerHTML = data; } catch (error) { console.error(error); }
}
Similar blocks of code found in 2 locations. Consider refactoring.
function updateGeneralSccoreInning(Score,id) {
if (Score !== undefined)
try { document.querySelector(".score > #"+id).innerHTML = Score; } catch (error) { console.error(error); }
}
Similar blocks of code found in 2 locations. Consider refactoring.
} else {
try { document.querySelector("div#"+id).classList.add("disabled"); } catch (error) { console.error(error); }
}
Similar blocks of code found in 2 locations. Consider refactoring.
if (base) {
try { document.querySelector("div#"+id).classList.remove("disabled"); } catch (error) { console.error(error); }
} else {
Similar blocks of code found in 2 locations. Consider refactoring.
if (data !== undefined)
try { document.querySelector("div.teamScore#"+team+" > span").innerHTML = data; } catch (error) { console.error(error); }
Similar blocks of code found in 2 locations. Consider refactoring.
if (data !== undefined && scoreboards.includes(document.URL.split("/").pop().split(".")[0]))
try { document.querySelector("div.teamName#" + team + " > div > span").innerHTML = data; } catch (error) { console.error(error); }
There are no issues that match your filters.