Page 1 of 1
[FIXED] 'Code: Select All' Does Not Select All
Posted: Sat Jan 06, 2018 6:21 pm
by barbaz
Like the title says.
Clicking "Select All" above should select the contents of the code block, "Test". But instead, it just opens this page in a new window.
I'm using Waterfox 56.0.1.
mozillaZine thread on the same problem:
http://forums.mozillazine.org/viewtopic ... &t=3028516
Re: 'Code: Select All' Does Not Select All
Posted: Sat Jan 06, 2018 6:33 pm
by barbaz
This change to the board's selectCode() looks to fix it. Needs testing in multiple browsers to be sure it's a good solution.
Code: Select all
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();
// Firefox and Opera
if (document.createRange)
{
// workaround for bug # 42885
if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
{
e.innerHTML = e.innerHTML + ' ';
}
var r = document.createRange();
r.setStart(e.firstChild, 0);
r.setEnd(e.lastChild, e.lastChild.nodeValue && e.lastChild.nodeValue.length);
s.removeAllRanges();
s.addRange(r);
}
// Safari
else if (s.setBaseAndExtent)
{
s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
}
}
// 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();
}
}
Re: 'Code: Select All' Does Not Select All
Posted: Sat Jan 06, 2018 7:19 pm
by fatboy
In Fx 57.0 new code works (I have replaced a code in the local file)
Re: 'Code: Select All' Does Not Select All
Posted: Sat Jan 06, 2018 8:56 pm
by barbaz
Thanks fatboy!
Also works for me on Pale Moon 27.6.2, Chromium 63.0.3239.84, and Opera 31.0.1889.174 (those just happen to be the versions I have on hand).
Still needs to be tested in Microsoft Edge, IE, and Safari. Any Windows or Mac OS users able to help?
Re: 'Code: Select All' Does Not Select All
Posted: Wed Jan 17, 2018 7:25 am
by barbaz
bump
Re: 'Code: Select All' Does Not Select All
Posted: Wed Jan 17, 2018 1:48 pm
by Giorgio Maone
Fixed, thanks.
Re: [FIXED] 'Code: Select All' Does Not Select All
Posted: Wed Jan 17, 2018 3:52 pm
by barbaz
Thanks Giorgio!