Select all in [code] and [php]
#41
I walked, I want the button to the right.
Not only the text
Reply
#42
Not working, just after click on "select all" page scroll top Sad
[MyBB 1.8 Czech translation] [MyBB 1.8 plugins]: Prune old PMs + optimize DB plugin --- Thank you/like system
Reply
#43
(2017-11-02, 08:09 PM)Eldenroot Wrote: Not working, just after click on "select all" page scroll top Sad

<script type="text/javascript">
function selectCode(a) {
   'use strict';

   // Get ID of code block
   var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
   var s, r;

   // Not IE and IE9+
   if (window.getSelection) {
      s = window.getSelection();
      // Safari and Chrome
      if (s.setBaseAndExtent) {
         var l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1;
         try {
            s.setBaseAndExtent(e, 0, e, l);
         } catch (error) {
            r = document.createRange();
            r.selectNodeContents(e);
            s.removeAllRanges();
            s.addRange(r);
         }
      }
      // Firefox and Opera
      else {
         // workaround for bug # 42885
         if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '<BR>') {
            e.innerHTML = e.innerHTML + '&nbsp;';
         }

         r = document.createRange();
         r.selectNodeContents(e);
         s.removeAllRanges();
         s.addRange(r);
      }
   }
   // Some older browsers
   else if (document.getSelection) {
      s = document.getSelection();
      r = document.createRange();
      r.selectNodeContents(e);
      s.removeAllRanges();
      s.addRange(r);
   }
   // IE
   else if (document.selection) {
      r = document.body.createTextRange();
      r.moveToElementText(e);
      r.select();
   }
}
</script>
Reply
#44
Thank you, great works fine! Rep added! +1
[MyBB 1.8 Czech translation] [MyBB 1.8 plugins]: Prune old PMs + optimize DB plugin --- Thank you/like system
Reply
#45
Sadly this still scrolls to the top
(2018-01-20, 04:15 PM)juniorferraz Wrote:
(2017-11-02, 08:09 PM)Eldenroot Wrote: Not working, just after click on "select all" page scroll top Sad

<script type="text/javascript">
function selectCode(a) {
   'use strict';

   // Get ID of code block
   var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
   var s, r;

   // Not IE and IE9+
   if (window.getSelection) {
      s = window.getSelection();
      // Safari and Chrome
      if (s.setBaseAndExtent) {
         var l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1;
         try {
            s.setBaseAndExtent(e, 0, e, l);
         } catch (error) {
            r = document.createRange();
            r.selectNodeContents(e);
            s.removeAllRanges();
            s.addRange(r);
         }
      }
      // Firefox and Opera
      else {
         // workaround for bug # 42885
         if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '<BR>') {
            e.innerHTML = e.innerHTML + '&nbsp;';
         }

         r = document.createRange();
         r.selectNodeContents(e);
         s.removeAllRanges();
         s.addRange(r);
      }
   }
   // Some older browsers
   else if (document.getSelection) {
      s = document.getSelection();
      r = document.createRange();
      r.selectNodeContents(e);
      s.removeAllRanges();
      s.addRange(r);
   }
   // IE
   else if (document.selection) {
      r = document.body.createTextRange();
      r.moveToElementText(e);
      r.select();
   }
}
</script>
Reply
#46
I'm going to take this tutorial and turn it into a better plugin option Smile. Will release soon
Reply
#47
I forgot to post, but here's the link to an actual plugin if anyone is still looking for it. It's at version 2 now
https://community.mybb.com/thread-239516.html
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)