!! We are offering existing members a one-time change in their usernames as a result of the site's adjustments. Please contact imToph for details. !!
!! Moderator and Graphic Designer Recruitment @ Announcements Board. !!

You are not connected. Please login or register

View previous topic View next topic Go down Message [Page 1 of 1]

1HTML Select All Code on Sat Jul 09, 2011 1:29 am


imToph

avatar
Administrator

View Extended User Information
TUTORIAL: "Select All" Code

Follow this simple steps to add "Select all" function to your code box.

1. Make an HTML page and paste this code: (click the spoiler)
Spoiler:
Code:
function selectCode(a)
{
  // Get ID of code block
  var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
 
  // Not IE
  if (window.getSelection)
  {
      var s = window.getSelection();
      // Safari
      if (s.setBaseAndExtent)
      {
        s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
      }
      // Firefox and Opera
      else
      {
        // workaround for bug # 42885
        if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
        {
            e.innerHTML = e.innerHTML + ' ';
        }
 
        var r = document.createRange();
        r.selectNodeContents(e);
        s.removeAllRanges();
        s.addRange(r);
      }
  }
  // Some older browsers
  else if (document.getSelection)
  {
      var s = document.getSelection();
      var r = document.createRange();
      r.selectNodeContents(e);
      s.removeAllRanges();
      s.addRange(r);
  }
  // IE
  else if (document.selection)
  {
      var r = document.body.createTextRange();
      r.moveToElementText(e);
      r.select();
  }
}
if(text){}else{ var text = 'Selecionar todos';}
jQuery(document).ready(function(){
  jQuery("dl.codebox dt").not("dl.spoiler > dt").html('Code: <a href="#" onclick="selectCode(this); return false;">Select All</a>');
});

2. Go to the Admin panel ~ Display ~ Templates ~ General ~ viewtopic_body or overall_header and put this script in the head tag:
Code:
<script src="HTML PAGE URL"></script>
http://one2studios.forum.st

View previous topic View next topic Back to top Message [Page 1 of 1]

Permissions in this forum: You cannot reply to topics in this forum




One2 Studios © 2011-2012
Designed and maintained by One2 studios.
Hosted by Forumotion | PunBB © | Report an Abuse



Forumotion.com | © PunBB | Free forum support | Contact | Report an abuse | Free forum