yacy_search_server/htroot/yacy/ui/js/jquery-faviconize-1.0.js
apfelmaennchen 2149728227 - major rework on YaCy-UI
- search results are retrieved from rss/xml, no other servlet needed
- added double accordion sidebar menus

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4718 6c8d7289-2bf4-0310-a012-ef5d649a1542
2008-04-19 11:31:41 +00:00

45 lines
1.4 KiB
JavaScript

/**
* Faviconize (http://www.babylon-design.com/share/faviconize/)
* A jQuery plugin for displaying a favicon on an external link.
*
* Version 1.0
* March 4th, 2008
*
* Author : Samuel Le Morvan (http://www.babylon-design.com/)
*
* Inspired by:
* Ask the CSS Guy (http://www.askthecssguy.com/2006/12/hyperlink_cues_with_favicons.html)
*
*
**/
(function($){
$.fn.faviconize = function(e) {
var e = $.extend({position:'before', linkable:false, exceptions: new Array()}, e);
function faviconizePlace(a, h) {
switch(e.position) {
case "before" : a.before(h+' '); break;
case "after" : a.after(' '+h); break;
default : break;
}
}
$(this).each(function() {
var a = $(this);
var r = a.attr("href").match(/http:\/\/[a-z0-9.-]*(\/)?/i);
var r = r[0] + ((r[1] == null) ? "/" : "");
if(r) {
if($.grep(e.exceptions, function(x) {x = (x.match(/\/$/) == null) ? x+"/" : x; return (x == r);}).length == 0) {
var f = r + 'favicon.ico';
var i = new Image(); $(i).attr("src", f);
var h = '<img src="'+f+'" alt="'+ ((e.linkable) ? a.text() : '') +'" '+ ((e.className) ? 'class="'+e.className+'"' : '') +' />';
h = (e.linkable) ? '<a href="'+a.attr("href")+'">'+h+'</a>' : h;
$(i).load(function() {faviconizePlace(a, h);});
$(i).error(function() {if(e.defaultImage) {faviconizePlace(a, h.replace(/src="(.*?)"/i, 'src="'+e.defaultImage+'"')); }});
}
}
});
}
})(jQuery);