src/correosESTracker.js
function createCorreosEsEntity(id, html) {

    let $ = parser.load(html)

    let table2 = $('#Table2').get(0);

    let states = []
    const fields = ['date', 'info']
    if (table2.children.length === 0 ||
        (table2.children[1] !== undefined
        && table2.children[1].data !== undefined
        && table2.children[1].data.trim() === 'fin tabla descripciones'))
        return null;

    table2.children.forEach(function (elem) {

        if (elem.attribs !== undefined && elem.attribs.class.trim() === 'txtCabeceraTabla') {
            let state = {}
            elem.children.forEach(function (_child) {
                if (_child.attribs !== undefined && _child.attribs.class !== undefined) {
                    let _class = _child.attribs.class.trim()
                    if (_class === 'txtDescripcionTabla') {
                        state['date'] = moment.tz(_child.children[0].data.trim(), "DD/MM/YYYY", zone).format()
                    } else if (_class === 'txtContenidoTabla' || _class === 'txtContenidoTablaOff') {
                        state['state'] = _child.children[1].children[0].data.trim()
                        if (_child.children[1].attribs !== undefined && _child.children[1].attribs !== undefined
                            && _child.children[1].attribs.title) {
                            state['title'] = _child.children[1].attribs.title.trim()
                        }
                    }
                }
            })
            if (Object.keys(state).length > 0) {
                states.push(state)
            }
        }

    })

    return new CorreosESInfo({
        'id': id,
        'state': states[states.length - 1].state,
        'states': states.reverse()
    })
}
function createCorreosEsEntity(id, html) {

    let $ = parser.load(html)

    let table2 = $('#Table2').get(0);

    let states = []
    const fields = ['date', 'info']
    if (table2.children.length === 0 ||
        (table2.children[1] !== undefined
        && table2.children[1].data !== undefined
        && table2.children[1].data.trim() === 'fin tabla descripciones'))
        return null;

    table2.children.forEach(function (elem) {

        if (elem.attribs !== undefined && elem.attribs.class.trim() === 'txtCabeceraTabla') {
            let state = {}
            elem.children.forEach(function (_child) {
                if (_child.attribs !== undefined && _child.attribs.class !== undefined) {
                    let _class = _child.attribs.class.trim()
                    if (_class === 'txtDescripcionTabla') {
                        state['date'] = moment.tz(_child.children[0].data.trim(), "DD/MM/YYYY", zone).format()
                    } else if (_class === 'txtContenidoTabla' || _class === 'txtContenidoTablaOff') {
                        state['state'] = _child.children[1].children[0].data.trim()
                        if (_child.children[1].attribs !== undefined && _child.children[1].attribs !== undefined
                            && _child.children[1].attribs.title) {
                            state['title'] = _child.children[1].attribs.title.trim()
                        }
                    }
                }
            })
            if (Object.keys(state).length > 0) {
                states.push(state)
            }
        }

    })

    return new CorreosESInfo({
        'id': id,
        'state': states[states.length - 1].state,
        'states': states.reverse()
    })
}
function createCorreosEsEntity ( id , html ) { let $ = parser . load ( html ) let table2 = $ ( '#Table2' ) . get ( 0 ) ; let states = [ ] const fields = [ 'date' , 'info' ] if ( table2 . children . length === 0 || ( table2 . children [ 1 ] !== undefined && table2 . children [ 1 ] . data !== undefined && table2 . children [ 1 ] . data . trim ( ) === 'fin tabla descripciones' ) ) return null ; table2 . children . forEach ( function ( elem ) { if ( elem . attribs !== undefined && elem . attribs . class . trim ( ) === 'txtCabeceraTabla' ) { let state = { } elem . children . forEach ( function ( _child ) { if ( _child . attribs !== undefined && _child . attribs . class !== undefined ) { let _class = _child . attribs . class . trim ( ) if ( _class === 'txtDescripcionTabla' ) { state [ 'date' ] = moment . tz ( _child . children [ 0 ] . data . trim ( ) , "DD/MM/YYYY" , zone ) . format ( ) } else if ( _class === 'txtContenidoTabla' || _class === 'txtContenidoTablaOff' ) { state [ 'state' ] = _child . children [ 1 ] . children [ 0 ] . data . trim ( ) if ( _child . children [ 1 ] . attribs !== undefined && _child . children [ 1 ] . attribs !== undefined && _child . children [ 1 ] . attribs . title ) { state [ 'title' ] = _child . children [ 1 ] . attribs . title . trim ( ) } } } } ) if ( Object . keys ( state ) . length > 0 ) { states . push ( state ) } } } ) return new CorreosESInfo ( { 'id' : id , 'state' : states [ states . length - 1 ] . state , 'states' : states . reverse ( ) } ) }
Create correos.es entity from html
@param html
Create correos . es entity from html