1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-05 02:39:47 +02:00

ajax loading thingy added to css, fixed random methods on rightbar and added a default sort to the browse methods

This commit is contained in:
Karl 'vollmerk' Vollmer 2007-09-28 02:18:08 +00:00
parent 9030c16466
commit 705fba8f49
10 changed files with 76 additions and 14 deletions

View file

@ -42,26 +42,31 @@ switch($_REQUEST['action']) {
case 'file': case 'file':
case 'album': case 'album':
Browse::set_type('album'); Browse::set_type('album');
Browse::set_sort('name','ASC');
$album_ids = Browse::get_objects(); $album_ids = Browse::get_objects();
Browse::show_objects($album_ids); Browse::show_objects($album_ids);
break; break;
case 'artist': case 'artist':
Browse::set_type('artist'); Browse::set_type('artist');
Browse::set_sort('name','ASC');
$artist_ids = Browse::get_objects(); $artist_ids = Browse::get_objects();
Browse::show_objects($artist_ids); Browse::show_objects($artist_ids);
break; break;
case 'genre': case 'genre':
Browse::set_type('genre'); Browse::set_type('genre');
Browse::set_sort('name','ASC');
$genre_ids = Browse::get_objects(); $genre_ids = Browse::get_objects();
Browse::show_objects($genre_ids); Browse::show_objects($genre_ids);
break; break;
case 'song': case 'song':
Browse::set_type('song'); Browse::set_type('song');
Browse::set_sort('title','ASC');
$song_ids = Browse::get_objects(); $song_ids = Browse::get_objects();
Browse::show_objects($song_ids); Browse::show_objects($song_ids);
break; break;
case 'live_stream': case 'live_stream':
Browse::set_type('live_stream'); Browse::set_type('live_stream');
Browse::set_sort('name','ASC');
$live_stream_ids = Browse::get_objects(); $live_stream_ids = Browse::get_objects();
Browse::show_objects($live_stream_ids); Browse::show_objects($live_stream_ids);
break; break;
@ -70,6 +75,7 @@ switch($_REQUEST['action']) {
break; break;
case 'playlist': case 'playlist':
Browse::set_type('playlist'); Browse::set_type('playlist');
Browse::set_sort('name','ASC');
$playlist_ids = Browse::get_objects(); $playlist_ids = Browse::get_objects();
Browse::show_objects($playlist_ids); Browse::show_objects($playlist_ids);
break; break;

View file

@ -4,6 +4,8 @@
-------------------------------------------------------------------------- --------------------------------------------------------------------------
v.3.4-Alpha3 v.3.4-Alpha3
- Fixed Random methods (rightbar)
- Added Loading box for ajax actions
- Added ability to append to existing playlists - Added ability to append to existing playlists
- Modified Play Method to use hidden iframe - Modified Play Method to use hidden iframe
- Fixed album random and by min random - Fixed album random and by min random

View file

@ -119,7 +119,7 @@ class Browse {
* set_sort * set_sort
* This sets the current sort(s) * This sets the current sort(s)
*/ */
public static function set_sort($sort) { public static function set_sort($sort,$order='') {
switch ($_SESSION['browse']['type']) { switch ($_SESSION['browse']['type']) {
case 'song': case 'song':
@ -147,7 +147,11 @@ class Browse {
return false; return false;
} }
if ($_SESSION['browse']['sort'][$sort] == 'DESC') { if ($order) {
$_SESSION['browse']['sort'] = array();
$_SESSION['browse']['sort'][$sort] = $order;
}
elseif ($_SESSION['browse']['sort'][$sort] == 'DESC') {
// Reset it till I can figure out how to interface the hotness // Reset it till I can figure out how to interface the hotness
$_SESSION['browse']['sort'] = array(); $_SESSION['browse']['sort'] = array();
$_SESSION['browse']['sort'][$sort] = 'ASC'; $_SESSION['browse']['sort'][$sort] = 'ASC';
@ -572,6 +576,9 @@ class Browse {
// First pull the objects // First pull the objects
$objects = self::get_saved(); $objects = self::get_saved();
// If there's nothing there don't do anything
if (!count($objects)) { return false; }
foreach ($objects as $object_id) { foreach ($objects as $object_id) {
$object_id = Dba::escape($object_id); $object_id = Dba::escape($object_id);
$where_sql .= "`id`='$object_id' OR"; $where_sql .= "`id`='$object_id' OR";

View file

@ -98,7 +98,7 @@ class Random {
} }
if (Config::get('require_session')) { if (Config::get('require_session')) {
$session_string = '&sid=' . session_id(); $session_string = '&sid=' . Stream::get_session();
} }
$web_path = Config::get('web_path'); $web_path = Config::get('web_path');

View file

@ -793,7 +793,7 @@ class Song {
$session_string = "&sid=" . $session_id; $session_string = "&sid=" . $session_id;
} }
else { else {
$session_string = "&sid=" . session_id(); $session_string = "&sid=" . Stream::get_session();
} }
} // if they are requiring a session } // if they are requiring a session

View file

@ -54,9 +54,6 @@ class Stream {
$this->web_path = preg_replace("/https/", "http",$this->web_path); $this->web_path = preg_replace("/https/", "http",$this->web_path);
} }
// Generate the session ID
self::$session = md5(uniqid(rand(), true));;
} // Constructor } // Constructor
/** /**
@ -103,6 +100,16 @@ class Stream {
} // manual_url_add } // manual_url_add
/**
* get_session
* This returns the current stream session
*/
public static function get_session() {
return self::$session;
} // get_session
/** /**
* insert_session * insert_session
* This inserts a row into the session_stream table * This inserts a row into the session_stream table
@ -207,7 +214,7 @@ class Stream {
if ($GLOBALS['user']->prefs['play_type'] == 'downsample') { if ($GLOBALS['user']->prefs['play_type'] == 'downsample') {
$ds = $GLOBALS['user']->prefs['sample_rate']; $ds = $GLOBALS['user']->prefs['sample_rate'];
} }
echo $song->get_url(self::$session); echo $song->get_url();
} // end foreach } // end foreach
/* Foreach the additional URLs */ /* Foreach the additional URLs */
@ -443,7 +450,7 @@ class Stream {
// Foreach the stuff we've got and add it // Foreach the stuff we've got and add it
foreach ($this->objects as $object) { foreach ($this->objects as $object) {
$localplay->add($object,self::$session); $localplay->add($object);
} }
$localplay->play(); $localplay->play();
@ -474,7 +481,7 @@ class Stream {
// Build up our object // Build up our object
$song_id = $this->songs['0']; $song_id = $this->songs['0'];
$song = new Song($song_id); $song = new Song($song_id);
$url = $song->get_url(self::$session); $url = $song->get_url();
// Append the fact we are downloading // Append the fact we are downloading
$url .= '&action=download'; $url .= '&action=download';
@ -496,11 +503,22 @@ class Stream {
header("Content-Type: audio/x-pn-realaudio ram;"); header("Content-Type: audio/x-pn-realaudio ram;");
foreach ($this->songs as $song_id) { foreach ($this->songs as $song_id) {
$song = new Song($song_id); $song = new Song($song_id);
echo $song->get_url(self::$session); echo $song->get_url();
} // foreach songs } // foreach songs
} // create_ram } // create_ram
/**
* auto_init
* This is called on class load it sets the session
*/
public static function auto_init() {
// Generate the session ID
self::$session = md5(uniqid(rand(), true));;
} // auto_init
} //end of stream class } //end of stream class
?> ?>

View file

@ -46,6 +46,10 @@ function ajaxPut(url,source) {
function getContents(http_request) { function getContents(http_request) {
// Display the loading doodly
document.getElementById('ajax-loading').style.display = 'block';
if (http_request.readyState == 4) { if (http_request.readyState == 4) {
if (http_request.status == 200) { if (http_request.status == 200) {
var data = http_request.responseXML; var data = http_request.responseXML;
@ -58,7 +62,7 @@ function getContents(http_request) {
$(newID).update(newContent[i].firstChild.nodeValue); $(newID).update(newContent[i].firstChild.nodeValue);
} }
} }
document.getElementById('ajax-loading').style.display = 'none';
} }
} }
} }

View file

@ -80,6 +80,7 @@ if (Config::get('use_rss')) { ?>
<!-- I hate IE... <!-- I hate IE...
<table class="smeg-ie" width="100%"><tr><td> --> <table class="smeg-ie" width="100%"><tr><td> -->
<!-- Tiny little iframe, used to cheat the system --> <!-- Tiny little iframe, used to cheat the system -->
<div id="ajax-loading">Loading . . .</div>
<iframe id="util_iframe" style="display:none;" src="<?php echo Config::get('web_path'); ?>/util.php"></iframe> <iframe id="util_iframe" style="display:none;" src="<?php echo Config::get('web_path'); ?>/util.php"></iframe>
<div id="content"> <div id="content">
<?php if (Config::get('int_config_version') != Config::get('config_version') AND $GLOBALS['user']->has_access(100)) { ?> <?php if (Config::get('int_config_version') != Config::get('config_version') AND $GLOBALS['user']->has_access(100)) { ?>

View file

@ -724,6 +724,18 @@ td.user_disabled {
border:2px solid #000; border:2px solid #000;
} }
#ajax-loading {
position: absolute;
right: 0px;
top: 0px;
float: right;
z-index: 100;
background: #99ccff;
display: none;
padding: 3px 25px 5px 25px;
border: 1px solid #000;
}
#mpdpl td { #mpdpl td {
padding:0 2px 0 2px; padding:0 2px 0 2px;
text-align:left; text-align:left;

View file

@ -818,6 +818,18 @@ input.text_input {
.display {} .display {}
#ajax-loading {
position: absolute;
right: 0px;
top: 0px;
float: right;
z-index: 100;
background: #99ccff;
display: none;
padding: 3px 25px 5px 25px;
border: 1px solid #000;
}
#mpdpl td { #mpdpl td {
padding: 0 2px 0 2px; padding: 0 2px 0 2px;
text-align: left; text-align: left;