From 2550d19130d64ef2207415b7bdf21b2936665549 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Sun, 19 Oct 2008 14:04:00 +0200 Subject: [PATCH] HistoryView: Only show Gravatar if connected to the net This invokes the SCNetwork framework to check if we can connect to a site without problems. If we can't, we don't even try to show the gravatar. --- html/commit.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/html/commit.js b/html/commit.js index a2e654bbd..8288f8ac6 100644 --- a/html/commit.js +++ b/html/commit.js @@ -98,6 +98,19 @@ var gistie = function() { } +var setGravatar = function(email, image) { + if (Controller && !Controller.isReachable_("www.gravatar.com")) + return; + + if (!email) { + $("gravatar").src = "http://www.gravatar.com/avatar/?d=wavatar&s=60"; + return; + } + + $("gravatar").src = "http://www.gravatar.com/avatar/" + + hex_md5(commit.author_email) + "?d=wavatar&s=60"; +} + var selectCommit = function(a) { Controller.selectCommit_(a); } @@ -164,10 +177,7 @@ var loadCommit = function() { $("details").innerHTML = "This is a large commit. Click here or press 'v' to view."; } - if (commit.author_email) - $("gravatar").src = "http://www.gravatar.com/avatar/" + hex_md5(commit.author_email) + "?d=wavatar&s=60"; - else - $("gravatar").src = "http://www.gravatar.com/avatar/?d=wavatar&s=60"; + setGravatar(commit.author_email, $("gravatar")); scroll(0, 0); }