Copy table without escaping HTML.
authorCMDR furrycat <elite@furrycat.net>
Fri, 17 Jun 2016 13:05:23 +0000 (09:05 -0400)
committerCMDR furrycat <elite@furrycat.net>
Fri, 17 Jun 2016 13:05:23 +0000 (09:05 -0400)
common.js

index 2db1bad..26dd094 100644 (file)
--- a/common.js
+++ b/common.js
@@ -11,9 +11,14 @@ function copy_clipboard(event) {
       area.style.width = '2em';
       area.style.padding = 0;
       area.style.background = 'transparent';
+      area.setAttribute('readonly', '');
       area.value = text;
       document.body.appendChild(area);
-      area.select();
+      var range = document.createRange();
+      range.selectNode(area);
+      var selection = window.getSelection();
+      selection.removeAllRanges();
+      selection.addRange(range);
       if (document.execCommand('copy')) console.log('Copied bbcode to clipboard.');
       else console.log('Failed to copy bbcode to clipboard.');
       document.body.removeChild(area);