Skip to content

Instantly share code, notes, and snippets.

@eventualbuddha
Created February 18, 2009 22:10
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save eventualbuddha/66579 to your computer and use it in GitHub Desktop.
Save eventualbuddha/66579 to your computer and use it in GitHub Desktop.
(function($) {
$.fn.clippy = function(text, bgcolor) {
if (!bgcolor) {
var node = $(this);
while (node.css('background-color') == 'transparent' && node.length) {
node = node.parent();
}
if (!node.length) {
bgcolor = '#ffffff';
} else {
bgcolor = node.css('background-color');
}
}
var m = bgcolor.match(/^rgb\(\s*(\d+),\s*(\d+)\s*,\s*(\d+)\s*\)$/i)
if (m) {
var r = parseInt(m[1], 10),
g = parseInt(m[2], 10),
b = parseInt(m[3], 10);
bgcolor = '#'+r.toString(16)+g.toString(16)+b.toString(16);
}
$(this)
.after($('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="110" height="14" id="clippy"> <param name="movie" value="/clippy.swf"/> <param name="allowScriptAccess" value="always" /> <param name="quality" value="high" /> <param name="scale" value="noscale" /> <param NAME="FlashVars" value="text='+escape(text)+'> <param name="bgcolor" value="'+bgcolor+'"> <embed src="/clippy.swf" width="110" height="14" name="clippy" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="text='+escape(text)+'" bgcolor="'+bgcolor+'" /> </object>'))
.after('&nbsp;');
};
})(jQuery);
@Serhioromano
Copy link

Was it harв ещ add small usage example. Lost 20 minuts trying to use it. Not every one is very smart. There are some beginners.

@wdburgdorf
Copy link

@Serhioromano: How about sharing your results? Thank you!

@maxholgasson
Copy link

Yes, is there somewhere a demo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment