Skip to content

Commit cf1f666

Browse files
committed
Ash/Salai - First working version of the plugin
1 parent 63b5d7b commit cf1f666

9 files changed

Lines changed: 204 additions & 0 deletions

File tree

_locales/en/messages.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"l10nTabName": {
3+
"message":"Localization"
4+
,"description":"name of the localization tab"
5+
}
6+
,"l10nHeader": {
7+
"message":"It does localization too! (this whole tab is, actually)"
8+
,"description":"Header text for the localization section"
9+
}
10+
,"l10nIntro": {
11+
"message":"'L10n' refers to 'Localization' - 'L' an 'n' are obvious, and 10 comes from the number of letters between those two. It is the process/whatever of displaying something in the language of choice. It uses 'I18n', 'Internationalization', which refers to the tools / framework supporting L10n. I.e., something is internationalized if it has I18n support, and can be localized. Something is localized for you if it is in your language / dialect."
12+
,"description":"introduce the basic idea."
13+
}
14+
,"l10nProd": {
15+
"message":"You <strong>are</strong> planning to allow localization, right? You have <em>no idea</em> who will be using your extension! You have no idea who will be translating it! At least support the basics, it's not hard, and having the framework in place will let you transition much more easily later on."
16+
,"description":"drive the point home. It's good for you."
17+
}
18+
,"l10nFirstParagraph": {
19+
"message":"When the options page loads, elements decorated with <strong>data-l10n</strong> will automatically be localized!"
20+
,"description":"inform that <el data-l10n='' /> elements will be localized on load"
21+
}
22+
,"l10nSecondParagraph": {
23+
"message":"If you need more complex localization, you can also define <strong>data-l10n-args</strong>. This should contain <span class='code'>$containerType$</span> filled with <span class='code'>$dataType$</span>, which will be passed into Chrome's i18n API as <span class='code'>$functionArgs$</span>. In fact, this paragraph does just that, and wraps the args in mono-space font. Easy!"
24+
,"description":"introduce the data-l10n-args attribute. End on a lame note."
25+
,"placeholders": {
26+
"containerType": {
27+
"content":"$1"
28+
,"example":"'array', 'list', or something similar"
29+
,"description":"type of the args container"
30+
}
31+
,"dataType": {
32+
"content":"$2"
33+
,"example":"string"
34+
,"description":"type of data in each array index"
35+
}
36+
,"functionArgs": {
37+
"content":"$3"
38+
,"example":"arguments"
39+
,"description":"whatever you call what you pass into a function/method. args, params, etc."
40+
}
41+
}
42+
}
43+
,"l10nThirdParagraph": {
44+
"message":"Message contents are passed right into innerHTML without processing - include any tags (or even scripts) that you feel like. If you have an input field, the placeholder will be set instead, and buttons will have the value attribute set."
45+
,"description":"inform that we handle placeholders, buttons, and direct HTML input"
46+
}
47+
,"l10nButtonsBefore": {
48+
"message":"Different types of buttons are handled as well. &lt;button&gt; elements have their html set:"
49+
}
50+
,"l10nButton": {
51+
"message":"in a <strong>button</strong>"
52+
}
53+
,"l10nButtonsBetween": {
54+
"message":"while &lt;input type='submit'&gt; and &lt;input type='button'&gt; get their 'value' set (note: no HTML):"
55+
}
56+
,"l10nSubmit": {
57+
"message":"a <strong>submit</strong> value"
58+
}
59+
,"l10nButtonsAfter": {
60+
"message":"Awesome, no?"
61+
}
62+
,"l10nExtras": {
63+
"message":"You can even set <span class='code'>data-l10n</span> on things like the &lt;title&gt; tag, which lets you have translatable page titles, or fieldset &lt;legend&gt; tags, or anywhere else - the default <span class='code'>Boil.localize()</span> behavior will check every tag in the document, not just the body."
64+
,"description":"inform about places which may not be obvious, like <title>, etc"
65+
}
66+
}

css/github-old-style.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.contrib-column-first {
2+
border-left: 0;
3+
}
4+
5+
.contrib-column {
6+
padding: 15px 0;
7+
border-top: 1px solid #ddd;
8+
border-left: 1px solid #ddd;
9+
font-size: 11px;
10+
text-align: center;
11+
}
12+
13+
.table-column {
14+
display: table-cell;
15+
width: 1%;
16+
vertical-align: top;
17+
}
18+
19+
.contrib-number {
20+
font-weight: 300;
21+
line-height: 1.3em;
22+
font-size: 24px;
23+
display: block;
24+
color: #333;
25+
}

