aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Häggqvist <[email protected]>2014-06-30 19:30:32 +0200
committerVictor Häggqvist <[email protected]>2014-06-30 19:30:32 +0200
commitdfdabbba0163b7796d7f7e9fecfdf216d0ef97cf (patch)
treea8d6564418d9bcf60a1abc99b28162d68a6548d6
parent004855dbc6a1a60b9f3827302c5bfae039bd3875 (diff)
lint free
-rw-r--r--lastcommit.js29
1 files changed, 15 insertions, 14 deletions
diff --git a/lastcommit.js b/lastcommit.js
index ddb1b81..9ce8772 100644
--- a/lastcommit.js
+++ b/lastcommit.js
@@ -1,3 +1,4 @@
+/*jshint browser:true*/
/**
* Widget that shows the last commit made in a users github repositories.
*
@@ -29,17 +30,6 @@
*/
(function(){
- var element = document.getElementsByClassName('lastcommit-widget')[0];
- user = element.getAttribute('data-user');
-
- getLastCommit(user, function (repo, commit) {
- renderWidget(element, {
- user: user,
- repo: repo,
- commit: commit
- });
- });
-
/**
* Wrapper function for widget, gets latest commit for user
*
@@ -48,7 +38,7 @@
*/
function getLastCommit(user, callback) {
- if (!user) { console.error('Did not find username on lastcommit widget'); return;};
+ if (!user) { console.error('Did not find username on lastcommit widget'); return;}
var r = new XMLHttpRequest();
r.open('GET', 'https://api.github.com/users/' + user + '/repos', true);
@@ -102,9 +92,20 @@
* @param data Data to populate the widget with.
*/
function renderWidget(element, data) {
- url = 'https://github.com/' + data.user + '/' + data.repo.name +'/commit/' + data.commit.sha
- var html = '<a href="' + url +'"> ' + data.commit.message + '</a>';
+ var url = 'https://github.com/' + data.user + '/' + data.repo.name +'/commit/' + data.commit.sha,
+ html = '<a href="' + url +'"> ' + data.commit.message + '</a>';
element.innerHTML = html;
}
+ var element = document.getElementsByClassName('lastcommit-widget')[0],
+ user = element.getAttribute('data-user');
+
+ getLastCommit(user, function (repo, commit) {
+ renderWidget(element, {
+ user: user,
+ repo: repo,
+ commit: commit
+ });
+ });
+
})();