scripts/ajax.js
changeset 5 9b96265b5918
parent 3 e7447a6044ec
child 6 5f35ebc4f9bb
equal deleted inserted replaced
4:cde92f6ec29f 5:9b96265b5918
     1 /**
     1 /**
     2  * AJAX functions
     2  * AJAX functions
     3  * 
     3  * 
     4  * Web control interface script for Amarok
     4  * Web control interface script for Amarok
     5  * Written by Dan Fuhry - 2008
     5  * Copyright (C) 2008 Dan Fuhry
     6  *
     6  *
     7  * This script is in the public domain. Use it for good, not evil.
     7  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
       
     8  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
       
    11  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
     8  */
    12  */
     9 
    13 
    10 var ajax;
    14 var ajax;
    11 var is_playing = false, current_track = -1, current_track_length, current_track_pos, ct_advance_timeout = false, ct_counter = false, playlist_md5 = false;
    15 var is_playing = false, current_track = -1, current_track_length, current_track_pos, ct_advance_timeout = false, ct_counter = false, playlist_md5 = false, first_load = true;
    12 
    16 
    13 function ajaxGet(uri, f)
    17 function ajaxGet(uri, f)
    14 {
    18 {
    15   if (window.XMLHttpRequest)
    19   if (window.XMLHttpRequest)
    16   {
    20   {
   145         update_clock();
   149         update_clock();
   146         if ( is_playing )
   150         if ( is_playing )
   147         {
   151         {
   148           ct_advance_timeout = setTimeout(refresh_playlist, ( 1000 * time_remaining ));
   152           ct_advance_timeout = setTimeout(refresh_playlist, ( 1000 * time_remaining ));
   149           ct_counter = setInterval(update_clock, 1000);
   153           ct_counter = setInterval(update_clock, 1000);
       
   154         }
       
   155         if ( first_load )
       
   156         {
       
   157           first_load = false;
       
   158           var top = $('track_' + current_track).Top() - 138;
       
   159           window.scroll(0, top);
   150         }
   160         }
   151       }
   161       }
   152     });
   162     });
   153 }
   163 }
   154 
   164