Skip to content

Instantly share code, notes, and snippets.

@paul
Created August 25, 2011 22:48
Show Gist options
  • Save paul/1172227 to your computer and use it in GitHub Desktop.
Save paul/1172227 to your computer and use it in GitHub Desktop.
$(function() {
callbacks = [];
inlineImages = function(content) {
content.find('a').each(function() {
if (/\.(gif|jpe?g|png)/i.test($(this).text()))
$(this).html('<img src="'+$(this).text()+'"/>')
});
}
callbacks.push(inlineImages)
$(document).delegate('#js-chat li', 'DOMNodeInserted', function(e) {
$(e.target).find('.content').each(function() {
var els = $(this);
if(!els.length == 0)
$.each(callbacks, function(i, cb) { cb(els) });
});
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment