Skip to content

Instantly share code, notes, and snippets.

@yuan3y
Created May 12, 2017 07:14
Show Gist options
  • Save yuan3y/c62556ac0fdabc3bab64869d4366588b to your computer and use it in GitHub Desktop.
Save yuan3y/c62556ac0fdabc3bab64869d4366588b to your computer and use it in GitHub Desktop.
find blood stock level in Singapore bloodbank https://www.redcross.sg/
/*jQuery way*/
Array.from([["last_update",jQuery('.last_update').text().slice(25)]].append(jQuery('div.human').map((a,b)=>{return [[jQuery(b).children('.blank_humam').text(), jQuery(b).children('.fill_humam').prop('style').height]];}))).reduce((p,c,i)=>{p[c[0]]=c[1]; return p;},{})
/*VanillaJS functional equivalence*/
Array.from([["last_update",document.querySelector('.last_update').innerText.slice(25)]].append(Array.from(document.querySelectorAll('div.human')).map((b)=>{return [b.children[0].innerText, b.children[1].style.height];}))).reduce((p,c,i)=>{p[c[0]]=c[1]; return p;},{})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment