blob: 3ef563aa1cb35e9f964a3a73e47414797d0b5152 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<script type="text/javascript" language="javascript">
<!-- Begin
// JS variables mpd_elapsed, mpd_song_length and mpd_state set in show_mpdplay.inc
// Set refresh interval (in seconds)
var refreshinterval=<?php echo conf('refresh_limit'); ?>
// Display the countdown inside the status bar?
// Set "1" for yes or "0" for no
var displaycountdown=1
// main-code
var starttime
var nowtime
var reloadseconds=0
var secondssinceloaded=0
var mpd_notstoppause=1
function starttime() {
starttime=new Date()
starttime=starttime.getTime()
if (mpd_state == "stop" || mpd_state == "pause") { mpd_notstoppause = 0; }
countdown()
}
function fmt_time (timenum) {
var min = Math.floor(timenum / 60)
var sec = Math.floor(timenum % 60)
var fmted = min + ':' + ((sec < 10) ? "0" : "") + sec
return fmted
}
function countdown() {
nowtime= new Date()
nowtime=nowtime.getTime()
secondssinceloaded=(nowtime-starttime)/1000
if (mpd_notstoppause) {
reloadseconds = Math.round(mpd_song_length - mpd_elapsed - secondssinceloaded)
}
else
{ reloadseconds = Math.round(refreshinterval - secondssinceloaded) }
if (displaycountdown=="1")
{
window.status="Refreshing in "+reloadseconds+" seconds";
if (mpd_notstoppause) {
NodeList = document.getElementsByName ('mpd_cur_track_pos');
for (var i = 0; i < NodeList.length; i++)
{ NodeList.item(i).firstChild.data = fmt_time (mpd_elapsed + secondssinceloaded); }
NodeList = document.getElementsByName ('mpd_on_deck_in');
for (var i = 0; i < NodeList.length; i++)
{ NodeList.item(i).firstChild.data = fmt_time (mpd_song_length - mpd_elapsed - secondssinceloaded); }
}
if (reloadseconds > 0) {
var timer=setTimeout("countdown()",1000)
}
else {
clearTimeout(timer)
window.location.reload(true)
} //if reloadseconds > 0
} // if displaycountdown
}
// start with page-load
window.onload=starttime
// End -->
</script>
|