aboutsummaryrefslogtreecommitdiff
path: root/addons/webinterface.default/js/MediaLibrary.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/webinterface.default/js/MediaLibrary.js')
-rwxr-xr-xaddons/webinterface.default/js/MediaLibrary.js834
1 files changed, 384 insertions, 450 deletions
diff --git a/addons/webinterface.default/js/MediaLibrary.js b/addons/webinterface.default/js/MediaLibrary.js
index 576833c850..0d8faf6daf 100755
--- a/addons/webinterface.default/js/MediaLibrary.js
+++ b/addons/webinterface.default/js/MediaLibrary.js
@@ -30,7 +30,6 @@ MediaLibrary.prototype = {
this.bindControls();
this.getPlaylists();
},
-
bindControls: function() {
$('#musicLibrary').click(jQuery.proxy(this.musicLibraryOpen, this));
$('#movieLibrary').click(jQuery.proxy(this.movieLibraryOpen, this));
@@ -48,42 +47,26 @@ MediaLibrary.prototype = {
$('#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;
+ replaceAll: function(haystack, needle, thread) {
+ return (haystack || '').split(needle || '').join(thread || '');
},
-
getPlaylists: function() {
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?GetPlaylists',
- data: '{"jsonrpc": "2.0", "method": "Playlist.GetPlaylists", "id": 1}',
- timeout: 3000,
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'Playlist.GetPlaylists',
+ 'timeout': 3000,
+ 'success': 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) {
+ },
+ 'error': function(data, error) {
xbmc.core.displayCommunicationError();
setTimeout(jQuery.proxy(this.updateState, this), 2000);
- }, this),
- dataType: 'json'});
+ }
+ });
},
remoteControlOpen: function(event) {
this.resetPage();
@@ -94,7 +77,7 @@ MediaLibrary.prototype = {
$('#spinner').show();
libraryContainer = $('<div>');
libraryContainer.attr('id', 'remoteContainer')
- .addClass('contentContainer');
+ .addClass('contentContainer');
$('#content').append(libraryContainer);
var keys=[
{name:'up',width:'40px',height:'30px',top:'28px',left:'58px'}
@@ -126,12 +109,9 @@ MediaLibrary.prototype = {
.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');
@@ -139,280 +119,163 @@ MediaLibrary.prototype = {
$('#spinner').hide();
},
-
pressRemoteKey: function(event) {
- var keyPressed=event.data.key;
+ var player = -1,
+ 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 'up':
+ return xbmc.rpc.request({
+ 'method': 'Input.Up'
+ });
+ case 'down':
+ return xbmc.rpc.request({
+ 'method': 'Input.Down'
+ });
+ case 'left':
+ return xbmc.rpc.request({
+ 'method': 'Input.Left'
+ });
+ case 'right':
+ return xbmc.rpc.request({
+ 'method': 'Input.Right'
+ });
+ case 'ok':
+ return xbmc.rpc.request({
+ 'method': 'Input.Select'
+ });
case 'cleanlib_a':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "AudioLibrary.Clean", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'AudioLibrary.Clean'
+ });
case 'updatelib_a':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "AudioLibrary.Scan", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'AudioLibrary.Scan'
+ });
case 'cleanlib_v':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'VideoLibrary.Clean'
+ });
case 'updatelib_v':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'VideoLibrary.Scan'
+ });
case 'back':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Input.Back", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'Input.Back'
+ });
case 'home':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Input.Home", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'Input.Home'
+ });
case 'mute':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Application.SetMute", "params": { "mute": "toggle" }, "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'Application.SetMute',
+ 'params': {
+ 'mute': 'toggle'
+ }
+ });
case 'power':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "System.Shutdown", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'System.Shutdown'
+ });
case 'volumeup':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": { "properties": [ "volume" ] }, "id": 1}',
- success: jQuery.proxy(function(data) {
+ return xbmc.rpc.request({
+ 'method': 'Application.GetProperties',
+ 'params': {
+ 'properties': [
+ 'volume'
+ ]
+ },
+ 'success': function(data) {
var volume = data.result.volume + 1;
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Application.SetVolume", "params": { "volume": '+volume+' }, "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- }, this),
- dataType: 'json'});
- return;
+ xbmc.rpc.request({
+ 'method': 'Application.SetVolume',
+ 'params': {
+ 'volume': volume
+ }
+ });
+ }
+ });
case 'volumedown':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": { "properties": [ "volume" ] }, "id": 1}',
- success: jQuery.proxy(function(data) {
+ return xbmc.rpc.request({
+ 'method': 'Application.GetProperties',
+ 'params': {
+ 'properties': [
+ 'volume'
+ ]
+ },
+ 'success': function(data) {
var volume = data.result.volume - 1;
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Application.SetVolume", "params": { "volume": '+volume+' }, "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- }, this),
- dataType: 'json'});
- return;
+ xbmc.rpc.request({
+ 'method': 'Application.SetVolume',
+ 'params': {
+ 'volume': volume
+ }
+ });
+ }
+ });
}
- switch(keyPressed) {
- case 'up':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Input.Up", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
- case 'down':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Input.Down", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
- case 'left':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Input.Left", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
- case 'right':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Input.Right", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
- case 'ok':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Input.Select", "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
- }
+ // TODO: Get active player
+ if($('#videoDescription').is(':visible'))
+ player = this.playlists["video"];
+ else if($('#audioDescription').is(':visible'))
+ player = this.playlists["audio"];
if (player >= 0)
{
switch(keyPressed) {
case 'playpause':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": ' + player + ' }, "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'Player.PlayPause',
+ 'params': {
+ 'playerid': player
+ }
+ });
case 'stop':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Player.Stop", "params": { "playerid": ' + player + ' }, "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'Player.Stop',
+ 'params': {
+ 'playerid': player
+ }
+ });
case 'next':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Player.GoTo", "params": { "playerid": ' + player + ', "to": "next" }, "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'Player.GoTo',
+ 'params': {
+ 'playerid': player,
+ 'to': 'next'
+ }
+ });
case 'previous':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Player.GoTo", "params": { "playerid": ' + player + ', "to": "previous" }, "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'Player.GoTo',
+ 'params': {
+ 'playerid': player,
+ 'to': 'previous'
+ }
+ });
case 'forward':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Player.SetSpeed", "params": { "playerid": ' + player + ', "speed": "increment" }, "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'Player.SetSpeed',
+ 'params': {
+ 'playerid': player,
+ 'speed': 'increment'
+ }
+ });
case 'rewind':
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?SendRemoteKey',
- data: '{"jsonrpc": "2.0", "method": "Player.SetSpeed", "params": { "playerid": ' + player + ', "speed": "decrement" }, "id": 1}',
- success: jQuery.proxy(function(data) {
- $('#spinner').hide();
- }, this),
- dataType: 'json'});
- return;
+ return xbmc.rpc.request({
+ 'method': 'Player.SetSpeed',
+ 'params': {
+ 'playerid': player,
+ 'speed': 'decrement'
+ }
+ });
}
}
},
-
musicLibraryOpen: function(event) {
this.resetPage();
$('#musicLibrary').addClass('selected');
@@ -422,14 +285,34 @@ MediaLibrary.prototype = {
$('#spinner').show();
libraryContainer = $('<div>');
libraryContainer.attr('id', 'libraryContainer')
- .addClass('contentContainer');
+ .addClass('contentContainer');
$('#content').append(libraryContainer);
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?GetAlbums',
- data: '{"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}',
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'AudioLibrary.GetAlbums',
+ 'params': {
+ 'limits': {
+ 'start': 0
+ },
+ 'properties': [
+ 'description',
+ 'theme',
+ 'mood',
+ 'style',
+ 'type',
+ 'albumlabel',
+ 'artist',
+ 'genre',
+ 'rating',
+ 'title',
+ 'year',
+ 'thumbnail'
+ ],
+ 'sort': {
+ 'method': 'artist'
+ }
+ },
+ 'success': function(data) {
if (data && data.result && data.result.albums) {
this.albumList = data.result.albums;
$.each($(this.albumList), jQuery.proxy(function(i, item) {
@@ -445,8 +328,8 @@ MediaLibrary.prototype = {
} else {
libraryContainer.html('');
}
- }, this),
- dataType: 'json'});
+ }
+ });
} else {
libraryContainer.show();
libraryContainer.trigger('scroll');
@@ -493,7 +376,6 @@ MediaLibrary.prototype = {
},
showAlbumSelectorBlock: function(album) {
if (album) {
- //Find album in stored array
var prevAlbum = null,
nextAlbum = null;
$.each($(this.albumList), jQuery.proxy(function(i, item) {
@@ -509,7 +391,7 @@ MediaLibrary.prototype = {
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>');
+ .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));
}
@@ -535,17 +417,30 @@ MediaLibrary.prototype = {
$('#topScrollFade').hide();
if (!albumDetailsContainer || albumDetailsContainer.length == 0) {
$('#spinner').show();
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?GetSongs',
- data: '{"jsonrpc": "2.0", "method": "AudioLibrary.GetSongs", "params": { "properties": ["title", "artist", "genre", "track", "duration", "year", "rating", "playcount"], "filter": { "albumid" : ' + event.data.album.albumid + ' } }, "id": 1}',
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'AudioLibrary.GetSongs',
+ 'params': {
+ 'properties': [
+ 'title',
+ 'artist',
+ 'genre',
+ 'track',
+ 'duration',
+ 'year',
+ 'rating',
+ 'playcount'
+ ],
+ 'filter': {
+ 'albumid' : event.data.album.albumid
+ }
+ },
+ 'success': 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>');
+ .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;
@@ -604,14 +499,13 @@ MediaLibrary.prototype = {
.append($('<div>').addClass('footerPadding'));
$('#spinner').hide();
myScroll = new iScroll('albumDetails' + event.data.album.albumid);
- }, this),
- dataType: 'json'});
+ }
+ });
} else {
$('.contentContainer').hide();
$('#albumDetails' + event.data.album.albumid).show();
}
},
-
togglePosterView: function(event){
var view=event.data.mode;
var wthumblist,hthumblist,hthumbdetails;
@@ -633,7 +527,7 @@ MediaLibrary.prototype = {
hthumbdetails='213px';
$("#toggleLandscape").addClass('activeMode');
break;
- default: //set banner view as default
+ default:
xbmc.core.setCookie('TVView','banner');
wthumblist='379px';
hthumblist='70px';
@@ -644,49 +538,45 @@ MediaLibrary.prototype = {
$(".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.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?GetTVShowSeasons',
- data: '{"jsonrpc": "2.0", "method": "VideoLibrary.GetSeasons", "params": { "properties": [ "season", "showtitle", "playcount", "episode", "thumbnail","fanart" ], "tvshowid" : ' + event.data.tvshow.tvshowid + ' }, "id": 1}',
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'VideoLibrary.GetSeasons',
+ 'params': {
+ 'properties': [
+ 'season',
+ 'showtitle',
+ 'playcount',
+ 'episode',
+ 'thumbnail',
+ 'fanart'
+ ],
+ 'tvshowid' : event.data.tvshow.tvshowid
+ },
+ 'success': function(data) {
tvshowDetailsContainer = $('<div>');
tvshowDetailsContainer.attr('id', 'tvShowDetails' + event.data.tvshow.tvshowid)
- .css('display', 'none')
- .addClass('contentContainer')
- .addClass('tvshowContainer');
+ .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;
+ $.each($(data.result.seasons), function(i, item) {
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);
@@ -706,8 +596,8 @@ MediaLibrary.prototype = {
tvshowDetailsContainer.fadeIn();
}
$('#spinner').hide();
- }, this),
- dataType: 'json'});
+ }
+ });
} else {
$('.contentContainer').hide();
$('#tvShowDetails' + event.data.tvshow.tvshowid).show();
@@ -715,21 +605,26 @@ MediaLibrary.prototype = {
}
},
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.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?GetTVSeasonEpisodes',
- data: '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "properties": [ "title", "thumbnail","episode","plot","season"], "season" : ' + seasons[selectedVal].season + ', "tvshowid" : ' + event.data.tvshow + ' }, "id": 1}',
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'VideoLibrary.GetEpisodes',
+ 'params': {
+ 'properties': [
+ 'title',
+ 'thumbnail',
+ 'episode',
+ 'plot',
+ 'season'
+ ],
+ 'season': seasons[selectedVal].season,
+ 'tvshowid': event.data.tvshow
+ },
+ 'success': 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) {
@@ -745,10 +640,9 @@ MediaLibrary.prototype = {
}, this));
episodeListingsContainer.append(episodeTable);
$(this.tvActiveShowContainer).append(episodeListingsContainer);
- }, this),
- dataType: '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)));
@@ -773,9 +667,6 @@ MediaLibrary.prototype = {
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));
}
@@ -784,17 +675,19 @@ MediaLibrary.prototype = {
$('#overlay').show();
this.updatePlayButtonLocation();
},
-
playTVShow: function(event) {
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?AddTvShowToPlaylist',
- data: '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "episodeid": ' + event.data.episode.episodeid + ' } }, "id": 1}',
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'Player.Open',
+ 'params': {
+ 'item': {
+ 'episodeid': event.data.episode.episodeid
+ }
+ },
+ 'success': function(data) {
this.hideOverlay();
- }, this),
- dataType: 'json'});
+ }
+ });
},
hideOverlay: function(event) {
if (this.activeCover) {
@@ -825,15 +718,18 @@ MediaLibrary.prototype = {
}
},
playMovie: function(event) {
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?PlayMovie',
- data: '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "movieid": ' + event.data.movie.movieid + ' } }, "id": 1}',
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'Player.Open',
+ 'params': {
+ 'item': {
+ 'movieid': event.data.movie.movieid
+ }
+ },
+ 'success': function(data) {
this.hideOverlay();
- }, this),
- dataType: 'json'});
+ }
+ });
},
displayMovieDetails: function(event) {
var movieDetails = $('<div>').attr('id', 'movie-' + event.data.movie.movieid).addClass('moviePopoverContainer');
@@ -853,9 +749,6 @@ MediaLibrary.prototype = {
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));
}
@@ -865,32 +758,37 @@ MediaLibrary.prototype = {
this.updatePlayButtonLocation();
},
playTrack: function(event) {
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?ClearPlaylist',
- data: '{"jsonrpc": "2.0", "method": "Playlist.Clear", "params": { "playlistid": ' + this.playlists["audio"] + ' }, "id": 1}',
- success: jQuery.proxy(function(data) {
- //check that clear worked.
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?AddAlbumToPlaylist',
- data: '{"jsonrpc": "2.0", "method": "Playlist.Add", "params": { "playlistid": ' + this.playlists["audio"] + ', "item": { "albumid": ' + event.data.album.albumid + ' } }, "id": 1}',
- success: jQuery.proxy(function(data) {
- //play specific song in playlist
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?PlaylistItemPlay',
- data: '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "playlistid": ' + this.playlists["audio"] + ', "position": '+ event.data.itmnbr + ' } }, "id": 1}',
- success: jQuery.proxy(function(data) {
- }, this),
- dataType: 'json'});
- }, this),
- dataType: 'json'});
- }, this),
- dataType: 'json'});
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'Playlist.Clear',
+ 'params': {
+ 'playlistid': this.playlists["audio"]
+ },
+ 'success': function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'Playlist.Add',
+ 'params': {
+ 'playlistid': this.playlists["audio"],
+ 'item': {
+ 'albumid': event.data.album.albumid
+ }
+ },
+ 'success': function(data) {
+ xbmc.rpc.request({
+ 'method': 'Player.Open',
+ 'params': {
+ 'item': {
+ 'playlistid': this.playlists["audio"],
+ 'position': event.data.itmnbr
+ }
+ },
+ 'success': function() {}
+ });
+ }
+ });
+ }
+ });
},
movieLibraryOpen: function() {
this.resetPage();
@@ -899,12 +797,36 @@ MediaLibrary.prototype = {
var libraryContainer = $('#movieLibraryContainer');
if (!libraryContainer || libraryContainer.length == 0) {
$('#spinner').show();
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?GetMovies',
- data: '{"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}',
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ '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
+ }
+ },
+ 'success': function(data) {
if (data && data.result && data.result.movies) {
libraryContainer = $('<div>');
libraryContainer.attr('id', 'movieLibraryContainer')
@@ -913,7 +835,6 @@ MediaLibrary.prototype = {
} 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));
@@ -923,10 +844,9 @@ MediaLibrary.prototype = {
$('#spinner').hide();
libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
libraryContainer.trigger('scroll');
- //$('#libraryContainer img').lazyload();
myScroll = new iScroll('movieLibraryContainer');
- }, this),
- dataType: 'json'});
+ }
+ });
} else {
libraryContainer.show();
libraryContainer.trigger('scroll');
@@ -942,31 +862,45 @@ MediaLibrary.prototype = {
toggle=$('<p>').addClass('toggle');
togglePoster= $('<span>Poster</span>');
togglePoster.attr('id', 'togglePoster')
- .css('cursor','pointer')
- .bind('click',{mode: 'poster'},jQuery.proxy(this.togglePosterView,this));
+ .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));
+ .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));
+ .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.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?GetTVShows',
- data: '{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "properties": ["genre", "plot", "title", "lastplayed", "episode", "year", "playcount", "rating", "thumbnail", "studio", "mpaa", "premiered"] }, "id": 1}',
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'VideoLibrary.GetTVShows',
+ 'params': {
+ 'properties': [
+ 'genre',
+ 'plot',
+ 'title',
+ 'lastplayed',
+ 'episode',
+ 'year',
+ 'playcount',
+ 'rating',
+ 'thumbnail',
+ 'studio',
+ 'mpaa',
+ 'premiered'
+ ]
+ },
+ 'success': function(data) {
if (data && data.result && data.result.tvshows) {
- libraryContainer = $('<div>');
- libraryContainer.append(toggle);
- libraryContainer.attr('id', 'tvshowLibraryContainer')
- .addClass('contentContainer');
- $('#content').append(libraryContainer);
+ libraryContainer = $('<div>');
+ libraryContainer.append(toggle);
+ libraryContainer.attr('id', 'tvshowLibraryContainer')
+ .addClass('contentContainer');
+ $('#content').append(libraryContainer);
} else {
libraryContainer.html('');
}
@@ -991,13 +925,12 @@ MediaLibrary.prototype = {
break;
}
}
- }, this),
- dataType: 'json'});
+ }
+ });
} else {
libraryContainer.prepend($(".toggle").detach()).show();
libraryContainer.trigger('scroll');
}
-
},
updateScrollEffects: function(event) {
if (event.data.activeLibrary && $(event.data.activeLibrary).scrollTop() > 0) {
@@ -1007,14 +940,17 @@ MediaLibrary.prototype = {
}
},
startSlideshow: function(event) {
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?StartSlideshow',
- data: '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recursive" : "true", "random": "true", "path" : "' + this.replaceAll(event.data.directory.file, "\\", "\\\\") + '" } }, "id": 1}',
- success: jQuery.proxy(function(data) {
- }, this),
- dataType: 'json'});
+ xbmc.rpc.request({
+ 'method': 'Player.Open',
+ 'params': {
+ 'item': {
+ 'recursive': 'true',
+ 'random': 'true',
+ 'path' : this.replaceAll(event.data.directory.file, "\\", "\\\\")
+ }
+ },
+ 'success': function() {}
+ });
},
showDirectory: function(event) {
var directory = event.data.directory.file;
@@ -1025,16 +961,18 @@ MediaLibrary.prototype = {
var libraryContainer = $('#pictureLibraryDirContainer' + directory);
if (!libraryContainer || libraryContainer.length == 0) {
$('#spinner').show();
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?GetDirectory',
- data: '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": { "media" : "pictures", "directory": "' + jsonDirectory + '" }, "id": 1}',
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'Files.GetDirectory',
+ 'params': {
+ 'media' : 'pictures',
+ 'directory': jsonDirectory
+ },
+ 'success': function(data) {
if (data && data.result && ( data.result.directories || data.result.files )) {
libraryContainer = $('<div>');
libraryContainer.attr('id', 'pictureLibraryDirContainer' + directory)
- .addClass('contentContainer');
+ .addClass('contentContainer');
$('#content').append(libraryContainer);
var breadcrumb = $('<div>');
var seperator = '/';
@@ -1043,7 +981,6 @@ MediaLibrary.prototype = {
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'));
}
});
@@ -1060,10 +997,6 @@ MediaLibrary.prototype = {
{
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));
@@ -1076,8 +1009,8 @@ MediaLibrary.prototype = {
libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
libraryContainer.trigger('scroll');
myScroll = new iScroll('#pictureLibraryDirContainer' + directory);
- }, this),
- dataType: 'json'});
+ }
+ });
} else {
libraryContainer.show();
libraryContainer.trigger('scroll');
@@ -1090,16 +1023,17 @@ MediaLibrary.prototype = {
var libraryContainer = $('#pictureLibraryContainer');
if (!libraryContainer || libraryContainer.length == 0) {
$('#spinner').show();
- jQuery.ajax({
- type: 'POST',
- contentType: 'application/json',
- url: xbmc.core.JSON_RPC + '?GetSources',
- data: '{"jsonrpc": "2.0", "method": "Files.GetSources", "params": { "media" : "pictures" }, "id": 1}',
- success: jQuery.proxy(function(data) {
+ xbmc.rpc.request({
+ 'context': this,
+ 'method': 'Files.GetSources',
+ 'params': {
+ 'media' : 'pictures'
+ },
+ 'success': function(data) {
if (data && data.result && data.result.shares) {
libraryContainer = $('<div>');
libraryContainer.attr('id', 'pictureLibraryContainer')
- .addClass('contentContainer');
+ .addClass('contentContainer');
$('#content').append(libraryContainer);
} else {
libraryContainer.html('');
@@ -1114,11 +1048,11 @@ MediaLibrary.prototype = {
libraryContainer.bind('scroll', { activeLibrary: libraryContainer }, jQuery.proxy(this.updateScrollEffects, this));
libraryContainer.trigger('scroll');
myScroll = new iScroll('#pictureLibraryContainer');
- }, this),
- dataType: 'json'});
+ }
+ });
} else {
libraryContainer.show();
libraryContainer.trigger('scroll');
}
}
-} \ No newline at end of file
+}