Skip to content

Instantly share code, notes, and snippets.

@aitor
Created September 16, 2008 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aitor/11067 to your computer and use it in GitHub Desktop.
Save aitor/11067 to your computer and use it in GitHub Desktop.
//
// copied from: http://www.tek-tips.com/viewthread.cfm?qid=1465395&page=5
// TODO: reference original author...
//
function copy(rubyurl) {
var flashcopier = 'flashcopier';
if(!document.getElementById(flashcopier)) {
var divholder = document.createElement('div');
divholder.id = flashcopier;
document.body.appendChild(divholder);
}
document.getElementById(flashcopier).innerHTML = '';
var divinfo = '<embed src="/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(rubyurl)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
document.getElementById(flashcopier).innerHTML = divinfo;
$('x_copy_button').hide();
$('x_copied').show();
}
Event.observe(window, 'load', function() {
// Watch for user's click on "Auto Copy" checkbox
if ($('auto_copy'))
Event.observe('auto_copy', 'change', function(event) { document.cookie = 'auto_copy='+($F('auto_copy') ? 1 : 0); });
// Perform auto-copy if prudent
if ((link = $$('#url.arrow a')).length && document.cookie.match(/auto_copy=1/))
copy(link[0].href);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment