aitor (owner)

Revisions

gist: 11067 Download_button fork
public
Public Clone URL: git://gist.github.com/11067.git
Embed All Files: show embed
copy to clipboard from a web page #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//
// 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);
});