Page 1 of 1
Code: SELECT ALL stops working
Posted: March 20th, 2017, 1:35 pm
by Alice0775
Code: SELECT ALL stops working since Firefox53beta and Chrome Dev ver.58.0.3026.3.
See detail:
http://forums.mozillazine.org/viewtopic.php?p=14738754#p14738754 wrote:
avada wrote:
There's another weird thing I noticed recently. The select all feature in forums, such as with the code "sections" on this forums don't work. The page is just scrolled to the top.
Chrome Dev ver.58.0.3026.3 is also same behavior.
This behavior was introduced by the following bug:
[*]
#1321623[Core:Selection]-Implement setBaseAndExtent[Uns][[platform-rel-Google][platform-rel-GoogleSuite][platform-rel-GoogleDocs] ]
And, I think Mozillazine needs to update phpBB code forum_fn.js.
Re: Code: SELECT ALL stops working
Posted: March 20th, 2017, 4:04 pm
by Mouse5
if thats the case, wouldnt it be just easier to apply a Updated forum software?
Re: Code: SELECT ALL stops working
Posted: March 20th, 2017, 5:08 pm
by Alice0775
-Arch- wrote:if thats the case, wouldnt it be just easier to apply a Updated forum software?
It will work again when replace "function selectCode" in
http://forums.mozillazine.org/styles/pr ... orum_fn.js.
Code: Select all
function selectCode(a)
{
// Get ID of code block
var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
// Not IE and IE9+
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();
}
}
to
Code: Select all
function selectCode(a) {
'use strict';
// Get ID of code block
var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
var s, r;
// Not IE and IE9+
if (window.getSelection) {
s = window.getSelection();
// Safari and Chrome
if (s.setBaseAndExtent) {
var l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1;
try {
s.setBaseAndExtent(e, 0, e, l);
} catch (error) {
r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
}
// Firefox and Opera
else {
// workaround for bug # 42885
if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '<BR>') {
e.innerHTML = e.innerHTML + ' ';
}
r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
}
// Some older browsers
else if (document.getSelection) {
s = document.getSelection();
r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
// IE
else if (document.selection) {
r = document.body.createTextRange();
r.moveToElementText(e);
r.select();
}
}
(The code is extracted from
https://github.com/phpbb/phpbb/blob/mas ... orum_fn.js)
Re: Code: SELECT ALL stops working
Posted: March 20th, 2017, 5:12 pm
by Mouse5
but my guess Kerz would have to do that?
Re: Code: SELECT ALL stops working
Posted: March 23rd, 2017, 4:15 pm
by Alice0775
workaround using Greasemonkey
Code: Select all
// ==UserScript==
// @name fix_SELECT_ALL_stops_working.user.js
// @description SELECT ALL stops working
// @include http://forums.mozillazine.org/viewtopic.php?*
// @grant none
// ==/UserScript==
var scriptCode = new Array(); // this is where we are going to build our new script
// here's the build of the new script, one line at a time
var func = function selectCode(a) {
'use strict';
// Get ID of code block
var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
var s, r;
// Not IE and IE9+
if (window.getSelection) {
s = window.getSelection();
// Safari and Chrome
if (s.setBaseAndExtent) {
var l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1;
try {
s.setBaseAndExtent(e, 0, e, l);
} catch (error) {
r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
}
// Firefox and Opera
else {
// workaround for bug # 42885
if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '<BR>') {
e.innerHTML = e.innerHTML + ' ';
}
r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
}
// Some older browsers
else if (document.getSelection) {
s = document.getSelection();
r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
// IE
else if (document.selection) {
r = document.body.createTextRange();
r.moveToElementText(e);
r.select();
}
}
scriptCode.push(func.toString());
// now, we put the script in a new script element in the DOM
var script = document.createElement('script'); // create the script element
script.innerHTML = scriptCode.join('\n'); // add the script code to it
scriptCode.length = 0; // recover the memory we used to build the script
// this is sort of hard to read, because it's doing 2 things:
// 1. finds the first <head> tag on the page
// 2. adds the new script just before the </head> tag
document.getElementsByTagName('head')[0].appendChild(script);
Re: Code: SELECT ALL stops working
Posted: May 16th, 2017, 12:39 am
by Guest
Another solution:
replace the line 210
in styles/prosilver/template/forum_fn.js
( or styles/titan/template/forum_fn.js )
( or styles/YOURTHEME/template/forum_fn.js)
Code: Select all
s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
with the line
Code: Select all
s.setBaseAndExtent(e, 0, e.parentNode, 1);