lifeviewer bug

Has something gone haywire? Let us know about it!
User avatar
PHPBB12345
Posts: 1115
Joined: August 5th, 2015, 11:55 pm
Contact:

Re: lifeviewer bug

Post by PHPBB12345 » June 2nd, 2024, 2:29 am

rowett wrote:
June 2nd, 2024, 1:20 am
PHPBB12345 wrote:
June 1st, 2024, 12:45 pm
Console error:

Code: Select all

Uncaught TypeError: Failed to construct 'ClipboardItem': Failed to convert value to 'Blob'
Please let me know which browser you are using on which device (including version numbers).
Chrome 94

User avatar
rowett
Moderator
Posts: 3860
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: lifeviewer bug

Post by rowett » June 2nd, 2024, 3:45 am

PHPBB12345 wrote:
June 2nd, 2024, 2:29 am
rowett wrote:
June 2nd, 2024, 1:20 am
Please let me know which browser you are using on which device (including version numbers).
Chrome 94
Thanks

Device? (e.g. PC running Windows 11 or iPhone 11)

User avatar
PHPBB12345
Posts: 1115
Joined: August 5th, 2015, 11:55 pm
Contact:

Re: lifeviewer bug

Post by PHPBB12345 » June 2nd, 2024, 3:49 am

rowett wrote:
June 2nd, 2024, 3:45 am
PHPBB12345 wrote:
June 2nd, 2024, 2:29 am
rowett wrote:
June 2nd, 2024, 1:20 am
Please let me know which browser you are using on which device (including version numbers).
Chrome 94
Thanks

Device? (e.g. PC running Windows 11 or iPhone 11)
Windows 7

User avatar
squareroot12621
Posts: 659
Joined: March 23rd, 2022, 4:53 pm

Re: lifeviewer bug

Post by squareroot12621 » June 3rd, 2024, 10:49 am

How to get the "Could not decode system clipboard" bug:
  1. Make sure that the rule you're using is a) not defined on LifeWiki, and b) is defined as a ruletable/ruletree in your pattern.
  2. Copy the pattern. The clipboard does copy the pattern, but not the ruletable/ruletree. This means that when you...
  3. paste the pattern, LifeViewer can't figure out what the rule is supposed to be, so it errors out.
Test it here:

Code: Select all

x = 3, y = 3, rule = ExampleTable
2o$b2o$bo!
@RULE ExampleTable
@TABLE
n_states:2
neighborhood:Moore
symmetries:permute
0, 1,1,1,0,0,0,0,0, 1
1, 0,0,0,0,0,0,0,0, 0
1, 1,0,0,0,0,0,0,0, 0
1, 1,1,1,1,0,0,0,0, 0
1, 1,1,1,1,1,0,0,0, 0
1, 1,1,1,1,1,1,0,0, 0
1, 1,1,1,1,1,1,1,0, 0
1, 1,1,1,1,1,1,1,1, 0

Code: Select all

x = 3, y = 3, rule = ExampleTree
2o$b2o$bo!
@RULE ExampleTree
@TREE
num_states=2
num_neighbors=8
num_nodes=32
1 0 0
2 0 0
1 0 1
2 0 2
3 1 3
1 1 1
2 2 5
3 3 6
4 4 7
2 5 0
3 6 9
4 7 10
5 8 11
3 9 1
4 10 13
5 11 14
6 12 15
3 1 1
4 13 17
5 14 18
6 15 19
7 16 20
4 17 17
5 18 22
6 19 23
7 20 24
8 21 25
5 22 22
6 23 27
7 24 28
8 25 29
9 26 30

Code: Select all

4b8o$4b8o$4b8o$4b8o$4o8b4o$4o8b4o$4o8b4o$4o8b4o$4o8b4o$4o8b4o$4o8b4o$4o8b4o$4b8o$4b8o$4b8o$4b8o![[ THEME 0 AUTOSTART GPS 8 Z 16 T 1 T 1 Z 19.027 T 2 T 2 Z 22.627 T 3 T 3 Z 26.909 T 4 T 4 Z 32 T 5 T 5 Z 38.055 T 6 T 6 Z 45.255 T 7 T 7 Z 53.817 LOOP 8 ]]

User avatar
rowett
Moderator
Posts: 3860
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: lifeviewer bug

Post by rowett » June 5th, 2024, 1:01 pm

squareroot12621 wrote:
June 3rd, 2024, 10:49 am
How to get the "Could not decode system clipboard" bug
Fixed, thanks!

User avatar
PHPBB12345
Posts: 1115
Joined: August 5th, 2015, 11:55 pm
Contact:

Re: lifeviewer bug

Post by PHPBB12345 » June 5th, 2024, 7:38 pm

bug found in Script constructor
test case:

Code: Select all

#C [[ "&<>&amp;&lt;&gt;&amp;lt;&amp;gt;" ]]
x=0,y=0,rule=B3/S23
o!
Last edited by PHPBB12345 on June 5th, 2024, 11:48 pm, edited 1 time in total.

User avatar
wirehead
Posts: 265
Joined: June 18th, 2022, 2:37 pm
Location: /dev/full
Contact:

Re: lifeviewer bug

Post by wirehead » June 5th, 2024, 9:42 pm

Just a question for Chris Rowett, why does the Lifeviewer sources still use the old prototype definitions for classes -- e.g.

Code: Select all

function Foo() { ... }
Foo.prototype.bar = function() { ... };
versus the new ES6 class syntax:

Code: Select all

class Foo {
  constructor() { ... }
  bar() { ... }
}
As far as I know, there are automated tools that can back-port the new syntax to the old (maybe it's even built-in to google closure compiler, I haven't read the documentation too thoroughly).
Langton's ant: Can't play the drums, can be taught.

User avatar
rowett
Moderator
Posts: 3860
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: lifeviewer bug

Post by rowett » June 6th, 2024, 4:57 am

wirehead wrote:
June 5th, 2024, 9:42 pm
Just a question for Chris Rowett, why does the Lifeviewer sources still use the old prototype definitions for classes
Because when I started the project ES6 wasn’t ratified. Since then I haven’t seen the value in changing.

User avatar
PHPBB12345
Posts: 1115
Joined: August 5th, 2015, 11:55 pm
Contact:

Re: lifeviewer bug

Post by PHPBB12345 » June 6th, 2024, 8:29 pm

Define two functions:

Code: Select all

/** @returns {string} */
function encodeHTML(/** @type {string} */ text) {
	return text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
}
/** @returns {string} */
function decodeHTML(/** @type {string} */ text) {
	return text.replace(/<br *\/?>/gi,"\n").replace(/<.*?>/g,"").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&nbsp;/gi," ").replace(/&amp;/gi,"&");
}
Example of using encodeHTML:

Code: Select all

textItem.innerHTML = encodeHTML(textItem.value);
Example of using decodeHTML:

Code: Select all

function cleanPattern(element) {
	var	/** @type {string} */ result = decodeHTML(element.innerHTML);

	// remove space or tab at the beginning of lines
	result = result.replace(/\n[ \t]+/g, "\n").trim();

	// if the result is empty make it a valid pattern
	if (result === "") {
		result = "!";
	}

	// return cleaned string
	return result;
}

Post Reply