Select Content Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
4 posters

    Select Content

    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Select Content

    Post by Kaizer Lee Wed 10 Oct - 8:19

    Code:
    function selectCode(a)
        {
        // Get ID of code block
        var e = jQuery(a).closest('tr').next().find('.cont_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();
        }
        }
        jQuery(function(){

        jQuery('div.postbody td.code').parent().prev().find('b').html('Code:
        <a href="javascript:void()" onClick="selectCode(this)"><font
        face="verdana" color="red"></font> Select Content </a>');
        });

    https://help.forumotion.com/t93456-select-content-button Followed that, won't work :/

    Edit:Phpbb2 user and Google Chrome. I tried editing it to this:

    Code:
    function selectCode(a)
        {
        // Get ID of code block
        var e = jQuery(a).closest('tr').next().find('.cont_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 Google Chrome
        else
        {
        // workaround for bug # 42885
        if (window.google chrome && 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();
        }
        }
        jQuery(function(){

        jQuery('div.postbody td.code').parent().prev().find('b').html('Code:
        <a href="javascript:void()" onClick="selectCode(this)"><font
        face="verdana" color="red"></font> Select Content </a>');
        });

    But won't work Sad


    Last edited by Frances Kaizer on Sun 21 Oct - 8:25; edited 1 time in total
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Wed 10 Oct - 14:53

    Yeah, we have phpbb2 and yes, it's turned on.

    http://www.medievalchaos.net/forum URL
    LGforum
    LGforum
    Hyperactive


    Male Posts : 2265
    Reputation : 264
    Language : English
    Location : UK

    Solved Re: Select Content

    Post by LGforum Wed 10 Oct - 19:54

    Try this more up to date tutorial: http://www.avacweb.com/t113-select-code
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Wed 10 Oct - 20:42

    I don't understand the select node int hat one. What is it?
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Thu 11 Oct - 14:39

    Code:
    function selectNode(elem) {
      var sel, range;
      if (window.getSelection && document.createRange) {
        sel = window.getSelection();
        range = document.createRange();
        range.selectNodeContents(elem);
        sel.removeAllRanges();
        sel.addRange(range);
      } else if (document.selection && document.selection.createRange) {
        range = document.selection.createRange();
        range.moveToElementText(elem);
        range.select();
      }
    };

    Where do I put that? ._." And this

    Code:
    $(function() {
      $('dl.codebox:not(.spoiler) dt').append('<a class="selectCode clearfix" onclick="selectNode(this.parentNode.nextSibling.firstChild)">Select code</a>');
    });

    All I know where to put is the CSS and yes, erm, about the typo I saw in the comments, where should I remove it? or is it okay with the code already?
    Tonight
    Tonight
    Forumember


    Male Posts : 312
    Reputation : 80
    Language : Estonian, English, Russian
    Location : Estonia

    Solved Re: Select Content

    Post by Tonight Thu 11 Oct - 15:41

    Create a new Javascript (ACP -> Modules -> Javascript codes management).
    ☑ In the topics.
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Thu 11 Oct - 16:35

    Those the 2 have to be in 1 javascript or what?
    Tonight
    Tonight
    Forumember


    Male Posts : 312
    Reputation : 80
    Language : Estonian, English, Russian
    Location : Estonia

    Solved Re: Select Content

    Post by Tonight Thu 11 Oct - 16:38

    You can put them in 1 if you want fufufu
    Doesn't matter actually.
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Thu 11 Oct - 16:41

    Code:
    function selectNode(elem) {
      var sel, range;
      if (window.getSelection && document.createRange) {
        sel = window.getSelection();
        range = document.createRange();
        range.selectNodeContents(elem);
        sel.removeAllRanges();
        sel.addRange(range);
      } else if (document.selection && document.selection.createRange) {
        range = document.selection.createRange();
        range.moveToElementText(elem);
        range.select();
      }
    };

    $(function() {
      $('dl.codebox:not(.spoiler) dt').append('<a class="selectCode clearfix" onclick="selectNode(this.parentNode.nextSibling.firstChild)">Select code</a>');
    });

    And I made sure it's in the topics too. Still won't work :/
    Tonight
    Tonight
    Forumember


    Male Posts : 312
    Reputation : 80
    Language : Estonian, English, Russian
    Location : Estonia

    Solved Re: Select Content

    Post by Tonight Thu 11 Oct - 18:02

    Have you done the CSS part too? (Colors -> CSS Stylesheet)

    Code:
            .selectCode {
              float: right;
              cursor: pointer;
            }
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Fri 12 Oct - 7:50

    Yes and yes, put it as the last lines in my CSS and Java is turned on.
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Sun 14 Oct - 16:53

    Uhm, it's phpBB2, I made another site.
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Tue 16 Oct - 21:58

    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Wed 17 Oct - 13:33

    How do you find out your syntax error?
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Thu 18 Oct - 6:23

    Meh, why'd the select content go to the right part o.O

    http://www.medievalchaos.net/t1165-misshingupawa-to-fumetsu-and-remilia-scarelet#5250 Sample

    Edit:

    Question, how can I make the code box look attractive? I can do the select content now but the code box is ugly :/

    I want to make the text green and select content green, the code white and stuff and add borders or whatever but I don't know where to change it.
    LGforum
    LGforum
    Hyperactive


    Male Posts : 2265
    Reputation : 264
    Language : English
    Location : UK

    Solved Re: Select Content

    Post by LGforum Fri 19 Oct - 14:26

    It goes to the right because of the bit in the CSS that says this for it: float: right;
    Change it to left or remove it.
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Fri 19 Oct - 15:33

    Would be changing to phpBB3 better?
    LGforum
    LGforum
    Hyperactive


    Male Posts : 2265
    Reputation : 264
    Language : English
    Location : UK

    Solved Re: Select Content

    Post by LGforum Fri 19 Oct - 21:47

    Haha yes probably. Razz But the choice is yours.
    Kaizer Lee
    Kaizer Lee
    Active Poster


    Female Posts : 1064
    Reputation : 54
    Language : English, Tagalog, Spanish and Chinese
    Location : Philippines

    Solved Re: Select Content

    Post by Kaizer Lee Sun 21 Oct - 8:24

    Alright, solved. Please lock this now.
    Sanket
    Sanket
    ForumGuru


    Male Posts : 48766
    Reputation : 2830
    Language : English
    Location : Mumbai

    Solved Re: Select Content

    Post by Sanket Sun 21 Oct - 8:28

    Topic Solved & Locked