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.

Select Content

4 posters

Go down

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

http://www.medievalchaos.net/forum

Back to top Go down

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
Kaizer Lee
Kaizer Lee
Active Poster

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

http://www.medievalchaos.net/forum

Back to top Go down

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
LGforum
LGforum
Hyperactive

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

Back to top Go down

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

http://www.medievalchaos.net/forum

Back to top Go down

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?
Kaizer Lee
Kaizer Lee
Active Poster

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

http://www.medievalchaos.net/forum

Back to top Go down

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.
Tonight
Tonight
Forumember

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

Back to top Go down

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?
Kaizer Lee
Kaizer Lee
Active Poster

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

http://www.medievalchaos.net/forum

Back to top Go down

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.
Tonight
Tonight
Forumember

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

Back to top Go down

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 :/
Kaizer Lee
Kaizer Lee
Active Poster

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

http://www.medievalchaos.net/forum

Back to top Go down

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;
        }
Tonight
Tonight
Forumember

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

Back to top Go down

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

http://www.medievalchaos.net/forum

Back to top Go down

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

http://www.medievalchaos.net/forum

Back to top Go down

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

http://www.medievalchaos.net/forum

Back to top Go down

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

http://www.medievalchaos.net/forum

Back to top Go down

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.
Kaizer Lee
Kaizer Lee
Active Poster

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

http://www.medievalchaos.net/forum

Back to top Go down

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.
LGforum
LGforum
Hyperactive

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

Back to top Go down

Solved Re: Select Content

Post by Kaizer Lee October 19th 2012, 3:33 pm

Would be changing to phpBB3 better?
Kaizer Lee
Kaizer Lee
Active Poster

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

http://www.medievalchaos.net/forum

Back to top Go down

Solved Re: Select Content

Post by LGforum October 19th 2012, 9:47 pm

Haha yes probably. Razz But the choice is yours.
LGforum
LGforum
Hyperactive

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

Back to top Go down

Solved Re: Select Content

Post by Kaizer Lee October 21st 2012, 8:24 am

Alright, solved. Please lock this now.
Kaizer Lee
Kaizer Lee
Active Poster

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

http://www.medievalchaos.net/forum

Back to top Go down

Solved Re: Select Content

Post by Sanket October 21st 2012, 8:28 am

Topic Solved & Locked
Sanket
Sanket
ForumGuru

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

Back to top Go down

Back to top

- Similar topics

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