Getting the index container name

When previewing the first hype_container is called index_hype_container but after export the hype_container takes on the export index html file name .

i.e syndTest2.html will result in the hype_container being called syndtest2._index_hype_container

I want to be able to account for this in code so I can run tests without having to change some hard codes lines.

I.e I need to be able to make adjustments the the height of the xx_hype_container and some of its chldren.

see:
Create Elements on the Fly

Which I have used an if clause for if index or if synd2 …

So I have now come up with this:

    var hypeMainContainerName =   $( "body div:first-child" ).attr('id');
var theMainSceneContainer = hypeDocument.getElementById(hypeMainContainerName );

Which works. I can use my code in preview and export with out having to change anything.

But can anyone see if this could get broken some how.

i.e the first div not being the main index page container.

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

if hype team would offer the function they use to clean the docname for the indexId it’ll be save :slight_smile:

Writing the above made me realise if we can filter for the attribute hyp_dn then we can use that to get the index name and the document name.

I wanted it in as little code as possible otherwise it would be a pain.

In Jquery we can use some thing like :

index name:

 var indexName = $("div").filter("[hyp_dn]")[0].id;

document name:

var hyp_dn = $("div").filter("[hyp_dn]")[0].getAttribute("hyp_dn"); 

Javascript:

index name:

   var indexName = document.querySelectorAll('[hyp_dn]')[0].id;

document name:

var hyp_dn = document.querySelectorAll('[hyp_dn]')[0].getAttribute("hyp_dn");

I like the js version most.

So just posted the above and just as I was about to edit and post.


That could work. But then they may as well offer it as one of the API's


I checked something in said APIs and staring me in the face was:

hypeDocument.documentId()
hypeDocument.documentName()

I am a dumb arse.... :cry:

yeah, but they do some cleaning up spaces, lowercase ect. …
to match this exact, you 've got to know their rules on this

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.

Get Hype Document_Names.hype.zip (42.2 KB)


This works for internal and my purpose of being able to get and adjust the main containers size.

But will not from an external page. So we still have to manually hard code the document name when doing that

ha ha, sometimes you (meant me :slight_smile: ) don't see the door in the wall :slight_smile: thx for pointing out!

1 Like