var NEGATIVE_ITEMS_LABEL = []; NEGATIVE_ITEMS_LABEL.push('DELINQUENT'); NEGATIVE_ITEMS_LABEL.push('DEROGATORY'); NEGATIVE_ITEMS_LABEL.push('COLLECTION'); var SUMMARY_PUBLIC_RECORD = "PUBLIC RECORDS"; var SUMMARY_INQUIRY = "INQUIRIES(2 YEARS)"; function getIQSummary(){ var result = {}; var account_history_tables = $('#Summary:contains(Summary)').nextAll('table.rpt_content_table').first(); var negative_items_values = {}; var inquiries_values = {}; var public_records_values = {}; var trans_val = 0; var exp_val = 0; var equif_val = 0; account_history_tables.find('tr').each(function (i,el) { var tds = $(this).find('td'); var label_name_td = $(this).find('td.label'); var other_td = $(this).find('td'); var label_name = $.trim(label_name_td.eq(0) .clone() //clone the element .children() //select all the children .remove() //remove all the children .end() //again go back to selected element .text()).replace(':',''); var td_text_1 = $.trim(other_td.eq(1) .clone() //clone the element .children() //select all the children .remove() //remove all the children .end() //again go back to selected element .text()); td_text_1 = parseInt(td_text_1); var td_text_2 = $.trim(other_td.eq(2) .clone() //clone the element .children() //select all the children .remove() //remove all the children .end() //again go back to selected element .text()); td_text_2 = parseInt(td_text_2); var td_text_3 = $.trim(other_td.eq(3) .clone() //clone the element .children() //select all the children .remove() //remove all the children .end() //again go back to selected element .text()); td_text_3 = parseInt(td_text_3); label_name = label_name.toUpperCase(); if($.inArray(label_name, NEGATIVE_ITEMS_LABEL) !== -1){ trans_val += td_text_1; exp_val += td_text_2; equif_val += td_text_3; } if(SUMMARY_PUBLIC_RECORD == label_name){ public_records_values['trans'] = td_text_1; public_records_values['exp'] = td_text_2; public_records_values['equif'] = td_text_3; } if(SUMMARY_INQUIRY == label_name){ inquiries_values['trans'] = td_text_1; inquiries_values['exp'] = td_text_2; inquiries_values['equif'] = td_text_3; } }) negative_items_values['trans'] = trans_val; negative_items_values['exp'] = exp_val; negative_items_values['equif'] = equif_val; result['negative_item_summary'] = negative_items_values; result['public_record_summary'] = public_records_values; result['inquiry_summary'] = inquiries_values; return result; } function getSCSummary(){ var result = {}; //var account_history_tables = $('table tr td#Summary').parents("table:first").next('table tr:first td table'); var account_history_tables = $('td.crLightTableBackground span b:contains(TOTAL ACCOUNTS:)').parents("table:first"); var negative_items_values = {}; var inquiries_values = {}; var public_records_values = {}; var trans_val = 0; var exp_val = 0; var equif_val = 0; account_history_tables.find('tr').each(function (i,el) { var tds = $(this).find('td'); var label_name_td = $(this).find('td span b'); var other_td = $(this).find('td'); var label_name = $.trim(label_name_td.eq(0) .clone() //clone the element .children() //select all the children .remove() //remove all the children .end() //again go back to selected element .text().replace(/<(?:.|\n)*?>/gm, '').replace(/\r?\n|\r/g, '').replace(/\s+/g, " ")).replace(':',''); var td_text_1 = $.trim(other_td.eq(1).find('span') .clone() //clone the element .children() //select all the children .remove() //remove all the children .end() //again go back to selected element .text()); td_text_1 = parseInt(td_text_1); var td_text_2 = $.trim(other_td.eq(2).find('span') .clone() //clone the element .children() //select all the children .remove() //remove all the children .end() //again go back to selected element .text()); td_text_2 = parseInt(td_text_2); var td_text_3 = $.trim(other_td.eq(3).find('span') .clone() //clone the element .children() //select all the children .remove() //remove all the children .end() //again go back to selected element .text()); td_text_3 = parseInt(td_text_3); label_name = label_name.toUpperCase(); console.log('label_name',label_name,td_text_1,td_text_2,td_text_3); if(!$.isNumeric(td_text_1)){ td_text_1 = 0; } if(!$.isNumeric(td_text_2)){ td_text_2 = 0; } if(!$.isNumeric(td_text_3)){ td_text_3 =0 ; } if($.inArray(label_name, NEGATIVE_ITEMS_LABEL) !== -1){ if($.isNumeric(td_text_1)){ trans_val += td_text_1; } if($.isNumeric(td_text_2)){ exp_val += td_text_2; } if($.isNumeric(td_text_3)){ equif_val += td_text_3; } } if(SUMMARY_PUBLIC_RECORD == label_name){ public_records_values['trans'] = td_text_1; public_records_values['exp'] = td_text_2; public_records_values['equif'] = td_text_3; } if('INQUIRIES' == label_name){ inquiries_values['trans'] = td_text_1; inquiries_values['exp'] = td_text_2; inquiries_values['equif'] = td_text_3; } }) negative_items_values['trans'] = trans_val; negative_items_values['exp'] = exp_val; negative_items_values['equif'] = equif_val; result['negative_item_summary'] = negative_items_values; result['public_record_summary'] = public_records_values; result['inquiry_summary'] = inquiries_values; return result; }