Sizmek Export Script Error - Loads the HYPE file twice

sizmek
exportscripts

(Darren Hayles) #1

Hi, I have just been trying out the new Sizmek Export Script and have been getting an error in so much as the Export Script is loading my HYPE document twice.

Please see the attached file. I have included a JS alert(); on the first ‘On Scene Load’ which should only run once, however when I use the Sizmek preview it runs through twice.

I have identified the following JS code that has been added to the HTML head by the export script that is causing the problem:

(function () {
  
  var thisHypeDocument = null;

  function preInit() {
  	if(EB.isInitialized()) {
  		init();
  	} else {
  		EB.addEventListener(EBG.EventName.EB_INITIALIZED, init);
  	}
  }

  function init() {
  	show();
  }

  function show() {
  	if(thisHypeDocument != null) {
  		thisHypeDocument.showSceneNamed(thisHypeDocument.sceneNames()[0]);
  	}
  }

  function hypeDocumentLoadCallback(hypeDocument, element, event) {
  	thisHypeDocument = hypeDocument;
  	if(!EB.isInitialized() ) {
  		// don't load the Hype document until Sizmek EBLoader has loaded
  		return false;
  	} 
  	return true;
  }
  if("HYPE_eventListeners" in window === false) {
  	window.HYPE_eventListeners = Array();
  }
  window.HYPE_eventListeners.push({"type":"HypeDocumentLoad", "callback":hypeDocumentLoadCallback});

  window.addEventListener('load', preInit);

})();

It looks like it is running EB.isInitialized() is running twice, once before the HYPE file has loaded and then again afterwards causing my custom Script in HYPE to run twice.

When I usually create Sizmek ads, I write the following script manually inside of HYPE in ‘On Scene Load’:

function onEBReady(){
if (typeof(EB) == ‘undefined’) {
setTimeout(onEBReady, 10);
} else {
if (!EB.isInitialized()) {
EB.addEventListener(EBG.EventName.EB_INITIALIZED,initSizmek);
}
else {
initSizmek()
}
}
}
function initSizmek(){
// Do Something
}
onEBReady();

So I guess the Export Script Doesn’t need the function preInit() { … } part ??

If I remove the following it works:

function preInit() {
  	if(EB.isInitialized()) {
  		init();
  	} else {
  		EB.addEventListener(EBG.EventName.EB_INITIALIZED, init);
  	}
  }

  function init() {
  	show();
  }

  function show() {
  	if(thisHypeDocument != null) {
  		thisHypeDocument.showSceneNamed(thisHypeDocument.sceneNames()[0]);
  	}
  }

My Question then, is can this be removed from the export script or is this needed in some way that I cannot see?

Thanks
Darren

Sizmek_ExportScript.hype.zip (20.5 KB)


3.6.3 update - Export Script Export Override
(Darren Hayles) #2

UPDATE.

I have been conversing with Sizmek support regarding this export script and they are as confused as I am.

Here is the latest transcript from Sizmek in response to one of my queries:

My Query

Do you think the HTML file actually needs the hypeDocumentLoadCallback function? If I comment it out it seems to work but I am I missing something?

or does it even need the preInit() function as this seems to load after the code within the HYPE document has already loaded?

Sizmeks Response:

I am quite confused actually of what is the purpose of both hypeDocumentLoadCallback and preInit. If they are doing the same thing, why does HYPE bothered to setup it like that? I’ve also looked at this library https://secure-ds.serving-sys.com/BurstingcachedScripts/libraries/hype/578/HYPE-578.thin.min.js and I’m pretty sure both are just doing the same thing. So I would suggest either just used one of them at the moment.

But for the show function, I think it’s for calling a specific scene and the hypeDocumentLoadCallback is calling your first scene when triggered.
I just noticed, so get rid of the callback and I think it should work. But anyway, I recommend you reaching out with HYPE since this is their library and to have a better understanding of why is this happening at the first place though.

Jonathan @hype are you the author of this export script? and are you able to jump in with myself and Sizmek to fix this problem?


(Jonathan Deutsch) #3

Yes, it looks like this was a bug since I was making an incorrect assumption about how the EB.js is loaded. I’ve made it a bit safer, and revised the script. Can you give it a try before I send it out? You can download it from:

https://raw.githubusercontent.com/tumult/hype-export-scripts/sizmek-2/Sizmek/Sizmek.hype-export.py

You should be able to replace the existing one in ~/Library/Application Scripts/com.tumult.Hype2/Sizmek/. If you just download it and move it, you’ll need to run this command in the Terminal also:

chmod 755 ~/Library/Application\ Scripts/com.tumult.Hype2/Sizmek/Sizmek.hype-export.py

(Darren Hayles) #4

Thanks Jonathan, i’ve replace the script and it now looks to be working fine, i’ll continue to test it on my next batch of ads and will let you know if I find anymore problems.

Incidentally I will have a batch of ads to create with Doubleclick before the end of the month so i’ll be able to fully test that export script also.

Many Thanks
Darren


(Darren Hayles) #5

It looks like the loading problem also exists for the doubleclick Export Script.

I have made the same amend you made to the Sizmek script to DoubleClick DCM and it seems to be working fine now.


(Jonathan Deutsch) #6

Thanks, I’ll make those adjustments there as well!


(Jonathan Deutsch) #7

I’ve made the adjustments and released new versions of the Sizmek export script and the DoubleClick Studio export script.