JavScript code clash mod_phoca_tree and highcharts.js

Phoca Gallery modules - modules for Phoca Gallery extension
Marco42
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 17 Jan 2022, 23:17

JavScript code clash mod_phoca_tree and highcharts.js

Post by Marco42 »

Hi,

I am developing a component J!TrackGallery for Joomla and received a question from a user who uses this in combination with the mod_phoca_tree module.

The issue is a conflict in function/object names: mod_phoca_tree loads the following JavaScript:

Code: Select all

$document->addScript( JURI::base(true) . '/media/mod_phocagallery_tree/dtree.js' );
which defines a function 'Node' which overrides the standard Node object (https://developer.mozilla.org/en-US/docs/Web/API/Node )

The J!Trackgallery code, uses highcharts for plotting (http://www.highcharts.com, example page: https://jtrackgalleryj4.gta-trek.eu/ind ... g/track/18), which uses win.Node.TEXT_NODE as a named constant (see https://developer.mozilla.org/en-US/doc ... e/nodeType) to identify text objects in the DOM tree. This constant is not defined when the dtree.js file is loaded.

dtree.js does not seem to be part of the source of the mod_phocagallery_tree. Is it generated by jstree?

I am not a JavaScript expert; is there a way to avoid this clash in the global namespace?

Best regards, Marco.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: JavScript code clash mod_phoca_tree and highcharts.js

Post by Jan »

Hi, unfortunately, I am not the author of this Javascript library so really hard to change some code inside this library. It is external Javascript library, so the only one solution is to not use it completely :idea:

Jan
If you find Phoca extensions useful, please support the project
Marco42
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 17 Jan 2022, 23:17

Re: JavaScript code clash mod_phoca_tree and highcharts.js

Post by Marco42 »

Dear Jan,

I looked into this in a bit more detail, and I think that dtree.js may not be used/needed anymore. I installed PhocaGallery and the tree module on my test site, and it seems to work, but there is no file dtree.js generated. You can find my test site here:

https://testing.gta-trek.eu/index.php/en/phocagallery

with the tree shows on the right. Looking at the HTML source in the browser, I see:

Code: Select all

	
	<script src="/media/mod_phocagallery_tree/jstree/jstree.min.js?0b85e27f8a6df9d3e13a175be87becc1"></script>
	<script src="/media/mod_phocagallery_tree/dtree.js"></script>
but the dtree.js script does not exist at: https://testing.gta-trek.eu/media/mod_p ... e/dtree.js

Could it be that dtree was used in an older version of the PhocaGallery tree module and that it is no longer used/needed? If so, could you remove the corresponding 'addScript' line (see original post) from the source code?

Best regards, Marco.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: JavScript code clash mod_phoca_tree and highcharts.js

Post by Jan »

Hi, dtree is used in version 4.4.0 (which is Joomla 3 version) and jstree in version 4.5.0 (which is used in Joomla 4 version)

And you right, there is bug in version 4.5.0 as it tries to load the dtree. If you are using Joomla 4, please update to 4.5.1 and let me know if this is OK now:
https://www.phoca.cz/download/category/ ... ree-module

Jan
If you find Phoca extensions useful, please support the project
Post Reply