Skip to content

Commit

Permalink
port some changes from 'd3' branch
Browse files Browse the repository at this point in the history
more i18n, new ContribsList.toPunchcard() method,
made punchcard's weekdays sorted as the weekdays graph's ones
  • Loading branch information
ricordisamoa committed Jun 11, 2014
1 parent 385161f commit d5fb231
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
1 change: 1 addition & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
5 changes: 2 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
<script type="text/javascript" src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>

<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<!-- g.Raphael - JavaScript charting library
(the main script needs to be up-to-date) -->
<!-- g.Raphael - JavaScript charting library (the main script is patched) -->
<script type="text/javascript" src="//tools.wmflabs.org/ricordisamoa/lib/g.raphael/g.raphael.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/graphael/0.5.1/g.bar-min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/graphael/0.5.1/g.dot-min.js"></script>
Expand Down Expand Up @@ -86,7 +85,7 @@ <h1><abbr title="Deep Wiki Inspector">DEWKIN</abbr><span>DE<span>ep </span>W<spa
<li><a href="#tags" data-toggle="tab" data-msg="tags-title">Tags</a></li>
<li><a href="#uploads" data-toggle="tab" data-msg="statistics-files">Uploads</a></li>
<li><a href="#code" data-toggle="tab" data-msg="code"></a></li>
<li><a href="#punchcard" data-toggle="tab">Punchcard</a></li>
<li><a href="#punchcard" data-toggle="tab" data-msg="punchcard"></a></li>
<li><a href="#map" data-toggle="tab" data-msg="map"></a></li>
<li><a href="#votes" data-toggle="tab" data-msg="votes"></a></li>
</ul>
Expand Down
10 changes: 5 additions & 5 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
24 changes: 15 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ 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;
},

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;
},
Expand Down Expand Up @@ -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(){
Expand Down Expand Up @@ -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]);
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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',
Expand All @@ -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,
Expand Down

0 comments on commit d5fb231

Please sign in to comment.