scripts/ajax.js
changeset 13 b5db2345c397
parent 11 0faea3a6c881
child 14 7a1573676cc4
equal deleted inserted replaced
12:b3fcc21e557f 13:b5db2345c397
   291 
   291 
   292 function secs_to_string(time)
   292 function secs_to_string(time)
   293 {
   293 {
   294   var count_seconds = time % 60;
   294   var count_seconds = time % 60;
   295   var count_minutes = ( time - count_seconds ) / 60;
   295   var count_minutes = ( time - count_seconds ) / 60;
       
   296   if ( isNaN(count_seconds) )
       
   297     count_seconds = 0;
       
   298   if ( isNaN(count_minutes) )
       
   299     count_minutes = 0;
   296   return fill_zeroes(count_minutes) + ':' + fill_zeroes(count_seconds);
   300   return fill_zeroes(count_minutes) + ':' + fill_zeroes(count_seconds);
   297 }
   301 }
   298 
   302 
   299 function fill_zeroes(str, len)
   303 function fill_zeroes(str, len)
   300 {
   304 {
   333     if ( match && !$(booby).hasClass('current') )
   337     if ( match && !$(booby).hasClass('current') )
   334     {
   338     {
   335       $(booby).rmClass(match[2]);
   339       $(booby).rmClass(match[2]);
   336     }
   340     }
   337   }
   341   }
       
   342   // recalculate list of rows that should pulse
   338   var tdlist_new = document.getElementsByClassName('current', 'tr');
   343   var tdlist_new = document.getElementsByClassName('current', 'tr');
   339   if ( pulsar_current == 0 && tdlist_new == pulsar_tdlist )
   344   if ( pulsar_current == 0 && tdlist_new == pulsar_tdlist )
   340   {
   345   {
   341     return true;
   346     return true;
   342   }
   347   }
       
   348   // reset everything to 0
   343   pulsar_tdlist = tdlist_new;
   349   pulsar_tdlist = tdlist_new;
   344   pulsar_current = 0;
   350   pulsar_current = 0;
       
   351   pulsar_direction = 1;
   345   for ( var i = 0; i < pulsar_tdlist.length; i++ )
   352   for ( var i = 0; i < pulsar_tdlist.length; i++ )
   346   {
   353   {
   347     var td = pulsar_reset[i];
   354     var td = pulsar_reset[i];
   348     for ( var i = 1; i < 10; i++ )
   355     for ( var i = 1; i < 10; i++ )
   349     {
   356     {
   359   }
   366   }
   360 }
   367 }
   361 
   368 
   362 var pulsar_advance = function()
   369 var pulsar_advance = function()
   363 {
   370 {
       
   371   // this should be as optimized as possible, it should use a precalculated
       
   372   // list of elements to pulse and whatnot... heck even right now it's not
       
   373   // really as optimized as it should be due to the logic, but a lot of it's
       
   374   // kinda more or less necessary.
   364   if ( !is_playing )
   375   if ( !is_playing )
   365     return true;
   376     return true;
   366   if ( pulsar_current + pulsar_direction == 10 )
   377   if ( pulsar_current + pulsar_direction == 10 )
   367   {
   378   {
   368     pulsar_direction = -1;
   379     pulsar_direction = -1;