I am using this Tuturial https://help.forumotion.com/t93456-select-content-button?highlight=Select+All to add content select function in my forum but its not working? My forum version is phpbb2.
Best Regards,
Dark-Avenger.
This is a Hitskin.com skin preview
Install the skin • Return to the skin page
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
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>');
});
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
Marios94 wrote:Can you please try adding this code to yours and check if it shows? Because to me it doesn't show anything!
- 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>');
});
This is the default code but it still doesn't show anything to me..
Dosen't work. I run PHPbb2. It pops up the select content but it wont select it & changes quote to codeSir. Mayo wrote:Marios94 wrote:Can you please try adding this code to yours and check if it shows? Because to me it doesn't show anything!
- 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>');
});
This is the default code but it still doesn't show anything to me..
DId you test this code on a punbb forum that is the code for phbb2 ONLY. that why it would not work on a Punbb forum.
I fixed the JS issue, I just removed the JS from it. To be honest it's just simply easier not to use it.Sir. Mayo wrote:Can you please link to a post that guests can see that has a code box so i can see the issue my self.
I already said that i am using this code to a test forum that is PHPBB2.Sir. Mayo wrote:Marios94 wrote:Can you please try adding this code to yours and check if it shows? Because to me it doesn't show anything!
- 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>');
});
This is the default code but it still doesn't show anything to me..
DId you test this code on a punbb forum that is the code for phbb2 ONLY. that why it would not work on a Punbb forum.
function selectCode(a){a=$(a).closest("dl").find(".cont_code,code")[0];if(window.getSelection){var c=window.getSelection();if(c.setBaseAndExtent)c.setBaseAndExtent(a,0,a,a.innerText.length-1);else{window.opera&&a.innerHTML.substring(a.innerHTML.length-4)=="<BR>"&&(a.innerHTML+=" ");var b=document.createRange();b.selectNodeContents(a);c.removeAllRanges();c.addRange(b)}}else document.getSelection?(c=document.getSelection(),b=document.createRange(),b.selectNodeContents(a),
c.removeAllRanges(),c.addRange(b)):document.selection&&(b=document.body.createTextRange(),b.moveToElementText(a),b.select())}
$(function(){
$("dl.codebox:not(.spoiler,.hidecode) > dd.code, dl.codebox:not(.spoiler,.hidecode) > dd > code").closest("dl").find('dt').append('<span onClick="selectCode(this)" class="selectCode">Select content</span>');
});
.selectCode { margin-left:10px; cursor:pointer; }
.selectCode:hover { color:#f00; }