aboutsummaryrefslogtreecommitdiff
path: root/addons/webinterface.default
diff options
context:
space:
mode:
authormontellese <montellese@xbmc.org>2012-01-11 11:23:21 +0100
committermontellese <montellese@xbmc.org>2012-01-11 11:38:44 +0100
commit257e8eac613940aa810b5668a5c4af1693b6cc14 (patch)
tree8d05be104d11f5eca5b95d82c82ce3344e350e4b /addons/webinterface.default
parentdcb6c0c832d6b09f40f4eae04733ab275ccabfaa (diff)
webinterface.default: cosmetics (spaces instead of tabs & fixed indentation)
Diffstat (limited to 'addons/webinterface.default')
-rwxr-xr-xaddons/webinterface.default/index.html154
-rw-r--r--addons/webinterface.default/js/Core.js124
-rw-r--r--addons/webinterface.default/js/Launcher.js62
-rwxr-xr-xaddons/webinterface.default/js/MediaLibrary.js1679
-rwxr-xr-xaddons/webinterface.default/js/NowPlayingManager.js986
5 files changed, 1494 insertions, 1511 deletions
diff --git a/addons/webinterface.default/index.html b/addons/webinterface.default/index.html
index a06a3fa6fb..9a29eb0d87 100755
--- a/addons/webinterface.default/index.html
+++ b/addons/webinterface.default/index.html
@@ -1,80 +1,80 @@
<!DOCTYPE html>
<html>
- <head>
- <title>XBMC</title>
- <meta http-equiv="Content-Language" content="EN" />
- <meta http-equiv="Content-Type" content="UTF-8" />
- <!-- <link rel="search" href="/provider.xml" type="application/opensearchdescription+xml" title="XBMC Library" /> -->
- <link rel="icon" href="/favicon.ico" type="image/x-icon">
- <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
- <!-- <link href="/images/logo.png" rel="image_src" /> -->
- <meta name="robots" content="NOINDEX, NOFOLLOW">
- <link href="/css/core.css?1.3.57" rel="stylesheet" type="text/css">
- <link href="/css/ipad.css?1.0.5" rel="stylesheet" media="only screen and (max-device-width: 1024px)" type="text/css">
- <script type="text/javascript" src="/js/jquery-1.5.2.js"></script>
- <script type="text/javascript" src="/js/Launcher.js?1.0.0"></script>
- </head>
- <body>
- <div id="header">
- <div id="commsErrorPanel" style="display: none;"></div>
- <div id="navigation">
- <ul>
- <li id="remoteControl">Remote</li>
- <li id="movieLibrary">Movies</li>
- <li id="tvshowLibrary">TV Shows</li>
- <li id="musicLibrary">Music</li>
- <!-- <li id="pictureLibrary">Pictures</li> TODO: needs pagination -->
- <!-- <li id="settingsPanel">Settings</li> -->
- </ul>
- </div>
- <img src="/images/ajax-loader.gif" alt="Loading please wait" id="spinner" style="display: none">
- </div>
- <div id="body">
- <div id="topScrollFade" style="display: none;"></div>
- <div id="content"></div>
- <div id="overlay" style="display: none;"></div>
- </div>
- <div id="footerPopover">
- <div id="nowPlayingPanel" style="display: none;">
- <div id="nowPlayingContent">
- <div id="audioDescription">
- <div id="audioCoverArt"></div>
- <div id="audioTrackWrap">
- <div id="audioArtistTitle"></div>
- <div id="audioAlbumTitle"></div>
- </div>
- <div id="audioTrackTitle"></div>
- <div id="audioDuration"></div>
- </div>
- <div id="videoDescription">
- <div id="videoCoverArt"></div>
- <div id="videoTrackWrap">
- <div id="videoShowTitle"></div>
- </div>
- <div id="videoTitle"></div>
- <div id="videoDuration"></div>
- </div>
- </div>
- <div id="playbackControls">
- <span id="pbPrev" title="Previous"></span>
- <span id="pbPause" title="Pause"></span>
- <span id="pbPlay" title="Play"></span>
- <span id="pbStop" title="Stop"></span>
- <span id="pbNext" title="Next"></span>
- <div id="progressBar">
- <div class="elapsedTime" style="width: 0%"></div>
- <span class="progressIndicator"></span>
- </div>
- </div>
- <span id="nextText">Next:</span>
- <div id="nextTrack" style="display: none;"></div>
- <div id="nowPlayingPlaylist" style="display: none;"></div>
- </div>
- </div>
- <script type="text/javascript">
- var mediaLibrary = new MediaLibrary();
- var nowPlayingManager = new NowPlayingManager();
- applyDeviceFixes();
- </script>
- </body>
+ <head>
+ <title>XBMC</title>
+ <meta http-equiv="Content-Language" content="EN" />
+ <meta http-equiv="Content-Type" content="UTF-8" />
+ <!-- <link rel="search" href="/provider.xml" type="application/opensearchdescription+xml" title="XBMC Library" /> -->
+ <link rel="icon" href="/favicon.ico" type="image/x-icon">
+ <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
+ <!-- <link href="/images/logo.png" rel="image_src" /> -->
+ <meta name="robots" content="NOINDEX, NOFOLLOW">
+ <link href="/css/core.css?1.3.57" rel="stylesheet" type="text/css">
+ <link href="/css/ipad.css?1.0.5" rel="stylesheet" media="only screen and (max-device-width: 1024px)" type="text/css">
+ <script type="text/javascript" src="/js/jquery-1.5.2.js"></script>
+ <script type="text/javascript" src="/js/Launcher.js?1.0.0"></script>
+ </head>
+ <body>
+ <div id="header">
+ <div id="commsErrorPanel" style="display: none;"></div>
+ <div id="navigation">
+ <ul>
+ <li id="remoteControl">Remote</li>
+ <li id="movieLibrary">Movies</li>
+ <li id="tvshowLibrary">TV Shows</li>
+ <li id="musicLibrary">Music</li>
+ <!-- <li id="pictureLibrary">Pictures</li> TODO: needs pagination -->
+ <!-- <li id="settingsPanel">Settings</li> -->
+ </ul>
+ </div>
+ <img src="/images/ajax-loader.gif" alt="Loading please wait" id="spinner" style="display: none">
+ </div>
+ <div id="body">
+ <div id="topScrollFade" style="display: none;"></div>
+ <div id="content"></div>
+ <div id="overlay" style="display: none;"></div>
+ </div>
+ <div id="footerPopover">
+ <div id="nowPlayingPanel" style="display: none;">
+ <div id="nowPlayingContent">
+ <div id="audioDescription">
+ <div id="audioCoverArt"></div>
+ <div id="audioTrackWrap">
+ <div id="audioArtistTitle"></div>
+ <div id="audioAlbumTitle"></div>
+ </div>
+ <div id="audioTrackTitle"></div>
+ <div id="audioDuration"></div>
+ </div>
+ <div id="videoDescription">
+ <div id="videoCoverArt"></div>
+ <div id="videoTrackWrap">
+ <div id="videoShowTitle"></div>
+ </div>
+ <div id="videoTitle"></div>
+ <div id="videoDuration"></div>
+ </div>
+ </div>
+ <div id="playbackControls">
+ <span id="pbPrev" title="Previous"></span>
+ <span id="pbPause" title="Pause"></span>
+ <span id="pbPlay" title="Play"></span>
+ <span id="pbStop" title="Stop"></span>
+ <span id="pbNext" title="Next"></span>
+ <div id="progressBar">
+ <div class="elapsedTime" style="width: 0%"></div>
+ <span class="progressIndicator"></span>
+ </div>
+ </div>
+ <span id="nextText">Next:</span>
+ <div id="nextTrack" style="display: none;"></div>
+ <div id="nowPlayingPlaylist" style="display: none;"></div>
+ </div>
+ </div>
+ <script type="text/javascript">
+ var mediaLibrary = new MediaLibrary();
+ var nowPlayingManager = new NowPlayingManager();
+ applyDeviceFixes();
+ </script>
+ </body>
</html>
diff --git a/addons/webinterface.default/js/Core.js b/addons/webinterface.default/js/Core.js
index 5142752e2e..a01e3ba149 100644
--- a/addons/webinterface.default/js/Core.js
+++ b/addons/webinterface.default/js/Core.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2010 Team XBMC
+ * Copyright (C) 2005-2011 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
@@ -28,96 +28,96 @@ var DEFAULT_VIDEO_COVER = 'images/DefaultVideo.png';
/* Prototypes */
String.prototype.startsWith = function(prefix) {
- return this.indexOf(prefix) === 0;
+ return this.indexOf(prefix) === 0;
}
String.prototype.endsWith = function(suffix) {
- return this.match(suffix + "$") == suffix;
+ return this.match(suffix + "$") == suffix;
}
function durationToString(duration) {
- if (!duration) {
- return '00:00';
- }
- minutes = Math.floor(duration / 60);
- hours = Math.floor(minutes / 60);
- minutes = minutes % 60;
- seconds = duration % 60;
- var result = '';
- if (hours) {
- result += (hours < 10 ? '0' + hours : hours) + ':';
- }
- result += (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds);
- return result;
+ if (!duration) {
+ return '00:00';
+ }
+ minutes = Math.floor(duration / 60);
+ hours = Math.floor(minutes / 60);
+ minutes = minutes % 60;
+ seconds = duration % 60;
+ var result = '';
+ if (hours) {
+ result += (hours < 10 ? '0' + hours : hours) + ':';
+ }
+ result += (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds);
+ return result;
}
function timeToString(duration, showMilliseconds) {
- if (!duration) {
- return '00:00';
- }
- milliseconds = duration.milliseconds
- var result = '';
- if (duration.hours) {
- result += (duration.hours < 10 ? '0' + duration.hours : duration.hours) + ':';
- }
- result += (duration.minutes < 10 ? '0' + duration.minutes : duration.minutes) + ':' + (duration.seconds < 10 ? '0' + duration.seconds : duration.seconds);
- if (showMilliseconds) {
- result += '.';
- if (duration.milliseconds < 1000) {
- result += '.';
- if (duration.milliseconds < 100) {
- result += '0';
- if (duration.milliseconds < 10) {
- result += '0';
- }
- }
- }
- result += duration.milliseconds;
- }
- return result;
+ if (!duration) {
+ return '00:00';
+ }
+ milliseconds = duration.milliseconds
+ var result = '';
+ if (duration.hours) {
+ result += (duration.hours < 10 ? '0' + duration.hours : duration.hours) + ':';
+ }
+ result += (duration.minutes < 10 ? '0' + duration.minutes : duration.minutes) + ':' + (duration.seconds < 10 ? '0' + duration.seconds : duration.seconds);
+ if (showMilliseconds) {
+ result += '.';
+ if (duration.milliseconds < 1000) {
+ result += '.';
+ if (duration.milliseconds < 100) {
+ result += '0';
+ if (duration.milliseconds < 10) {
+ result += '0';
+ }
+ }
+ }
+ result += duration.milliseconds;
+ }
+ return result;
}
function timeToDuration(time) {
- return time.hours * 3600 + time.minutes * 60 + time.seconds;
+ return time.hours * 3600 + time.minutes * 60 + time.seconds;
}
function applyDeviceFixes() {
- document.addEventListener('touchmove', function(e){ e.preventDefault(); });
+ document.addEventListener('touchmove', function(e){ e.preventDefault(); });
}
var commsErrorTimeout;
function displayCommunicationError(m) {
- clearTimeout(commsErrorTimeout);
- var message = m || 'Connection to server lost';
- $('#commsErrorPanel').html(message).show();
- commsErrorTimeout = setTimeout('hideCommunicationError()', 5000);
+ clearTimeout(commsErrorTimeout);
+ var message = m || 'Connection to server lost';
+ $('#commsErrorPanel').html(message).show();
+ commsErrorTimeout = setTimeout('hideCommunicationError()', 5000);
}
function hideCommunicationError() {
- $('#commsErrorPanel').hide();
+ $('#commsErrorPanel').hide();
}
function setCookie(name,value,days) {
- if (days) {
- var date = new Date();
- date.setTime(date.getTime()+(days*24*60*60*1000));
- var expires = "; expires="+date.toGMTString();
- }
- else var expires = "";
- document.cookie = name+"="+value+expires+"; path=/";
+ if (days) {
+ var date = new Date();
+ date.setTime(date.getTime()+(days*24*60*60*1000));
+ var expires = "; expires="+date.toGMTString();
+ }
+ else var expires = "";
+ document.cookie = name+"="+value+expires+"; path=/";
}
function getCookie(name) {
- var nameEQ = name + "=";
- var ca = document.cookie.split(';');
- for(var i=0;i < ca.length;i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') c = c.substring(1,c.length);
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
- }
- return null;
+ var nameEQ = name + "=";
+ var ca = document.cookie.split(';');
+ for(var i=0;i < ca.length;i++) {
+ var c = ca[i];
+ while (c.charAt(0)==' ') c = c.substring(1,c.length);
+ if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
+ }
+ return null;
}
function deleteCookie(name) {
- setCookie(name,"",-1);
+ setCookie(name,"",-1);
} \ No newline at end of file
diff --git a/addons/webinterface.default/js/Launcher.js b/addons/webinterface.default/js/Launcher.js
index 39445333bd..4f23fcf3ec 100644
--- a/addons/webinterface.default/js/Launcher.js
+++ b/addons/webinterface.default/js/Launcher.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2010 Team XBMC
+ * Copyright (C) 2005-2011 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
@@ -22,7 +22,7 @@
/* This launcher is based on the scriptaculous.js launch script */
// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-//
+//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
@@ -30,7 +30,7 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
@@ -47,36 +47,36 @@
var DEBUG_MODE = true; /* Set to false to enable cached javascript */
var Launcher = {
- VERSION: '1.0.0',
- REQUIRED_JQUERY: '1.5.2',
- load: function(libraryName) {
- document.write('<script type="text/javascript" src="' + libraryName + '?' + (DEBUG_MODE ? this.randomValue() : this.VERSION) + '"><\/script>');
- },
- init: function() {
- function convertVersionString(versionString) {
- var v = versionString.replace(/_.*|\./g, '');
- v = parseInt(v + (v.length == 4 ? '' : '0'));
- return versionString.indexOf('_') > -1 ? v-1 : v;
- }
+ VERSION: '1.0.0',
+ REQUIRED_JQUERY: '1.5.2',
+ load: function(libraryName) {
+ document.write('<script type="text/javascript" src="' + libraryName + '?' + (DEBUG_MODE ? this.randomValue() : this.VERSION) + '"><\/script>');
+ },
+ init: function() {
+ function convertVersionString(versionString) {
+ var v = versionString.replace(/_.*|\./g, '');
+ v = parseInt(v + (v.length == 4 ? '' : '0'));
+ return versionString.indexOf('_') > -1 ? v-1 : v;
+ }
- if(!jQuery || (convertVersionString(jQuery.fn.jquery) < convertVersionString(Launcher.REQUIRED_JQUERY)))
- throw("XBMC Web Interface requires the jQuery JavaScript framework >= " + Launcher.REQUIRED_JQUERY);
+ if(!jQuery || (convertVersionString(jQuery.fn.jquery) < convertVersionString(Launcher.REQUIRED_JQUERY)))
+ throw("XBMC Web Interface requires the jQuery JavaScript framework >= " + Launcher.REQUIRED_JQUERY);
- var js = /Launcher\.js(\?.*)?$/;
- $('html').find('script[src]').each(
- function(i, s) {
- if (s.src.match(js)) {
- var path = s.src.replace(js, ''),
- includes = s.src.match(/\?.*load=([a-z,]*)/);
- $.each((includes ? includes[1] : 'jquery.lazyload,iscroll-min,Core,MediaLibrary,NowPlayingManager').split(','), function(i, include) {
- Launcher.load(path + include + '.js')
- });
- }
- });
- },
- randomValue: function() {
- return Math.random();
- }
+ var js = /Launcher\.js(\?.*)?$/;
+ $('html').find('script[src]').each(
+ function(i, s) {
+ if (s.src.match(js)) {
+ var path = s.src.replace(js, ''),
+ includes = s.src.match(/\?.*load=([a-z,]*)/);
+ $.each((includes ? includes[1] : 'jquery.lazyload,iscroll-min,Core,MediaLibrary,NowPlayingManager').split(','), function(i, include) {
+ Launcher.load(path + include + '.js')
+ });
+ }
+ });
+ },
+ randomValue: function() {
+ return Math.random();
+ }
}
Launcher.init(); \ No newline at end of file
diff --git a/addons/webinterface.default/js/MediaLibrary.js b/addons/webinterface.default/js/MediaLibrary.js
index 4886efc44f..18a48e624b 100755
--- a/addons/webinterface.default/js/MediaLibrary.js
+++ b/addons/webinterface.default/js/MediaLibrary.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2010 Team XBMC
+ * Copyright (C) 2005-2011 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
@@ -20,861 +20,844 @@
*/
var MediaLibrary = function() {
- this.init();
- return true;
- }
+ this.init();
+ return true;
+}
MediaLibrary.prototype = {
- playlists: { },
-
- init: function() {
- this.bindControls();
- this.getPlaylists();
- },
-
- bindControls: function() {
- $('#musicLibrary').click(jQuery.proxy(this.musicLibraryOpen, this));
- $('#movieLibrary').click(jQuery.proxy(this.movieLibraryOpen, this));
- $('#tvshowLibrary').click(jQuery.proxy(this.tvshowLibraryOpen, this));
- $('#pictureLibrary').click(jQuery.proxy(this.pictureLibraryOpen, this));
- $('#remoteControl').click(jQuery.proxy(this.remoteControlOpen, this));
- $('#overlay').click(jQuery.proxy(this.hideOverlay, this));
- $(window).resize(jQuery.proxy(this.updatePlayButtonLocation, this));
- },
- resetPage: function() {
- $('#musicLibrary').removeClass('selected');
- $('#movieLibrary').removeClass('selected');
- $('#tvshowLibrary').removeClass('selected');
- $('#remoteControl').removeClass('selected');
- $('#pictureLibrary').removeClass('selected');
- this.hideOverlay();
- },
- replaceAll: function(haystack, find, replace) {
- var parts = haystack.split(find);
- var result = "";
- var first = true;
- for (index in parts)
- {
- if (!first)
- result += replace;
- else
- first = false;
-
- result += parts[index];
- }
-
- return result;
- },
+ playlists: { },
- getPlaylists: function() {
- jQuery.ajax({
- type: 'POST',
- url: JSON_RPC + '?GetPlaylists',
- data: '{"jsonrpc": "2.0", "method": "Playlist.GetPlaylists", "id": 1}',
- timeout: 3000,
- success: jQuery.proxy(function(data) {
- if (data && data.result && data.result.length > 0) {
- $.each($(data.result), jQuery.proxy(function(i, item) {
- this.playlists[item.type] = item.playlistid;
- }, this));
- }
- }, this),
- error: jQuery.proxy(function(data, error) {
- displayCommunicationError();
- setTimeout(jQuery.proxy(this.updateState, this), 2000);
- }, this),
- dataType: 'json'});
- },
- remoteControlOpen: function(event) {
- this.resetPage();
- $('#remoteControl').addClass('selected');
- $('.contentContainer').hide();
- var libraryContainer = $('#remoteContainer');
- if (!libraryContainer || libraryContainer.length == 0) {
- $('#spinner').show();
- libraryContainer = $('<div>');
- libraryContainer.attr('id', 'remoteContainer')
- .addClass('contentContainer');
- $('#content').append(libraryContainer);
- var keys=[
- {name:'up',width:'40px',height:'30px',top:'28px',left:'58px'}
- ,{name:'down',width:'40px',height:'30px',top:'122px',left:'58px'}
- ,{name:'left',width:'40px',height:'30px',top:'74px',left:'15px'}
- ,{name:'right',width:'40px',height:'30px',top:'74px',left:'104px'}
- ,{name:'ok',width:'40px',height:'30px',top:'74px',left:'58px'}
- ,{name:'back',width:'40px',height:'30px',top:'13px',left:'161px'}
- ,{name:'home',width:'40px',height:'30px',top:'154px',left:'8px'}
- ,{name:'mute',width:'40px',height:'30px',top:'107px',left:'391px'}
- ,{name:'power',width:'30px',height:'30px',top:'-3px',left:'13px'}
- ,{name:'volumeup',width:'30px',height:'30px',top:'49px',left:'422px'}
- ,{name:'volumedown',width:'30px',height:'30px',top:'49px',left:'367px'}
- ,{name:'playpause',width:'32px',height:'23px',top:'62px',left:'260px'}
- ,{name:'stop',width:'32px',height:'23px',top:'62px',left:'211px'}
- ,{name:'next',width:'38px',height:'25px',top:'102px',left:'304px'}
- ,{name:'previous',width:'38px',height:'25px',top:'101px',left:'160px'}
- ,{name:'forward',width:'32px',height:'23px',top:'102px',left:'259px'}
- ,{name:'rewind',width:'32px',height:'23px',top:'101px',left:'211px'}
- ,{name:'cleanlib_a',width:'46px',height:'26px',top:'47px',left:'553px'}
- ,{name:'updatelib_a',width:'46px',height:'26px',top:'47px',left:'492px'}
- ,{name:'cleanlib_v',width:'46px',height:'26px',top:'111px',left:'553px'}
- ,{name:'updatelib_v',width:'46px',height:'26px',top:'111px',left:'492px'}
- ];
- for (var akey in keys) {
- var aremotekey=$('<p>').attr('id',keys[akey]['name']);
- aremotekey.addClass('remote_key')
- .css('height',keys[akey]['height'])
- .css('width',keys[akey]['width'])
- .css('top',keys[akey]['top'])
- .css('left',keys[akey]['left'])
- //.css('border','1px solid black')
- .bind('click',{key: keys[akey]['name']},jQuery.proxy(this.pressRemoteKey,this));
- libraryContainer.append(aremotekey);
- }
-
-
- } else {
- libraryContainer.show();
- libraryContainer.trigger('scroll');
- }
+ init: function() {
+ this.bindControls();
+ this.getPlaylists();
+ },
+
+ bindControls: function() {
+ $('#musicLibrary').click(jQuery.proxy(this.musicLibraryOpen, this));
+ $('#movieLibrary').click(jQuery.proxy(this.movieLibraryOpen, this));
+ $('#tvshowLibrary').click(jQuery.proxy(this.tvshowLibraryOpen, this));
+ $('#pictureLibrary').click(jQuery.proxy(this.pictureLibraryOpen, this));
+ $('#remoteControl').click(jQuery.proxy(this.remoteControlOpen, this));
+ $('#overlay').click(jQuery.proxy(this.hideOverlay, this));
+ $(window).resize(jQuery.proxy(this.updatePlayButtonLocation, this));
+ },
+ resetPage: function() {
+ $('#musicLibrary').removeClass('selected');
+ $('#movieLibrary').removeClass('selected');
+ $('#tvshowLibrary').removeClass('selected');
+ $('#remoteControl').removeClass('selected');
+ $('#pictureLibrary').removeClass('selected');
+ this.hideOverlay();
+ },
+ replaceAll: function(haystack, find, replace) {
+ var parts = haystack.split(find);
+ var result = "";
+ var first = true;
+ for (index in parts)
+ {
+ if (!first)
+ result += replace;
+ else
+ first = false;
+
+ result += parts[index];
+ }
+
+ return result;
+ },
+
+ getPlaylists: function() {
+ jQuery.ajax({
+ type: 'POST',
+ url: JSON_RPC + '?GetPlaylists',
+ data: '{"jsonrpc": "2.0", "method": "Playlist.GetPlaylists", "id": 1}',
+ timeout: 3000,
+ success: jQuery.proxy(function(data) {
+ if (data && data.result && data.result.length > 0) {
+ $.each($(data.result), jQuery.proxy(function(i, item) {
+ this.playlists[item.type] = item.playlistid;
+ }, this));
+ }
+ }, this),
+ error: jQuery.proxy(function(data, error) {
+ displayCommunicationError();
+ setTimeout(jQuery.proxy(this.updateState, this), 2000);
+ }, this),
+ dataType: 'json'});
+ },
+ remoteControlOpen: function(event) {
+ this.resetPage();
+ $('#remoteControl').addClass('selected');
+ $('.contentContainer').hide();
+ var libraryContainer = $('#remoteContainer');
+ if (!libraryContainer || libraryContainer.length == 0) {
+ $('#spinner').show();
+ libraryContainer = $('<div>');
+ libraryContainer.attr('id', 'remoteContainer')
+ .addClass('contentContainer');
+ $('#content').append(libraryContainer);
+ var keys=[
+ {name:'up',width:'40px',height:'30px',top:'28px',left:'58px'}
+ ,{name:'down',width:'40px',height:'30px',top:'122px',left:'58px'}
+ ,{name:'left',width:'40px',height:'30px',top:'74px',left:'15px'}
+ ,{name:'right',width:'40px',height:'30px',top:'74px',left:'104px'}
+ ,{name:'ok',width:'40px',height:'30px',top:'74px',left:'58px'}
+ ,{name:'back',width:'40px',height:'30px',top:'13px',left:'161px'}
+ ,{name:'home',width:'40px',height:'30px',top:'154px',left:'8px'}
+ ,{name:'mute',width:'40px',height:'30px',top:'107px',left:'391px'}
+ ,{name:'power',width:'30px',height:'30px',top:'-3px',left:'13px'}
+ ,{name:'volumeup',width:'30px',height:'30px',top:'49px',left:'422px'}
+ ,{name:'volumedown',width:'30px',height:'30px',top:'49px',left:'367px'}
+ ,{name:'playpause',width:'32px',height:'23px',top:'62px',left:'260px'}
+ ,{name:'stop',width:'32px',height:'23px',top:'62px',left:'211px'}
+ ,{name:'next',width:'38px',height:'25px',top:'102px',left:'304px'}
+ ,{name:'previous',width:'38px',height:'25px',top:'101px',left:'160px'}
+ ,{name:'forward',width:'32px',height:'23px',top:'102px',left:'259px'}
+ ,{name:'rewind',width:'32px',height:'23px',top:'101px',left:'211px'}
+ ,{name:'cleanlib_a',width:'46px',height:'26px',top:'47px',left:'553px'}
+ ,{name:'updatelib_a',width:'46px',height:'26px',top:'47px',left:'492px'}
+ ,{name:'cleanlib_v',width:'46px',height:'26px',top:'111px',left:'553px'}
+ ,{name:'updatelib_v',width:'46px',height:'26px',top:'111px',left:'492px'}
+ ];
+ for (var akey in keys) {
+ var aremotekey=$('<p>').attr('id',keys[akey]['name']);
+ aremotekey.addClass('remote_key')
+ .css('height',keys[akey]['height'])
+ .css('width',keys[akey]['width'])
+ .css('top',keys[akey]['top'])
+ .css('left',keys[akey]['left'])
+ //.css('border','1px solid black')
+ .bind('click',{key: keys[akey]['name']},jQuery.proxy(this.pressRemoteKey,this));
+ libraryContainer.append(aremotekey);
+ }
+
+
+ } else {
+ libraryContainer.show();
+ libraryContainer.trigger('scroll');
+ }
+
+ $('#spinner').hide();
+ },
- $('#spinner').hide();
- },
+ pressRemoteKey: function(event) {
+ var keyPressed=event.data.key;
+ $('#spinner').show();
+ var player = -1;
+ // TODO: Get active player
+ if($('#videoDescription').is(':visible'))
+ player = this.playlists["video"];
+ else if($('#audioDescription').is(':visible'))
+ player = this.playlists["audio"];
- pressRemoteKey: function(event) {
- var keyPressed=event.data.key;
- $('#spinner').show();
- var player = -1;
- // TODO: Get active player
- if($('#videoDescription').is(':visible'))
- player = this.playlists["video"];
- else if($('#audioDescription').is(':visible'))
- player = this.playlists["audio"];
-
- //common part
- switch(keyPressed) {
- case 'cleanlib_a':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "AudioLibrary.Clean", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'updatelib_a':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "AudioLibrary.Scan", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'cleanlib_v':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'updatelib_v':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'back':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Back", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'home':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Home", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'mute':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Application.SetMute", "params": { "mute": "toggle" }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'power':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "System.Shutdown", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'volumeup':
+ //common part
+ switch(keyPressed) {
+ case 'cleanlib_a':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "AudioLibrary.Clean", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'updatelib_a':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "AudioLibrary.Scan", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'cleanlib_v':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'updatelib_v':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'back':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Back", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'home':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Home", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'mute':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Application.SetMute", "params": { "mute": "toggle" }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'power':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "System.Shutdown", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'volumeup':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": { "properties": [ "volume" ] }, "id": 1}', function(data){
+ var volume = data.result.volume + 1;
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Application.SetVolume", "params": { "volume": '+volume+' }, "id": 1}', function(data){
+ $('#spinner').hide();
+ }, 'json');
+ }, 'json');
+ return;
+ case 'volumedown':
jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": { "properties": [ "volume" ] }, "id": 1}', function(data){
- var volume = data.result.volume + 1;
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Application.SetVolume", "params": { "volume": '+volume+' }, "id": 1}', function(data){
-
- $('#spinner').hide();
- }, 'json');
- }, 'json');
- return;
- case 'volumedown':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": { "properties": [ "volume" ] }, "id": 1}', function(data){
- var volume = data.result.volume - 1;
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Application.SetVolume", "params": { "volume": '+volume+' }, "id": 1}', function(data){
-
- $('#spinner').hide();
- }, 'json');
- }, 'json');
- return;
- }
- //menus or other sections
- if (player == -1)
- {
- switch(keyPressed) {
- case 'up':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Up", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'down':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Down", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'left':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Left", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'right':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Right", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'ok':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Select", "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- }
- }
-
- if (player >= 0)
- {
- switch(keyPressed) {
- case 'up':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.Seek", "params": { "playerid": ' + player + ', "value": "bigforward" }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'down':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.Seek", "params": { "playerid": ' + player + ', "value": "bigbackward" }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'left':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.Seek", "params": { "playerid": ' + player + ', "value": "smallbackward" }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'right':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.Seek", "params": { "playerid": ' + player + ', "value": "smallforward" }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'playpause':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": ' + player + ' }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'stop':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.Stop", "params": { "playerid": ' + player + ' }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'next':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.GoNext", "params": { "playerid": ' + player + ' }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'previous':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.GoPrevious", "params": { "playerid": ' + player + ' }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'forward':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.SetSpeed", "params": { "playerid": ' + player + ', "speed": "increment" }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
- case 'rewind':
- jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.SetSpeed", "params": { "playerid": ' + player + ', "speed": "decrement" }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
- return;
+ var volume = data.result.volume - 1;
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Application.SetVolume", "params": { "volume": '+volume+' }, "id": 1}', function(data){
+ $('#spinner').hide();
+ }, 'json');
+ }, 'json');
+ return;
+ }
+
+ switch(keyPressed) {
+ case 'up':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Up", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'down':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Down", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'left':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Left", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'right':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Right", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'ok':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Input.Select", "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ }
+
+ if (player >= 0)
+ {
+ switch(keyPressed) {
+ case 'playpause':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": ' + player + ' }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'stop':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.Stop", "params": { "playerid": ' + player + ' }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'next':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.GoNext", "params": { "playerid": ' + player + ' }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'previous':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.GoPrevious", "params": { "playerid": ' + player + ' }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'forward':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.SetSpeed", "params": { "playerid": ' + player + ', "speed": "increment" }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ case 'rewind':
+ jQuery.post(JSON_RPC + '?SendRemoteKey', '{"jsonrpc": "2.0", "method": "Player.SetSpeed", "params": { "playerid": ' + player + ', "speed": "decrement" }, "id": 1}', function(data){$('#spinner').hide();}, 'json');
+ return;
+ }
+ }
+ },
+
+ musicLibraryOpen: function(event) {
+ this.resetPage();
+ $('#musicLibrary').addClass('selected');
+ $('.contentContainer').hide();
+ var libraryContainer = $('#libraryContainer');
+ if (!libraryContainer || libraryContainer.length == 0) {
+ $('#spinner').show();
+ libraryContainer = $('<div>');
+ libraryContainer.attr('id', 'libraryContainer')
+ .addClass('contentContainer');
+ $('#content').append(libraryContainer);
+ jQuery.post(JSON_RPC + '?GetAlbums', '{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "limits": { "start": 0 }, "properties": ["description", "theme", "mood", "style", "type", "albumlabel", "artist", "genre", "rating", "title", "year", "thumbnail"], "sort": { "method": "artist" } }, "id": 1}', jQuery.proxy(function(data) {
+ if (data && data.result && data.result.albums) {
+ this.albumList = data.result.albums;
+ $.each($(this.albumList), jQuery.proxy(function(i, item) {
+ var floatableAlbum = this.generateThumb('album', item.thumbnail, item.title, item.artist);
+ floatableAlbum.bind('click', { album: item }, jQuery.proxy(this.displayAlbumDetails, this));
+ libraryContainer.append(floatableAlbum);
+ }, this));
+ libraryContainer.append($('<div>').addClass('footerPadding'));
+ $('#spinner').hide();
+ libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
+ libraryContainer.trigger('scroll');
+ myScroll = new iScroll('libraryContainer');
+ } else {
+ libraryContainer.html('');
+ }
+ }, this), 'json');
+ } else {
+ libraryContainer.show();
+ libraryContainer.trigger('scroll');
+ }
+ },
+ getThumbnailPath: function(thumbnail) {
+ return thumbnail ? ('/vfs/' + thumbnail) : DEFAULT_ALBUM_COVER;
+ },
+ generateThumb: function(type, thumbnail, title, artist) {
+ var floatableAlbum = $('<div>');
+ var path = this.getThumbnailPath(thumbnail);
+ title = title || '';
+ artist = artist ||'';
+ if (title.length > 18 && !(title.length <= 21)) {
+ title = title.substring(0, 18) + '...';
+ }
+ if (artist.length > 20 && !(artist.length <= 22)) {
+ artist = artist.substring(0, 20) + '...';
+ }
+ var className = '';
+ var code = '';
+ switch(type) {
+ case 'album':
+ className = 'floatableAlbum';
+ code = '<p class="album" title="' + title + '">' + title + '</p><p class="artist" title="' + artist + '">' + artist + '</p>';
+ break;
+ case 'movie':
+ className = 'floatableMovieCover';
+ code = '<p class="album" title="' + title + '">' + title + '</p>';
+ break;
+ case 'tvshow':
+ className = 'floatableTVShowCover';
+ break;
+ case 'tvshowseason':
+ className = 'floatableTVShowCoverSeason';
+ break;
+ case 'image':
+ case 'directory':
+ className = 'floatableAlbum';
+ code = '<p class="album" title="' + title + '">' + title + '</p>';
+ break;
+ }
+ return floatableAlbum.addClass(className).html('<div class="imgWrapper"><div class="inner"><img src="' + path + '" alt="' + title + '" /></div></div>' + code);
+ },
+ showAlbumSelectorBlock: function(album) {
+ if (album) {
+ //Find album in stored array
+ var prevAlbum = null,
+ nextAlbum = null;
+ $.each($(this.albumList), jQuery.proxy(function(i, item) {
+ if (item.albumid == album.albumid) {
+ if (this.albumList.length > 1) {
+ prevAlbum = this.albumList[i <= 0 ? this.albumList.length-1 : i-1];
+ nextAlbum = this.albumList[i >= this.albumList.length ? 0 : i+1];
+ }
+ return false; /* .each break */
}
+ }, this));
+ var albumSelectorBlock = $('#albumSelector');
+ if (!albumSelectorBlock || albumSelectorBlock.length == 0) {
+ albumSelectorBlock = $('<div>');
+ albumSelectorBlock.attr('id', 'albumSelector')
+ .html('<table><tr><td class="allAlbums">All Albums</td><td class="activeAlbumTitle"></td><td class="prevAlbum">&nbsp;</td><td class="nextAlbum">&nbsp;</td></tr></table>');
+ $('#content').prepend(albumSelectorBlock);
+ $('#albumSelector .allAlbums').bind('click', jQuery.proxy(this.hideAlbumDetails, this));
}
- },
+ $('#albumSelector .prevAlbum').unbind();
+ $('#albumSelector .nextAlbum').unbind();
+ if (prevAlbum) {
+ $('#albumSelector .prevAlbum').bind('click', {album: prevAlbum}, jQuery.proxy(this.displayAlbumDetails, this));
+ }
+ if (nextAlbum) {
+ $('#albumSelector .nextAlbum').bind('click', {album: nextAlbum}, jQuery.proxy(this.displayAlbumDetails, this));
+ }
+ $('#albumSelector .activeAlbumTitle').html(album.title||'Unknown Album');
+ albumSelectorBlock.show();
+ }
+ },
+ hideAlbumDetails: function() {
+ $('.contentContainer').hide();
+ this.musicLibraryOpen();
+ },
+ displayAlbumDetails: function(event) {
+ this.showAlbumSelectorBlock(event.data.album);
+ var albumDetailsContainer = $('#albumDetails' + event.data.album.albumid);
+ $('#topScrollFade').hide();
+ if (!albumDetailsContainer || albumDetailsContainer.length == 0) {
+ $('#spinner').show();
+ jQuery.post(JSON_RPC + '?GetSongs', '{"jsonrpc": "2.0", "method": "AudioLibrary.GetSongs", "params": { "properties": ["title", "artist", "genre", "track", "duration", "year", "rating", "playcount"], "albumid" : ' + event.data.album.albumid + ' }, "id": 1}', jQuery.proxy(function(data) {
+ albumDetailsContainer = $('<div>');
+ albumDetailsContainer.attr('id', 'albumDetails' + event.data.album.albumid)
+ .addClass('contentContainer')
+ .addClass('albumContainer')
+ .html('<table class="albumView"><thead><tr class="headerRow"><th>Artwork</th><th>&nbsp;</th><th>Name</th><th class="time">Time</th><th>Artist</th><th>Genre</th></tr></thead><tbody class="resultSet"></tbody></table>');
+ $('.contentContainer').hide();
+ $('#content').append(albumDetailsContainer);
+ var albumThumbnail = event.data.album.thumbnail;
+ var albumTitle = event.data.album.title||'Unknown Album';
+ var albumArtist = event.data.album.artist||'Unknown Artist';
+ var trackCount = data.result.limits.total;
+ $.each($(data.result.songs), jQuery.proxy(function(i, item) {
+ if (i == 0) {
+ var trackRow = $('<tr>').addClass('trackRow').addClass('tr' + i % 2);
+ trackRow.append($('<td>').attr('rowspan', ++trackCount + 1).addClass('albumThumb'));
+ for (var a = 0; a < 5; a++) {
+ trackRow.append($('<td>').html('&nbsp').attr('style', 'display: none'));
+ }
+ $('#albumDetails' + event.data.album.albumid + ' .resultSet').append(trackRow);
+ }
+ var trackRow = $('<tr>').addClass('trackRow').addClass('tr' + i % 2).bind('click', { album: event.data.album, itmnbr: i }, jQuery.proxy(this.playTrack,this));
+ var trackNumberTD = $('<td>')
+ .html(item.track)
+
+ trackRow.append(trackNumberTD);
+ var trackTitleTD = $('<td>')
+ .html(item.title);
+
+ trackRow.append(trackTitleTD);
+ var trackDurationTD = $('<td>')
+ .addClass('time')
+ .html(durationToString(item.duration));
+
+ trackRow.append(trackDurationTD);
+ var trackArtistTD = $('<td>')
+ .html(item.artist);
+
+ trackRow.append(trackArtistTD);
+ var trackGenreTD = $('<td>')
+ .html(item.genre);
+
+ trackRow.append(trackGenreTD);
+ $('#albumDetails' + event.data.album.albumid + ' .resultSet').append(trackRow);
+ }, this));
+ if (trackCount > 0) {
+ var trackRow = $('<tr>').addClass('fillerTrackRow');
+ for (var i = 0; i < 5; i++) {
+ trackRow.append($('<td>').html('&nbsp'));
+ }
+ $('#albumDetails' + event.data.album.albumid + ' .resultSet').append(trackRow);
- musicLibraryOpen: function(event) {
- this.resetPage();
- $('#musicLibrary').addClass('selected');
- $('.contentContainer').hide();
- var libraryContainer = $('#libraryContainer');
- if (!libraryContainer || libraryContainer.length == 0) {
- $('#spinner').show();
- libraryContainer = $('<div>');
- libraryContainer.attr('id', 'libraryContainer')
- .addClass('contentContainer');
- $('#content').append(libraryContainer);
- jQuery.post(JSON_RPC + '?GetAlbums', '{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "limits": { "start": 0 }, "properties": ["description", "theme", "mood", "style", "type", "albumlabel", "artist", "genre", "rating", "title", "year", "thumbnail"], "sort": { "method": "artist" } }, "id": 1}', jQuery.proxy(function(data) {
- if (data && data.result && data.result.albums) {
- this.albumList = data.result.albums;
- $.each($(this.albumList), jQuery.proxy(function(i, item) {
- var floatableAlbum = this.generateThumb('album', item.thumbnail, item.title, item.artist);
- floatableAlbum.bind('click', { album: item }, jQuery.proxy(this.displayAlbumDetails, this));
- libraryContainer.append(floatableAlbum);
- }, this));
- libraryContainer.append($('<div>').addClass('footerPadding'));
- $('#spinner').hide();
- libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
- libraryContainer.trigger('scroll');
- myScroll = new iScroll('libraryContainer');
- } else {
- libraryContainer.html('');
- }
- }, this), 'json');
- } else {
- libraryContainer.show();
- libraryContainer.trigger('scroll');
- }
- },
- getThumbnailPath: function(thumbnail) {
- return thumbnail ? ('/vfs/' + thumbnail) : DEFAULT_ALBUM_COVER;
- },
- generateThumb: function(type, thumbnail, title, artist) {
- var floatableAlbum = $('<div>');
- var path = this.getThumbnailPath(thumbnail);
- title = title || '';
- artist = artist ||'';
- if (title.length > 18 && !(title.length <= 21)) {
- title = title.substring(0, 18) + '...';
- }
- if (artist.length > 20 && !(artist.length <= 22)) {
- artist = artist.substring(0, 20) + '...';
- }
- var className = '';
- var code = '';
- switch(type) {
- case 'album':
- className = 'floatableAlbum';
- code = '<p class="album" title="' + title + '">' + title + '</p><p class="artist" title="' + artist + '">' + artist + '</p>';
- break;
- case 'movie':
- className = 'floatableMovieCover';
- code = '<p class="album" title="' + title + '">' + title + '</p>';
- break;
- case 'tvshow':
- className = 'floatableTVShowCover';
- break;
- case 'tvshowseason':
- className = 'floatableTVShowCoverSeason';
- break;
- case 'image':
- case 'directory':
- className = 'floatableAlbum';
- code = '<p class="album" title="' + title + '">' + title + '</p>';
- break;
- }
- return floatableAlbum.addClass(className).html('<div class="imgWrapper"><div class="inner"><img src="' + path + '" alt="' + title + '" /></div></div>' + code);
- },
- showAlbumSelectorBlock: function(album) {
- if (album) {
- //Find album in stored array
- var prevAlbum = null,
- nextAlbum = null;
- $.each($(this.albumList), jQuery.proxy(function(i, item) {
- if (item.albumid == album.albumid) {
- if (this.albumList.length > 1) {
- prevAlbum = this.albumList[i <= 0 ? this.albumList.length-1 : i-1];
- nextAlbum = this.albumList[i >= this.albumList.length ? 0 : i+1];
- }
- return false; /* .each break */
- }
- }, this));
- var albumSelectorBlock = $('#albumSelector');
- if (!albumSelectorBlock || albumSelectorBlock.length == 0) {
- albumSelectorBlock = $('<div>');
- albumSelectorBlock.attr('id', 'albumSelector')
- .html('<table><tr><td class="allAlbums">All Albums</td><td class="activeAlbumTitle"></td><td class="prevAlbum">&nbsp;</td><td class="nextAlbum">&nbsp;</td></tr></table>');
- $('#content').prepend(albumSelectorBlock);
- $('#albumSelector .allAlbums').bind('click', jQuery.proxy(this.hideAlbumDetails, this));
- }
- $('#albumSelector .prevAlbum').unbind();
- $('#albumSelector .nextAlbum').unbind();
- if (prevAlbum) {
- $('#albumSelector .prevAlbum').bind('click', {album: prevAlbum}, jQuery.proxy(this.displayAlbumDetails, this));
- }
- if (nextAlbum) {
- $('#albumSelector .nextAlbum').bind('click', {album: nextAlbum}, jQuery.proxy(this.displayAlbumDetails, this));
- }
- $('#albumSelector .activeAlbumTitle').html(album.title||'Unknown Album');
- albumSelectorBlock.show();
- }
- },
- hideAlbumDetails: function() {
- $('.contentContainer').hide();
- this.musicLibraryOpen();
- },
- displayAlbumDetails: function(event) {
- this.showAlbumSelectorBlock(event.data.album);
- var albumDetailsContainer = $('#albumDetails' + event.data.album.albumid);
- $('#topScrollFade').hide();
- if (!albumDetailsContainer || albumDetailsContainer.length == 0) {
- $('#spinner').show();
- jQuery.post(JSON_RPC + '?GetSongs', '{"jsonrpc": "2.0", "method": "AudioLibrary.GetSongs", "params": { "properties": ["title", "artist", "genre", "track", "duration", "year", "rating", "playcount"], "albumid" : ' + event.data.album.albumid + ' }, "id": 1}', jQuery.proxy(function(data) {
- albumDetailsContainer = $('<div>');
- albumDetailsContainer.attr('id', 'albumDetails' + event.data.album.albumid)
- .addClass('contentContainer')
- .addClass('albumContainer')
- .html('<table class="albumView"><thead><tr class="headerRow"><th>Artwork</th><th>&nbsp;</th><th>Name</th><th class="time">Time</th><th>Artist</th><th>Genre</th></tr></thead><tbody class="resultSet"></tbody></table>');
- $('.contentContainer').hide();
- $('#content').append(albumDetailsContainer);
- var albumThumbnail = event.data.album.thumbnail;
- var albumTitle = event.data.album.title||'Unknown Album';
- var albumArtist = event.data.album.artist||'Unknown Artist';
- var trackCount = data.result.limits.total;
- $.each($(data.result.songs), jQuery.proxy(function(i, item) {
- if (i == 0) {
- var trackRow = $('<tr>').addClass('trackRow').addClass('tr' + i % 2);
- trackRow.append($('<td>').attr('rowspan', ++trackCount + 1).addClass('albumThumb'));
- for (var a = 0; a < 5; a++) {
- trackRow.append($('<td>').html('&nbsp').attr('style', 'display: none'));
- }
- $('#albumDetails' + event.data.album.albumid + ' .resultSet').append(trackRow);
- }
- var trackRow = $('<tr>').addClass('trackRow').addClass('tr' + i % 2).bind('click', { album: event.data.album, itmnbr: i }, jQuery.proxy(this.playTrack,this));
- var trackNumberTD = $('<td>')
- .html(item.track)
-
- trackRow.append(trackNumberTD);
- var trackTitleTD = $('<td>')
- .html(item.title);
-
- trackRow.append(trackTitleTD);
- var trackDurationTD = $('<td>')
- .addClass('time')
- .html(durationToString(item.duration));
-
- trackRow.append(trackDurationTD);
- var trackArtistTD = $('<td>')
- .html(item.artist);
-
- trackRow.append(trackArtistTD);
- var trackGenreTD = $('<td>')
- .html(item.genre);
-
- trackRow.append(trackGenreTD);
- $('#albumDetails' + event.data.album.albumid + ' .resultSet').append(trackRow);
- }, this));
- if (trackCount > 0) {
- var trackRow = $('<tr>').addClass('fillerTrackRow');
- for (var i = 0; i < 5; i++) {
- trackRow.append($('<td>').html('&nbsp'));
- }
- $('#albumDetails' + event.data.album.albumid + ' .resultSet').append(trackRow);
+ var trackRow2 = $('<tr>').addClass('fillerTrackRow2');
+ trackRow2.append($('<td>').addClass('albumBG').html('&nbsp'));
+ for (var i = 0; i < 5; i++) {
+ trackRow2.append($('<td>').html('&nbsp'));
+ }
+ $('#albumDetails' + event.data.album.albumid + ' .resultSet').append(trackRow2);
+ }
+ $('#albumDetails' + event.data.album.albumid + ' .albumThumb')
+ .append(this.generateThumb('album', albumThumbnail, albumTitle, albumArtist))
+ .append($('<div>').addClass('footerPadding'));
+ $('#spinner').hide();
+ myScroll = new iScroll('albumDetails' + event.data.album.albumid);
+ }, this), 'json');
+ } else {
+ $('.contentContainer').hide();
+ $('#albumDetails' + event.data.album.albumid).show();
+ }
+ },
+
+ togglePosterView: function(event){
+ var view=event.data.mode;
+ var wthumblist,hthumblist,hthumbdetails;
+ $("#toggleBanner").removeClass('activeMode');
+ $("#togglePoster").removeClass('activeMode');
+ $("#toggleLandscape").removeClass('activeMode');
+ switch(view) {
+ case 'poster':
+ setCookie('TVView','poster');
+ wthumblist='135px';
+ hthumblist='199px';
+ hthumbdetails='559px';
+ $("#togglePoster").addClass('activeMode');
+ break;
+ case 'landscape':
+ setCookie('TVView','landscape');
+ wthumblist='210px';
+ hthumblist='118px';
+ hthumbdetails='213px';
+ $("#toggleLandscape").addClass('activeMode');
+ break;
+ default: //set banner view as default
+ setCookie('TVView','banner');
+ wthumblist='379px';
+ hthumblist='70px';
+ hthumbdetails='70px';
+ $("#toggleBanner").addClass('activeMode');
+ break;
+ }
+ $(".floatableTVShowCover, .floatableTVShowCover div.imgWrapper, .floatableTVShowCover img, .floatableTVShowCover div.imgWrapper div.inner").css('width',wthumblist).css('height',hthumblist);
+ $(".floatableTVShowCoverSeason div.imgWrapper, .floatableTVShowCoverSeason div.imgWrapper div.inner,.floatableTVShowCoverSeason img, .floatableTVShowCoverSeason").css('height',hthumbdetails);
+ },
+
+ displayTVShowDetails: function(event) {
+ var tvshowDetailsContainer = $('#tvShowDetails' + event.data.tvshow.tvshowid);
+ $('#topScrollFade').hide();
+ toggle=this.toggle.detach();
+ if (!tvshowDetailsContainer || tvshowDetailsContainer.length == 0) {
+ $('#spinner').show();
+ jQuery.post(JSON_RPC + '?GetTVShowSeasons', '{"jsonrpc": "2.0", "method": "VideoLibrary.GetSeasons", "params": { "properties": [ "season", "showtitle", "playcount", "episode", "thumbnail","fanart" ], "tvshowid" : ' + event.data.tvshow.tvshowid + ' }, "id": 1}', jQuery.proxy(function(data) {
+ tvshowDetailsContainer = $('<div>');
+ tvshowDetailsContainer.attr('id', 'tvShowDetails' + event.data.tvshow.tvshowid)
+ .css('display', 'none')
+ .addClass('contentContainer')
+ .addClass('tvshowContainer');
+ var showThumb = this.generateThumb('tvshowseason', event.data.tvshow.thumbnail, event.data.tvshow.title);
+ if (data && data.result && data.result.seasons && data.result.seasons.length > 0) {
+ var showDetails = $('<div>').addClass('showDetails');
+ showDetails.append(toggle);
+ showDetails.append($('<p>').html(data.result.seasons[0].showtitle).addClass('showTitle'));
+ var seasonSelectionSelect = $('<select>').addClass('seasonPicker');
+ //var episodeCount = 0;
+ this.tvActiveShowContainer = tvshowDetailsContainer;
+ //var fanart;
+ $.each($(data.result.seasons), jQuery.proxy(function(i, item) {
+// if(fanart==null && item.fanart!=null){
+// fanart=item.fanart;
+// }
+// //episodeCount += item.episode;
+ var season = $('<option>').attr('value',i);
+ season.text(item.label);
+ seasonSelectionSelect.append(season);
+
+ }, this));
+// if(fanart!=null)
+// {
+// $('.contentContainer').css('background','url("'+this.getThumbnailPath(fanart)+'")').css('background-size','cover');
+// }
+ seasonSelectionSelect.bind('change', {tvshow: event.data.tvshow.tvshowid, seasons: data.result.seasons, element: seasonSelectionSelect}, jQuery.proxy(this.displaySeasonListings, this));
+ //showDetails.append($('<p>').html('<span class="heading">Episodes:</span> ' + episodeCount));
+ showDetails.append(seasonSelectionSelect);
+ tvshowDetailsContainer.append(showDetails);
+ tvshowDetailsContainer.append(showThumb);
+ seasonSelectionSelect.trigger('change');
+ $('#content').append(tvshowDetailsContainer);
+ if(getCookie('TVView')!=null && getCookie('TVView')!='banner'){
+ var view=getCookie('TVView');
+ switch(view) {
+ case 'poster':
+ togglePoster.trigger('click');
+ break;
+ case 'landscape':
+ toggleLandscape.trigger('click')
+ break;
+ }
+ }
+ tvshowDetailsContainer.fadeIn();
+ }
+ $('#spinner').hide();
+ }, this), 'json');
+ } else {
+ $('.contentContainer').hide();
+ $('#tvShowDetails' + event.data.tvshow.tvshowid).show();
+ $('#tvShowDetails' + event.data.tvshow.tvshowid +' select').trigger('change');
+ }
+ },
+ displaySeasonListings: function(event) {
+ //retrieve selected season
+ var selectedVal=event.data.element.val();
+ var seasons=event.data.seasons;
+ $('#topScrollFade').hide();
+ //Hide old listings
+ var oldListings = $('.episodeListingsContainer', this.tvActiveShowContainer).fadeOut();
+ //Update ActiveSeason
+ this.tvActiveSeason = selectedVal;
+ //Populate new listings
+ jQuery.post(JSON_RPC + '?GetTVSeasonEpisodes', '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "properties": [ "title", "thumbnail","episode","plot","season"], "season" : ' + seasons[selectedVal].season + ', "tvshowid" : ' + event.data.tvshow + ' }, "id": 1}', jQuery.proxy(function(data) {
+ var episodeListingsContainer = $('<div>').addClass('episodeListingsContainer');
+ var episodeTable= $('<table>').addClass('seasonView').html('<thead><tr class="headerRow"><th class="thumbHeader">N&deg;</th><th>Title</th><th class="thumbHeader">Thumb</th><th class="thumbHeader">Details</th></tr></thead><tbody class="resultSet"></tbody>');
+ $.each($(data.result.episodes), jQuery.proxy(function(i, item) {
+ var episodeRow = $('<tr>').addClass('episodeRow').addClass('tr' + i % 2);
+ var episodePictureImg = $('<img>').bind('click', { episode: item }, jQuery.proxy(this.playTVShow, this)).css('cursor','pointer');
+ episodePictureImg.attr('src', this.getThumbnailPath(item.thumbnail));
+ var episodePicture=$('<td>').addClass('episodeThumb').append(episodePictureImg).bind('click', { episode: item }, jQuery.proxy(this.playTVShow, this));
+ var episodeNumber = $('<td>').addClass('episodeNumber').html(item.episode).bind('click', { episode: item }, jQuery.proxy(this.playTVShow, this));
+ var episodeTitle = $('<td>').html(item.title).bind('click', { episode: item }, jQuery.proxy(this.playTVShow, this));
+ var episodeDetails = $('<td class="info">').html('').bind('click',{episode:item}, jQuery.proxy(this.displayEpisodeDetails, this)).css('cursor','pointer');
+ episodeRow.append(episodeNumber).append(episodeTitle).append(episodePicture).append(episodeDetails);
+ episodeTable.append(episodeRow);
+ }, this));
+ episodeListingsContainer.append(episodeTable);
+ $(this.tvActiveShowContainer).append(episodeListingsContainer);
+ }, this), 'json');
+
+ },
- var trackRow2 = $('<tr>').addClass('fillerTrackRow2');
- trackRow2.append($('<td>').addClass('albumBG').html('&nbsp'));
- for (var i = 0; i < 5; i++) {
- trackRow2.append($('<td>').html('&nbsp'));
- }
- $('#albumDetails' + event.data.album.albumid + ' .resultSet').append(trackRow2);
- }
- $('#albumDetails' + event.data.album.albumid + ' .albumThumb')
- .append(this.generateThumb('album', albumThumbnail, albumTitle, albumArtist))
- .append($('<div>').addClass('footerPadding'));
- $('#spinner').hide();
- myScroll = new iScroll('albumDetails' + event.data.album.albumid);
- }, this), 'json');
- } else {
- $('.contentContainer').hide();
- $('#albumDetails' + event.data.album.albumid).show();
- }
- },
-
- togglePosterView: function(event){
- var view=event.data.mode;
- var wthumblist,hthumblist,hthumbdetails;
- $("#toggleBanner").removeClass('activeMode');
- $("#togglePoster").removeClass('activeMode');
- $("#toggleLandscape").removeClass('activeMode');
- switch(view) {
- case 'poster':
- setCookie('TVView','poster');
- wthumblist='135px';
- hthumblist='199px';
- hthumbdetails='559px';
- $("#togglePoster").addClass('activeMode');
- break;
- case 'landscape':
- setCookie('TVView','landscape');
- wthumblist='210px';
- hthumblist='118px';
- hthumbdetails='213px';
- $("#toggleLandscape").addClass('activeMode');
- break;
- default: //set banner view as default
- setCookie('TVView','banner');
- wthumblist='379px';
- hthumblist='70px';
- hthumbdetails='70px';
- $("#toggleBanner").addClass('activeMode');
- break;
- }
- $(".floatableTVShowCover, .floatableTVShowCover div.imgWrapper, .floatableTVShowCover img, .floatableTVShowCover div.imgWrapper div.inner").css('width',wthumblist).css('height',hthumblist);
- $(".floatableTVShowCoverSeason div.imgWrapper, .floatableTVShowCoverSeason div.imgWrapper div.inner,.floatableTVShowCoverSeason img, .floatableTVShowCoverSeason").css('height',hthumbdetails);
- },
-
- displayTVShowDetails: function(event) {
- var tvshowDetailsContainer = $('#tvShowDetails' + event.data.tvshow.tvshowid);
- $('#topScrollFade').hide();
- toggle=this.toggle.detach();
- if (!tvshowDetailsContainer || tvshowDetailsContainer.length == 0) {
- $('#spinner').show();
- jQuery.post(JSON_RPC + '?GetTVShowSeasons', '{"jsonrpc": "2.0", "method": "VideoLibrary.GetSeasons", "params": { "properties": [ "season", "showtitle", "playcount", "episode", "thumbnail","fanart" ], "tvshowid" : ' + event.data.tvshow.tvshowid + ' }, "id": 1}', jQuery.proxy(function(data) {
- tvshowDetailsContainer = $('<div>');
- tvshowDetailsContainer.attr('id', 'tvShowDetails' + event.data.tvshow.tvshowid)
- .css('display', 'none')
- .addClass('contentContainer')
- .addClass('tvshowContainer');
- var showThumb = this.generateThumb('tvshowseason', event.data.tvshow.thumbnail, event.data.tvshow.title);
- if (data && data.result && data.result.seasons && data.result.seasons.length > 0) {
- var showDetails = $('<div>').addClass('showDetails');
- showDetails.append(toggle);
- showDetails.append($('<p>').html(data.result.seasons[0].showtitle).addClass('showTitle'));
- var seasonSelectionSelect = $('<select>').addClass('seasonPicker');
- //var episodeCount = 0;
- this.tvActiveShowContainer = tvshowDetailsContainer;
- //var fanart;
- $.each($(data.result.seasons), jQuery.proxy(function(i, item) {
-// if(fanart==null && item.fanart!=null){
-// fanart=item.fanart;
-// }
-// //episodeCount += item.episode;
- var season = $('<option>').attr('value',i);
- season.text(item.label);
- seasonSelectionSelect.append(season);
-
- }, this));
-// if(fanart!=null)
-// {
-// $('.contentContainer').css('background','url("'+this.getThumbnailPath(fanart)+'")').css('background-size','cover');
-// }
- seasonSelectionSelect.bind('change', {tvshow: event.data.tvshow.tvshowid, seasons: data.result.seasons, element: seasonSelectionSelect}, jQuery.proxy(this.displaySeasonListings, this));
- //showDetails.append($('<p>').html('<span class="heading">Episodes:</span> ' + episodeCount));
- showDetails.append(seasonSelectionSelect);
- tvshowDetailsContainer.append(showDetails);
- tvshowDetailsContainer.append(showThumb);
- seasonSelectionSelect.trigger('change');
- $('#content').append(tvshowDetailsContainer);
- if(getCookie('TVView')!=null && getCookie('TVView')!='banner'){
- var view=getCookie('TVView');
- switch(view) {
- case 'poster':
- togglePoster.trigger('click');
- break;
- case 'landscape':
- toggleLandscape.trigger('click')
- break;
- }
- }
- tvshowDetailsContainer.fadeIn();
- }
- $('#spinner').hide();
- }, this), 'json');
- } else {
- $('.contentContainer').hide();
- $('#tvShowDetails' + event.data.tvshow.tvshowid).show();
- $('#tvShowDetails' + event.data.tvshow.tvshowid +' select').trigger('change');
- }
- },
- displaySeasonListings: function(event) {
- //retrieve selected season
- var selectedVal=event.data.element.val();
- var seasons=event.data.seasons;
- $('#topScrollFade').hide();
- //Hide old listings
- var oldListings = $('.episodeListingsContainer', this.tvActiveShowContainer).fadeOut();
- //Update ActiveSeason
- this.tvActiveSeason = selectedVal;
- //Populate new listings
- jQuery.post(JSON_RPC + '?GetTVSeasonEpisodes', '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "properties": [ "title", "thumbnail","episode","plot","season"], "season" : ' + seasons[selectedVal].season + ', "tvshowid" : ' + event.data.tvshow + ' }, "id": 1}', jQuery.proxy(function(data) {
- var episodeListingsContainer = $('<div>').addClass('episodeListingsContainer');
- var episodeTable= $('<table>').addClass('seasonView').html('<thead><tr class="headerRow"><th class="thumbHeader">N&deg;</th><th>Title</th><th class="thumbHeader">Thumb</th><th class="thumbHeader">Details</th></tr></thead><tbody class="resultSet"></tbody>');
- $.each($(data.result.episodes), jQuery.proxy(function(i, item) {
- var episodeRow = $('<tr>').addClass('episodeRow').addClass('tr' + i % 2);
- var episodePictureImg = $('<img>').bind('click', { episode: item }, jQuery.proxy(this.playTVShow, this)).css('cursor','pointer');
- episodePictureImg.attr('src', this.getThumbnailPath(item.thumbnail));
- var episodePicture=$('<td>').addClass('episodeThumb').append(episodePictureImg).bind('click', { episode: item }, jQuery.proxy(this.playTVShow, this));
- var episodeNumber = $('<td>').addClass('episodeNumber').html(item.episode).bind('click', { episode: item }, jQuery.proxy(this.playTVShow, this));
- var episodeTitle = $('<td>').html(item.title).bind('click', { episode: item }, jQuery.proxy(this.playTVShow, this));
- var episodeDetails = $('<td class="info">').html('').bind('click',{episode:item}, jQuery.proxy(this.displayEpisodeDetails, this)).css('cursor','pointer');
- episodeRow.append(episodeNumber).append(episodeTitle).append(episodePicture).append(episodeDetails);
- episodeTable.append(episodeRow);
- }, this));
- episodeListingsContainer.append(episodeTable);
- $(this.tvActiveShowContainer).append(episodeListingsContainer);
- }, this), 'json');
-
- },
-
- displayEpisodeDetails: function(event) {
- var episodeDetails = $('<div>').attr('id', 'episode-' + event.data.episode.episodeid).addClass('episodePopoverContainer');
- episodeDetails.append($('<img>').attr('src', '/images/close-button.png').addClass('closeButton').bind('click', jQuery.proxy(this.hideOverlay, this)));
- episodeDetails.append($('<img>').attr('src', this.getThumbnailPath(event.data.episode.thumbnail)).addClass('episodeCover'));
- episodeDetails.append($('<div>').addClass('playIcon').bind('click', {episode: event.data.episode}, jQuery.proxy(this.playTVShow, this)));
- var episodeTitle = $('<p>').addClass('episodeTitle');
- var yearText = event.data.episode.year ? ' <span class="year">(' + event.data.episode.year + ')</span>' : '';
- episodeTitle.html(event.data.episode.title + yearText);
- episodeDetails.append(episodeTitle);
- if (event.data.episode.runtime) {
- episodeDetails.append($('<p>').addClass('runtime').html('<strong>Runtime:</strong> ' + event.data.epispde.runtime + ' minutes'));
- }
- if (event.data.episode.season) {
- episodeDetails.append($('<p>').addClass('season').html('<strong>Season:</strong> ' + event.data.episode.season));
- }
- if (event.data.episode.episode) {
- episodeDetails.append($('<p>').addClass('episode').html('<strong>Episode:</strong> ' + event.data.episode.episode));
- }
- if (event.data.episode.plot) {
- episodeDetails.append($('<p>').addClass('plot').html('<strong>Plot:</strong> <br/><br/>' +event.data.episode.plot));
- }
- if (event.data.episode.genre) {
- episodeDetails.append($('<p>').addClass('genre').html('<strong>Genre:</strong> ' + event.data.episode.genre));
- }
- if (event.data.episode.rating) {
- //Todo
- }
- if (event.data.episode.director) {
- episodeDetails.append($('<p>').addClass('director').html('<strong>Directed By:</strong> ' + event.data.episode.director));
- }
- this.activeCover = episodeDetails;
- $('body').append(episodeDetails);
- $('#overlay').show();
- this.updatePlayButtonLocation();
- },
-
- playTVShow: function(event) {
- jQuery.post(JSON_RPC + '?AddTvShowToPlaylist', '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "episodeid": ' + event.data.episode.episodeid + ' } }, "id": 1}', jQuery.proxy(function(data) {
- this.hideOverlay();
+ displayEpisodeDetails: function(event) {
+ var episodeDetails = $('<div>').attr('id', 'episode-' + event.data.episode.episodeid).addClass('episodePopoverContainer');
+ episodeDetails.append($('<img>').attr('src', '/images/close-button.png').addClass('closeButton').bind('click', jQuery.proxy(this.hideOverlay, this)));
+ episodeDetails.append($('<img>').attr('src', this.getThumbnailPath(event.data.episode.thumbnail)).addClass('episodeCover'));
+ episodeDetails.append($('<div>').addClass('playIcon').bind('click', {episode: event.data.episode}, jQuery.proxy(this.playTVShow, this)));
+ var episodeTitle = $('<p>').addClass('episodeTitle');
+ var yearText = event.data.episode.year ? ' <span class="year">(' + event.data.episode.year + ')</span>' : '';
+ episodeTitle.html(event.data.episode.title + yearText);
+ episodeDetails.append(episodeTitle);
+ if (event.data.episode.runtime) {
+ episodeDetails.append($('<p>').addClass('runtime').html('<strong>Runtime:</strong> ' + event.data.epispde.runtime + ' minutes'));
+ }
+ if (event.data.episode.season) {
+ episodeDetails.append($('<p>').addClass('season').html('<strong>Season:</strong> ' + event.data.episode.season));
+ }
+ if (event.data.episode.episode) {
+ episodeDetails.append($('<p>').addClass('episode').html('<strong>Episode:</strong> ' + event.data.episode.episode));
+ }
+ if (event.data.episode.plot) {
+ episodeDetails.append($('<p>').addClass('plot').html('<strong>Plot:</strong> <br/><br/>' +event.data.episode.plot));
+ }
+ if (event.data.episode.genre) {
+ episodeDetails.append($('<p>').addClass('genre').html('<strong>Genre:</strong> ' + event.data.episode.genre));
+ }
+ if (event.data.episode.rating) {
+ //Todo
+ }
+ if (event.data.episode.director) {
+ episodeDetails.append($('<p>').addClass('director').html('<strong>Directed By:</strong> ' + event.data.episode.director));
+ }
+ this.activeCover = episodeDetails;
+ $('body').append(episodeDetails);
+ $('#overlay').show();
+ this.updatePlayButtonLocation();
+ },
+
+ playTVShow: function(event) {
+ jQuery.post(JSON_RPC + '?AddTvShowToPlaylist', '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "episodeid": ' + event.data.episode.episodeid + ' } }, "id": 1}', jQuery.proxy(function(data) {
+ this.hideOverlay();
+ }, this), 'json');
+ },
+ hideOverlay: function(event) {
+ if (this.activeCover) {
+ $(this.activeCover).remove();
+ this.activeCover = null;
+ }
+ $('#overlay').hide();
+ },
+ updatePlayButtonLocation: function(event) {
+ var movieContainer = $('.movieCover');
+ if (movieContainer.length > 0) {
+ var playIcon = $('.playIcon');
+ if (playIcon.length > 0) {
+ var heightpi=$(movieContainer[0]).height();
+ playIcon.width(Math.floor(0.65*heightpi));
+ playIcon.height(heightpi);
+ }
+ }
+ var episodeContainer = $('.episodeCover');
+ if (episodeContainer.length > 0) {
+ var playIcon = $('.playIcon');
+ if (playIcon.length > 0) {
+ var widthpi=$(episodeContainer[0]).width();
+ playIcon.width(widthpi);
+ //assume 16/9 thumb
+ playIcon.height(Math.floor(widthpi*9/16));
+ }
+ }
+ },
+ playMovie: function(event) {
+ jQuery.post(JSON_RPC + '?PlayMovie', '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "movieid": ' + event.data.movie.movieid + ' } }, "id": 1}', jQuery.proxy(function(data) {
+ this.hideOverlay();
+ }, this), 'json');
+ },
+ displayMovieDetails: function(event) {
+ var movieDetails = $('<div>').attr('id', 'movie-' + event.data.movie.movieid).addClass('moviePopoverContainer');
+ movieDetails.append($('<img>').attr('src', '/images/close-button.png').addClass('closeButton').bind('click', jQuery.proxy(this.hideOverlay, this)));
+ movieDetails.append($('<img>').attr('src', this.getThumbnailPath(event.data.movie.thumbnail)).addClass('movieCover'));
+ movieDetails.append($('<div>').addClass('playIcon').bind('click', {movie: event.data.movie}, jQuery.proxy(this.playMovie, this)));
+ var movieTitle = $('<p>').addClass('movieTitle');
+ var yearText = event.data.movie.year ? ' <span class="year">(' + event.data.movie.year + ')</span>' : '';
+ movieTitle.html(event.data.movie.title + yearText);
+ movieDetails.append(movieTitle);
+ if (event.data.movie.runtime) {
+ movieDetails.append($('<p>').addClass('runtime').html('<strong>Runtime:</strong> ' + event.data.movie.runtime + ' minutes'));
+ }
+ if (event.data.movie.plot) {
+ movieDetails.append($('<p>').addClass('plot').html(event.data.movie.plot));
+ }
+ if (event.data.movie.genre) {
+ movieDetails.append($('<p>').addClass('genre').html('<strong>Genre:</strong> ' + event.data.movie.genre));
+ }
+ if (event.data.movie.rating) {
+ //Todo
+ }
+ if (event.data.movie.director) {
+ movieDetails.append($('<p>').addClass('director').html('<strong>Directed By:</strong> ' + event.data.movie.director));
+ }
+ this.activeCover = movieDetails;
+ $('body').append(movieDetails);
+ $('#overlay').show();
+ this.updatePlayButtonLocation();
+ },
+ playTrack: function(event) {
+ jQuery.post(JSON_RPC + '?ClearPlaylist', '{"jsonrpc": "2.0", "method": "Playlist.Clear", "params": { "playlistid": ' + this.playlists["audio"] + ' }, "id": 1}', jQuery.proxy(function(data) {
+ //check that clear worked.
+ jQuery.post(JSON_RPC + '?AddAlbumToPlaylist', '{"jsonrpc": "2.0", "method": "Playlist.Add", "params": { "playlistid": ' + this.playlists["audio"] + ', "item": { "albumid": ' + event.data.album.albumid + ' } }, "id": 1}', jQuery.proxy(function(data) {
+ //play specific song in playlist
+ jQuery.post(JSON_RPC + '?PlaylistItemPlay', '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "playlistid": ' + this.playlists["audio"] + ', "position": '+ event.data.itmnbr + ' } }, "id": 1}', function() {}, 'json');
+ }, this), 'json');
+ }, this), 'json');
+ },
+ movieLibraryOpen: function() {
+ this.resetPage();
+ $('#movieLibrary').addClass('selected');
+ $('.contentContainer').hide();
+ var libraryContainer = $('#movieLibraryContainer');
+ if (!libraryContainer || libraryContainer.length == 0) {
+ $('#spinner').show();
+ jQuery.post(JSON_RPC + '?GetMovies', '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "limits": { "start": 0 }, "properties": [ "genre", "director", "trailer", "tagline", "plot", "plotoutline", "title", "originaltitle", "lastplayed", "runtime", "year", "playcount", "rating", "thumbnail", "file" ], "sort": { "method": "sorttitle", "ignorearticle": true } }, "id": 1}', jQuery.proxy(function(data) {
+ if (data && data.result && data.result.movies) {
+ libraryContainer = $('<div>');
+ libraryContainer.attr('id', 'movieLibraryContainer')
+ .addClass('contentContainer');
+ $('#content').append(libraryContainer);
+ } else {
+ libraryContainer.html('');
+ }
+ //data.result.movies.sort(jQuery.proxy(this.movieTitleSorter, this));
+ $.each($(data.result.movies), jQuery.proxy(function(i, item) {
+ var floatableMovieCover = this.generateThumb('movie', item.thumbnail, item.title);
+ floatableMovieCover.bind('click', { movie: item }, jQuery.proxy(this.displayMovieDetails, this));
+ libraryContainer.append(floatableMovieCover);
+ }, this));
+ libraryContainer.append($('<div>').addClass('footerPadding'));
+ $('#spinner').hide();
+ libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
+ libraryContainer.trigger('scroll');
+ //$('#libraryContainer img').lazyload();
+ myScroll = new iScroll('movieLibraryContainer');
+ }, this), 'json');
+ } else {
+ libraryContainer.show();
+ libraryContainer.trigger('scroll');
+ }
+ },
+ tvshowLibraryOpen: function() {
+ this.resetPage();
+ $('#tvshowLibrary').addClass('selected');
+ $('.contentContainer').hide();
+ var libraryContainer = $('#tvshowLibraryContainer');
+ if (!libraryContainer || libraryContainer.length == 0) {
+ $('#spinner').show();
+ toggle=$('<p>').addClass('toggle');
+ togglePoster= $('<span>Poster</span>');
+ togglePoster.attr('id', 'togglePoster')
+ .css('cursor','pointer')
+ .bind('click',{mode: 'poster'},jQuery.proxy(this.togglePosterView,this));
+ toggleBanner= $('<span>Banner</span>');
+ toggleBanner.attr('id', 'toggleBanner')
+ .css('cursor','pointer')
+ .addClass('activeMode')
+ .bind('click',{mode: 'banner'},jQuery.proxy(this.togglePosterView,this));
+ toggleLandscape= $('<span>Landscape</span>');
+ toggleLandscape.attr('id', 'toggleLandscape')
+ .css('cursor','pointer')
+ .bind('click',{mode: 'landscape'},jQuery.proxy(this.togglePosterView,this));
+ toggle.append(toggleBanner).append(' | ').append(togglePoster).append(' | ').append(toggleLandscape);
+ this.toggle=toggle;
+ jQuery.post(JSON_RPC + '?GetTVShows', '{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "properties": ["genre", "plot", "title", "lastplayed", "episode", "year", "playcount", "rating", "thumbnail", "studio", "mpaa", "premiered"] }, "id": 1}', jQuery.proxy(function(data) {
+ if (data && data.result && data.result.tvshows) {
+ libraryContainer = $('<div>');
+ libraryContainer.append(toggle);
+ libraryContainer.attr('id', 'tvshowLibraryContainer')
+ .addClass('contentContainer');
+ $('#content').append(libraryContainer);
+ } else {
+ libraryContainer.html('');
+ }
+ $.each($(data.result.tvshows), jQuery.proxy(function(i, item) {
+ var floatableTVShowCover = this.generateThumb('tvshow', item.thumbnail, item.title);
+ floatableTVShowCover.bind('click', { tvshow: item }, jQuery.proxy(this.displayTVShowDetails, this));
+ libraryContainer.append(floatableTVShowCover);
+ }, this));
+ libraryContainer.append($('<div>').addClass('footerPadding'));
+ $('#spinner').hide();
+ libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
+ libraryContainer.trigger('scroll');
+ myScroll = new iScroll('tvshowLibraryContainer');
+ if(getCookie('TVView')!=null && getCookie('TVView')!='banner'){
+ var view=getCookie('TVView');
+ switch(view) {
+ case 'poster':
+ togglePoster.trigger('click');
+ break;
+ case 'landscape':
+ toggleLandscape.trigger('click')
+ break;
+ }
+ }
+ }, this), 'json');
+ } else {
+ libraryContainer.prepend($(".toggle").detach()).show();
+ libraryContainer.trigger('scroll');
+ }
+
+ },
+ updateScrollEffects: function(event) {
+ if (event.data.activeLibrary && $(event.data.activeLibrary).scrollTop() > 0) {
+ $('#topScrollFade').fadeIn();
+ } else {
+ $('#topScrollFade').fadeOut();
+ }
+ },
+ startSlideshow: function(event) {
+ jQuery.post(JSON_RPC + '?StartSlideshow', '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recursive" : "true", "random":"true", "path" : "' + this.replaceAll(event.data.directory.file, "\\", "\\\\") + '" } }, "id": 1}', null, 'json');
+ },
+ showDirectory: function(event) {
+ var directory = event.data.directory.file;
+ var jsonDirectory = this.replaceAll(directory, "\\", "\\\\");
+ this.resetPage();
+ $('#pictureLibrary').addClass('selected');
+ $('.contentContainer').hide();
+ var libraryContainer = $('#pictureLibraryDirContainer' + directory);
+ if (!libraryContainer || libraryContainer.length == 0) {
+ $('#spinner').show();
+ jQuery.post(JSON_RPC + '?GetDirectory', '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": { "media" : "pictures", "directory": "' + jsonDirectory + '" }, "id": 1}', jQuery.proxy(function(data) {
+ if (data && data.result && ( data.result.directories || data.result.files )) {
+ libraryContainer = $('<div>');
+ libraryContainer.attr('id', 'pictureLibraryDirContainer' + directory)
+ .addClass('contentContainer');
+ $('#content').append(libraryContainer);
+ var breadcrumb = $('<div>');
+ var seperator = '/';
+ var item = '';
+ var directoryArray = directory.split(seperator);
+ jQuery.each(directoryArray, function(i,v) {
+ if(v != '') {
+ item += v + seperator;
+ //tmp.bind('click', { directory: item }, jQuery.proxy(this.showDirectory, this));
+ breadcrumb.append($('<div>').text(' > ' + v).css('float','left').addClass('breadcrumb'));
+ }
+ });
+ libraryContainer.append(breadcrumb);
+ libraryContainer.append($('<div>').css('clear','both'));
+ if (data.result.files) {
+ $.each($(data.result.files), jQuery.proxy(function(i, item) {
+ if (item.filetype == "file")
+ {
+ var floatableImage = this.generateThumb('image', item.file, item.label);
+ libraryContainer.append(floatableImage);
+ }
+ else if (item.filetype == "directory")
+ {
+ var floatableShare = this.generateThumb('directory', item.thumbnail, item.label);
+ floatableShare.bind('click', { directory: item }, jQuery.proxy(this.showDirectory, this));
+ //var slideshow = $('<div">');
+ //slideshow.html('<div>Slideshow</div>');
+ //slideshow.bind('click', { directory: item }, jQuery.proxy(this.startSlideshow, this));
+ //floatableShare.append(slideshow);
+ libraryContainer.append(floatableShare);
+ }
+ }, this));
+ }
+ libraryContainer.append($('<div>').addClass('footerPadding'));
+ } else {
+ libraryContainer.html('');
+ }
+ $('#spinner').hide();
+ libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
+ libraryContainer.trigger('scroll');
+ myScroll = new iScroll('#pictureLibraryDirContainer' + directory);
+ }, this), 'json');
+ } else {
+ libraryContainer.show();
+ libraryContainer.trigger('scroll');
+ }
+ },
+ pictureLibraryOpen: function() {
+ this.resetPage();
+ $('#pictureLibrary').addClass('selected');
+ $('.contentContainer').hide();
+ var libraryContainer = $('#pictureLibraryContainer');
+ if (!libraryContainer || libraryContainer.length == 0) {
+ $('#spinner').show();
+ jQuery.post(JSON_RPC + '?GetSources', '{"jsonrpc": "2.0", "method": "Files.GetSources", "params": { "media" : "pictures" }, "id": 1}', jQuery.proxy(function(data) {
+ if (data && data.result && data.result.shares) {
+ libraryContainer = $('<div>');
+ libraryContainer.attr('id', 'pictureLibraryContainer')
+ .addClass('contentContainer');
+ $('#content').append(libraryContainer);
+ } else {
+ libraryContainer.html('');
+ }
+ $.each($(data.result.shares), jQuery.proxy(function(i, item) {
+ var floatableShare = this.generateThumb('directory', item.thumbnail, item.label);
+ floatableShare.bind('click', { directory: item }, jQuery.proxy(this.showDirectory, this));
+ libraryContainer.append(floatableShare);
+ }, this));
+ libraryContainer.append($('<div>').addClass('footerPadding'));
+ $('#spinner').hide();
+ libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
+ libraryContainer.trigger('scroll');
+ myScroll = new iScroll('#pictureLibraryContainer');
}, this), 'json');
- },
- hideOverlay: function(event) {
- if (this.activeCover) {
- $(this.activeCover).remove();
- this.activeCover = null;
- }
- $('#overlay').hide();
- },
- updatePlayButtonLocation: function(event) {
- var movieContainer = $('.movieCover');
- if (movieContainer.length > 0) {
- var playIcon = $('.playIcon');
- if (playIcon.length > 0) {
- var heightpi=$(movieContainer[0]).height();
- playIcon.width(Math.floor(0.65*heightpi));
- playIcon.height(heightpi);
- }
- }
- var episodeContainer = $('.episodeCover');
- if (episodeContainer.length > 0) {
- var playIcon = $('.playIcon');
- if (playIcon.length > 0) {
- var widthpi=$(episodeContainer[0]).width();
- playIcon.width(widthpi);
- //assume 16/9 thumb
- playIcon.height(Math.floor(widthpi*9/16));
- }
- }
- },
- playMovie: function(event) {
- jQuery.post(JSON_RPC + '?PlayMovie', '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "movieid": ' + event.data.movie.movieid + ' } }, "id": 1}', jQuery.proxy(function(data) {
- this.hideOverlay();
- }, this), 'json');
- },
- displayMovieDetails: function(event) {
- var movieDetails = $('<div>').attr('id', 'movie-' + event.data.movie.movieid).addClass('moviePopoverContainer');
- movieDetails.append($('<img>').attr('src', '/images/close-button.png').addClass('closeButton').bind('click', jQuery.proxy(this.hideOverlay, this)));
- movieDetails.append($('<img>').attr('src', this.getThumbnailPath(event.data.movie.thumbnail)).addClass('movieCover'));
- movieDetails.append($('<div>').addClass('playIcon').bind('click', {movie: event.data.movie}, jQuery.proxy(this.playMovie, this)));
- var movieTitle = $('<p>').addClass('movieTitle');
- var yearText = event.data.movie.year ? ' <span class="year">(' + event.data.movie.year + ')</span>' : '';
- movieTitle.html(event.data.movie.title + yearText);
- movieDetails.append(movieTitle);
- if (event.data.movie.runtime) {
- movieDetails.append($('<p>').addClass('runtime').html('<strong>Runtime:</strong> ' + event.data.movie.runtime + ' minutes'));
- }
- if (event.data.movie.plot) {
- movieDetails.append($('<p>').addClass('plot').html(event.data.movie.plot));
- }
- if (event.data.movie.genre) {
- movieDetails.append($('<p>').addClass('genre').html('<strong>Genre:</strong> ' + event.data.movie.genre));
- }
- if (event.data.movie.rating) {
- //Todo
- }
- if (event.data.movie.director) {
- movieDetails.append($('<p>').addClass('director').html('<strong>Directed By:</strong> ' + event.data.movie.director));
- }
- this.activeCover = movieDetails;
- $('body').append(movieDetails);
- $('#overlay').show();
- this.updatePlayButtonLocation();
- },
- playTrack: function(event) {
- jQuery.post(JSON_RPC + '?ClearPlaylist', '{"jsonrpc": "2.0", "method": "Playlist.Clear", "params": { "playlistid": ' + this.playlists["audio"] + ' }, "id": 1}', jQuery.proxy(function(data) {
- //check that clear worked.
- jQuery.post(JSON_RPC + '?AddAlbumToPlaylist', '{"jsonrpc": "2.0", "method": "Playlist.Add", "params": { "playlistid": ' + this.playlists["audio"] + ', "item": { "albumid": ' + event.data.album.albumid + ' } }, "id": 1}', jQuery.proxy(function(data) {
- //play specific song in playlist
- jQuery.post(JSON_RPC + '?PlaylistItemPlay', '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "playlistid": ' + this.playlists["audio"] + ', "position": '+ event.data.itmnbr + ' } }, "id": 1}', function() {}, 'json');
- }, this), 'json');
- }, this), 'json');
- },
- movieLibraryOpen: function() {
- this.resetPage();
- $('#movieLibrary').addClass('selected');
- $('.contentContainer').hide();
- var libraryContainer = $('#movieLibraryContainer');
- if (!libraryContainer || libraryContainer.length == 0) {
- $('#spinner').show();
- jQuery.post(JSON_RPC + '?GetMovies', '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "limits": { "start": 0 }, "properties": [ "genre", "director", "trailer", "tagline", "plot", "plotoutline", "title", "originaltitle", "lastplayed", "runtime", "year", "playcount", "rating", "thumbnail", "file" ], "sort": { "method": "sorttitle", "ignorearticle": true } }, "id": 1}', jQuery.proxy(function(data) {
- if (data && data.result && data.result.movies) {
- libraryContainer = $('<div>');
- libraryContainer.attr('id', 'movieLibraryContainer')
- .addClass('contentContainer');
- $('#content').append(libraryContainer);
- } else {
- libraryContainer.html('');
- }
- //data.result.movies.sort(jQuery.proxy(this.movieTitleSorter, this));
- $.each($(data.result.movies), jQuery.proxy(function(i, item) {
- var floatableMovieCover = this.generateThumb('movie', item.thumbnail, item.title);
- floatableMovieCover.bind('click', { movie: item }, jQuery.proxy(this.displayMovieDetails, this));
- libraryContainer.append(floatableMovieCover);
- }, this));
- libraryContainer.append($('<div>').addClass('footerPadding'));
- $('#spinner').hide();
- libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
- libraryContainer.trigger('scroll');
- //$('#libraryContainer img').lazyload();
- myScroll = new iScroll('movieLibraryContainer');
- }, this), 'json');
- } else {
- libraryContainer.show();
- libraryContainer.trigger('scroll');
- }
- },
- tvshowLibraryOpen: function() {
- this.resetPage();
- $('#tvshowLibrary').addClass('selected');
- $('.contentContainer').hide();
- var libraryContainer = $('#tvshowLibraryContainer');
- if (!libraryContainer || libraryContainer.length == 0) {
- $('#spinner').show();
- toggle=$('<p>').addClass('toggle');
- togglePoster= $('<span>Poster</span>');
- togglePoster.attr('id', 'togglePoster')
- .css('cursor','pointer')
- .bind('click',{mode: 'poster'},jQuery.proxy(this.togglePosterView,this));
- toggleBanner= $('<span>Banner</span>');
- toggleBanner.attr('id', 'toggleBanner')
- .css('cursor','pointer')
- .addClass('activeMode')
- .bind('click',{mode: 'banner'},jQuery.proxy(this.togglePosterView,this));
- toggleLandscape= $('<span>Landscape</span>');
- toggleLandscape.attr('id', 'toggleLandscape')
- .css('cursor','pointer')
- .bind('click',{mode: 'landscape'},jQuery.proxy(this.togglePosterView,this));
- toggle.append(toggleBanner).append(' | ').append(togglePoster).append(' | ').append(toggleLandscape);
- this.toggle=toggle;
- jQuery.post(JSON_RPC + '?GetTVShows', '{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "properties": ["genre", "plot", "title", "lastplayed", "episode", "year", "playcount", "rating", "thumbnail", "studio", "mpaa", "premiered"] }, "id": 1}', jQuery.proxy(function(data) {
- if (data && data.result && data.result.tvshows) {
- libraryContainer = $('<div>');
- libraryContainer.append(toggle);
- libraryContainer.attr('id', 'tvshowLibraryContainer')
- .addClass('contentContainer');
- $('#content').append(libraryContainer);
- } else {
- libraryContainer.html('');
- }
- $.each($(data.result.tvshows), jQuery.proxy(function(i, item) {
- var floatableTVShowCover = this.generateThumb('tvshow', item.thumbnail, item.title);
- floatableTVShowCover.bind('click', { tvshow: item }, jQuery.proxy(this.displayTVShowDetails, this));
- libraryContainer.append(floatableTVShowCover);
- }, this));
- libraryContainer.append($('<div>').addClass('footerPadding'));
- $('#spinner').hide();
- libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
- libraryContainer.trigger('scroll');
- myScroll = new iScroll('tvshowLibraryContainer');
- if(getCookie('TVView')!=null && getCookie('TVView')!='banner'){
- var view=getCookie('TVView');
- switch(view) {
- case 'poster':
- togglePoster.trigger('click');
- break;
- case 'landscape':
- toggleLandscape.trigger('click')
- break;
- }
- }
- }, this), 'json');
- } else {
- libraryContainer.prepend($(".toggle").detach()).show();
- libraryContainer.trigger('scroll');
- }
-
- },
- updateScrollEffects: function(event) {
- if (event.data.activeLibrary && $(event.data.activeLibrary).scrollTop() > 0) {
- $('#topScrollFade').fadeIn();
- } else {
- $('#topScrollFade').fadeOut();
- }
- },
- startSlideshow: function(event) {
- jQuery.post(JSON_RPC + '?StartSlideshow', '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recursive" : "true", "random":"true", "path" : "' + this.replaceAll(event.data.directory.file, "\\", "\\\\") + '" } }, "id": 1}', null, 'json');
- },
- showDirectory: function(event) {
- var directory = event.data.directory.file;
- var jsonDirectory = this.replaceAll(directory, "\\", "\\\\");
- this.resetPage();
- $('#pictureLibrary').addClass('selected');
- $('.contentContainer').hide();
- var libraryContainer = $('#pictureLibraryDirContainer' + directory);
- if (!libraryContainer || libraryContainer.length == 0) {
- $('#spinner').show();
- jQuery.post(JSON_RPC + '?GetDirectory', '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": { "media" : "pictures", "directory": "' + jsonDirectory + '" }, "id": 1}', jQuery.proxy(function(data) {
- if (data && data.result && ( data.result.directories || data.result.files )) {
- libraryContainer = $('<div>');
- libraryContainer.attr('id', 'pictureLibraryDirContainer' + directory)
- .addClass('contentContainer');
- $('#content').append(libraryContainer);
- var breadcrumb = $('<div>');
- var seperator = '/';
- var item = '';
- var directoryArray = directory.split(seperator);
- jQuery.each(directoryArray, function(i,v) {
- if(v != '') {
- item += v + seperator;
- //tmp.bind('click', { directory: item }, jQuery.proxy(this.showDirectory, this));
- breadcrumb.append($('<div>').text(' > ' + v).css('float','left').addClass('breadcrumb'));
- }
- });
- libraryContainer.append(breadcrumb);
- libraryContainer.append($('<div>').css('clear','both'));
- if (data.result.files) {
- $.each($(data.result.files), jQuery.proxy(function(i, item) {
- if (item.filetype == "file")
- {
- var floatableImage = this.generateThumb('image', item.file, item.label);
- libraryContainer.append(floatableImage);
- }
- else if (item.filetype == "directory")
- {
- var floatableShare = this.generateThumb('directory', item.thumbnail, item.label);
- floatableShare.bind('click', { directory: item }, jQuery.proxy(this.showDirectory, this));
- //var slideshow = $('<div">');
- //slideshow.html('<div>Slideshow</div>');
- //slideshow.bind('click', { directory: item }, jQuery.proxy(this.startSlideshow, this));
- //floatableShare.append(slideshow);
- libraryContainer.append(floatableShare);
- }
- }, this));
- }
- libraryContainer.append($('<div>').addClass('footerPadding'));
- } else {
- libraryContainer.html('');
- }
- $('#spinner').hide();
- libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
- libraryContainer.trigger('scroll');
- myScroll = new iScroll('#pictureLibraryDirContainer' + directory);
- }, this), 'json');
- } else {
- libraryContainer.show();
- libraryContainer.trigger('scroll');
- }
- },
- pictureLibraryOpen: function() {
- this.resetPage();
- $('#pictureLibrary').addClass('selected');
- $('.contentContainer').hide();
- var libraryContainer = $('#pictureLibraryContainer');
- if (!libraryContainer || libraryContainer.length == 0) {
- $('#spinner').show();
- jQuery.post(JSON_RPC + '?GetSources', '{"jsonrpc": "2.0", "method": "Files.GetSources", "params": { "media" : "pictures" }, "id": 1}', jQuery.proxy(function(data) {
- if (data && data.result && data.result.shares) {
- libraryContainer = $('<div>');
- libraryContainer.attr('id', 'pictureLibraryContainer')
- .addClass('contentContainer');
- $('#content').append(libraryContainer);
- } else {
- libraryContainer.html('');
- }
- $.each($(data.result.shares), jQuery.proxy(function(i, item) {
- var floatableShare = this.generateThumb('directory', item.thumbnail, item.label);
- floatableShare.bind('click', { directory: item }, jQuery.proxy(this.showDirectory, this));
- libraryContainer.append(floatableShare);
- }, this));
- libraryContainer.append($('<div>').addClass('footerPadding'));
- $('#spinner').hide();
- libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
- libraryContainer.trigger('scroll');
- myScroll = new iScroll('#pictureLibraryContainer');
- }, this), 'json');
- } else {
- libraryContainer.show();
- libraryContainer.trigger('scroll');
- }
- }
- } \ No newline at end of file
+ } else {
+ libraryContainer.show();
+ libraryContainer.trigger('scroll');
+ }
+ }
+} \ No newline at end of file
diff --git a/addons/webinterface.default/js/NowPlayingManager.js b/addons/webinterface.default/js/NowPlayingManager.js
index 6ebc1782ca..a9add9e7bc 100755
--- a/addons/webinterface.default/js/NowPlayingManager.js
+++ b/addons/webinterface.default/js/NowPlayingManager.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2010 Team XBMC
+ * Copyright (C) 2005-2011 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
@@ -20,505 +20,505 @@
*/
var NowPlayingManager = function() {
- this.init();
- return true;
- }
+ this.init();
+ return true;
+}
NowPlayingManager.prototype = {
- updateCounter: 0,
- activePlayer: "",
- activePlayerId: -1,
- currentItem: -1,
- playing: false,
- paused: false,
- playlistid: -1,
-
- init: function() {
- $('#pbPause').hide(); /* Assume we are not playing something */
- this.bindPlaybackControls();
- this.updateState();
- $('#nextTrack').bind('click', jQuery.proxy(this.showPlaylist, this));
- $('#nowPlayingPlaylist').bind('click', function() {return false;});
- $(window).bind('click', jQuery.proxy(this.hidePlaylist, this));
- },
- updateState: function() {
- jQuery.ajax({
- type: 'POST',
- url: JSON_RPC + '?UpdateState',
- data: '{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}',
- timeout: 3000,
- success: jQuery.proxy(function(data) {
- if (data && data.result && data.result.length > 0) {
- if (data.result[0].playerid != this.activePlayerId) {
- this.activePlayerId = data.result[0].playerid;
- this.activePlayer = data.result[0].type;
- if (this.activePlayer == "audio")
- {
- this.stopVideoPlaylistUpdate();
- this.displayAudioNowPlaying();
+ updateCounter: 0,
+ activePlayer: "",
+ activePlayerId: -1,
+ currentItem: -1,
+ playing: false,
+ paused: false,
+ playlistid: -1,
+
+ init: function() {
+ $('#pbPause').hide(); /* Assume we are not playing something */
+ this.bindPlaybackControls();
+ this.updateState();
+ $('#nextTrack').bind('click', jQuery.proxy(this.showPlaylist, this));
+ $('#nowPlayingPlaylist').bind('click', function() {return false;});
+ $(window).bind('click', jQuery.proxy(this.hidePlaylist, this));
+ },
+ updateState: function() {
+ jQuery.ajax({
+ type: 'POST',
+ url: JSON_RPC + '?UpdateState',
+ data: '{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}',
+ timeout: 3000,
+ success: jQuery.proxy(function(data) {
+ if (data && data.result && data.result.length > 0) {
+ if (data.result[0].playerid != this.activePlayerId) {
+ this.activePlayerId = data.result[0].playerid;
+ this.activePlayer = data.result[0].type;
+ if (this.activePlayer == "audio")
+ {
+ this.stopVideoPlaylistUpdate();
+ this.displayAudioNowPlaying();
+ }
+ else if (this.activePlayer == "video")
+ {
+ this.stopAudioPlaylistUpdate();
+ this.displayVideoNowPlaying();
+ }
+ else
+ {
+ this.stopVideoPlaylistUpdate();
+ this.stopAudioPlaylistUpdate();
+ this.activePlayer = "";
+ this.activePlayerId = -1;
+ }
+
+ this.stopRefreshTime();
+
+ this.updatePlayer();
+ }
+ }
+ else if (data.result.length <= 0)
+ {
+ this.stopVideoPlaylistUpdate();
+ this.stopAudioPlaylistUpdate();
+ this.activePlayer = "";
+ this.activePlayerId = -1;
+ }
+
+ if (this.activePlayerId >= 0)
+ this.showFooter();
+ else {
+ this.stopRefreshTime();
+ this.hideFooter();
+ }
+
+ setTimeout(jQuery.proxy(this.updateState, this), 1000);
+ }, this),
+ error: jQuery.proxy(function(data, error) {
+ displayCommunicationError();
+ setTimeout(jQuery.proxy(this.updateState, this), 2000);
+ }, this),
+ dataType: 'json'});
+ },
+ updatePlayer: function() {
+ jQuery.post(JSON_RPC + '?UpdatePlayer',
+ '{"jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "playerid": ' + this.activePlayerId + ', "properties": [ "playlistid", "speed", "position", "totaltime", "time" ] }, "id": 1}',
+ jQuery.proxy(function(data) {
+ if (data && data.result)
+ {
+ this.playlistid = data.result.playlistid;
+ this.playing = data.result.speed != 0;
+ this.paused = data.result.speed == 0;
+ this.currentItem = data.result.position;
+ this.trackBaseTime = timeToDuration(data.result.time);
+ this.trackDurationTime = timeToDuration(data.result.totaltime);
+ if (!this.autoRefreshAudioData && !this.autoRefreshVideoData && this.playing) {
+ if (this.activePlayer == 'audio') {
+ this.autoRefreshAudioData = true;
+ this.refreshAudioData();
+ } else if (this.activePlayer == 'video') {
+ this.autoRefreshVideoData = true;
+ this.refreshVideoData();
+ }
+ }
+ }
+ if ((this.autoRefreshAudioData || this.autoRefreshVideoData) && !this.activeItemTimer) {
+ this.activeItemTimer = 1;
+ setTimeout(jQuery.proxy(this.updateActiveItemDurationLoop, this), 1000);
+ }
+ }, this), 'json');
+ },
+ bindPlaybackControls: function() {
+ $('#pbNext').bind('click', jQuery.proxy(this.nextTrack, this));
+ $('#pbPrev').bind('click', jQuery.proxy(this.prevTrack, this));
+ $('#pbStop').bind('click', jQuery.proxy(this.stopTrack, this));
+ $('#pbPlay').bind('click', jQuery.proxy(this.playPauseTrack, this));
+ $('#pbPause').bind('click', jQuery.proxy(this.playPauseTrack, this));
+ },
+ showPlaylist: function() {
+ $('#nextText').html('Playlist: ');
+ $('#nowPlayingPlaylist').show();
+ return false;
+ },
+ hidePlaylist: function() {
+ $('#nextText').html('Next: ');
+ $('#nowPlayingPlaylist').hide();
+ return false;
+ },
+ hideFooter: function() {
+ $('#footerPopover').hide();
+ $('#overlay').css('bottom','0px');
+ },
+ showFooter: function() {
+ $('#footerPopover').show();
+ $('#overlay').css('bottom','150px');
+ },
+ nextTrack: function() {
+ if (this.activePlayer) {
+ jQuery.post(JSON_RPC + '?SkipNext', '{"jsonrpc": "2.0", "method": "Player.GoNext", "params": { "playerid": ' + this.activePlayerId + ' }, "id": 1}', jQuery.proxy(function(data) {
+ if (data && data.result == 'OK') {
+ //this.updateAudioPlaylist(true);
+ }
+ }, this), 'json');
+ }
+ },
+ prevTrack: function() {
+ if (this.activePlayer) {
+ jQuery.post(JSON_RPC + '?SkipPrevious', '{"jsonrpc": "2.0", "method": "Player.GoPrevious", "params": { "playerid": ' + this.activePlayerId + ' }, "id": 1}', jQuery.proxy(function(data) {
+ if (data && data.result == 'OK') {
+ //this.updateAudioPlaylist(true);
+ }
+ }, this), 'json');
+ }
+ },
+ stopTrack: function() {
+ if (this.activePlayer) {
+ jQuery.post(JSON_RPC + '?Stop', '{"jsonrpc": "2.0", "method": "Player.Stop", "params": { "playerid": ' + this.activePlayerId + ' }, "id": 1}', jQuery.proxy(function(data) {
+ if (data && data.result == 'OK') {
+ this.playing = false;
+ this.paused = false;
+ this.trackBaseTime = 0;
+ this.trackDurationTime = 0;
+ this.showPlayButton();
+ }
+ }, this), 'json');
+ }
+ },
+ playPauseTrack: function() {
+ if (this.activePlayer) {
+ var method = ((this.playing || this.paused) ? 'Player.PlayPause' : 'Playlist.Play');
+ jQuery.post(JSON_RPC + '?PlayPause', '{"jsonrpc": "2.0", "method": "' + method + '", "params": { "playerid": ' + this.activePlayerId + ' }, "id": 1}', jQuery.proxy(function(data) {
+ if (data && data.result) {
+ this.playing = data.result.speed != 0;
+ this.paused = data.result.speed == 0;
+ if (this.playing) {
+ this.showPauseButton();
+ } else {
+ this.showPlayButton();
+ }
+ }
+ }, this), 'json');
+ }
+ },
+ showPauseButton: function() {
+ $('#pbPause').show();
+ $('#pbPlay').hide();
+ },
+ showPlayButton: function() {
+ $('#pbPause').hide();
+ $('#pbPlay').show();
+ },
+ displayAudioNowPlaying: function() {
+ if (!this.autoRefreshAudioPlaylist) {
+ this.autoRefreshAudioPlaylist = true;
+ this.updateAudioPlaylist();
+ }
+ },
+ displayVideoNowPlaying: function() {
+ if (!this.autoRefreshVideoPlaylist) {
+ this.autoRefreshVideoPlaylist = true;
+ this.updateVideoPlaylist();
+ }
+ },
+ playPlaylistItem: function(sender) {
+ var sequenceId = $(sender.currentTarget).attr('seq');
+ if (!this.activePlaylistItem || (this.activePlaylistItem !== undefined && sequenceId != this.activePlaylistItem.seq)) {
+ jQuery.post(JSON_RPC + '?PlaylistItemPlay', '{"jsonrpc": "2.0", "method": "Player.GoTo", "params": { "playerid": ' + this.activePlayerId + ', "item": ' + sequenceId + '}, "id": 1}', function() {}, 'json');
+ }
+ this.hidePlaylist();
+ },
+ playlistChanged: function(newPlaylist) {
+ if (this.activePlaylist && !newPlaylist || !this.activePlaylist && newPlaylist) {
+ return true;
+ }
+ if (!this.activePlaylist && !newPlaylist) {
+ return false;
+ }
+ if (this.activePlaylist.length != newPlaylist.length) {
+ return true;
+ }
+ for (var i = 0; i < newPlaylist.length; i++) {
+ if (!this.comparePlaylistItems(this.activePlaylist[i], newPlaylist[i])) {
+ return true;
+ }
+ }
+ return false;
+ },
+ updateAudioPlaylist: function() {
+ jQuery.ajax({
+ type: 'POST',
+ url: JSON_RPC + '?updateAudioPlaylist',
+ data: '{"jsonrpc": "2.0", "method": "Playlist.GetItems", "params": { "playlistid": ' + this.playlistid + ', "properties": [ "title", "album", "artist", "duration", "thumbnail" ] }, "id": 1}',
+ success: jQuery.proxy(function(data) {
+ if (data && data.result && data.result.items && data.result.items.length > 0 && data.result.limits.total > 0) {
+ //Compare new playlist to active playlist, only redraw if a change is noticed
+ if (!this.activePlaylistItem || this.playlistChanged(data.result.items) || (this.activePlaylistItem && (this.activePlaylistItem.seq != this.currentItem))) {
+ var ul = $('<ul>');
+ var activeItem;
+ $.each($(data.result.items), jQuery.proxy(function(i, item) {
+ var li = $('<li>');
+ var code = '<span class="duration">' + durationToString(item.duration) + '</span><div class="trackInfo" title="' + item.title + ' - ' + item.artist + '"><span class="trackTitle">' + item.title + '</span> - <span class="trackArtist">' + item.artist + '</span></div>';
+ if (i == this.currentItem) {
+ activeItem = item;
+ activeItem.seq = i;
+ li.addClass('activeItem');
}
- else if (this.activePlayer == "video")
- {
- this.stopAudioPlaylistUpdate();
- this.displayVideoNowPlaying();
+ if (i == (this.currentItem + 1)) {
+ $('#nextTrack').html(code).show();
}
- else
- {
- this.stopVideoPlaylistUpdate();
- this.stopAudioPlaylistUpdate();
- this.activePlayer = "";
- this.activePlayerId = -1;
+ li.bind('click', jQuery.proxy(this.playPlaylistItem, this));
+ ul.append(li.attr('seq', i).html(code));
+ }, this));
+ if (data.result.limits.total > 1) {
+ if (activeItem && data.result.limits.total-1 == activeItem.seq) {
+ $('#nextTrack').html('<div class="trackInfo">Last track in playlist</div>').show();
}
-
- this.stopRefreshTime();
-
- this.updatePlayer();
+ $('#nextText').show();
+ $('#nowPlayingPlaylist').html('').append(ul);
+ } else {
+ $('#nextText').hide();
+ $('#nowPlayingPlaylist').hide();
+ $('#nextTrack').hide();
}
- }
- else if (data.result.length <= 0)
- {
- this.stopVideoPlaylistUpdate();
- this.stopAudioPlaylistUpdate();
- this.activePlayer = "";
- this.activePlayerId = -1;
- }
-
- if (this.activePlayerId >= 0)
- this.showFooter();
- else {
- this.stopRefreshTime();
- this.hideFooter();
- }
-
- setTimeout(jQuery.proxy(this.updateState, this), 1000);
- }, this),
- error: jQuery.proxy(function(data, error) {
- displayCommunicationError();
- setTimeout(jQuery.proxy(this.updateState, this), 2000);
- }, this),
- dataType: 'json'});
- },
- updatePlayer: function() {
- jQuery.post(JSON_RPC + '?UpdatePlayer',
- '{"jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "playerid": ' + this.activePlayerId + ', "properties": [ "playlistid", "speed", "position", "totaltime", "time" ] }, "id": 1}',
- jQuery.proxy(function(data) {
- if (data && data.result)
- {
- this.playlistid = data.result.playlistid;
- this.playing = data.result.speed != 0;
- this.paused = data.result.speed == 0;
- this.currentItem = data.result.position;
- this.trackBaseTime = timeToDuration(data.result.time);
- this.trackDurationTime = timeToDuration(data.result.totaltime);
- if (!this.autoRefreshAudioData && !this.autoRefreshVideoData && this.playing) {
- if (this.activePlayer == 'audio') {
- this.autoRefreshAudioData = true;
- this.refreshAudioData();
- } else if (this.activePlayer == 'video') {
- this.autoRefreshVideoData = true;
- this.refreshVideoData();
+ if (!this.comparePlaylistItems(activeItem, this.activePlaylistItem)) {
+ this.activePlaylistItem = activeItem;
+ if (!this.updateActiveItemDurationRunOnce) {
+ this.updateActiveItemDurationRunOnce = true;
+ this.updatePlayer();
}
+ } else if (!activeItem) {
+ this.stopRefreshTime();
}
+ this.activePlaylist = data.result.items;
+ $('#videoDescription').hide();
+ $('#audioDescription').show();
+ $('#nowPlayingPanel').show();
}
- if ((this.autoRefreshAudioData || this.autoRefreshVideoData) && !this.activeItemTimer) {
- this.activeItemTimer = 1;
- setTimeout(jQuery.proxy(this.updateActiveItemDurationLoop, this), 1000);
+ } else {
+ this.activePlaylist = null;
+ $('#audioDescription').hide();
+ $('#nowPlayingPanel').hide();
+ }
+ if (this.autoRefreshAudioPlaylist) {
+ setTimeout(jQuery.proxy(this.updateAudioPlaylist, this), 1000);
+ }
+ }, this),
+ error: jQuery.proxy(function(data) {
+ displayCommunicationError();
+ if (this.autoRefreshAudioPlaylist) {
+ setTimeout(jQuery.proxy(this.updateAudioPlaylist, this), 2000); /* Slow down request period */
+ }
+ }, this),
+ dataType: 'json'
+ });
+ },
+ stopAudioPlaylistUpdate: function() {
+ this.autoRefreshAudioPlaylist = false;
+ this.updateActiveItemDurationRunOnce = false;
+ },
+ stopVideoPlaylistUpdate: function() {
+ this.autoRefreshVideoPlaylist = false;
+ this.updateActiveItemDurationRunOnce = false;
+ },
+ updateActiveItemDurationLoop: function() {
+ this.activeItemTimer = 0;
+ this.updatePlayer();
+ },
+ refreshAudioDataLoop: function() {
+ this.audioRefreshTimer = 0;
+ this.refreshAudioData();
+ },
+ refreshAudioData: function() {
+ if (this.autoRefreshAudioData && !this.audioRefreshTimer) {
+ this.audioRefreshTimer = 1;
+ setTimeout(jQuery.proxy(this.refreshAudioDataLoop, this), 1000);
+ }
+ if (this.playing && !this.paused) {
+ this.trackBaseTime++;
+ }
+ if (this.paused) {
+ this.showPlayButton();
+ } else if (this.playing) {
+ this.showPauseButton();
+ }
+ if (this.activePlaylistItem) {
+ if (this.activePlaylistItem != this.lastPlaylistItem) {
+ this.lastPlaylistItem = this.activePlaylistItem;
+ var imgPath = DEFAULT_ALBUM_COVER;
+ if (this.activePlaylistItem.thumbnail) {
+ imgPath = (this.activePlaylistItem.thumbnail.startsWith('special://') ? '/vfs/' : 'images/') + this.activePlaylistItem.thumbnail;
+ }
+ $('#audioCoverArt').html('<img src="' + imgPath + '" alt="' + this.activePlaylistItem.album + ' cover art">');
+ $('#audioTrackTitle').html('<span title="' + this.activePlaylistItem.title + '">' + this.activePlaylistItem.title + '</span>');
+ if (this.activePlaylistItem.album) {
+ $('#audioAlbumTitle').html('<span title="' + this.activePlaylistItem.album + '">' + this.activePlaylistItem.album + '</span>')
+ .show();
+ } else {
+ $('#audioAlbumTitle').hide();
+ }
+ $('#audioArtistTitle').html(this.activePlaylistItem.artist);
+ $('#progressBar').attr('style', '');
+ }
+ $('#audioDuration').html(durationToString(this.trackBaseTime) + ' / ' + durationToString(this.trackDurationTime));
+ var buttonWidth = $('#progressBar .progressIndicator').width();
+ var progressBarWidth = (this.trackBaseTime / this.trackDurationTime) * 100;
+ var progressSliderPosition = Math.ceil(($('#progressBar').width() / 100) * progressBarWidth) - buttonWidth;
+ if (progressSliderPosition < 0) {
+ progressSliderPosition = 0;
+ }
+ if (progressBarWidth <= 100) {
+ $('#progressBar .elapsedTime').width(progressBarWidth + '%');
+ $('#progressBar .progressIndicator').css('left', progressSliderPosition);
+ }
+ }
+ },
+ refreshVideoDataLoop: function() {
+ this.videoRefreshTimer = 0;
+ this.refreshVideoData();
+ },
+ refreshVideoData: function() {
+ if (this.autoRefreshVideoData && !this.videoRefreshTimer) {
+ this.videoRefreshTimer = 1;
+ setTimeout(jQuery.proxy(this.refreshVideoDataLoop, this), 1500);
+ }
+ if (this.playing && !this.paused) {
+ this.trackBaseTime++;
+ }
+ if (this.paused) {
+ this.showPlayButton();
+ } else if (this.playing) {
+ this.showPauseButton();
+ }
+ if (this.activePlaylistItem) {
+ if (this.activePlaylistItem != this.lastPlaylistItem) {
+ this.lastPlaylistItem = this.activePlaylistItem;
+ var imgPath = DEFAULT_VIDEO_COVER;
+ if (this.activePlaylistItem.thumbnail) {
+ imgPath = (this.activePlaylistItem.thumbnail.startsWith('special://') ? '/vfs/' : 'images/') + this.activePlaylistItem.thumbnail;
+ }
+ $('#videoCoverArt').html('<img src="' + imgPath + '" alt="' + this.activePlaylistItem.title + ' cover art">');
+ $('#videoShowTitle').html(this.activePlaylistItem.showtitle||'&nbsp;');
+ var extra = '';
+ if (this.activePlaylistItem.season >= 0 && this.activePlaylistItem.episode >= 0) {
+ extra = this.activePlaylistItem.season + 'x' + this.activePlaylistItem.episode + ' ';
+ }
+ $('#videoTitle').html(extra + this.activePlaylistItem.title);
+ }
+ $('#videoDuration').html(durationToString(this.trackBaseTime) + ' / ' + durationToString(this.trackDurationTime));
+ var buttonWidth = $('#progressBar .progressIndicator').width();
+ var progressBarWidth = (this.trackBaseTime / this.trackDurationTime) * 100;
+ var progressSliderPosition = Math.ceil(($('#progressBar').width() / 100) * progressBarWidth) - buttonWidth;
+ if (progressSliderPosition < 0) {
+ progressSliderPosition = 0;
+ }
+ if (progressBarWidth <= 100) {
+ $('#progressBar .elapsedTime').width(progressBarWidth + '%');
+ $('#progressBar .progressIndicator').css('left', progressSliderPosition);
+ }
+ }
+ },
+ stopRefreshTime: function() {
+ this.autoRefreshAudioData = false;
+ this.autoRefreshVideoData = false;
+ },
+ comparePlaylistItems: function(item1, item2) {
+ if (!item1 || !item2) {
+ if (!item1 && !item2) {
+ return true;
+ }
+ return false;
+ }
+ if (item1.title != item2.title) {
+ return false;
+ }
+ if (item1.album != item2.album) {
+ return false;
+ }
+ if (item1.artist != item2.artist) {
+ return false;
+ }
+ if (item1.duration != item2.duration) {
+ return false;
+ }
+ if (item1.label != item2.label) {
+ return false;
+ }
+ if (item1.season != item2.season) {
+ return false;
+ }
+ if (item1.episode != item2.episode) {
+ return false;
+ }
+ return true;
+ },
+ updateVideoPlaylist: function() {
+ jQuery.ajax({
+ type: 'POST',
+ url: JSON_RPC + '?updateVideoPlaylist',
+ data: '{"jsonrpc": "2.0", "method": "Playlist.GetItems", "params": { "playlistid": ' + this.playlistid + ', "properties": ["title", "season", "episode", "plot", "runtime", "showtitle","thumbnail"] }, "id": 1}',
+ success: jQuery.proxy(function(data) {
+ if (data && data.result && data.result.items && data.result.items.length > 0 && data.result.limits.total > 0) {
+ //Compare new playlist to active playlist, only redraw if a change is noticed.
+ if (this.playlistChanged(data.result.items)) {
+ var ul = $('<ul>');
+ var activeItem;
+ $.each($(data.result.items), jQuery.proxy(function(i, item) {
+ var li = $('<li>');
+ var extra = '';
+ if (item.season >= 0 && item.episode >= 0) {
+ extra = item.season + 'x' + item.episode + ' ';
+ }
+ var code = '<span class="duration">' + durationToString(item.runtime) + '</span><div class="trackInfo" title="' + extra + item.title + '"><span class="trackTitle">' + extra + item.title + '</span></div>';
+ if (i == this.currentItem) {
+ activeItem = item;
+ activeItem.seq = i;
+ li.addClass('activeItem');
+ }
+ if (i == (this.currentItem + 1)) {
+ $('#nextTrack').html(code).show();
+ }
+ li.bind('click', jQuery.proxy(this.playPlaylistItem, this));
+ ul.append(li.attr('seq', i).html(code));
+ }, this));
+ if (data.result.limits.total > 1) {
+ $('#nextText').show();
+ if (activeItem && data.result.limits.total == activeItem.seq) {
+ $('#nextTrack').html('<div class="trackInfo">Last track in playlist</div>').show();
+ }
+ $('#nowPlayingPlaylist').html('').append(ul);
+ } else {
+ $('#nextText').hide();
+ $('#nowPlayingPlaylist').hide();
+ $('#nextTrack').hide();
+ }
+ if (!this.comparePlaylistItems(activeItem, this.activePlaylistItem)) {
+ this.activePlaylistItem = activeItem;
+ if (!this.updateActiveItemDurationRunOnce) {
+ this.updateActiveItemDurationRunOnce = true;
+ this.updatePlayer();
+ }
+ } else if (!activeItem) {
+ this.stopRefreshTime();
+ }
+ this.activePlaylist = data.result.items;
+ $('#videoDescription').show();
+ $('#audioDescription').hide();
+ $('#nowPlayingPanel').show();
}
- }, this), 'json');
- },
- bindPlaybackControls: function() {
- $('#pbNext').bind('click', jQuery.proxy(this.nextTrack, this));
- $('#pbPrev').bind('click', jQuery.proxy(this.prevTrack, this));
- $('#pbStop').bind('click', jQuery.proxy(this.stopTrack, this));
- $('#pbPlay').bind('click', jQuery.proxy(this.playPauseTrack, this));
- $('#pbPause').bind('click', jQuery.proxy(this.playPauseTrack, this));
- },
- showPlaylist: function() {
- $('#nextText').html('Playlist: ');
- $('#nowPlayingPlaylist').show();
- return false;
- },
- hidePlaylist: function() {
- $('#nextText').html('Next: ');
- $('#nowPlayingPlaylist').hide();
- return false;
- },
- hideFooter: function() {
- $('#footerPopover').hide();
- $('#overlay').css('bottom','0px');
- },
- showFooter: function() {
- $('#footerPopover').show();
- $('#overlay').css('bottom','150px');
- },
- nextTrack: function() {
- if (this.activePlayer) {
- jQuery.post(JSON_RPC + '?SkipNext', '{"jsonrpc": "2.0", "method": "Player.GoNext", "params": { "playerid": ' + this.activePlayerId + ' }, "id": 1}', jQuery.proxy(function(data) {
- if (data && data.result == 'OK') {
- //this.updateAudioPlaylist(true);
- }
- }, this), 'json');
- }
- },
- prevTrack: function() {
- if (this.activePlayer) {
- jQuery.post(JSON_RPC + '?SkipPrevious', '{"jsonrpc": "2.0", "method": "Player.GoPrevious", "params": { "playerid": ' + this.activePlayerId + ' }, "id": 1}', jQuery.proxy(function(data) {
- if (data && data.result == 'OK') {
- //this.updateAudioPlaylist(true);
- }
- }, this), 'json');
- }
- },
- stopTrack: function() {
- if (this.activePlayer) {
- jQuery.post(JSON_RPC + '?Stop', '{"jsonrpc": "2.0", "method": "Player.Stop", "params": { "playerid": ' + this.activePlayerId + ' }, "id": 1}', jQuery.proxy(function(data) {
- if (data && data.result == 'OK') {
- this.playing = false;
- this.paused = false;
- this.trackBaseTime = 0;
- this.trackDurationTime = 0;
- this.showPlayButton();
- }
- }, this), 'json');
- }
- },
- playPauseTrack: function() {
- if (this.activePlayer) {
- var method = ((this.playing || this.paused) ? 'Player.PlayPause' : 'Playlist.Play');
- jQuery.post(JSON_RPC + '?PlayPause', '{"jsonrpc": "2.0", "method": "' + method + '", "params": { "playerid": ' + this.activePlayerId + ' }, "id": 1}', jQuery.proxy(function(data) {
- if (data && data.result) {
- this.playing = data.result.speed != 0;
- this.paused = data.result.speed == 0;
- if (this.playing) {
- this.showPauseButton();
- } else {
- this.showPlayButton();
- }
- }
- }, this), 'json');
- }
- },
- showPauseButton: function() {
- $('#pbPause').show();
- $('#pbPlay').hide();
- },
- showPlayButton: function() {
- $('#pbPause').hide();
- $('#pbPlay').show();
- },
- displayAudioNowPlaying: function() {
- if (!this.autoRefreshAudioPlaylist) {
- this.autoRefreshAudioPlaylist = true;
- this.updateAudioPlaylist();
- }
- },
- displayVideoNowPlaying: function() {
- if (!this.autoRefreshVideoPlaylist) {
- this.autoRefreshVideoPlaylist = true;
- this.updateVideoPlaylist();
- }
- },
- playPlaylistItem: function(sender) {
- var sequenceId = $(sender.currentTarget).attr('seq');
- if (!this.activePlaylistItem || (this.activePlaylistItem !== undefined && sequenceId != this.activePlaylistItem.seq)) {
- jQuery.post(JSON_RPC + '?PlaylistItemPlay', '{"jsonrpc": "2.0", "method": "Player.GoTo", "params": { "playerid": ' + this.activePlayerId + ', "item": ' + sequenceId + '}, "id": 1}', function() {}, 'json');
- }
- this.hidePlaylist();
- },
- playlistChanged: function(newPlaylist) {
- if (this.activePlaylist && !newPlaylist || !this.activePlaylist && newPlaylist) {
- return true;
- }
- if (!this.activePlaylist && !newPlaylist) {
- return false;
- }
- if (this.activePlaylist.length != newPlaylist.length) {
- return true;
- }
- for (var i = 0; i < newPlaylist.length; i++) {
- if (!this.comparePlaylistItems(this.activePlaylist[i], newPlaylist[i])) {
- return true;
- }
- }
- return false;
- },
- updateAudioPlaylist: function() {
- jQuery.ajax({
- type: 'POST',
- url: JSON_RPC + '?updateAudioPlaylist',
- data: '{"jsonrpc": "2.0", "method": "Playlist.GetItems", "params": { "playlistid": ' + this.playlistid + ', "properties": [ "title", "album", "artist", "duration", "thumbnail" ] }, "id": 1}',
- success: jQuery.proxy(function(data) {
- if (data && data.result && data.result.items && data.result.items.length > 0 && data.result.limits.total > 0) {
- //Compare new playlist to active playlist, only redraw if a change is noticed
- if (!this.activePlaylistItem || this.playlistChanged(data.result.items) || (this.activePlaylistItem && (this.activePlaylistItem.seq != this.currentItem))) {
- var ul = $('<ul>');
- var activeItem;
- $.each($(data.result.items), jQuery.proxy(function(i, item) {
- var li = $('<li>');
- var code = '<span class="duration">' + durationToString(item.duration) + '</span><div class="trackInfo" title="' + item.title + ' - ' + item.artist + '"><span class="trackTitle">' + item.title + '</span> - <span class="trackArtist">' + item.artist + '</span></div>';
- if (i == this.currentItem) {
- activeItem = item;
- activeItem.seq = i;
- li.addClass('activeItem');
- }
- if (i == (this.currentItem + 1)) {
- $('#nextTrack').html(code).show();
- }
- li.bind('click', jQuery.proxy(this.playPlaylistItem, this));
- ul.append(li.attr('seq', i).html(code));
- }, this));
- if (data.result.limits.total > 1) {
- if (activeItem && data.result.limits.total-1 == activeItem.seq) {
- $('#nextTrack').html('<div class="trackInfo">Last track in playlist</div>').show();
- }
- $('#nextText').show();
- $('#nowPlayingPlaylist').html('').append(ul);
- } else {
- $('#nextText').hide();
- $('#nowPlayingPlaylist').hide();
- $('#nextTrack').hide();
- }
- if (!this.comparePlaylistItems(activeItem, this.activePlaylistItem)) {
- this.activePlaylistItem = activeItem;
- if (!this.updateActiveItemDurationRunOnce) {
- this.updateActiveItemDurationRunOnce = true;
- this.updatePlayer();
- }
- } else if (!activeItem) {
- this.stopRefreshTime();
- }
- this.activePlaylist = data.result.items;
- $('#videoDescription').hide();
- $('#audioDescription').show();
- $('#nowPlayingPanel').show();
- }
- } else {
- this.activePlaylist = null;
- $('#audioDescription').hide();
- $('#nowPlayingPanel').hide();
- }
- if (this.autoRefreshAudioPlaylist) {
- setTimeout(jQuery.proxy(this.updateAudioPlaylist, this), 1000);
- }
- }, this),
- error: jQuery.proxy(function(data) {
- displayCommunicationError();
- if (this.autoRefreshAudioPlaylist) {
- setTimeout(jQuery.proxy(this.updateAudioPlaylist, this), 2000); /* Slow down request period */
- }
- }, this),
- dataType: 'json'
- });
- },
- stopAudioPlaylistUpdate: function() {
- this.autoRefreshAudioPlaylist = false;
- this.updateActiveItemDurationRunOnce = false;
- },
- stopVideoPlaylistUpdate: function() {
- this.autoRefreshVideoPlaylist = false;
- this.updateActiveItemDurationRunOnce = false;
- },
- updateActiveItemDurationLoop: function() {
- this.activeItemTimer = 0;
- this.updatePlayer();
- },
- refreshAudioDataLoop: function() {
- this.audioRefreshTimer = 0;
- this.refreshAudioData();
- },
- refreshAudioData: function() {
- if (this.autoRefreshAudioData && !this.audioRefreshTimer) {
- this.audioRefreshTimer = 1;
- setTimeout(jQuery.proxy(this.refreshAudioDataLoop, this), 1000);
- }
- if (this.playing && !this.paused) {
- this.trackBaseTime++;
- }
- if (this.paused) {
- this.showPlayButton();
- } else if (this.playing) {
- this.showPauseButton();
- }
- if (this.activePlaylistItem) {
- if (this.activePlaylistItem != this.lastPlaylistItem) {
- this.lastPlaylistItem = this.activePlaylistItem;
- var imgPath = DEFAULT_ALBUM_COVER;
- if (this.activePlaylistItem.thumbnail) {
- imgPath = (this.activePlaylistItem.thumbnail.startsWith('special://') ? '/vfs/' : 'images/') + this.activePlaylistItem.thumbnail;
- }
- $('#audioCoverArt').html('<img src="' + imgPath + '" alt="' + this.activePlaylistItem.album + ' cover art">');
- $('#audioTrackTitle').html('<span title="' + this.activePlaylistItem.title + '">' + this.activePlaylistItem.title + '</span>');
- if (this.activePlaylistItem.album) {
- $('#audioAlbumTitle').html('<span title="' + this.activePlaylistItem.album + '">' + this.activePlaylistItem.album + '</span>')
- .show();
- } else {
- $('#audioAlbumTitle').hide();
- }
- $('#audioArtistTitle').html(this.activePlaylistItem.artist);
- $('#progressBar').attr('style', '');
- }
- $('#audioDuration').html(durationToString(this.trackBaseTime) + ' / ' + durationToString(this.trackDurationTime));
- var buttonWidth = $('#progressBar .progressIndicator').width();
- var progressBarWidth = (this.trackBaseTime / this.trackDurationTime) * 100;
- var progressSliderPosition = Math.ceil(($('#progressBar').width() / 100) * progressBarWidth) - buttonWidth;
- if (progressSliderPosition < 0) {
- progressSliderPosition = 0;
- }
- if (progressBarWidth <= 100) {
- $('#progressBar .elapsedTime').width(progressBarWidth + '%');
- $('#progressBar .progressIndicator').css('left', progressSliderPosition);
- }
- }
- },
- refreshVideoDataLoop: function() {
- this.videoRefreshTimer = 0;
- this.refreshVideoData();
- },
- refreshVideoData: function() {
- if (this.autoRefreshVideoData && !this.videoRefreshTimer) {
- this.videoRefreshTimer = 1;
- setTimeout(jQuery.proxy(this.refreshVideoDataLoop, this), 1500);
- }
- if (this.playing && !this.paused) {
- this.trackBaseTime++;
- }
- if (this.paused) {
- this.showPlayButton();
- } else if (this.playing) {
- this.showPauseButton();
- }
- if (this.activePlaylistItem) {
- if (this.activePlaylistItem != this.lastPlaylistItem) {
- this.lastPlaylistItem = this.activePlaylistItem;
- var imgPath = DEFAULT_VIDEO_COVER;
- if (this.activePlaylistItem.thumbnail) {
- imgPath = (this.activePlaylistItem.thumbnail.startsWith('special://') ? '/vfs/' : 'images/') + this.activePlaylistItem.thumbnail;
- }
- $('#videoCoverArt').html('<img src="' + imgPath + '" alt="' + this.activePlaylistItem.title + ' cover art">');
- $('#videoShowTitle').html(this.activePlaylistItem.showtitle||'&nbsp;');
- var extra = '';
- if (this.activePlaylistItem.season >= 0 && this.activePlaylistItem.episode >= 0) {
- extra = this.activePlaylistItem.season + 'x' + this.activePlaylistItem.episode + ' ';
- }
- $('#videoTitle').html(extra + this.activePlaylistItem.title);
- }
- $('#videoDuration').html(durationToString(this.trackBaseTime) + ' / ' + durationToString(this.trackDurationTime));
- var buttonWidth = $('#progressBar .progressIndicator').width();
- var progressBarWidth = (this.trackBaseTime / this.trackDurationTime) * 100;
- var progressSliderPosition = Math.ceil(($('#progressBar').width() / 100) * progressBarWidth) - buttonWidth;
- if (progressSliderPosition < 0) {
- progressSliderPosition = 0;
- }
- if (progressBarWidth <= 100) {
- $('#progressBar .elapsedTime').width(progressBarWidth + '%');
- $('#progressBar .progressIndicator').css('left', progressSliderPosition);
- }
- }
- },
- stopRefreshTime: function() {
- this.autoRefreshAudioData = false;
- this.autoRefreshVideoData = false;
- },
- comparePlaylistItems: function(item1, item2) {
- if (!item1 || !item2) {
- if (!item1 && !item2) {
- return true;
- }
- return false;
- }
- if (item1.title != item2.title) {
- return false;
- }
- if (item1.album != item2.album) {
- return false;
- }
- if (item1.artist != item2.artist) {
- return false;
- }
- if (item1.duration != item2.duration) {
- return false;
- }
- if (item1.label != item2.label) {
- return false;
- }
- if (item1.season != item2.season) {
- return false;
- }
- if (item1.episode != item2.episode) {
- return false;
- }
- return true;
- },
- updateVideoPlaylist: function() {
- jQuery.ajax({
- type: 'POST',
- url: JSON_RPC + '?updateVideoPlaylist',
- data: '{"jsonrpc": "2.0", "method": "Playlist.GetItems", "params": { "playlistid": ' + this.playlistid + ', "properties": ["title", "season", "episode", "plot", "runtime", "showtitle","thumbnail"] }, "id": 1}',
- success: jQuery.proxy(function(data) {
- if (data && data.result && data.result.items && data.result.items.length > 0 && data.result.limits.total > 0) {
- //Compare new playlist to active playlist, only redraw if a change is noticed.
- if (this.playlistChanged(data.result.items)) {
- var ul = $('<ul>');
- var activeItem;
- $.each($(data.result.items), jQuery.proxy(function(i, item) {
- var li = $('<li>');
- var extra = '';
- if (item.season >= 0 && item.episode >= 0) {
- extra = item.season + 'x' + item.episode + ' ';
- }
- var code = '<span class="duration">' + durationToString(item.runtime) + '</span><div class="trackInfo" title="' + extra + item.title + '"><span class="trackTitle">' + extra + item.title + '</span></div>';
- if (i == this.currentItem) {
- activeItem = item;
- activeItem.seq = i;
- li.addClass('activeItem');
- }
- if (i == (this.currentItem + 1)) {
- $('#nextTrack').html(code).show();
- }
- li.bind('click', jQuery.proxy(this.playPlaylistItem, this));
- ul.append(li.attr('seq', i).html(code));
- }, this));
- if (data.result.limits.total > 1) {
- $('#nextText').show();
- if (activeItem && data.result.limits.total == activeItem.seq) {
- $('#nextTrack').html('<div class="trackInfo">Last track in playlist</div>').show();
- }
- $('#nowPlayingPlaylist').html('').append(ul);
- } else {
- $('#nextText').hide();
- $('#nowPlayingPlaylist').hide();
- $('#nextTrack').hide();
- }
- if (!this.comparePlaylistItems(activeItem, this.activePlaylistItem)) {
- this.activePlaylistItem = activeItem;
- if (!this.updateActiveItemDurationRunOnce) {
- this.updateActiveItemDurationRunOnce = true;
- this.updatePlayer();
- }
- } else if (!activeItem) {
- this.stopRefreshTime();
- }
- this.activePlaylist = data.result.items;
- $('#videoDescription').show();
- $('#audioDescription').hide();
- $('#nowPlayingPanel').show();
- }
- } else {
- this.activePlaylist = null;
- $('#videoDescription').hide();
- $('#nowPlayingPanel').hide();
- }
- if (this.autoRefreshVideoPlaylist) {
- setTimeout(jQuery.proxy(this.updateVideoPlaylist, this), 1000);
- }
- }, this),
- error: jQuery.proxy(function(data) {
- displayCommunicationError();
- if (this.autoRefreshVideoPlaylist) {
- setTimeout(jQuery.proxy(this.updateVideoPlaylist, this), 2000); /* Slow down request period */
- }
- }, this),
- dataType: 'json'
- });
- }
- }
+ } else {
+ this.activePlaylist = null;
+ $('#videoDescription').hide();
+ $('#nowPlayingPanel').hide();
+ }
+ if (this.autoRefreshVideoPlaylist) {
+ setTimeout(jQuery.proxy(this.updateVideoPlaylist, this), 1000);
+ }
+ }, this),
+ error: jQuery.proxy(function(data) {
+ displayCommunicationError();
+ if (this.autoRefreshVideoPlaylist) {
+ setTimeout(jQuery.proxy(this.updateVideoPlaylist, this), 2000); /* Slow down request period */
+ }
+ }, this),
+ dataType: 'json'
+ });
+ }
+}