diff --git a/application/models/Schedule.php b/application/models/Schedule.php index 5daa2c513..0ccefd7f6 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -452,7 +452,7 @@ class Schedule { $sql = "SELECT * FROM $CC_CONFIG[scheduleTable], $CC_CONFIG[filesTable]" ." WHERE ($CC_CONFIG[scheduleTable].ends < TIMESTAMP '$timeNow')" ." AND ($CC_CONFIG[scheduleTable].file_id = $CC_CONFIG[filesTable].id)" - ." ORDER BY $CC_CONFIG[scheduleTable].id" + ." ORDER BY $CC_CONFIG[scheduleTable].starts DESC" ." LIMIT $prevCount"; $rows = $CC_DBC->GetAll($sql); return $rows; @@ -474,7 +474,7 @@ class Schedule { $sql = "SELECT * FROM $CC_CONFIG[scheduleTable], $CC_CONFIG[filesTable]" ." WHERE ($CC_CONFIG[scheduleTable].starts > TIMESTAMP '$timeNow')" ." AND ($CC_CONFIG[scheduleTable].file_id = $CC_CONFIG[filesTable].id)" - ." ORDER BY $CC_CONFIG[scheduleTable].id" + ." ORDER BY $CC_CONFIG[scheduleTable].starts" ." LIMIT $nextCount"; $rows = $CC_DBC->GetAll($sql); return $rows; diff --git a/application/views/scripts/schedule/get-scheduler-time.phtml b/application/views/scripts/schedule/get-scheduler-time.phtml index 4152f4c54..49ba61b1c 100644 --- a/application/views/scripts/schedule/get-scheduler-time.phtml +++ b/application/views/scripts/schedule/get-scheduler-time.phtml @@ -6,5 +6,4 @@ });
- diff --git a/public/js/playlist/playlist.js b/public/js/playlist/playlist.js index 4983117e5..064864205 100644 --- a/public/js/playlist/playlist.js +++ b/public/js/playlist/playlist.js @@ -20,15 +20,23 @@ prevDiv.setAttribute("id", "previous"); $(cc.currentElem).append(prevDiv); + var currParentDiv = document.createElement('div'); + currParentDiv.setAttribute("style", "background-color:#bbbbbb;"); + $(cc.currentElem).append(currParentDiv); + var currDiv = document.createElement('div'); currDiv.setAttribute("id", "current"); - $(cc.currentElem).append(currDiv); + $(currParentDiv).append(currDiv); + + var nextDiv = document.createElement('div'); + nextDiv.setAttribute("id", "progressbar"); + $(currParentDiv).append(nextDiv); var nextDiv = document.createElement('div'); nextDiv.setAttribute("id", "next"); $(cc.currentElem).append(nextDiv); - $('#spaceused1').progressBar(0); + $('#progressbar').progressBar(0); getScheduleFromServer(); updateProgressBarValue(); @@ -40,13 +48,10 @@ var day = s.substring(8, 10); var hour = s.substring(11, 13); var minute = s.substring(14, 16); - var sec = 0; + var sec = s.substring(17, 19); var msec = 0; if (s.length >= 20){ - sec = s.substring(17, 19); msec = s.substring(20); - } else { - sec = s.substring(17); } return Date.UTC(year, month, day, hour, minute, sec, msec); @@ -62,17 +67,21 @@ if (cc.currentSong.length > 0){ var percentDone = (cc.estimatedSchedulePosixTime - cc.currentSong[0].songStartPosixTime)/cc.currentSong[0].songLengthMs*100; if (percentDone <= 100){ - $('#spaceused1').progressBar(percentDone); + $('#progressbar').progressBar(percentDone); } else { - if (nextSongs.length > 0){ + if (cc.nextSongs.length > 0){ cc.currentSong[0] = cc.nextSongs.shift(); } else { cc.currentSong = new Array(); } - $('#spaceused1').progressBar(0); + $('#progressbar').progressBar(0); + //at the end of each song we are updating the + //server time we have been estimating client-side + //with the real server time. cc.estimatedSchedulePosixTime = cc.schedulePosixTime; } - } + } else + $('#progressbar').progressBar(0); updatePlaylist(); } setTimeout(secondsTimer, 1000); @@ -93,19 +102,16 @@ var divElem = document.createElement('div'); divElem.innerHTML = createPlaylistElementString(cc.previousSongs[i]); $('#previous').append(divElem); - //cc.currentElem.html(createPlaylistElementString(previousSongs[i])); } for (var i=0; i