So I found that if I am only using the hype page as the web page then all works well with the above when exporting.
But if I insert the hype div into another document then var hypeMainContainerName = $( "body div:first-child" ).attr('id'); gets broken. Which I guess I expected.
using:
var hypeMainContainerName = $("[id$='_hype_container']")[0].id ;
to find the first div that ends with _hype_container resolves this where I only have one hype inserted. (Which I think will be the normal case scenario )
But I did run into something I did not expect but I guess should have.
My hype doc has jquery added to the resources. But I had to also link it to the main pages head
@Daniel do you know of a better way of doing this. It would be much easier if the main hype div had a unique class name we could use. something like class="hyp_dn_name"
Not only for getting this index/document name but we could also use in some of the scenarios here:
by obtaining the hyp_dn attribute of the uniquely named div which is the document name
I spotted that issue when I originally started playing with this. the Lower case caught me off guard. Until I realised that I could just use the id from the first div in the document container. Which had all the cleaning done to it.
hypeDocument.documentId() returns the sanitised name.