summaryrefslogtreecommitdiff
path: root/public/javascripts
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-06-18 15:57:31 +0200
committerfranck cuny <franck@lumberjaph.net>2011-06-18 15:57:31 +0200
commit7f31f1adde1689824afaf2e3b732a6433ee64118 (patch)
tree8606f44d28b2b62f1f67d03e4727a67a3b18b55f /public/javascripts
parentcss for the infobox (diff)
downloadstargit-7f31f1adde1689824afaf2e3b732a6433ee64118.tar.gz
handle the userinfo and the errors
Signed-off-by: franck cuny <franck@lumberjaph.net>
Diffstat (limited to 'public/javascripts')
-rw-r--r--public/javascripts/stargit.js56
1 files changed, 39 insertions, 17 deletions
diff --git a/public/javascripts/stargit.js b/public/javascripts/stargit.js
index 9ed7a2f..c08e8fd 100644
--- a/public/javascripts/stargit.js
+++ b/public/javascripts/stargit.js
@@ -119,16 +119,29 @@ var stargit=(function(){
// This function refreshes the graph from the login of
// a user:
function getGithubGraph(user){
+ $("#user").hide();
+ $("#error").hide();
url = "/graph/local/"+user;
-
$.ajax({
url: url,
dataType: 'json',
+ error:function(){
+ $("#user").hide();
+ $("#error").show();
+ $("#error_reason").text("Can't find graph for user " + user);
+ },
success:
- function(json){
- resetGraph(json);
- if(document.getElementById("query_input").value) document.getElementById("query_input").value = user;
- }
+ function(json){
+ console.log(json);
+ if (json.nodes.length == 0){
+ $("#error").show();
+ $("#error_reason").text("This user has not received any contributions");
+ }
+ $("#info_graph_desc").text("The graph for " + user + " contains " + json.nodes.length + " nodes and " + json.edges.length + " edges");
+ resetGraph(json);
+ if(document.getElementById("query_input").value)
+ document.getElementById("query_input").value = user;
+ }
});
}
@@ -264,17 +277,26 @@ var stargit=(function(){
},
onOverNodes: function(nodesArray){
-// var url = "/";
-//
-// $.ajax({
-// url: url,
-// dataType: 'json',
-// success:
-// function(json){
-// graphAttributes = (json && json["attributes"]) ? json["attributes"] : {};
-// setComboBoxes();
-// }
-// });
+ if (nodesArray[0]){
+ var url = "/profile/" + nodesArray[0];
+ $.ajax({
+ url: url,
+ dataType: 'json',
+ success:
+ function(json){
+ $("#error").hide();
+ $("#user").show();
+ var gravatar = "http://www.gravatar.com/avatar/" + json.gravatar;
+ $("#gravatared").attr("src", gravatar);
+ $("#gravatared").show();
+ $("#user_name").text(json.name);
+ $("#user_website").text(json.website);
+ $("#user_indegree").text(json.indegree);
+ $("#user_country").text(json.country);
+ $("#user_language").text(json.language);
+ }
+ });
+ }
}
};
-})(); \ No newline at end of file
+})();