From 3fd17a09e36b20c5ab6cd31c26a1fce1f277dc83 Mon Sep 17 00:00:00 2001 From: Athou Date: Tue, 7 May 2013 08:54:57 +0200 Subject: [PATCH] load icons in parallel --- src/main/webapp/js/directives.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/js/directives.js b/src/main/webapp/js/directives.js index 545e456f..87ac710e 100644 --- a/src/main/webapp/js/directives.js +++ b/src/main/webapp/js/directives.js @@ -26,6 +26,14 @@ module.directive('favicon', function() { replace : true, template : '', controller : ['$scope', function($scope) { + + var firstLetterDomain = function(url) { + url = url.replace('http://', ''); + url = url.replace('https://', ''); + url = url.replace('www.', ''); + return url.substring(0, 1); + } + $scope.iconUrl = function() { var url = $scope.url; @@ -35,13 +43,17 @@ module.directive('favicon', function() { if (!url) { return defaultIcon; } - + + var prefix = firstLetterDomain(url); var index = Math.max(url.length, url.lastIndexOf('?')); - var iconUrl = 'http://g.etfv.co/'; + + var iconUrl = 'http://' + prefix + '.getfavicon.appspot.com/'; iconUrl += encodeURIComponent(url.substring(0, index)); iconUrl += '?defaulticon=none'; return iconUrl; }; + + }] }; });