Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(function($) {
- var SERVICES = {
- 'twitpic.com': function(path) {
- var code = path.match(/\/([a-zA-Z0-9]+)/)[1];
- return "http://twitpic.com/show/thumb/" + code;
- }
- };
- var expression = $.keys(SERVICES).join('|');
- var imageLinks = $("a[href*='" + expression + "']");
- function findService(hostname) {
- $.each($.keys(SERVICES), function(i, service) {
- if (hostname.indexOf(service) > 0)
- return service;
- });
- }
- function showImage(link) {
- var service = findService(link.host);
- var thumbnailURL = SERVICES[service](link.pathname);
- var img = new Image();
- img.src = thumbnailURL;
- img.onload = function() {
- $(this.element).parents('div.tweet').find('.imagebin').append(img);
- }
- }
- $(document).onscroll(function() {
- $.each(imageLinks, function(link) {
- if ((window.scrollY + window.innerHeight + 100) >= $(link).offset().top)
- showImage(link);
- })
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement