Skip to content

Commit 468e490

Browse files
author
Jason Long
committed
Merge pull request jasonlong#21 from jasonlong/use-new-gh-markup
Fixes to work with recent GitHub markup changes
2 parents a316973 + 71f911d commit 468e490

File tree

3 files changed

+67
-59
lines changed

3 files changed

+67
-59
lines changed

chrome/iso.coffee

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
class Iso
2+
COLORS = [
3+
new obelisk.CubeColor().getByHorizontalColor(0xeeeeee),
4+
new obelisk.CubeColor().getByHorizontalColor(0xd6e685),
5+
new obelisk.CubeColor().getByHorizontalColor(0x8cc665),
6+
new obelisk.CubeColor().getByHorizontalColor(0x44a340),
7+
new obelisk.CubeColor().getByHorizontalColor(0x1e6823)
8+
]
9+
210
constructor: (target) ->
311
if target
412
observer = new MutationObserver (mutations) =>
@@ -29,10 +37,10 @@ class Iso
2937
days = $('.js-calendar-graph-svg rect')
3038
bestDay = null
3139
maxCount = null
32-
(d3.selectAll days).attr 'data-contrib-count', (d, i) ->
33-
if d[1] > maxCount
34-
[bestDay, maxCount] = d
35-
d[1]
40+
(d3.selectAll days).each ->
41+
if $(this).data('count') > maxCount
42+
bestDay = ($ this).data('date')
43+
maxCount = ($ this).data('count')
3644
observer.disconnect()
3745
target.setAttribute 'data-max-contributions', maxCount
3846
target.setAttribute 'data-best-day', bestDay
@@ -71,15 +79,15 @@ class Iso
7179
(($ this).find 'rect').each (r) ->
7280
r = ($ this).get 0
7381
y = parseInt (($ this).attr 'y') / GH_OFFSET
74-
style = ($ this).attr 'style'
75-
contribCount = parseInt ($ this).data 'contrib-count'
82+
fill = ($ this).attr 'fill'
83+
contribCount = parseInt ($ this).data 'count'
7684
cubeHeight = 3
7785

7886
if maxContributions > 0
7987
cubeHeight += parseInt MAX_HEIGHT / maxContributions * contribCount
8088

8189
dimension = new obelisk.CubeDimension SIZE, SIZE, cubeHeight
82-
color = self.getSquareColor style
90+
color = self.getSquareColor fill
8391
cube = new obelisk.Cube dimension, color, false
8492
p3d = new obelisk.Point3D SIZE * x, SIZE * y, 0
8593
pixelView.renderObject cube, p3d
@@ -154,10 +162,12 @@ class Iso
154162

155163
# Best day
156164
countBest = ($ '.js-calendar-graph').data 'max-contributions'
157-
dateParts = (($ '.js-calendar-graph').data 'best-day').split ' '
165+
dateParts = (($ '.js-calendar-graph').data 'best-day').split '-'
158166
dateBest = 'Not so busy after all.'
159-
if dateParts[1]?
160-
dateBest = "#{dateParts[1]} #{dateParts[2]} #{dateParts[3]}"
167+
if dateParts[0]?
168+
options = {month: "long", day: "numeric"}
169+
date = new Date(dateParts[0], dateParts[1] - 1, dateParts[2], 0, 0, 0)
170+
dateBest = date.toLocaleDateString('en-US', options)
161171

162172
html = """
163173
<div class="ic-stats-block ic-stats-top">
@@ -226,19 +236,13 @@ class Iso
226236
"""
227237
($ html).appendTo $ '.ic-contributions-wrapper'
228238

229-
getSquareColor: (style) ->
230-
color0 = new obelisk.CubeColor().getByHorizontalColor 0xeeeeee
231-
color1 = new obelisk.CubeColor().getByHorizontalColor 0xd6e685
232-
color2 = new obelisk.CubeColor().getByHorizontalColor 0x8cc665
233-
color3 = new obelisk.CubeColor().getByHorizontalColor 0x44a340
234-
color4 = new obelisk.CubeColor().getByHorizontalColor 0x1e6823
235-
236-
color = switch style
237-
when 'fill: rgb(238, 238, 238);', 'fill: #eeeeee;' then color0
238-
when 'fill: rgb(214, 230, 133);', 'fill: #d6e685;' then color1
239-
when 'fill: rgb(140, 198, 101);', 'fill: #8cc665;' then color2
240-
when 'fill: rgb(68, 163, 64);', 'fill: #44a340;' then color3
241-
when 'fill: rgb(30, 104, 35);', 'fill: #1e6823;' then color4
239+
getSquareColor: (fill) ->
240+
color = switch fill
241+
when 'rgb(238, 238, 238)', '#eeeeee' then COLORS[0]
242+
when 'rgb(214, 230, 133)', '#d6e685' then COLORS[1]
243+
when 'rgb(140, 198, 101)', '#8cc665' then COLORS[2]
244+
when 'rgb(68, 163, 64)', '#44a340' then COLORS[3]
245+
when 'rgb(30, 104, 35)', '#1e6823' then COLORS[4]
242246

243247
# Inject code
244248
Iso.inject()

chrome/iso.js

Lines changed: 39 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chrome/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Isometric Contributions",
3-
"version": "0.8.9",
3+
"version": "0.8.10",
44
"description": "Renders an isometric pixel view of GitHub contribution graphs.",
55
"content_scripts": [ {
66
"css": [ "iso.css" ],

0 commit comments

Comments
 (0)