Sha256: 665d8fa5ffa74ae9924dd0fdb213c48008cf3d3cf6e5fdfd1cd8633def4ff5f9

Contents?: true

Size: 816 Bytes

Versions: 5

Compression:

Stored size: 816 Bytes

Contents

function getSelectionText(){
  var selectedText = ""
  if (window.getSelection){ // all modern browsers and IE9+
      selectedText = window.getSelection().toString()
  }
  return selectedText;
}

function copyHandler() {
  var thetext = getSelectionText()
  if (thetext.length > 0) { // check there's some text selected
      console.log(thetext);
      document.execCommand("copy"); // logs whatever textual content the user has selected on the page
  }
}

document.addEventListener("DOMContentLoaded", function() {
  if (!!document.getElementById('console')) {
    document.getElementById('console').addEventListener('mouseup', copyHandler, false);
  }

  if (!!document.getElementById('logs')) {
    document.getElementById('logs').addEventListener('mouseup', copyHandler, false);
  }
});

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
logs_explorer-0.1.4 app/views/logs_explorer/javascripts/selection.js
logs_explorer-0.1.3 app/views/logs_explorer/javascripts/selection.js
logs_explorer-0.1.1 app/views/logs_explorer/javascripts/selection.js
logs_explorer-0.1.0 app/views/logs_explorer/javascripts/selection.js
sweet_staging-0.1.2 app/views/sweet_staging/javascripts/selection.js