-
-
Save achalv/7a55f5b6034d01a39a6a to your computer and use it in GitHub Desktop.
fetch names of repos you've contributed to.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$.ajax({ | |
type: "get", | |
url: "https://api.github.com/users/achalv/repos?type=public&sort=updated&direction=desc", | |
dataType: "json", | |
success: function(returnedData){ | |
console.log(returnedData); | |
var contribs = []; | |
returnedData.forEach(function(obj) { | |
//console.log(obj.fork); | |
var isFork = obj.fork; | |
var createdAt = obj.created_at; | |
var lastPushedAt = obj.pushed_at; | |
if((isFork)&&lastPushedAt>createdAt){ | |
contribs.push(obj); | |
} | |
//contribs.forEach(function(result)) | |
}); | |
//console.log(contribs); | |
function sortByKey(array, key) { | |
return array.sort(function(a, b) { | |
var x = a[key]; var y = b[key]; | |
return ((x < y) ? -1 : ((x > y) ? 1 : 0)); | |
}); | |
} | |
var sContribs = sortByKey(contribs, 'size'); | |
console.log(sContribs); | |
for(var i=0; i<sContribs.length;i++){ | |
var subObj = sContribs[i]; | |
console.log(subObj.name); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment