I am trying to include the timeline API, and install the timline files on my webserver. The timeline-api.js gives an example of an HTML page that contain the following code.
<script>
var Timeline_ajax_url="http://YOUR_SERVER/apis/timeline/ajax/simile-ajax-api.js";
var Timeline_urlPrefix='http://YOUR_SERVER/apis/timeline/';
</script>
<script src="http://YOUR_SERVER/javascripts/timeline/timeline-api.js"
type="text/javascript">
</script>
It also contain the following comment.
/*
* Eg the two next lines pass the same parameters:
* Timeline_parameters='bundle=true'; // pass parameter via js variable
* <script src="http://....timeline-api.js?bundle=true" // pass parameter via url
*/
I am trying to do the same thing in Drupal using the following code.
$timeline_lib_path = $base_path . libraries_get_path('simile_timeline');
// Set some global js variables that the library is going to need for proper inclusion and functionality.
$timeline_inline_js = "
var Timeline_ajax_url = '$timeline_lib_path/timeline_ajax/simile-ajax-api.js',
Timeline_urlPrefix = '$timeline_lib_path/timeline_js/',
Timeline_parameters = 'bundle=true';
";
drupal_add_js('similetimeline',$timeline_inline_js);
drupal_add_js('similetimeline','$timeline_lib_path/timeline_js/timeline-api.js');
I have an uncaught reference error: Timeline is not defined.
drupal_add_js
statement should use double quotes and not simple ones to work.var
statement should also use double quotes, as it contains PHP variables.