scripts/ajax.js
changeset 3 e7447a6044ec
parent 2 860ba7141641
child 5 9b96265b5918
equal deleted inserted replaced
2:860ba7141641 3:e7447a6044ec
    64 }
    64 }
    65 
    65 
    66 function setAjaxLoading()
    66 function setAjaxLoading()
    67 {
    67 {
    68   $('ajax_status').object.src = img_ajax;
    68   $('ajax_status').object.src = img_ajax;
       
    69   $('ajax_status').object.style.display = 'block';
    69 }
    70 }
    70 
    71 
    71 function unsetAjaxLoading()
    72 function unsetAjaxLoading()
    72 {
    73 {
    73   $('ajax_status').object.src = 'about:blank';
    74   $('ajax_status').object.src = 'about:blank';
       
    75   $('ajax_status').object.style.display = 'none';
    74 }
    76 }
    75 
    77 
    76 var refresh_playlist = function()
    78 var refresh_playlist = function()
    77 {
    79 {
    78   setAjaxLoading();
    80   setAjaxLoading();
   109           {
   111           {
   110             $(nt_id).addClass('current');
   112             $(nt_id).addClass('current');
   111           }
   113           }
   112         }
   114         }
   113         // update playing status
   115         // update playing status
   114         var img = $('btn_playpause').object.getElementsByTagName('img')[0];
       
   115         is_playing = response.is_playing;
   116         is_playing = response.is_playing;
   116         if ( is_playing )
   117         if ( allow_control )
   117         {
   118         {
   118           img.src = img_pause;
   119           var img = $('btn_playpause').object.getElementsByTagName('img')[0];
   119         }
   120           if ( is_playing )
   120         else
   121           {
   121         {
   122             img.src = img_pause;
   122           img.src = img_play;
   123           }
       
   124           else
       
   125           {
       
   126             img.src = img_play;
       
   127           }
   123         }
   128         }
   124         // update volume
   129         // update volume
   125         if ( response.volume != current_volume )
   130         if ( response.volume != current_volume )
   126         {
   131         {
   127           set_volume_fill(response.volume);
   132           set_volume_fill(response.volume);
   163 
   168 
   164 function jump_to_song(tid)
   169 function jump_to_song(tid)
   165 {
   170 {
   166   setAjaxLoading();
   171   setAjaxLoading();
   167   if ( tid == current_track )
   172   if ( tid == current_track )
       
   173     return false;
       
   174   if ( !allow_control )
   168     return false;
   175     return false;
   169   ajaxGet('/action.json/jump/' + tid, function()
   176   ajaxGet('/action.json/jump/' + tid, function()
   170     {
   177     {
   171       if ( ajax.readyState == 4 && ajax.status == 200 )
   178       if ( ajax.readyState == 4 && ajax.status == 200 )
   172       {
   179       {