MyBB Community Forums

Full Version: Select all in [code] and [php]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
First of all, you need to add this code into headerinclude template:
<script type="text/javascript">
function selectCode(a)
{
   var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
   if (window.getSelection)
   {
      var s = window.getSelection();
       if (s.setBaseAndExtent)
      {
         s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
      }
      else
      {
         var r = document.createRange();
         r.selectNodeContents(e);
         s.removeAllRanges();
         s.addRange(r);
      }
   }
   else if (document.getSelection)
   {
      var s = document.getSelection();
      var r = document.createRange();
      r.selectNodeContents(e);
      s.removeAllRanges();
      s.addRange(r);
   }
   else if (document.selection)
   {
      var r = document.body.createTextRange();
      r.moveToElementText(e);
      r.select();
   }
}
</script>

Next you go to ACP > Configuration > Languages > English or the language that your board are using > global.lang.php and find:

Quote: php_code

then add this behind anything that already have in the box:

 <a href="#" onclick="selectCode(this); return false;">(SELECT ALL)</a> 

and do the same way for

Quote: code

=> Save it, then you're done.

Demo online: http://mybbvn.com/forum/thread-126.mybbvn
He is allowed to put it here, until a mod moves it, that's how it works.
yeah, I just followed this thread http://community.mybboard.net/thread-5001.html
thanks mate! Smile it is good if you can make it as a plugin not just do file edit.. Toungue
Amazing. Thank you very much!
Nice!

Good Suggestion for Include as an Option on Core Smile

In Opera Browser, when I click SELECT ALL it select all the page and not all the Tag Content Huh, this only on the first PHP Code.
(2009-09-29, 06:18 AM)AndrewPH Wrote: [ -> ]thanks mate! Smile it is good if you can make it as a plugin not just do file edit.. Toungue

I were think about that, but this TUT just take some minutes, so I think that's not the big problem to do that. If you really need a plugin , I can make it for you.

(2009-09-29, 12:14 PM)Rafael Wrote: [ -> ]In Opera Browser, when I click SELECT ALL it select all the page and not all the Tag Content Huh, this only on the first PHP Code.

Oh sorry, I don't use Opera, so I didn't see this problem, and by the way, I don't know how to fix the problem. Sad
maybe i try porting this to a plugin Smile i'll report back in a day Big Grin thanks for the idea
(2009-10-03, 11:44 AM)AndrewPH Wrote: [ -> ]maybe i try porting this to a plugin Smile i'll report back in a day Big Grin thanks for the idea

That should be good Big Grin
(2009-10-03, 04:49 PM)Joey_Pham423 Wrote: [ -> ]
(2009-10-03, 11:44 AM)AndrewPH Wrote: [ -> ]maybe i try porting this to a plugin Smile i'll report back in a day Big Grin thanks for the idea

That should be good Big Grin

plugin attached.

use this in editing language file after "Code:"
<a href="#" onclick="selectCode(this); return false;"><span style="text-transform: uppercase; font-size: 0.8em; font-weight: bold;">[SELECT ALL]</span></a>

i don't know how to do a plugin which change the language file Toungue
Pages: 1 2 3 4 5