LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LQ Suggestions & Feedback (https://www.linuxquestions.org/questions/lq-suggestions-and-feedback-7/)
-   -   Copy-code button (https://www.linuxquestions.org/questions/lq-suggestions-and-feedback-7/copy-code-button-4175470746/)

szboardstretcher 07-24-2013 08:34 AM

Copy-code button
 
sorry if this is a repeat, searching for 'copy' and 'code' doesn't yield anything useful!

I think it would be great to have a javascript button next to any CODE section to quick select all that code and copy it to the local buffer, for easy pasting/testing.

Additionally, there are quite a few great syntax highlighters out there these days for more relaxed reading.

Sydney 07-24-2013 05:19 PM

Just a suggestion why this may not be happening, interacting with the clipboard is by some a little bit of a security no no. With that said I have used JavaScript to do this exact thing, though I think it only worked in IE in Windows. It has been several years so maybe things have changed, but this is the JavaScript I used.
Code:

function ClipBoard() {
  build('document.note.pad');
  selectAll('note.pad');
  //set the clipboard
  var Tex = document.getElementById("pad").value;
  window.clipboardData.setData("Text",Tex);
}
function select() {
  selectAll('note.pad');
}

BTW I think these are great suggestions.

szboardstretcher 07-25-2013 09:58 PM

wow. that is awesome.

nice job!

jeremy 07-26-2013 12:19 AM

Thanks for the feedback. We don't have any plans to incorporate javascript-based copy, but the PHP code tag does do some syntax highlighting.

http://www.linuxquestions.org/questi...?do=bbcode#php

--jeremy


All times are GMT -5. The time now is 02:23 PM.