server/sports/sports-parsing.js
// Parses the information from a normal result row (6 items) into a result dictionary.
Parses the information from a normal result row (6 items) into a result dictionary.
Parses the information from a normal result row ( 6 items ) into a result dictionary .
function parseNormalResultRow(itemsInRow, schoolYears) {
    if (itemsInRow.length == 6) {
        var resultDictionary = {}
        var dateString = strip(itemsInRow[2].innerHTML);
        var homeInfo = strip(itemsInRow[3].innerHTML).split(' '); 
        var opponentInfo = strip(itemsInRow[4].innerHTML).split(' '); 
        if (dateString) {
            resultDictionary['date'] = formattedDateString(dateString, null, schoolYears);
            if (homeInfo.length == 2) {
                resultDictionary['home_score'] = homeInfo[1];
            } else if (homeInfo.length == 3) {
                resultDictionary['home_score'] = homeInfo[2];
            } else {
                resultDictionary['home_score'] = -1;
            }
            if (opponentInfo.length == 2) {
                resultDictionary['opponent_name'] = opponentInfo[0];
                resultDictionary['opponent_score'] = opponentInfo[1];
            } else if (opponentInfo.length == 3) {
                resultDictionary['opponent_name'] = opponentInfo[0] + ' ' + opponentInfo[1];
                resultDictionary['opponent_score'] = opponentInfo[2];
            } else {
                resultDictionary['opponent_name'] = 'Multiple Opponents';
                resultDictionary['opponent_score'] = -1;
            }
            return resultDictionary;
        } else {
            return null; 
        }
    } else {
        return null;
    }
}
function parseNormalResultRow ( itemsInRow , schoolYears ) { if ( itemsInRow . length == 6 ) { var resultDictionary = { } var dateString = strip ( itemsInRow [ 2 ] . innerHTML ) ; var homeInfo = strip ( itemsInRow [ 3 ] . innerHTML ) . split ( ' ' ) ; var opponentInfo = strip ( itemsInRow [ 4 ] . innerHTML ) . split ( ' ' ) ; if ( dateString ) { resultDictionary [ 'date' ] = formattedDateString ( dateString , null , schoolYears ) ; if ( homeInfo . length == 2 ) { resultDictionary [ 'home_score' ] = homeInfo [ 1 ] ; } else if ( homeInfo . length == 3 ) { resultDictionary [ 'home_score' ] = homeInfo [ 2 ] ; } else { resultDictionary [ 'home_score' ] = - 1 ; } if ( opponentInfo . length == 2 ) { resultDictionary [ 'opponent_name' ] = opponentInfo [ 0 ] ; resultDictionary [ 'opponent_score' ] = opponentInfo [ 1 ] ; } else if ( opponentInfo . length == 3 ) { resultDictionary [ 'opponent_name' ] = opponentInfo [ 0 ] + ' ' + opponentInfo [ 1 ] ; resultDictionary [ 'opponent_score' ] = opponentInfo [ 2 ] ; } else { resultDictionary [ 'opponent_name' ] = 'Multiple Opponents' ; resultDictionary [ 'opponent_score' ] = - 1 ; } return resultDictionary ; } else { return null ; } } else { return null ; } }
Parses the information from a normal result row (6 items) into a result dictionary.
Parses the information from a normal result row ( 6 items ) into a result dictionary .
//array with school name and score //array with school name and score //date doesn't exist