icons/icon128.png

25.8 KB
Loading

icons/icon16.png

789 Bytes
Loading

icons/icon19.png

749 Bytes
Loading

icons/icon48.png

5.82 KB
Loading

js/github-contributions.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
chrome.extension.sendMessage({}, function(response) {
2+
$(document).ready(function() {
3+
var largest = largestStreak();
4+
var commits = totalCommits();
5+
6+
$("#contributions-calendar").append("<div class='contrib-column contrib-column-first table-column'><span class='text-muted'>Contributions in the last year</span><span class='contrib-number'>"+ new Intl.NumberFormat().format(commits) + " total</span><span class=text-muted>" + contribDateFormat(largest.epoch) + " - " + contribDateFormat(largest.end) + "</span></div>");
7+
$("#contributions-calendar").append("<div class='contrib-column table-column'><span class='text-muted'>Longest streak</span><span class='contrib-number'>" + largest.streak + " days</span><span class='text-muted'>" + streakDateFormat(largest.lStart) + " to " + streakDateFormat(largest.lEnd) + "</span></div>");
8+
$("#contributions-calendar").append("<div class='contrib-column table-column'><span class='text-muted'>Current Streak</span><span class='contrib-number'>" + largest.current + " days</span><span class='text-muted'>Last Contributed on " + currentStreakDateFormat(largest.end) + "</span></div>");
9+
});
10+
});
11+
12+
function streakDateFormat(date) {
13+
return moment.utc(date, "YYYY-MM-DD").format("MMMM D");
14+
}
15+
16+
function contribDateFormat(date) {
17+
return moment.utc(date, "YYYY-MM-DD").format("MMM D, YYYY");
18+
}
19+
20+
function currentStreakDateFormat(date) {
21+
return moment.utc(date).format("MMMM D");
22+
}
23+
24+
25+
function largestStreak() {
26+
var largestStreak = 0;
27+
var largestStartDate = "";
28+
var largestEndDate = "";
29+
var start = "";
30+
var end = "";
31+
32+
33+
var currentStreak = 0;
34+
var startDate = "";
35+
var prevDate = "";
36+
var endDate = "";
37+
$.each($("rect.day[data-date]"), function(idx, elem) {
38+
var date = $(elem).attr("data-date");
39+
var count = parseInt($(elem).attr("data-count"));
40+
if (idx == 0) {
41+
start = date;
42+
}
43+
44+
if (startDate == "") {
45+
startDate = date;
46+
}
47+
48+
if (count > 0) {
49+
prevDate = date;
50+
51+
currentStreak+=1;
52+
} else {
53+
endDate = prevDate;
54+
// console.log("Current Streak is " + currentStreak + " from " + startDate + " to " + endDate);
55+
if (currentStreak > largestStreak) {
56+
largestStreak = currentStreak;
57+
largestStartDate = startDate;
58+
largestEndDate = endDate;
59+
}
60+
startDate = ""
61+
endDate = ""
62+
currentStreak = 0;
63+
}
64+
});
65+
66+
endDate = prevDate;
67+
// console.log("Current Streak is " + currentStreak + " from " + startDate + " to " + endDate);
68+
if (currentStreak > largestStreak) {
69+
largestStreak = currentStreak;
70+
largestStartDate = startDate;
71+
largestEndDate = endDate;
72+
}
73+
74+
// console.log("Largest Streak is " + largestStreak + " from " + largestStartDate + " to " + largestEndDate);
75+
return {
76+
streak: largestStreak,
77+
epoch: start,
78+
lStart: largestStartDate,
79+
lEnd: largestEndDate,
80+
current: currentStreak,
81+
end: endDate
82+
};
83+
}
84+
85+
86+
function totalCommits() {
87+
$.each($(".js-calendar-graph-svg g rect"), function(idx, elem) {
88+
var date = jQuery(elem).attr("data-date");
89+
var count = jQuery(elem).attr("data-count");
90+
// console.log("Contributed " + count + " commits on " + date);
91+
});
92+
93+
var totalContributions = 0;
94+
$.each($(".js-calendar-graph-svg g rect"), function(idx, elem) {
95+
var count = parseInt(jQuery(elem).attr("data-count"));
96+
totalContributions += count;
97+
});
98+
// console.log("Total Contributions is " + totalContributions);
99+
return totalContributions;
100+
}

js/jquery.min.js

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

js/moment.min.js

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

0 commit comments

Comments
 (0)