src/cjahTracker.js
function createCjahEntity(id, html, cb) {
    let entity = null
    try {
        let $ = parser.load(html)
        let trs = $('table tbody tr')

        // Not found
        if (!trs || trs.length === 0) {
            cb(utils.errorNoData())
            return
        }

        let states = utils.tableParser(
        trs,
        {
            'id': { 'idx': 1, 'mandatory': true },
            'date': {'idx': 3, 'mandatory': true, 'parser': elem => { return moment.tz( elem, 'DD/MM/YYYY h:mm:ssa', 'en', zone).format()}},
            'state': { 'idx': 5, 'mandatory': true }
        },
        elem => true)

        entity = new CjahInfo({
            id: states[0].id,
            state: states[0].state,
            states: states
        })
    } catch (error) {
        return cb(utils.errorParser(id, error.message))
    }

    cb(null, entity)
}
function createCjahEntity(id, html, cb) {
    let entity = null
    try {
        let $ = parser.load(html)
        let trs = $('table tbody tr')

        // Not found
        if (!trs || trs.length === 0) {
            cb(utils.errorNoData())
            return
        }

        let states = utils.tableParser(
        trs,
        {
            'id': { 'idx': 1, 'mandatory': true },
            'date': {'idx': 3, 'mandatory': true, 'parser': elem => { return moment.tz( elem, 'DD/MM/YYYY h:mm:ssa', 'en', zone).format()}},
            'state': { 'idx': 5, 'mandatory': true }
        },
        elem => true)

        entity = new CjahInfo({
            id: states[0].id,
            state: states[0].state,
            states: states
        })
    } catch (error) {
        return cb(utils.errorParser(id, error.message))
    }

    cb(null, entity)
}
function createCjahEntity ( id , html , cb ) { let entity = null try { let $ = parser . load ( html ) let trs = $ ( 'table tbody tr' ) // Not found if ( ! trs || trs . length === 0 ) { cb ( utils . errorNoData ( ) ) return } let states = utils . tableParser ( trs , { 'id' : { 'idx' : 1 , 'mandatory' : true } , 'date' : { 'idx' : 3 , 'mandatory' : true , 'parser' : elem => { return moment . tz ( elem , 'DD/MM/YYYY h:mm:ssa' , 'en' , zone ) . format ( ) } } , 'state' : { 'idx' : 5 , 'mandatory' : true } } , elem => true ) entity = new CjahInfo ( { id : states [ 0 ] . id , state : states [ 0 ] . state , states : states } ) } catch ( error ) { return cb ( utils . errorParser ( id , error . message ) ) } cb ( null , entity ) }
Create cjah entity from html
@param id
@param html
@param cb
Create cjah entity from html