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.
The forum of the forums
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 October 10th 2012, 8:19 am

    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 October 21st 2012, 8:25 am; 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 October 10th 2012, 2:53 pm

    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 October 10th 2012, 7:54 pm

    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 October 10th 2012, 8:42 pm

    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 October 11th 2012, 2:39 pm

    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 October 11th 2012, 3:41 pm

    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 October 11th 2012, 4:35 pm

    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 October 11th 2012, 4:38 pm

    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 October 11th 2012, 4:41 pm

    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 October 11th 2012, 6:02 pm

    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 October 12th 2012, 7:50 am

    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 October 14th 2012, 4:53 pm

    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 October 16th 2012, 9:58 pm

    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 October 17th 2012, 1:33 pm

    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 October 18th 2012, 6:23 am

    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 October 19th 2012, 2:26 pm

    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 October 19th 2012, 3:33 pm

    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 October 19th 2012, 9:47 pm

    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 October 21st 2012, 8:24 am

    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 October 21st 2012, 8:28 am

    Topic Solved & Locked

      Current date/time is September 22nd 2024, 3:15 pm