canimus
3/10/2018 - 9:40 AM

Xpath Challenge - 1 liner 255 chars

Xpath Challenge - 1 liner 255 chars

r=$x("//h3 | //h3/following-sibling::ul/li[contains(text(),'Released')]").map(x=>x.innerText.trim());for(var i=0;i<r.length/2;i++){console.log((i<9?" "+(i+1):(i+1))+":  "+(new Date(r[i+24].replace("Released",""))).toDateString()+"  >>>  "+r[i])}

// Result
//  1:  Mon Mar 05 2018  >>>  1.0.1
//  2:  Wed Nov 01 2017  >>>  1.0.0
//  3:  Fri Nov 17 2017  >>>  0.11.0.2
//  4:  Wed Sep 13 2017  >>>  0.11.0.1
//  5:  Wed Jun 28 2017  >>>  0.11.0.0
//  6:  Wed Apr 26 2017  >>>  0.10.2.1
//  7:  Tue Feb 21 2017  >>>  0.10.2.0
//  8:  Tue Dec 20 2016  >>>  0.10.1.1
//  9:  Thu Oct 20 2016  >>>  0.10.1.0
// 10:  Wed Aug 10 2016  >>>  0.10.0.1
// 11:  Sun May 22 2016  >>>  0.10.0.0
// 12:  Fri Feb 19 2016  >>>  0.9.0.1
// 13:  Mon Nov 23 2015  >>>  0.9.0.0
// 14:  Fri Oct 02 2015  >>>  0.8.2.2
// 15:  Wed Mar 11 2015  >>>  0.8.2.1
// 16:  Mon Feb 02 2015  >>>  0.8.2.0
// 17:  Tue Oct 28 2014  >>>  0.8.2-beta
// 18:  Tue Apr 29 2014  >>>  0.8.1.1 Release
// 19:  Wed Mar 12 2014  >>>  0.8.1 Release
// 20:  Tue Dec 03 2013  >>>  0.8.0 Release
// 21:  Fri Jun 28 2013  >>>  0.8.0 Beta1 Release
// 22:  Wed Oct 10 2012  >>>  0.7.2 Release
// 23:  Wed Jun 27 2012  >>>  0.7.1 Release
// 24:  Wed Jan 04 2012  >>>  0.7.0 Release



// Level 1
a=[];r=$x("//h3 | //h3/following-sibling::ul/li[contains(text(),'Rel')]").map(x=>x.innerText.trim());for(var i=0;i<r.length/2;i++){a.push({t:(new Date(r[i+24].replace("Released",""))),v:r[i].replace("Release","").trim()})};a.forEach(x=>console.log(x))


// Level 2
a=[];r=$x("//h3 | //h3/following-sibling::ul/li[contains(text(),'Rel')]").map(x=>x.innerText.trim());for(var i=0;i<r.length/2;i++){a.push({t:(new Date(r[i+24].replace("Released",""))),v:r[i].replace("Release","").trim()})};a.forEach(x=>{console.log("%s >>> %s",x.t.toDateString(),x.v);})


// Level 3
a=[];r=$x("//h3 | //h3/following-sibling::ul/li[contains(text(),'Rel')]").map(x=>x.innerText.trim());for(var i=0;i<r.length/2;i++){a.push({t:(new Date(r[i+24].replace("Released",""))),v:r[i].replace("Release","").trim()})};a.forEach(x=>{console.groupCollapsed(x.v);console.log(x.t.toDateString());console.groupEnd();})

// Order by Date Descend
a.sort((a,b)=>{return a.t-b.t;})


// Group by Day of the week
javascript:var el=document.createElement('script');el.src="https://cdn.jsdelivr.net/lodash/4.11.1/lodash.min.js";el.type = "text/javascript";document.head.appendChild(el);
g=_.values(_.sortBy(_.groupBy(a, function(d){return d.t.getDay()}), function(a){return a.length}).reverse())
var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
r=[];g.forEach(x=>r.push({day: days[x[0].t.getDay()], releases: x.length}));r