[FIXED] 'Code: Select All' Does Not Select All

Discussion about the board itself, forums organization and site bugs.
Post Reply
barbaz
Senior Member
Posts: 10938
Joined: Sat Aug 03, 2013 5:45 pm

[FIXED] 'Code: Select All' Does Not Select All

Post by barbaz »

Like the title says.

Code: Select all

Test
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
*Always* check the changelogs BEFORE updating that important software!
-
barbaz
Senior Member
Posts: 10938
Joined: Sat Aug 03, 2013 5:45 pm

Re: 'Code: Select All' Does Not Select All

Post 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 + '&nbsp;';
			}

			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();
	}
}
*Always* check the changelogs BEFORE updating that important software!
-
fatboy
Senior Member
Posts: 97
Joined: Fri Jul 25, 2014 6:56 am
Contact:

Re: 'Code: Select All' Does Not Select All

Post by fatboy »

In Fx 57.0 new code works (I have replaced a code in the local file)
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 SM/2.38 NS/2.9.0.12
barbaz
Senior Member
Posts: 10938
Joined: Sat Aug 03, 2013 5:45 pm

Re: 'Code: Select All' Does Not Select All

Post 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?
*Always* check the changelogs BEFORE updating that important software!
-
barbaz
Senior Member
Posts: 10938
Joined: Sat Aug 03, 2013 5:45 pm

Re: 'Code: Select All' Does Not Select All

Post by barbaz »

bump
*Always* check the changelogs BEFORE updating that important software!
-
User avatar
Giorgio Maone
Site Admin
Posts: 9481
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: 'Code: Select All' Does Not Select All

Post by Giorgio Maone »

Fixed, thanks.
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0
barbaz
Senior Member
Posts: 10938
Joined: Sat Aug 03, 2013 5:45 pm

Re: [FIXED] 'Code: Select All' Does Not Select All

Post by barbaz »

Thanks Giorgio! Image
*Always* check the changelogs BEFORE updating that important software!
-
Post Reply