mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Create table.js
This commit is contained in:
parent
c51bfdeb50
commit
24dac3eff7
1 changed files with 35 additions and 0 deletions
35
scripts/core/table.js
Normal file
35
scripts/core/table.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
const table = {}
|
||||
|
||||
table.create = function (data, cols) {
|
||||
let output = '<table>\n'
|
||||
|
||||
output += ' <thead>\n <tr>'
|
||||
for (let column of cols) {
|
||||
output += `<th>${column}</th>`
|
||||
}
|
||||
output += '</tr>\n </thead>\n'
|
||||
|
||||
output += ' <tbody>\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 += ' <tr>'
|
||||
if (i === 0) {
|
||||
const name = item.flag ? `${item.flag} ${item.name}` : item.name
|
||||
output += `<td valign="top"${rowspan}>${name}</td>`
|
||||
}
|
||||
output += `<td align="right">${item.channels}</td>`
|
||||
output += `<td nowrap>${item.epg}</td>`
|
||||
output += `<td>${item.status}</td>`
|
||||
output += '</tr>\n'
|
||||
}
|
||||
}
|
||||
output += ' </tbody>\n'
|
||||
|
||||
output += '</table>'
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
module.exports = table
|
Loading…
Add table
Add a link
Reference in a new issue