import * as cheerio from "cheerio" ; import { trimRemoveLineBreaks } from "../../helpers" ; export abstract class BoxrecPageScheduleCommon { protected readonly $ : CheerioStatic ; constructor ( boxrecBodyString ) { this . $ = cheerio . load ( boxrecBodyString ) ; } param headerColumns returns protected parse ( headerColumns ) { const tableChildren = this . $ ( ".calendarTable > *" ) ; let event = "" ; const events = [ ] ; tableChildren . each ( ( i , elem ) => { const el = this . $ ( elem ) ; const tagName = el . get ( 0 ) . tagName ; if ( tagName === "thead" ) { event += `<thead>${ el . html ( ) }</thead>` ; event += headerColumns ; } else { const contentLength = trimRemoveLineBreaks ( el . text ( ) || "" ) . length ; if ( contentLength ) { event += `<tbody>${ el . html ( ) }</tbody>` ; } else { events . push ( `<table id="eventResults">${ event }</table>` ) ; event = "" ; } } } ) ; return events ; } }