diff --git a/scripts/core/table.js b/scripts/core/table.js
index f9315f1e..0c5d363f 100644
--- a/scripts/core/table.js
+++ b/scripts/core/table.js
@@ -1,35 +1,47 @@
const table = {}
table.create = function (data, cols) {
- let output = '
\n'
+ let output = '\r\n'
- output += ' \n '
+ output += ' \r\n '
for (let column of cols) {
- output += `${column} | `
+ output += `${column} | `
}
- output += '
\n \n'
+ output += '
\r\n \r\n'
- output += ' \n'
- for (let groupId in data) {
- const group = data[groupId]
- for (let [i, item] of group.entries()) {
- const rowspan = group.length > 1 ? ` rowspan="${group.length}"` : ''
- output += ' '
- if (i === 0) {
- const name = item.flag ? `${item.flag} ${item.name}` : item.name
- output += `${name} | `
- }
- output += `${item.channels} | `
- output += `${item.epg} | `
- output += `${item.status} | `
- output += '
\n'
- }
- }
- output += ' \n'
+ output += ' \r\n'
+ output += getHTMLRows(data)
+ output += ' \r\n'
output += '
'
return output
}
+function getHTMLRows(data) {
+ let output = ''
+ for (let group of data) {
+ let rowspan = group.length
+ for (let [j, row] of group.entries()) {
+ output += ' '
+ for (let [i, value] of row.entries()) {
+ if (i === 0 && j === 0) {
+ output += `${value} | `
+ } else if (i > 0) {
+ if (typeof value === 'number') {
+ output += `${value} | `
+ } else {
+ output += `${value} | `
+ }
+ }
+ }
+ output += '
\r\n'
+ }
+ }
+
+ return output
+}
+
+function getSpan() {}
+
module.exports = table