-a lot of code cleanup
This commit is contained in:
parent
ac0dd03d82
commit
b5a1f0fa81
14 changed files with 122 additions and 173 deletions
|
@ -12,8 +12,13 @@ class NowplayingController extends Zend_Controller_Action
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.min.js','text/javascript');
|
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.min.js','text/javascript');
|
||||||
|
$this->view->headScript()->appendFile('/js/playlist/nowplayingdatagrid.js','text/javascript');
|
||||||
$this->view->headLink()->appendStylesheet('/css/pro_dropdown_3.css');
|
$this->view->headLink()->appendStylesheet('/css/pro_dropdown_3.css');
|
||||||
$this->view->headLink()->appendStylesheet('/css/styles.css');
|
$this->view->headLink()->appendStylesheet('/css/styles.css');
|
||||||
|
//$this->view->headLink()->appendStylesheet('/css/datatables/demo_page.css');
|
||||||
|
//$this->view->headLink()->appendStylesheet('/css/datatables/demo_table.css');
|
||||||
|
//$this->view->headLink()->appendStylesheet('/css/datatables/demo_table_jui.css');
|
||||||
|
//$this->view->headLink()->appendStylesheet('/css/styles.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDataGridDataAction()
|
public function getDataGridDataAction()
|
||||||
|
|
|
@ -227,19 +227,6 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function viewPlaylistAction()
|
|
||||||
{
|
|
||||||
$this->view->headScript()->appendFile('/js/playlist/playlist.js','text/javascript');
|
|
||||||
$this->view->headScript()->appendFile('/js/progressbar/jquery.progressbar.min.js','text/javascript');
|
|
||||||
|
|
||||||
$this->_helper->viewRenderer->setResponseSegment('nowplaying');
|
|
||||||
|
|
||||||
this->_helper->actionStack('', '');
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getCurrentPlaylistAction()
|
public function getCurrentPlaylistAction()
|
||||||
{
|
{
|
||||||
$this->view->entries = Schedule::GetPlayOrderRange();
|
$this->view->entries = Schedule::GetPlayOrderRange();
|
||||||
|
|
|
@ -1,97 +1 @@
|
||||||
<div id='demo'></div>
|
<div id='demo'></div>
|
||||||
<script>
|
|
||||||
function getDateText(obj){
|
|
||||||
//var str = "";
|
|
||||||
//for (s in obj.oSettings)
|
|
||||||
// str += s + ", ";
|
|
||||||
//alert(str);
|
|
||||||
var str = obj.aData[ obj.iDataColumn ];
|
|
||||||
if (str.indexOf(" ") != -1){
|
|
||||||
return changeTimePrecision(str.substring(0, str.indexOf(" ")));
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTimeText(obj){
|
|
||||||
var str = obj.aData[ obj.iDataColumn ];
|
|
||||||
if (str.indexOf(" ") != -1){
|
|
||||||
return changeTimePrecision(str.substring(str.indexOf(" ")+1));
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeTimePrecisionInit(obj){
|
|
||||||
var str = obj.aData[ obj.iDataColumn ];
|
|
||||||
return changeTimePrecision(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeTimePrecision(str){
|
|
||||||
if (str.indexOf(".") != -1){
|
|
||||||
if (str.length - str.indexOf(".") > 2)
|
|
||||||
var extraLength = str.length - str.indexOf(".") -3;
|
|
||||||
return str.substring(0, str.length - extraLength);
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function notifySongEnd(){
|
|
||||||
for (row in datagridData.rows){
|
|
||||||
if (row[0] == "c")
|
|
||||||
row[0] = "p";
|
|
||||||
if (row[0] == "n"){
|
|
||||||
row[0] = "c";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
createDataGrid();
|
|
||||||
}
|
|
||||||
|
|
||||||
function createDataGrid(){
|
|
||||||
|
|
||||||
datagridData.columnHeaders[1]["fnRender"] = getDateText;
|
|
||||||
datagridData.columnHeaders[2]["fnRender"] = getTimeText;
|
|
||||||
datagridData.columnHeaders[3]["fnRender"] = getTimeText;
|
|
||||||
datagridData.columnHeaders[4]["fnRender"] = changeTimePrecisionInit;
|
|
||||||
|
|
||||||
$('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" width="100%" id="nowplayingtable"></table>' );
|
|
||||||
$('#nowplayingtable').dataTable( {
|
|
||||||
"bSort" : false,
|
|
||||||
"bJQueryUI": true,
|
|
||||||
"bFilter": false,
|
|
||||||
"bInfo": false,
|
|
||||||
"bLengthChange": false,
|
|
||||||
"aaData": datagridData.rows,
|
|
||||||
"aoColumns": datagridData.columnHeaders,
|
|
||||||
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
|
||||||
if (aData[0] == "p"){
|
|
||||||
//$(nRow).attr("style", "background-color:blue;");
|
|
||||||
} else if (aData[0] == "c"){
|
|
||||||
$(nRow).attr("style", "background-color:#61B329;");
|
|
||||||
} else if (aData[0] == "n"){
|
|
||||||
}
|
|
||||||
return nRow;
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
var registered = false
|
|
||||||
|
|
||||||
function init2(){
|
|
||||||
$.ajax({ url: "/Nowplaying/get-data-grid-data/format/json", dataType:"json", success:function(data){
|
|
||||||
datagridData = data.entries;
|
|
||||||
createDataGrid();
|
|
||||||
}});
|
|
||||||
|
|
||||||
if (typeof registerSongEndListener == 'function' && !registered){
|
|
||||||
registered = true;
|
|
||||||
registerSongEndListener(notifySongEnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(init2, 5000);
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
init2();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
|
@ -34,24 +34,3 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
function popup(mylink){
|
|
||||||
if (!window.focus)
|
|
||||||
return true;
|
|
||||||
var href;
|
|
||||||
if (typeof(mylink) == 'string')
|
|
||||||
href=mylink;
|
|
||||||
else
|
|
||||||
href=mylink.href;
|
|
||||||
window.open(href, "player", 'width=300,height=100,scrollbars=yes');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function() {
|
|
||||||
//initialize the playlist bar in the included playlist.js
|
|
||||||
init("nowplayingbar");
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
<div id='col0' style='float:left; width: 10%; height: 100%;'>
|
|
||||||
<div>Listen</div>
|
|
||||||
<div>Volume</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id='col1' style='float:left; width: 25%; height: 100%;'>
|
|
||||||
<div>Show: <span id='show'></span></div>
|
|
||||||
<div>Playlist: <span id='playlist'></span></div>
|
|
||||||
<div>Host: <span id='host'></span></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id='col2' style='float:left; width: 30%; height: 100%;'>
|
|
||||||
<div>Previous: <span id='previous'></span></div>
|
|
||||||
<div>Current: <span id='current'></span></div>
|
|
||||||
<div>Upcoming: <span id='next'></span></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id='list0' style='float:left; width: 35%; height: 100%;'></div>
|
|
||||||
<div>Start: <span id='start'></span></div>
|
|
||||||
<div>End: <span id='end'></span></div>
|
|
||||||
<div><span id='progressbar'></span> <span id='songposition'></span> | <span id='songlength'></span></div>
|
|
||||||
</div>
|
|
94
public/js/playlist/nowplayingdatagrid.js
Normal file
94
public/js/playlist/nowplayingdatagrid.js
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
function getDateText(obj){
|
||||||
|
//var str = "";
|
||||||
|
//for (s in obj.oSettings)
|
||||||
|
// str += s + ", ";
|
||||||
|
//alert(str);
|
||||||
|
var str = obj.aData[ obj.iDataColumn ];
|
||||||
|
if (str.indexOf(" ") != -1){
|
||||||
|
return changeTimePrecision(str.substring(0, str.indexOf(" ")));
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTimeText(obj){
|
||||||
|
var str = obj.aData[ obj.iDataColumn ];
|
||||||
|
if (str.indexOf(" ") != -1){
|
||||||
|
return changeTimePrecision(str.substring(str.indexOf(" ")+1));
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeTimePrecisionInit(obj){
|
||||||
|
var str = obj.aData[ obj.iDataColumn ];
|
||||||
|
return changeTimePrecision(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeTimePrecision(str){
|
||||||
|
if (str.indexOf(".") != -1){
|
||||||
|
if (str.length - str.indexOf(".") > 2)
|
||||||
|
var extraLength = str.length - str.indexOf(".") -3;
|
||||||
|
return str.substring(0, str.length - extraLength);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
function notifySongEnd(){
|
||||||
|
for (row in datagridData.rows){
|
||||||
|
if (row[0] == "c")
|
||||||
|
row[0] = "p";
|
||||||
|
if (row[0] == "n"){
|
||||||
|
row[0] = "c";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createDataGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDataGrid(){
|
||||||
|
|
||||||
|
datagridData.columnHeaders[1]["fnRender"] = getDateText;
|
||||||
|
datagridData.columnHeaders[2]["fnRender"] = getTimeText;
|
||||||
|
datagridData.columnHeaders[3]["fnRender"] = getTimeText;
|
||||||
|
datagridData.columnHeaders[4]["fnRender"] = changeTimePrecisionInit;
|
||||||
|
|
||||||
|
$('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" width="100%" id="nowplayingtable"></table>' );
|
||||||
|
$('#nowplayingtable').dataTable( {
|
||||||
|
"bSort" : false,
|
||||||
|
"bJQueryUI": true,
|
||||||
|
"bFilter": false,
|
||||||
|
"bInfo": false,
|
||||||
|
"bLengthChange": false,
|
||||||
|
"aaData": datagridData.rows,
|
||||||
|
"aoColumns": datagridData.columnHeaders,
|
||||||
|
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
||||||
|
if (aData[0] == "p"){
|
||||||
|
//$(nRow).attr("style", "background-color:blue;");
|
||||||
|
} else if (aData[0] == "c"){
|
||||||
|
$(nRow).attr("style", "background-color:#61B329;");
|
||||||
|
} else if (aData[0] == "n"){
|
||||||
|
}
|
||||||
|
return nRow;
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
var registered = false
|
||||||
|
|
||||||
|
function init2(){
|
||||||
|
$.ajax({ url: "/Nowplaying/get-data-grid-data/format/json", dataType:"json", success:function(data){
|
||||||
|
datagridData = data.entries;
|
||||||
|
createDataGrid();
|
||||||
|
}});
|
||||||
|
|
||||||
|
if (typeof registerSongEndListener == 'function' && !registered){
|
||||||
|
registered = true;
|
||||||
|
registerSongEndListener(notifySongEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(init2, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
init2();
|
||||||
|
});
|
|
@ -165,11 +165,11 @@ function updateProgressBarValue(){
|
||||||
|
|
||||||
function updatePlaybar(){
|
function updatePlaybar(){
|
||||||
/* Column 0 update */
|
/* Column 0 update */
|
||||||
$('#previous').text("none,");
|
$('#previous').text("Prev Song: N/A");
|
||||||
$('#prev-length').text("n/a,");
|
$('#prev-length').text("n/a,");
|
||||||
$('#current').text("none,");
|
$('#current').text("Current Song: N/A");
|
||||||
$('#next').text("none,");
|
$('#next').text("Next Song: N/A");
|
||||||
$('#next-length').text("n/a");
|
$('#next-length').empty();
|
||||||
if (previousSongs.length > 0){
|
if (previousSongs.length > 0){
|
||||||
$('#previous').text(getTrackInfo(previousSongs[previousSongs.length-1]));
|
$('#previous').text(getTrackInfo(previousSongs[previousSongs.length-1]));
|
||||||
$('#prev-length').text(previousSongs[previousSongs.length-1].clip_length);
|
$('#prev-length').text(previousSongs[previousSongs.length-1].clip_length);
|
||||||
|
@ -204,7 +204,7 @@ function updatePlaybar(){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Column 1 update */
|
/* Column 1 update */
|
||||||
$('#playlist').text("Unknown");
|
$('#playlist').text("Current Show: N/A");
|
||||||
for (var i=0; i<currentSong.length; i++){
|
for (var i=0; i<currentSong.length; i++){
|
||||||
$('#playlist').text(currentSong[i].name);
|
$('#playlist').text(currentSong[i].name);
|
||||||
}
|
}
|
||||||
|
@ -266,15 +266,26 @@ function getScheduleFromServer(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function init(elemID) {
|
function init(elemID) {
|
||||||
var currentElem = $("#" + elemID).attr("style", "z-index: 1; width: 100%; left: 0px; right: 0px; bottom: 0px; color: black; min-height: 100px; background-color: #FEF1B5;");
|
|
||||||
|
|
||||||
//$('#progressbar').progressBar(0, {showText : false});
|
|
||||||
//$('#showprogressbar').progressBar(0, {showText : false, barImage:'/js/progressbar/images/progressbg_red.gif'});
|
|
||||||
|
|
||||||
//begin producer "thread"
|
//begin producer "thread"
|
||||||
getScheduleFromServer();
|
getScheduleFromServer();
|
||||||
|
|
||||||
//begin consumer "thread"
|
//begin consumer "thread"
|
||||||
updateProgressBarValue();
|
updateProgressBarValue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function popup(mylink){
|
||||||
|
if (!window.focus)
|
||||||
|
return true;
|
||||||
|
var href;
|
||||||
|
if (typeof(mylink) == 'string')
|
||||||
|
href=mylink;
|
||||||
|
else
|
||||||
|
href=mylink.href;
|
||||||
|
window.open(href, "player", 'width=300,height=100,scrollbars=yes');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
//initialize the playlist bar in the included playlist.js
|
||||||
|
init("nowplayingbar");
|
||||||
|
});
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 120 B |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
|
@ -1,9 +0,0 @@
|
||||||
|
|
||||||
(function($){$.extend({progressBar:new function(){this.defaults={increment:2,speed:15,showText:true,width:120,boxImage:'/js/progressbar/images/progressbar.gif',barImage:'/js/progressbar/images/progressbg_green.gif',height:12};this.construct=function(arg1,arg2){var argpercentage=null;var argconfig=null;if(arg1!=null){if(!isNaN(arg1)){argpercentage=arg1;if(arg2!=null){argconfig=arg2;}}else{argconfig=arg1;}}
|
|
||||||
return this.each(function(child){var pb=this;if(argpercentage!=null&&this.bar!=null&&this.config!=null){this.config.tpercentage=argpercentage;if(argconfig!=null)
|
|
||||||
pb.config=$.extend(this.config,argconfig);}else{var $this=$(this);var config=$.extend({},$.progressBar.defaults,argconfig);var percentage=argpercentage;if(argpercentage==null)
|
|
||||||
var percentage=$this.html().replace("%","");$this.html("");var bar=document.createElement('img');var text=document.createElement('span');bar.id=this.id+"_percentImage";text.id=this.id+"_percentText";bar.src=config.boxImage;bar.width=config.width;var $bar=$(bar);var $text=$(text);this.bar=$bar;this.ntext=$text;this.config=config;this.config.cpercentage=0;this.config.tpercentage=percentage;$bar.css("width",config.width+"px");$bar.css("height",config.height+"px");$bar.css("background-image","url("+config.barImage+")");$bar.css("padding","0");$bar.css("margin","0");$this.append($bar);$this.append($text);bar.alt=this.tpercentage;bar.title=this.tpercentage;}
|
|
||||||
var t=setInterval(function(){var config=pb.config;var cpercentage=parseInt(config.cpercentage);var tpercentage=parseInt(config.tpercentage);var increment=parseInt(config.increment);var bar=pb.bar;var text=pb.ntext;var pixels=config.width/100;bar.css("background-position",(((config.width*-1))+(cpercentage*pixels))+'px 50%');if(config.showText)
|
|
||||||
text.html(" "+Math.round(cpercentage)+"%");if(cpercentage>tpercentage){if(cpercentage-increment<tpercentage){pb.config.cpercentage=0+tpercentage}else{pb.config.cpercentage-=increment;}}
|
|
||||||
else if(pb.config.cpercentage<pb.config.tpercentage){if(cpercentage+increment>tpercentage){pb.config.cpercentage=tpercentage}else{pb.config.cpercentage+=increment;}}
|
|
||||||
else{clearInterval(t);}},pb.config.speed);});};}});$.fn.extend({progressBar:$.progressBar.construct});})(jQuery);
|
|
Loading…
Add table
Add a link
Reference in a new issue