JavaScript being modified by Xibo

Hi there,

I have a scenario where the JavaScript I’m creating through an Embedded HTML item is being modified by Xibo.

The actual line I entered in the “HTML to Embed” box is:

pfImage = pfPhotosContainer.getElementsByTagName(“photo”)[3].childNodes[0].nodeValue;

When it arrives in the library directory on the Xibo Player (1.8 RC1) the line has been modified to:

pfImage = pfPhotosContainer.getElementsByTagName(“photo”)moment.js.childNodes[0].nodeValue;

From what I can tell the rest of the JS code looks right.

Interestingly, when I change it to:

pfImage = pfPhotosContainer.getElementsByTagName(“photo”)[0].childNodes[0].nodeValue;

the code does NOT get modified. Is there something special about the “[3]” string that prevents it from being used?

erm @dan any idea about this? :slight_smile:

Yes, we use [mediaId] notation to replace content with media from the library - so 3 in your case is the file in the media table with ID:3, which just happens to be moment.js in your case.

Its an interesting issue which i’m surprised we’ve not hit before.

You could try to rewrite your selector as:


Which I appreciate isn’t a great workaround, but its all I can come up with at the moment.

I think that in the long term we will have to change our selector to something more unique, like {{mediaId}} for example

1 Like

Dan - your workaround is perfect, and I can’t thank you enough. I used a different workaround, which was to Assign a separate JS file to the Display which contained the failing code, and then referenced it in the HEAD element:

script type=“text/javascript” src=“236.js”

However my workaround would have required a large number of JS files assigned to the correct Displays. Your solution saves us a ton of time and potential for human error. THANK YOU!

1 Like

You’re welcome - im pleased it was useful! :blush: