From d5fb2317188d217cb418d6b4a3dc1febe51052cb Mon Sep 17 00:00:00 2001 From: ricordisamoa Date: Wed, 11 Jun 2014 18:42:18 +0200 Subject: [PATCH] port some changes from 'd3' branch more i18n, new ContribsList.toPunchcard() method, made punchcard's weekdays sorted as the weekdays graph's ones --- i18n/en.json | 1 + i18n/it.json | 1 + index.html | 5 ++--- main.css | 10 +++++----- main.js | 24 +++++++++++++++--------- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index c419528..520e145 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -15,6 +15,7 @@ "no log entries": "No log entries found.", "code": "Code", "code desc": "This tab shows information about the programming languages in which the user has contributed.", + "punchcard": "Punch card", "map": "Map", "bytes with nchanges": "$1 with $2", "no geodata": "No geolocation data about edited pages found.", diff --git a/i18n/it.json b/i18n/it.json index 80ff14c..b2930be 100644 --- a/i18n/it.json +++ b/i18n/it.json @@ -15,6 +15,7 @@ "no log entries": "Nessuna entrata di registro trovata.", "code": "Codice", "code desc": "Questa scheda mostra informazioni circa i linguaggi di programmazione in cui l'utente ha contribuito.", + "punchcard": "Punch card", "map": "Mappa", "bytes with nchanges": "$1 con $2", "no geodata": "Nessun dato di geolocalizzazione trovato per le pagine modificate.", diff --git a/index.html b/index.html index 4ae0ba5..b76f5ea 100644 --- a/index.html +++ b/index.html @@ -36,8 +36,7 @@ - + @@ -86,7 +85,7 @@

DEWKINDEep WTags
  • Uploads
  • -
  • Punchcard
  • +
  • diff --git a/main.css b/main.css index 499f2bd..320b1ba 100644 --- a/main.css +++ b/main.css @@ -60,10 +60,10 @@ footer{ } /* Punchcard styles */ -#punchcard svg circle{ - fill:#444!important; +#punchcard svg circle { + fill: #444!important; } -#punchcard svg circle.day-hover{ - fill:#4183C4!important; - z-index:9999!important; +#punchcard svg circle.day-hover { + fill: #4183C4!important; + z-index: 9999!important; } diff --git a/main.js b/main.js index d132b18..f0e3371 100644 --- a/main.js +++ b/main.js @@ -87,7 +87,7 @@ ContribsList.prototype = { filterByDay: function(){ var contr = {}; for(var j = 0; j < 7; j++){ - contr[j] = this.grepByDay(j).length; + contr[j] = this.grepByDay(j); } return contr; }, @@ -95,7 +95,7 @@ ContribsList.prototype = { filterByHour: function(){ var contr = []; for(var j = 0; j < 24; j++){ - contr = contr.concat(this.grepByHour(j).length); + contr.push(this.grepByHour(j)); } return contr; }, @@ -264,6 +264,16 @@ ContribsList.prototype = { return [sortedOccurr, overflow]; }, + toPunchcard: function(){ + var data = []; + for(var d = 0; d < 7; d++){ + data = data.concat($.map(this.grepByDay(d).filterByHour(), function(c){ + return c.length; + })); + } + return data; + }, + /* Compute the longest sequence of consecutive days with contributions */ longestStreak: function(){ @@ -938,7 +948,6 @@ $(document).ready(function(){ util.weekdaysShort = $.map(util.weekdaysShort, function(el){ return vars.messages[el]; }); - util.weekdaysAlt = util.weekdays.slice(1).concat(util.weekdays[0]).reverse(); $('[data-msg]').each(function(){ $(this).text(vars.messages[this.dataset.msg]); }); @@ -1047,7 +1056,7 @@ $(document).ready(function(){ } ) ; var dayColors = ['#4d89f9', '#c6d9fd'], dayFiltered = $.map(contribs.filterByDay(), function(e){ - return [e]; + return e.length; }); while(dayColors.length < dayFiltered.length){ dayColors = dayColors.concat(dayColors.slice(0, 2)).slice(0, dayFiltered.length); @@ -1108,14 +1117,11 @@ $(document).ready(function(){ }); /* GitHub-like Punchcard */ - var punch = $.map([1, 2, 3, 4, 5, 6, 0], function(j){ - return contribs.grepByDay(j).filterByHour(); - }); $('li>a[href="#punchcard"]').one('shown', function(){ var r = Raphael('punchcard-chart', 1200, 500), xs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], ys = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; - r.dotchart(10, 0, 1200, 500, xs, ys, punch, { + r.dotchart(10, 0, 1200, 500, xs, ys, contribs.toPunchcard(), { symbol: 'o', max: 21, axis: '0 0 1 1', @@ -1124,7 +1130,7 @@ $(document).ready(function(){ axisxlabels: ['12am', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12pm', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'], axisxtype: ' ', axisytype: ' ', - axisylabels: util.weekdaysAlt, + axisylabels: util.weekdays.slice().reverse(), init: true }).hover(function () { var self = this,