aboutsummaryrefslogtreecommitdiff
path: root/addons/webinterface.default/js
diff options
context:
space:
mode:
authorasylumfunk <asylumfunk@asylumfunk.com>2012-10-06 11:58:15 -0700
committerasylumfunk <asylumfunk@asylumfunk.com>2012-10-06 13:39:12 -0700
commitfb58bfab63889bee3a3d1cc2eac14ad175e0eebd (patch)
treeaf46e1359bd9efc7918672cbee6ed01406237f1c /addons/webinterface.default/js
parent5717f4094c8b6f6451aeb40aae5fb5b252cb53f9 (diff)
cleanup - no more global variables
- removed unused prototype definitions - explicitly access the local window - cleaned up logic, declared all implied variables - renamed file to follow convention - updated copyright year
Diffstat (limited to 'addons/webinterface.default/js')
-rw-r--r--addons/webinterface.default/js/Core.js91
-rwxr-xr-xaddons/webinterface.default/js/MediaLibrary.js96
-rwxr-xr-xaddons/webinterface.default/js/NowPlayingManager.js44
-rw-r--r--addons/webinterface.default/js/xbmc.core.js90
-rw-r--r--addons/webinterface.default/js/xbmc.init.js2
-rw-r--r--addons/webinterface.default/js/xbmc.launcher.js4
6 files changed, 163 insertions, 164 deletions
diff --git a/addons/webinterface.default/js/Core.js b/addons/webinterface.default/js/Core.js
deleted file mode 100644
index aae947f2d6..0000000000
--- a/addons/webinterface.default/js/Core.js
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2005-2011 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-/* Global Paths */
-var commsErrorTimeout;
-var JSON_RPC = 'jsonrpc';
-var DEFAULT_ALBUM_COVER = 'images/DefaultAlbumCover.png';
-var DEFAULT_VIDEO_COVER = 'images/DefaultVideo.png';
-
-/* Prototypes */
-
-String.prototype.startsWith = function(prefix) {
- return this.indexOf(prefix) === 0;
-}
-
-String.prototype.endsWith = function(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;
-}
-
-function timeToDuration(time) {
- return time.hours * 3600 + time.minutes * 60 + time.seconds;
-}
-
-function applyDeviceFixes() {
- document.addEventListener('touchmove', function(e){ e.preventDefault(); });
-}
-
-function displayCommunicationError(m) {
- clearTimeout(commsErrorTimeout);
- var message = m || 'Connection to server lost';
- $('#commsErrorPanel').html(message).show();
- commsErrorTimeout = setTimeout('hideCommunicationError()', 5000);
-}
-
-function hideCommunicationError() {
- $('#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=/";
-}
-
-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;
-}
-
diff --git a/addons/webinterface.default/js/MediaLibrary.js b/addons/webinterface.default/js/MediaLibrary.js
index 3a5271fcf8..576833c850 100755
--- a/addons/webinterface.default/js/MediaLibrary.js
+++ b/addons/webinterface.default/js/MediaLibrary.js
@@ -69,7 +69,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?GetPlaylists',
+ url: xbmc.core.JSON_RPC + '?GetPlaylists',
data: '{"jsonrpc": "2.0", "method": "Playlist.GetPlaylists", "id": 1}',
timeout: 3000,
success: jQuery.proxy(function(data) {
@@ -80,7 +80,7 @@ MediaLibrary.prototype = {
}
}, this),
error: jQuery.proxy(function(data, error) {
- displayCommunicationError();
+ xbmc.core.displayCommunicationError();
setTimeout(jQuery.proxy(this.updateState, this), 2000);
}, this),
dataType: 'json'});
@@ -156,7 +156,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "AudioLibrary.Clean", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -167,7 +167,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "AudioLibrary.Scan", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -178,7 +178,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -189,7 +189,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -200,7 +200,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "Input.Back", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -211,7 +211,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "Input.Home", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -222,7 +222,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ 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();
@@ -233,7 +233,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "System.Shutdown", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -244,14 +244,14 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": { "properties": [ "volume" ] }, "id": 1}',
success: jQuery.proxy(function(data) {
var volume = data.result.volume + 1;
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ 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();
@@ -264,14 +264,14 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": { "properties": [ "volume" ] }, "id": 1}',
success: jQuery.proxy(function(data) {
var volume = data.result.volume - 1;
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ 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();
@@ -287,7 +287,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "Input.Up", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -298,7 +298,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "Input.Down", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -309,7 +309,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "Input.Left", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -320,7 +320,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "Input.Right", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -331,7 +331,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ url: xbmc.core.JSON_RPC + '?SendRemoteKey',
data: '{"jsonrpc": "2.0", "method": "Input.Select", "id": 1}',
success: jQuery.proxy(function(data) {
$('#spinner').hide();
@@ -347,7 +347,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ 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();
@@ -358,7 +358,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ 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();
@@ -369,7 +369,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ 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();
@@ -380,7 +380,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ 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();
@@ -391,7 +391,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ 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();
@@ -402,7 +402,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SendRemoteKey',
+ 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();
@@ -427,7 +427,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?GetAlbums',
+ 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) {
if (data && data.result && data.result.albums) {
@@ -453,7 +453,7 @@ MediaLibrary.prototype = {
}
},
getThumbnailPath: function(thumbnail) {
- return thumbnail ? ('image/' + encodeURI(thumbnail)) : DEFAULT_ALBUM_COVER;
+ return thumbnail ? ('image/' + encodeURI(thumbnail)) : xbmc.core.DEFAULT_ALBUM_COVER;
},
generateThumb: function(type, thumbnail, title, artist) {
var floatableAlbum = $('<div>');
@@ -538,7 +538,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?GetSongs',
+ 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) {
albumDetailsContainer = $('<div>');
@@ -572,7 +572,7 @@ MediaLibrary.prototype = {
trackRow.append(trackTitleTD);
var trackDurationTD = $('<td>')
.addClass('time')
- .html(durationToString(item.duration));
+ .html(xbmc.core.durationToString(item.duration));
trackRow.append(trackDurationTD);
var trackArtistTD = $('<td>')
@@ -620,21 +620,21 @@ MediaLibrary.prototype = {
$("#toggleLandscape").removeClass('activeMode');
switch(view) {
case 'poster':
- setCookie('TVView','poster');
+ xbmc.core.setCookie('TVView','poster');
wthumblist='135px';
hthumblist='199px';
hthumbdetails='559px';
$("#togglePoster").addClass('activeMode');
break;
case 'landscape':
- setCookie('TVView','landscape');
+ xbmc.core.setCookie('TVView','landscape');
wthumblist='210px';
hthumblist='118px';
hthumbdetails='213px';
$("#toggleLandscape").addClass('activeMode');
break;
default: //set banner view as default
- setCookie('TVView','banner');
+ xbmc.core.setCookie('TVView','banner');
wthumblist='379px';
hthumblist='70px';
hthumbdetails='70px';
@@ -654,7 +654,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?GetTVShowSeasons',
+ 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) {
tvshowDetailsContainer = $('<div>');
@@ -692,8 +692,8 @@ MediaLibrary.prototype = {
tvshowDetailsContainer.append(showThumb);
seasonSelectionSelect.trigger('change');
$('#content').append(tvshowDetailsContainer);
- if(getCookie('TVView')!=null && getCookie('TVView')!='banner'){
- var view=getCookie('TVView');
+ if(xbmc.core.getCookie('TVView')!=null && xbmc.core.getCookie('TVView')!='banner'){
+ var view=xbmc.core.getCookie('TVView');
switch(view) {
case 'poster':
togglePoster.trigger('click');
@@ -727,7 +727,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?GetTVSeasonEpisodes',
+ 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) {
var episodeListingsContainer = $('<div>').addClass('episodeListingsContainer');
@@ -789,7 +789,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?AddTvShowToPlaylist',
+ 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) {
this.hideOverlay();
@@ -828,7 +828,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?PlayMovie',
+ 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) {
this.hideOverlay();
@@ -868,21 +868,21 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?ClearPlaylist',
+ 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: JSON_RPC + '?AddAlbumToPlaylist',
+ 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: JSON_RPC + '?PlaylistItemPlay',
+ 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),
@@ -902,7 +902,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?GetMovies',
+ 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) {
if (data && data.result && data.result.movies) {
@@ -958,7 +958,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?GetTVShows',
+ 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) {
if (data && data.result && data.result.tvshows) {
@@ -980,8 +980,8 @@ MediaLibrary.prototype = {
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');
+ if(xbmc.core.getCookie('TVView')!=null && xbmc.core.getCookie('TVView')!='banner') {
+ var view=xbmc.core.getCookie('TVView');
switch(view) {
case 'poster':
togglePoster.trigger('click');
@@ -1010,7 +1010,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?StartSlideshow',
+ 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),
@@ -1028,7 +1028,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?GetDirectory',
+ 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) {
if (data && data.result && ( data.result.directories || data.result.files )) {
@@ -1093,7 +1093,7 @@ MediaLibrary.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?GetSources',
+ url: xbmc.core.JSON_RPC + '?GetSources',
data: '{"jsonrpc": "2.0", "method": "Files.GetSources", "params": { "media" : "pictures" }, "id": 1}',
success: jQuery.proxy(function(data) {
if (data && data.result && data.result.shares) {
diff --git a/addons/webinterface.default/js/NowPlayingManager.js b/addons/webinterface.default/js/NowPlayingManager.js
index d32d657d0a..0a6dfdc689 100755
--- a/addons/webinterface.default/js/NowPlayingManager.js
+++ b/addons/webinterface.default/js/NowPlayingManager.js
@@ -44,7 +44,7 @@ NowPlayingManager.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?UpdateState',
+ url: xbmc.core.JSON_RPC + '?UpdateState',
data: '{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}',
timeout: 3000,
success: jQuery.proxy(function(data) {
@@ -93,7 +93,7 @@ NowPlayingManager.prototype = {
setTimeout(jQuery.proxy(this.updateState, this), 1000);
}, this),
error: jQuery.proxy(function(data, error) {
- displayCommunicationError();
+ xbmc.core.displayCommunicationError();
setTimeout(jQuery.proxy(this.updateState, this), 2000);
}, this),
dataType: 'json'});
@@ -102,7 +102,7 @@ NowPlayingManager.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?UpdatePlayer',
+ url: xbmc.core.JSON_RPC + '?UpdatePlayer',
data: '{"jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "playerid": ' + this.activePlayerId + ', "properties": [ "playlistid", "speed", "position", "totaltime", "time" ] }, "id": 1}',
success: jQuery.proxy(function(data) {
if (data && data.result)
@@ -111,8 +111,8 @@ NowPlayingManager.prototype = {
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);
+ this.trackBaseTime = xbmc.core.timeToDuration(data.result.time);
+ this.trackDurationTime = xbmc.core.timeToDuration(data.result.totaltime);
if (!this.autoRefreshAudioData && !this.autoRefreshVideoData && this.playing) {
if (this.activePlayer == 'audio') {
this.autoRefreshAudioData = true;
@@ -160,7 +160,7 @@ NowPlayingManager.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SkipNext',
+ url: xbmc.core.JSON_RPC + '?SkipNext',
data: '{"jsonrpc": "2.0", "method": "Player.GoTo", "params": { "playerid": ' + this.activePlayerId + ', "to": "next" }, "id": 1}',
success: jQuery.proxy(function(data) {
if (data && data.result == 'OK') {
@@ -175,7 +175,7 @@ NowPlayingManager.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?SkipPrevious',
+ url: xbmc.core.JSON_RPC + '?SkipPrevious',
data: '{"jsonrpc": "2.0", "method": "Player.GoTo", "params": { "playerid": ' + this.activePlayerId + ', "to": "previous" }, "id": 1}',
success: jQuery.proxy(function(data) {
if (data && data.result == 'OK') {
@@ -190,7 +190,7 @@ NowPlayingManager.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?Stop',
+ url: xbmc.core.JSON_RPC + '?Stop',
data: '{"jsonrpc": "2.0", "method": "Player.Stop", "params": { "playerid": ' + this.activePlayerId + ' }, "id": 1}',
success: jQuery.proxy(function(data) {
if (data && data.result == 'OK') {
@@ -210,7 +210,7 @@ NowPlayingManager.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?PlayPause',
+ url: xbmc.core.JSON_RPC + '?PlayPause',
data: '{"jsonrpc": "2.0", "method": "' + method + '", "params": { "playerid": ' + this.activePlayerId + ' }, "id": 1}',
success: jQuery.proxy(function(data) {
if (data && data.result) {
@@ -252,7 +252,7 @@ NowPlayingManager.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?PlaylistItemPlay',
+ url: xbmc.core.JSON_RPC + '?PlaylistItemPlay',
data: '{"jsonrpc": "2.0", "method": "Player.GoTo", "params": { "playerid": ' + this.activePlayerId + ', "to": ' + sequenceId + '}, "id": 1}',
success: jQuery.proxy(function(data) {
@@ -282,7 +282,7 @@ NowPlayingManager.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?updateAudioPlaylist',
+ url: xbmc.core.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) {
@@ -292,7 +292,7 @@ NowPlayingManager.prototype = {
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>';
+ var code = '<span class="duration">' + xbmc.core.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;
@@ -339,7 +339,7 @@ NowPlayingManager.prototype = {
}
}, this),
error: jQuery.proxy(function(data) {
- displayCommunicationError();
+ xbmc.core.displayCommunicationError();
if (this.autoRefreshAudioPlaylist) {
setTimeout(jQuery.proxy(this.updateAudioPlaylist, this), 2000); /* Slow down request period */
}
@@ -379,7 +379,7 @@ NowPlayingManager.prototype = {
if (this.activePlaylistItem) {
if (this.activePlaylistItem != this.lastPlaylistItem) {
this.lastPlaylistItem = this.activePlaylistItem;
- var imgPath = DEFAULT_ALBUM_COVER;
+ var imgPath = xbmc.core.DEFAULT_ALBUM_COVER;
if (this.activePlaylistItem.thumbnail) {
imgPath = 'image/' + encodeURI(this.activePlaylistItem.thumbnail);
}
@@ -394,7 +394,7 @@ NowPlayingManager.prototype = {
$('#audioArtistTitle').html(this.activePlaylistItem.artist);
$('#progressBar').attr('style', '');
}
- $('#audioDuration').html(durationToString(this.trackBaseTime) + ' / ' + durationToString(this.trackDurationTime));
+ $('#audioDuration').html(xbmc.core.durationToString(this.trackBaseTime) + ' / ' + xbmc.core.durationToString(this.trackDurationTime));
var buttonWidth = $('#progressBar .progressIndicator').width();
var progressBarWidth = (this.trackBaseTime / this.trackDurationTime) * 100;
var progressSliderPosition = Math.ceil(($('#progressBar').width() / 100) * progressBarWidth) - buttonWidth;
@@ -427,7 +427,7 @@ NowPlayingManager.prototype = {
if (this.activePlaylistItem) {
if (this.activePlaylistItem != this.lastPlaylistItem) {
this.lastPlaylistItem = this.activePlaylistItem;
- var imgPath = DEFAULT_VIDEO_COVER;
+ var imgPath = xbmc.core.DEFAULT_VIDEO_COVER;
if (this.activePlaylistItem.thumbnail) {
imgPath = 'image/' + encodeURI(this.activePlaylistItem.thumbnail);
}
@@ -439,7 +439,7 @@ NowPlayingManager.prototype = {
}
$('#videoTitle').html(extra + this.activePlaylistItem.title);
}
- $('#videoDuration').html(durationToString(this.trackBaseTime) + ' / ' + durationToString(this.trackDurationTime));
+ $('#videoDuration').html(xbmc.core.durationToString(this.trackBaseTime) + ' / ' + xbmc.core.durationToString(this.trackDurationTime));
var buttonWidth = $('#progressBar .progressIndicator').width();
var progressBarWidth = (this.trackBaseTime / this.trackDurationTime) * 100;
var progressSliderPosition = Math.ceil(($('#progressBar').width() / 100) * progressBarWidth) - buttonWidth;
@@ -490,7 +490,7 @@ NowPlayingManager.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?updateVideoPlaylist',
+ url: xbmc.core.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) {
@@ -504,7 +504,7 @@ NowPlayingManager.prototype = {
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>';
+ var code = '<span class="duration">' + xbmc.core.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;
@@ -545,7 +545,7 @@ NowPlayingManager.prototype = {
jQuery.ajax({
type: 'POST',
contentType: 'application/json',
- url: JSON_RPC + '?updateVideoPlayer',
+ url: xbmc.core.JSON_RPC + '?updateVideoPlayer',
data: '{"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "playerid": ' + this.playlistid + ', "properties": ["title", "season", "episode", "plot", "runtime", "showtitle","thumbnail"] }, "id": 1}',
success: jQuery.proxy(function(data) {
if (data && data.result && data.result.item) {
@@ -570,7 +570,7 @@ NowPlayingManager.prototype = {
}
}, this),
error: jQuery.proxy(function(data) {
- displayCommunicationError();
+ xbmc.core.displayCommunicationError();
if (this.autoRefreshVideoPlaylist) {
setTimeout(jQuery.proxy(this.updateVideoPlaylist, this), 2000); /* Slow down request period */
}
@@ -583,7 +583,7 @@ NowPlayingManager.prototype = {
}
}, this),
error: jQuery.proxy(function(data) {
- displayCommunicationError();
+ xbmc.core.displayCommunicationError();
if (this.autoRefreshVideoPlaylist) {
setTimeout(jQuery.proxy(this.updateVideoPlaylist, this), 2000); /* Slow down request period */
}
diff --git a/addons/webinterface.default/js/xbmc.core.js b/addons/webinterface.default/js/xbmc.core.js
new file mode 100644
index 0000000000..00830a7a2f
--- /dev/null
+++ b/addons/webinterface.default/js/xbmc.core.js
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+(function (window) {
+ "use strict";
+
+ var xbmc = window.xbmc || {};
+ xbmc.core = {
+ 'DEFAULT_ALBUM_COVER': 'images/DefaultAlbumCover.png',
+ 'DEFAULT_VIDEO_COVER': 'images/DefaultVideo.png',
+ 'JSON_RPC': 'jsonrpc',
+ 'applyDeviceFixes': function () {
+ window.document.addEventListener('touchmove', function (e) {
+ e.preventDefault();
+ });
+ },
+ 'displayCommunicationError': function (m) {
+ window.clearTimeout(xbmc.core.commsErrorTiemout);
+ var message = m || 'Connection to server lost';
+ $('#commsErrorPanel').html(message).show();
+ xbmc.core.commsErrorTiemout = window.setTimeout('xbmc.core.hideCommunicationError()', 5000);
+ },
+ 'durationToString': function (duration) {
+ var total_seconds = duration || 0,
+ seconds = total_seconds % 60,
+ minutes = Math.floor(total_seconds / 60) % 60,
+ hours = Math.floor(total_seconds / 3600),
+ result = ((hours > 0 && ((hours < 10 ? '0' : '') + hours + ':')) || '');
+ result += (minutes < 10 ? '0' : '') + minutes + ':';
+ result += (seconds < 10 ? '0' : '') + seconds;
+ return result;
+ },
+ 'getCookie': function (name) {
+ var i,
+ match,
+ haystack = window.document.cookie.split(';');
+ for (i = 0; i < haystack.length; i += 1) {
+ match = haystack[i].match(/^\s*[\S\s]*=([\s\S]*)\s*$/);
+ if (match && match.length === 2) {
+ return match[1];
+ }
+ }
+ return null;
+ },
+ 'hideCommunicationError': function () {
+ $('#commsErrorPanel').hide();
+ },
+ 'setCookie': function (name, value, days) {
+ var date,
+ expires;
+ if (name) {
+ if (days) {
+ date = new Date();
+ date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
+ expires = "; expires=" + date.toGMTString();
+ } else {
+ expires = '';
+ }
+ window.document.cookie = name + "=" + value + expires + "; path=/";
+ }
+ },
+ 'timeToDuration': function (time) {
+ var duration;
+ time = time || {};
+ duration = ((time.hours || 0) * 3600);
+ duration += ((time.minutes || 0) * 60);
+ duration += (time.seconds || 0);
+ return duration;
+ }
+ };
+
+ window.xbmc = xbmc;
+}(window));
diff --git a/addons/webinterface.default/js/xbmc.init.js b/addons/webinterface.default/js/xbmc.init.js
index 66cf63f577..05a4124967 100644
--- a/addons/webinterface.default/js/xbmc.init.js
+++ b/addons/webinterface.default/js/xbmc.init.js
@@ -23,6 +23,6 @@
var mediaLibrary = new MediaLibrary(),
nowPlayingManager = new NowPlayingManager();
- applyDeviceFixes();
+ xbmc.core.applyDeviceFixes();
}());
diff --git a/addons/webinterface.default/js/xbmc.launcher.js b/addons/webinterface.default/js/xbmc.launcher.js
index 6877a208ca..0f29e51bab 100644
--- a/addons/webinterface.default/js/xbmc.launcher.js
+++ b/addons/webinterface.default/js/xbmc.launcher.js
@@ -24,12 +24,12 @@
var i,
script,
debug = false, /* Set to true to disable cached javascript */
- version = (debug ? Math.random() : '2.0.5'),
+ version = (debug ? Math.random() : '2.0.6'),
scripts = [
"js/jquery-1.5.2.min.js",
"js/jquery.lazyload.js",
"js/iscroll-min.js",
- "js/Core.js",
+ "js/xbmc.core.js",
"js/MediaLibrary.js",
"js/NowPlayingManager.js",
"js/xbmc.init.js"