Skip to content

Commit a526be2

Browse files
authored
Update predbat-table-card.js
fix crash bug with debug_columns
1 parent 6135b55 commit a526be2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

predbat-table-card.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class PredbatTableCard extends HTMLElement {
9898
theTable.setAttribute('cellpadding', '0px');
9999
let newTableHead = document.createElement('thead');
100100

101+
console.log(this.config.debug_columns);
102+
101103
// Create an optional Last Updated Table Header Row
102104
if(this.config.hide_last_update !== true) {
103105

@@ -988,13 +990,12 @@ class PredbatTableCard extends HTMLElement {
988990

989991
let debugSVG = ``;
990992
let debugString = theItem.value;
991-
console.log(this.config.debug_columns.indexOf(column));
992993
if (theItem.value.includes("(") || theItem.value.includes(")")) {
993994
const match = theItem.value.match(/(\d+)\s*\((\d+(?:\.\d+)?)\)/);
994995

995996
// match[1]
996997

997-
if(this.config.debug_columns.indexOf(column) > -1){
998+
if(this.config.debug_columns !== undefined && this.config.debug_columns.indexOf(column) > -1){
998999
if(match[1] != match[2]){
9991000
debugSVG = `<svg version="1.1" width="26" height="26" id="limitSVG">
10001001
<circle cx="13" cy="13" r="11" stroke="#2a3240" stroke-width="1" stroke-dasharray="5,3" fill="#e1e1e1"/>
@@ -1024,7 +1025,7 @@ class PredbatTableCard extends HTMLElement {
10241025
// manage debug price pills appropriately
10251026
// debug_prices_only | true | false
10261027

1027-
if ((theItem.value.includes("(") || theItem.value.includes(")")) && this.config.debug_columns.indexOf(column) > -1) {
1028+
if ((theItem.value.includes("(") || theItem.value.includes(")")) && this.config.debug_columns !== undefined && this.config.debug_columns.indexOf(column) > -1) {
10281029
// if debug prices are present based on ( ) search
10291030

10301031
let newPills = "";
@@ -1054,7 +1055,7 @@ class PredbatTableCard extends HTMLElement {
10541055
}
10551056
}
10561057

1057-
} else if((theItem.value.includes("(") || theItem.value.includes(")")) && this.config.debug_columns.indexOf(column) === -1){
1058+
} else if((theItem.value.includes("(") || theItem.value.includes(")")) && this.config.debug_columns !== undefined && this.config.debug_columns.indexOf(column) === -1){
10581059

10591060
const hasBoldTags = /<b>.*?<\/b>/.test(theItem.value);
10601061
const hasItalicTags = /<i>.*?<\/i>/.test(theItem.value);

0 commit comments

Comments
 (0)