fixed config bug. popcorn-port
authorhamidouk
Mon, 09 Jan 2012 16:43:36 +0100
branchpopcorn-port
changeset 600 4e669328ab6d
parent 599 a5a5e70d46a7
child 601 02b857c0c9f1
fixed config bug.
src/js/widgets/sparklineWidget.js
test/integration/polemic-platform.htm
--- a/src/js/widgets/sparklineWidget.js	Mon Jan 09 15:38:54 2012 +0100
+++ b/src/js/widgets/sparklineWidget.js	Mon Jan 09 16:43:36 2012 +0100
@@ -27,16 +27,16 @@
   var duration = +this._serializer.currentMedia().meta["dc:duration"];
   var time_step = duration / num_columns; /* the time interval between two columns */
   var results = [];
-  var i = 0; /* the index in the loop */
+  var i = 0; /* the index in the loop */  
 
   /* this algorithm makes one assumption : that the array is sorted 
      (it's done for us by the JSONSerializer). We go through the array 
      and count how many comments fall within a peculiar time piece.
      As i is preserved between each iteration, it's O(n).
   */
-  for(var j = 0; j < num_columns; j++) {
+  
+  for(var j = 0; j < num_columns && i < this._serializer._data.annotations.length; j++) {    
     var count = 0;
-    
     var annotation_begin = +(this._serializer._data.annotations[i].begin);
     
     while(annotation_begin >= j * time_step && annotation_begin <= (j + 1) * time_step ) {
@@ -51,6 +51,7 @@
     
     results.push(count);
   }
+
   
   this.selector.append(templ);
   this.selector.find(".Ldt-sparkLine").css("background", "#c7c8cc");
--- a/test/integration/polemic-platform.htm	Mon Jan 09 15:38:54 2012 +0100
+++ b/test/integration/polemic-platform.htm	Mon Jan 09 16:43:36 2012 +0100
@@ -19,7 +19,7 @@
   
   <div id="video"></div>
   <div id="LdtPlayer"></div>
-  
+  <div id="Sparkline"></div>
   <script  type="text/javascript">
     var platf_url = "http://localhost/pf/ldtplatform/ldt/";
     var project_id = "47e3eef0-3ab4-11e1-9423-001d7d7c6d1d";
@@ -44,6 +44,14 @@
 						  src:platf_url + 'cljson/id/' + project_id,
 						  type:'json'}
 						},
+            {type: "SparklineWidget",
+             width: 640, /* required for this widget */
+             height: 50,            
+						 metadata:{
+						  format:'cinelab',
+						  src:platf_url + 'cljson/id/' + project_id,
+						  type:'json'}
+						},
             {type: "PlayerWidget", // please note that type refers directly to the constructor of the widget.
              mode: "radio",
              metadata:{