Skip to Content
2
Sep 03, 2014 at 04:44 PM

Design Studio SDK - Using Google JavaScript Quirk - What's going on??

40 Views

I'm playing with a Google Geochart API and I've always had some flaky luck with it loading consistently using Google's CDN loader approach. I decided to get to the bottom of it and figure out what's going on...

My contribution.xml:

<component id="GeoChart" title="Google Geocharts" handlerType = "div" icon="res/map.png" group="sampleutilities">
  <jsInclude>http://www.google.com/jsapi</jsInclude>
  <jsInclude>res/js/geochart.js</jsInclude>
  <initialization>
  <defaultValue property="HEIGHT">400</defaultValue>
  <defaultValue property="WIDTH">300</defaultValue>
  </initialization>
  </component>

My init in geochart.js:

 this.init = function() {
    if(this._alive){
    this.drawMap();
    return;
    }
    google.load('visualization', '1', {'packages': ['geochart'], "callback" : function(component){
    var comp = component;
    return function(){
    comp.drawMap();
    };
    }(this)});            
    };  

Basic stuff. The URL http://http://www.google.com/jsapi returns JavaScript which includes the global google object. I run the 'load' method that asynchronously loads the geochart and issues a callback when done.

This all works fine. But only when I'm running in DEBUG mode (Control+Alt+Shift+D).

When I run in non-debug mode, my contribution.xml include is CHANGING (!!!) to what you can see below from an excerpt from the source:

...

<script type="text/javascript" src="/aad/zen.rt.components.filterpanel/resources/js/docking-min.js?version=1409761436058"></script>

<script type="text/javascript" src="/aad/zen.rt.components.filterpanel/resources/js/emptyComponent-min.js?version=1409761436058"></script>

<script type="text/javascript" src="http://www.google.com/js-min.js"></script>

<script type="text/javascript" src="zen/mimes/sdk_include/com.sample.utilities/res/js/geochart.js?version=1409761436-min.js"></script>

<script type="text/javascript" src="/aad/zen.rt.components/resources/js/statisticspanel_handler-min.js?version=1409761436058"></script>

...

What's going on??? Has anyone seen this rewrite happen as well? Where is the SDK logic that rewrites jsInclude URLs? This drove me crazy and sure enough when I run in DEBUG mode, I get the correct include:

...

<script type="text/javascript" src="/aad/zen.rt.components.pagebook/resources/js/pagebook_handler.js?version=1409761436058&nocache="></script>

<script type="text/javascript" src="/aad/zen.rt.components.pagebook/resources/js/transitionhandler.js?version=1409761436058&nocache="></script>

<script type="text/javascript" src="/aad/zen.rt.components.crosstab/resources/js/crosstab_handler.js?version=1409761436058&nocache="></script>

<script type="text/javascript" src="http://www.google.com/jsapi"></script>

<script type="text/javascript" src="zen/mimes/sdk_include/com.sample.utilities/res/js/geochart.js?version=1409761436058"></script>

<script type="text/javascript" src="/aad/zen.rt.components/resources/js/messageview_handler.js?version=1409761436058&nocache="></script>

<script type="text/javascript" src="/aad/zen.rt.components/resources/js/statisticspanel_handler.js?version=1409761436058&nocache="></script>

...

Is this a specific SDK check that's done for Google or a URL pattern replacement? Any info would be helpful.

Thanks!