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

formatting

This commit is contained in:
John Moore 2013-07-28 19:18:27 -05:00
parent 3b4bcc08c2
commit f21379318f

View file

@ -28,14 +28,12 @@ function play_item(event)
} }
function adjust_buttons() function adjust_buttons()
{ {
if(!current_playlist_item.player.paused) if(!current_playlist_item.player.paused) {
{
$('#play').addClass('inactive'); $('#play').addClass('inactive');
$('#pause').removeClass('inactive'); $('#pause').removeClass('inactive');
$('#stop').removeClass('inactive'); $('#stop').removeClass('inactive');
} }
else else {
{
$('#play').removeClass('inactive'); $('#play').removeClass('inactive');
$('#pause').addClass('inactive'); $('#pause').addClass('inactive');
$('#stop').addClass('inactive'); $('#stop').addClass('inactive');
@ -43,8 +41,7 @@ function adjust_buttons()
} }
function stop(event) function stop(event)
{ {
if(current_playlist_item) if(current_playlist_item) {
{
current_playlist_item.player.pause(); current_playlist_item.player.pause();
current_playlist_item.player.currentTime = 0; current_playlist_item.player.currentTime = 0;
current_playlist_item.element.removeClass('playing'); current_playlist_item.element.removeClass('playing');
@ -53,8 +50,7 @@ function stop(event)
} }
function pause(event) function pause(event)
{ {
if(current_playlist_item) if(current_playlist_item) {
{
current_playlist_item.player.pause(); current_playlist_item.player.pause();
adjust_buttons(); adjust_buttons();
} }
@ -76,8 +72,7 @@ function play(event)
} }
function next(event) function next(event)
{ {
if(current_playlist_item && current_playlist_item.next) if(current_playlist_item && current_playlist_item.next) {
{
stop(); stop();
var next = current_playlist_item.next; var next = current_playlist_item.next;
current_playlist_item = next; current_playlist_item = next;
@ -86,8 +81,7 @@ function next(event)
} }
function previous(event) function previous(event)
{ {
if(current_playlist_item && current_playlist_item.previous) if(current_playlist_item && current_playlist_item.previous) {
{
stop(); stop();
current_playlist_item = current_playlist_item.previous; current_playlist_item = current_playlist_item.previous;
play(); play();
@ -102,16 +96,13 @@ function timeupdate(event)
if(current_playlist_item) if(current_playlist_item)
{ {
$('#progress_text').text(seconds_to_string(current_playlist_item.player.currentTime) + "/" + seconds_to_string(current_playlist_item.time)); $('#progress_text').text(seconds_to_string(current_playlist_item.player.currentTime) + "/" + seconds_to_string(current_playlist_item.time));
if(current_playlist_item.player.currentTime > current_playlist_item.time / 2) if(current_playlist_item.player.currentTime > current_playlist_item.time / 2) {
{ if(current_playlist_item.next) {
if(current_playlist_item.next)
{
current_playlist_item.next.player.writeAttribute('preload', 'auto'); current_playlist_item.next.player.writeAttribute('preload', 'auto');
} }
} }
//fix for chrome where ended is not thrown properly //fix for chrome where ended is not thrown properly
if(current_playlist_item.player.currentTime >= current_playlist_item.time) if(current_playlist_item.player.currentTime >= current_playlist_item.time) {
{
ended(event); ended(event);
} }
} }
@ -135,7 +126,7 @@ function search(event)
function clear_search(event) function clear_search(event)
{ {
$('#input_search').val(''); $('#input_search').val('');
//search(event); search(event);
} }
$(document).ready(function() { $(document).ready(function() {
@ -155,19 +146,16 @@ $(document).ready(function() {
player.on('ended', ended); player.on('ended', ended);
player.on('timeupdate', timeupdate); player.on('timeupdate', timeupdate);
playlist_items[id].element = li; playlist_items[id].element = li;
if(last_item) if(last_item) {
{
last_item.next = playlist_items[id]; last_item.next = playlist_items[id];
} }
playlist_items[id].previous = last_item; playlist_items[id].previous = last_item;
last_item = playlist_items[id]; last_item = playlist_items[id];
if(first_item == null) if(first_item == null) {
{
first_item = playlist_items[id]; first_item = playlist_items[id];
} }
} }
if(first_item) if(first_item) {
{
first_item.previous = last_item; first_item.previous = last_item;
last_item.next = first_item; last_item.next = first_item;
current_playlist_item = first_item; current_playlist_item = first_item;