diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-06-21 16:38:27 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-06-21 16:38:27 +0000 |
commit | fbab0ebea531927baf98e6144599057db464c49b (patch) | |
tree | 94d18a10ad3f4cb2b6a7f5416524191f0bb378a5 | |
parent | 280ee86ed799fbc39139c46b49d43cfc150ddae4 (diff) | |
download | ampache-fbab0ebea531927baf98e6144599057db464c49b.tar.gz ampache-fbab0ebea531927baf98e6144599057db464c49b.tar.bz2 ampache-fbab0ebea531927baf98e6144599057db464c49b.zip |
fixed nowplaying refresh issues and switched it to div layout
-rw-r--r-- | config/ampache.cfg.php.dist | 9 | ||||
-rwxr-xr-x | docs/CHANGELOG | 2 | ||||
-rw-r--r-- | index.php | 12 | ||||
-rw-r--r-- | server/ajax.server.php | 3 | ||||
-rw-r--r-- | templates/basestyle.inc.php | 4 | ||||
-rw-r--r-- | templates/javascript_refresh.inc | 94 | ||||
-rw-r--r-- | templates/javascript_refresh.inc.php | 26 | ||||
-rw-r--r-- | templates/show_now_playing.inc | 111 | ||||
-rw-r--r-- | templates/show_now_playing_row.inc.php | 45 |
9 files changed, 122 insertions, 184 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist index 12a0cd16..bb0adc7a 100644 --- a/config/ampache.cfg.php.dist +++ b/config/ampache.cfg.php.dist @@ -259,9 +259,16 @@ site_charset = iso-8859-1 # This is disabled by default, enabled only # if needed. It's specifically needed for Russian # so that is the default -# Default: cp1251 +# DEFAULT: cp1251 #lc_charset = cp1251 +# Refresh Limit +# This defines the default refresh limit in seconds for +# pages with dynamic content, such as now playing +# DEFAULT: 60 +# Possible Values: Int > 5 +refresh_limit = "60" + ########################################################## # Public Registration settings, defaults to disabled # ########################################################## diff --git a/docs/CHANGELOG b/docs/CHANGELOG index c0475e6b..651e168c 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,8 @@ -------------------------------------------------------------------------- v.3.3.2-Beta3 + - Fixed Nowplaying, now div based layout and AJAX refreshed + based on config files refresh_limit - Moved /modules/init.php to /lib/init.php - Removed Checkboxes from Search page and added ability to search on Comment and Rating @@ -31,6 +31,18 @@ require_once('lib/init.php'); show_template('header'); $action = scrub_in($_REQUEST['action']); + +/** + * Check for the refresh mojo, if it's there then require the + * refresh_javascript include. Must be greater then 5, I'm not + * going to let them break their servers + */ +if (conf('refresh_limit') > 5) { + $ajax_url = conf('web_path') . '/server/ajax.server.php?action=reloadnp&user_id=' . $GLOBALS['user']->id . + '&sessid=' . session_id(); + $ajax_object = 'nowplaying'; + require_once(conf('prefix') . '/templates/javascript_refresh.inc.php'); +} ?> <!-- Big Daddy Table --> diff --git a/server/ajax.server.php b/server/ajax.server.php index 42189c6e..aa519c3f 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -57,6 +57,9 @@ switch ($action) { require_once(conf('prefix') . '/templates/show_localplay_switch.inc.php'); break; + case 'reloadnp': + show_now_playing(); + break; default: echo "Default Action"; break; diff --git a/templates/basestyle.inc.php b/templates/basestyle.inc.php index f9c1a88d..f08b1486 100644 --- a/templates/basestyle.inc.php +++ b/templates/basestyle.inc.php @@ -278,5 +278,9 @@ color: <?php echo conf('font_color3'); ?>; border:1px solid <?php echo conf('base_color2'); ?>; } + .np_cell { + float: left; + margin: 10px; + } --> </style> diff --git a/templates/javascript_refresh.inc b/templates/javascript_refresh.inc deleted file mode 100644 index d8d56a67..00000000 --- a/templates/javascript_refresh.inc +++ /dev/null @@ -1,94 +0,0 @@ -<script type="text/javascript" language="javascript"> -<!-- Begin -// when a page/song is loaded, we get starttime and mpd_elapsed. -// mpd_elapsed is # of seconds elapsed in the now playing song when the page/song was refreshed -// secondssinceloaded is the calculated number of seconds since mpd_elapsed was set (less some load & execute lag). - -// Set refresh interval (in seconds) -var refreshinterval=<?php echo conf('refresh_limit'); ?>; -var web_path = "<?php echo conf('web_path');?>"; - -<?php -if ($user->prefs['play_type'] == 'mpd') { - echo 'var player = "mpd"' . - '; var mpd_elapsed = '. $myMpd->current_track_position . - '; var mpd_song_length = '. $myMpd->current_track_length . - '; var mpd_songid = 0'.$myMpd->current_track_id. - '; var mpdpl_first = 0' . -// $myMpd->current_track_id-1 . - '; var player_state = "'. $myMpd->state .'";'; -} else { - echo 'var player = "'. $user->prefs['play_type'] . - '"; var player_state = "";'; -} -?> - - -// 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 (player_state == "stop" || player_state == "pause") { mpd_notstoppause = 0; } - countdown() -} - -function fmt_time (timenum) { -var sec = Math.floor(timenum % 60); -return Math.floor((1/60) * timenum) + ':' + ((sec < 10) ? '0' : '') + sec; - -} - -function countdown() { - nowtime= new Date() - nowtime=nowtime.getTime() - secondssinceloaded=(nowtime-starttime)/1000 - - if (player_state == 'play') { - 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 ((player == 'mpd') && (player_state == 'play')) { - if (NodeList = document.getElementById ('mpd_cur_track_pos')) - { NodeList.firstChild.data = fmt_time((mpd_elapsed) + (secondssinceloaded)); } - if (NodeList = document.getElementById ('mpd_on_deck_in')) - { NodeList.firstChild.data = fmt_time (mpd_song_length - mpd_elapsed - secondssinceloaded); } - if (NodeList = document.getElementById ('mpd_pctplayed')) - { NodeList.firstChild.data = Math.floor (100*(mpd_elapsed + secondssinceloaded)/mpd_song_length); } - } - if (reloadseconds > 0) { - var timer=setTimeout("countdown()",1000) - } - else { - clearTimeout(timer) - if (true) { /* rig it for AJAX for now; later replace with conf('AJAX') */ - startRequest('action=now_playing'); - starttime = new Date(); - starttime=starttime.getTime() - var timer=setTimeout("countdown()",1000) - } - else { - window.location.reload(true) - } - } //if reloadseconds > 0 - } // if displaycountdown -} - -// start with page-load -window.onload=starttime -// End --> -</script> - diff --git a/templates/javascript_refresh.inc.php b/templates/javascript_refresh.inc.php new file mode 100644 index 00000000..6fbdd9b6 --- /dev/null +++ b/templates/javascript_refresh.inc.php @@ -0,0 +1,26 @@ +<script type="text/javascript" language="javascript"> +<!-- Begin +// Set refresh interval (in seconds) +var refreshinterval=<?php echo conf('refresh_limit'); ?>; + +function doLoad() +{ + // the timeout value should be the same as in the "refresh" meta-tag + setTimeout( "refresh()", refreshinterval*1000 ); +} + +function refresh() +{ + // This version of the refresh function will cause a new + // entry in the visitor's history. It is provided for + // those browsers that only support JavaScript 1.0. + // + ajaxPut('<?php echo $ajax_url; ?>','<?php echo $ajax_object; ?>'); + doLoad(); +} + +// start with page-load +window.onload=doLoad(); +// End --> +</script> + diff --git a/templates/show_now_playing.inc b/templates/show_now_playing.inc index 9aff071c..98fd71eb 100644 --- a/templates/show_now_playing.inc +++ b/templates/show_now_playing.inc @@ -19,101 +19,34 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/*! -@header Show Now Playing Ajax -*/ +/** + * This is the now playing container, it holds the master div for now playing + * and loops through what's current playing as passed and includes + * the now_playing_row's This will display regardless, but potentially + * goes all ajaxie if you've got javascript on + */ -// would change this to input some with the current now playing data. -// so this same script can be used even if the ajax doesnt refresh it. -$c=0; if (count($results)) { +?> + <div id="nowplaying"> + <div id="np_title"> + <h1><?php echo _('Now Playing'); ?></h1> + </div> +<?php foreach ($results as $item) { $song = $item['song']; $np_user = $item['user']; - if (is_object($song)) { - $result = $result.'<song>'; - if (!$np_user->fullname) { $np_user->fullname = "Unknown User"; } - if (conf('use_auth')) { $result = $result.'<fullname>'.$np_user->fullname.'</fullname>';} - else { $result = $result.'<fullname></fullname>'; } -?> - <div id='np_container_<?php echo $c; ?>' style="width:43.5em; display: block; z-index: -10000;"> - <?php if ($c==0) { ?> - <table class="border" cellspacing="1" cellpadding="3" border="0" width="100%"> - <tr class="table-header"> - <td><?php echo _('Now Playing'); ?></td> - </tr> - </table> - <?php } ?> - <table class="border" cellspacing="1" cellpadding="3" border="0" width="100%"> - <tr class="even"> - <td width="20%"> - <div id="np_songid_<?php echo $c; ?>_holder" style="visibility: hidden; position:absolute; z-index: 10000;"> - <?php echo $song->id; ?> - </div> - <div id="np_fullname_<?php echo $c; ?>"> - <?php if (conf('use_auth')) { echo $np_user->fullname; } ?> - </div> - </td> - <td width="30%"> - <div id="np_song_<?php echo $c; ?>"> - <a title="<?php echo scrub_out($song->f_title); ?>" href="<?php echo $web_path; ?>/song.php?action=single_song&song_id=<?php echo $song->id; ?>"> - <?php echo $song->f_title; ?> - </a> - </div> - </td> - <td width="30%"> - <div id="np_albumartist_<?php echo $c; ?>"> - <a title="<?php echo scrub_out($song->f_album); ?>" href="<?php echo $web_path; ?>/albums.php?action=show&album=<?php echo $song->album; ?>"> - <?php echo $song->f_album; ?> - </a> / - <a title="<?php echo scrub_out($song->f_artist); ?>" href="<?php echo $web_path; ?>/artists.php?action=show&artist=<?php echo $song->artist; ?>"> - <?php echo $song->f_artist; ?> - </a> - </div> - </td> - <?php if (conf('play_album_art')) { ?> - <td width="20%"> - <div id="np_img_<?php echo $c; ?>"> - <a target="_blank" href="<?php echo $web_path; ?>/albumart.php?id=<?php echo $song->album; ?>&type=popup" onclick="popup_art('<?php echo $web_path; ?>/albumart.php?id=<?php echo $song->album; ?>&type=popup'); return false;"> - <img align="middle" border="0" src="<?php echo $web_path; ?>/albumart.php?id=<?php echo $song->album; ?>&fast=1&thumb=1" alt="Album Art" height="75" /> - </a> - </div> - </td> - <?php } ?> - </tr> - </table> - </div> -<?php - $c++; - } // end if (is_object($song)) -} // end foreach($results as $item) -} // end if (count($results)) -for ($x=$c; $x<5; $x++) { + + /* If we've gotten a non-song object just skip this row */ + if (!is_object($song)) { continue; } + if (!$np_user->fullname) { $np_user->fullname = "Unknown User"; } + + require(conf('prefix') . '/templates/show_now_playing_row.inc.php'); + +} // end foreach ?> - <div id='np_container_<?php echo $x; ?>' style="display: none; z-index: -10000;"> - <?php - if ($x==0) { ?> - <table class="border" cellspacing="1" cellpadding="3" border="0" width="100%"> - <tr class="table-header"> - <td><?php echo _('Now Playing'); ?></td> - </tr> - </table> - <?php } // end if ($x==0)?> - <table class="border" cellspacing="1" cellpadding="3" border="0" width="100%"> - <tr class="even"> - <td width="20%"> - <div id="np_songid_<?php echo $x; ?>_holder" style="visibility: hidden; position:absolute; z-index: 10000;"></div> - <div id="np_fullname_<?php echo $x; ?>"></div> - </td> - <td width="30%"><div id="np_song_<?php echo $x; ?>"></div></td> - <td width="30%"><div id="np_albumartist_<?php echo $x; ?>"></div></td> - <td width="20%"><div id="np_img_<?php echo $x; ?>"></div></td> - </tr> - </table> + <!-- End Now Playing --> </div> -<?php -} //end for ($x=$c; $x<5; $x++) -?> <br /> - +<?php } // end if count results ?> diff --git a/templates/show_now_playing_row.inc.php b/templates/show_now_playing_row.inc.php new file mode 100644 index 00000000..33ac673b --- /dev/null +++ b/templates/show_now_playing_row.inc.php @@ -0,0 +1,45 @@ +<?php +/* + +Copyright (c) 2001 - 2006 Ampache.org +All rights reserved. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +?> +<div class="np_row"> + <div class="np_cell"><?php echo scrub_out($np_user->fullname); ?></div> + <div class="np_cell"> + <a title="<?php echo scrub_out($song->f_title); ?>" href="<?php echo $web_path; ?>/song.php?action=single_song&song_id=<?php echo $song->id; ?>"> + <?php echo scrub_out($song->f_title); ?> + </a> + </div> + <div class="np_cell"> + <a title="<?php echo scrub_out($song->f_album); ?>" href="<?php echo $web_path; ?>/albums.php?action=show&album=<?php echo $song->album; ?>"> + <?php echo scrub_out($song->f_album); ?> + </a> / + <a title="<?php echo scrub_out($song->f_artist); ?>" href="<?php echo $web_path; ?>/artists.php?action=show&artist=<?php echo $song->artist; ?>"> + <?php echo scrub_out($song->f_artist); ?> + </a> + </div> + <?php if (conf('play_album_art')) { ?> + <div class="np_cell"> + <a target="_blank" href="<?php echo $web_path; ?>/albumart.php?id=<?php echo $song->album; ?>&type=popup" onclick="popup_art('<?php echo $web_path; ?>/albumart.php?id=<?php echo $song->album; ?>&type=popup'); return false;"> + <img align="middle" border="0" src="<?php echo $web_path; ?>/albumart.php?id=<?php echo $song->album; ?>&fast=1&thumb=1" alt="Album Art" height="75" /> + </a> + </div> + <?php } // end play album art ?> +</div> |