Last active
March 19, 2019 20:47
-
-
Save jasp402/fe904eb707ec627c58271a7131c236d4 to your computer and use it in GitHub Desktop.
JavaScript - Get content Table and merge with head
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let headTable = c.TABLE_HEAD; | |
let table = $$(c.TABLE) | |
.map(tr=>tr.getHTML().match(c.REGEX_TD) | |
.map(x=>x.indexOf('View EOB')===-1 | |
? x.replace(c.REGEX_TAGS,'') | |
: x.match(c.REGEX_ONCLICK) | |
.map(x=>x.replace(/onclick=|"/ig,''))[0])); | |
let result = table.map((el, idx)=> { | |
let obj = {id: idx+1}; headTable.map((h,i)=>obj[headTable[i]] = el[i]); | |
return obj; | |
}); | |
/**Para unir los resultados de 2 tablas en 1 solo**/ | |
// let merge = resultTableFlatt.map(function (item, index) { | |
// console.log('response:>>', resultResponseFlatt[index]); | |
// let objTemp = Object.assign(item, resultResponseFlatt[index]); | |
// return objTemp; | |
// }); | |
REGEX_TD : /<.[^>].*?<\/td>/g, | |
REGEX_TAGS : /<(.|\n)*?>/g, | |
REGEX_ONCLICK : /(onclick=\").*?\"/g, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment