-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.min.js
1 lines (1 loc) · 1.71 KB
/
index.min.js
1
!function(){function t(t){const r=Number(t.getAttribute('data-count'));return{rect:t,fill:t.getAttribute('fill'),count:r,curr:r>0?1:0,next:0}}function r(r){console.log(r);const e=r.querySelectorAll('.day');return Array.from(e).map(t)}function e(t){t.forEach(function(t){t.rect.setAttribute('fill','#ffffff')})}function n(t){var r,e,n,o=1/0,c=-(1/0);for(r=0;r<t.length;r+=1){const u=t[r];for(e=0;e<u.length;e+=1)n=u[e].count,n<o&&(o=n),n>c&&(c=n)}return{min:o,max:c}}function o(t,r){return t||3!==r?t?r<2?0:r>3?0:1:0:1}function c(t){var r,e,n,c;for(r=0;r<m;r+=1){const u=0===r?51:r-1,f=51===r?0:r+1;for(e=0;e<g;e+=1){const i=0===e?6:e-1,l=6===e?0:e+1;n=0,n+=t[u][i].curr,n+=t[u][e].curr,n+=t[u][l].curr,n+=t[r][i].curr,n+=t[r][l].curr,n+=t[f][i].curr,n+=t[f][e].curr,n+=t[f][l].curr,t[r][e].neighbours=n,c=t[r][e].curr,t[r][e].next=o(c,n)}}}function u(t){const r='#eeeeee',e='#d6e685';var n,o;for(n=0;n<m;n+=1)for(o=0;o<g;o+=1){const c=t[n][o];if(c.curr){const u=c.fill===r?e:c.fill;c.rect.setAttribute('fill',u)}else c.rect.setAttribute('fill',r)}}function f(t){var r,e,n=!1;for(r=0;r<m;r+=1)for(e=0;e<g;e+=1){const o=t[r][e];o.curr!==o.next&&(n=!0),o.curr=o.next}return n}function i(){const t=250;c(b),u(b),y+=1;const r=f(b);var e;r?(e=''+y+' generations',s.innerText=e,setTimeout(i,t)):(e='Game of GitHub lost after '+y+' generations 😞',s.innerText=e)}const l=document.querySelector('.js-calendar-graph-svg').querySelectorAll('g g');console.log('%d weeks',l.length);const s=document.querySelector('.js-yearly-contributions h2'),a=document.querySelector('.contrib-footer a');a.href='https://github.com/bahmutov/game-of-github',a.innerText='Game of GitHub';const g=7,m=52;var b=Array.from(l).map(r);const h=b.pop();e(h),console.log(n(b));var y=0;i()}();