2.3.6 undo basic auth

This commit is contained in:
Trevor Squillario 2012-12-06 21:40:11 -05:00
parent 8643f01647
commit 53ed1bc0d4
11 changed files with 1261 additions and 1239 deletions

View file

@ -24,12 +24,12 @@
<script src="js/plugins/jquery.scrollTo-1.4.2-min.js" type="text/javascript"></script> <script src="js/plugins/jquery.scrollTo-1.4.2-min.js" type="text/javascript"></script>
<script src="js/jplayer/jquery.jplayer.min.js" type="text/javascript"></script> <script src="js/jplayer/jquery.jplayer.min.js" type="text/javascript"></script>
<script src="js/fancybox/jquery.fancybox.pack.js" type="text/javascript"></script> <script src="js/fancybox/jquery.fancybox.pack.js" type="text/javascript"></script>
<script src="js/libs/api.js" type="text/javascript"></script>
<script src="js/libs/utils.js" type="text/javascript"></script> <script src="js/libs/utils.js" type="text/javascript"></script>
<script src="js/app.js" type="text/javascript"></script>
<script src="js/libs/api.js" type="text/javascript"></script>
<script src="js/libs/chat.js" type="text/javascript"></script> <script src="js/libs/chat.js" type="text/javascript"></script>
<script src="js/libs/generators.js" type="text/javascript"></script> <script src="js/libs/generators.js" type="text/javascript"></script>
<script src="js/libs/player.js" type="text/javascript"></script> <script src="js/libs/player.js" type="text/javascript"></script>
<script src="js/app.js" type="text/javascript"></script>
<script src="js/ui-ready.js" type="text/javascript"></script> <script src="js/ui-ready.js" type="text/javascript"></script>
<script src="js/ui-load.js" type="text/javascript"></script> <script src="js/ui-load.js" type="text/javascript"></script>
</head> </head>
@ -224,6 +224,7 @@
<div class="clear"></div> <div class="clear"></div>
<div class="subsection floatleft"> <div class="subsection floatleft">
<h3 class="title">Options</h3> <h3 class="title">Options</h3>
<label class="red">* Refresh (F5) required</label><br />
<label for="Theme">Theme</label><br /> <label for="Theme">Theme</label><br />
<select id="Theme" name="Theme" class="large"> <select id="Theme" name="Theme" class="large">
<option value="default">Default</option> <option value="default">Default</option>
@ -236,7 +237,7 @@
<input type="text" id="AutoAlbumSize" name="AutoAlbumSize" class="large" title="Number of Albums to Get on the Music Library tab"/><br /> <input type="text" id="AutoAlbumSize" name="AutoAlbumSize" class="large" title="Number of Albums to Get on the Music Library tab"/><br />
<label for="AutoPlaylistSize">Auto Playlist Size (Default 25)</label><br /> <label for="AutoPlaylistSize">Auto Playlist Size (Default 25)</label><br />
<input type="text" id="AutoPlaylistSize" name="AutoPlaylistSize" class="large" title="Number of Songs to Get on the Playlist tab"/><br /> <input type="text" id="AutoPlaylistSize" name="AutoPlaylistSize" class="large" title="Number of Songs to Get on the Playlist tab"/><br />
<label for="ApplicationName">Application Name (Default MiniSub)</label><br /> <label for="ApplicationName">Application Name (Default MiniSub)*</label><br />
<input type="text" id="ApplicationName" name="ApplicationName" class="large" title="Custom Player Name"/><br /> <input type="text" id="ApplicationName" name="ApplicationName" class="large" title="Custom Player Name"/><br />
</div> </div>
<div class="subsection floatleft"> <div class="subsection floatleft">
@ -255,8 +256,11 @@
<div class="inputwrap"><input type="checkbox" id="Debug" name="Debug" value="1" title="Enable Debug Mode (Events will be logged to the Javascript Console)"/></div> <div class="inputwrap"><input type="checkbox" id="Debug" name="Debug" value="1" title="Enable Debug Mode (Events will be logged to the Javascript Console)"/></div>
<label for="Debug">Debug Mode</label> <label for="Debug">Debug Mode</label>
<div class="clear"></div> <div class="clear"></div>
<div class="inputwrap"><input type="checkbox" id="ForceFlash" name="ForceFlash" value="1" title="Force Flash (Option doesn't work with Chrome App)"/></div> <div class="inputwrap"><input type="checkbox" id="ForceFlash" name="ForceFlash" value="1" title="Force Flash Plugin for Audio (Option doesn't work with Chrome App)"/></div>
<label for="ForceFlash">Force Flash </label> <label for="ForceFlash">Force Flash </label>
<div class="clear"></div>
<div class="inputwrap"><input type="checkbox" id="Protocol" name="Protocol" value="1" title="Enable Cross-Domain AJAX Requests (Use if MiniSub is hosted in a different domain than Subsonic)"/></div>
<label for="Protocol">Enable JSONP*</label>
</fieldset> </fieldset>
<div class="clear"></div> <div class="clear"></div>
<fieldset> <fieldset>
@ -296,10 +300,15 @@
<span class="changes">- </span> <span class="changes">- </span>
</li> </li>
--> -->
<li class="log"><span class="version"> - 2.3.6</span>
<span class="changes">- Added Setting to toggle JSONP (This is for cross-domain requests, aka Subsonic is hosted on a different domain than MiniSub)</span>
<span class="changes">- Switched back to URL authentication (Including coverArt)</span>
</li>
<li class="log"><span class="version">12/3/2012 - 2.3.5</span> <li class="log"><span class="version">12/3/2012 - 2.3.5</span>
<span class="changes">- Added keyboard volume controls back. Use the plus (=/+) and minus (-/_) keys</span> <span class="changes">- Added keyboard volume controls back. Use the plus (=/+) and minus (-/_) keys</span>
<span class="changes">- Change Save Current Position to Save Progress, added an indicator next to volume</span> <span class="changes">- Change Save Current Position to Save Progress, added an indicator next to volume</span>
<span class="changes">- Fixed Last.fm scrobble feature, this works again!</span> <span class="changes">- Fixed Last.fm scrobble feature, this works again!</span>
<span class="changes">- Switch to Basic Authentication</span>
</li> </li>
<li class="log"><span class="version">11/27/2012 - 2.3.4</span> <li class="log"><span class="version">11/27/2012 - 2.3.4</span>
<span class="changes">- Basic Breadcrumb navigation implemented</span> <span class="changes">- Basic Breadcrumb navigation implemented</span>

107
js/app.js
View file

@ -2,47 +2,17 @@
var debug = false; var debug = false;
var audio = null; var audio = null;
var hostURL = location.href; var hostURL = location.href;
var protocol = 'json';
var baseURL; var baseURL;
var baseParams;
var apiVersion; var apiVersion;
var username; var username;
var password; var password;
var passwordenc; var passwordenc;
var server; var server;
var smwidth; var smwidth;
var currentVersion = '2.3.5'; var apiVersion = '1.6.0';
var currentVersion = '2.3.6';
function getCookie(value) {
if ($.cookie(value)) {
return $.cookie(value);
} else {
return false;
}
/* jQuery.cookies.js
if (browserStorageCheck) {
var item = localStorage.getItem(value);
if (item != '' && item != undefined) {
return true;
} else {
return false;
}
} else {
if (debug) { console.log('HTML5::loadStorage not supported on your browser' + html.length + ' characters'); }
}
*/
}
function setCookie(key, value) {
$.cookie(key, value, { expires: 365 });
/* jQuery.cookies.js
try {
if (debug) { console.log('Saving : ' + key + ':' + value); }
localStorage.setItem(key, value);
} catch (e) {
if (e == QUOTA_EXCEEDED_ERR) {
alert('Quota exceeded!');
}
}
*/
}
// Get URL Querystring Parameters // Get URL Querystring Parameters
var u = getParameterByName('u'); var u = getParameterByName('u');
@ -64,9 +34,7 @@ if (u && p && s) {
} }
window.location.href = getPathFromUrl(window.location); window.location.href = getPathFromUrl(window.location);
} }
if (getCookie('Server')) {
baseURL = getCookie('Server') + '/rest';
}
var applicationName; var applicationName;
if (getCookie('ApplicationName')) { if (getCookie('ApplicationName')) {
applicationName = getCookie('ApplicationName'); applicationName = getCookie('ApplicationName');
@ -87,65 +55,8 @@ if (getCookie('password')) {
setCookie('passwordenc', 'enc:' + HexEncode(getCookie('password'))); setCookie('passwordenc', 'enc:' + HexEncode(getCookie('password')));
setCookie('password', null); setCookie('password', null);
} }
if (getCookie('Protocol')) {
protocol = 'jsonp';
}
var auth = makeBaseAuth(username, password.substring(4, password.length).hexDecode()); var auth = makeBaseAuth(username, password.substring(4, password.length).hexDecode());
var apiVersion = '1.6.0'; baseParams = 'u=' + username + '&p=' + password + '&f=' + protocol;
function loadTabContent(tab) {
var tabid = '#action_' + tab.substring(1, tab.length);
$("ul.tabs li a").removeClass("active"); //Remove any "active" class
$(tabid).addClass("active"); //Add "active" class to selected tab
$(".tabcontent").hide(); //Hide all tab content
window.location.hash = tab;
switch (tab) {
case '#tabLibrary':
if (debug) { console.log("TAG LIBRARY"); }
if (getCookie('MusicFolders')) {
loadArtists(getCookie('MusicFolders'), false);
} else {
loadArtists();
}
getMusicFolders();
break;
case '#tabQueue':
if (debug) { console.log("TAG QUEUE"); }
var header = generateSongHeaderHTML();
$('#CurrentPlaylistContainer thead').html(header);
var count = $('#CurrentPlaylistContainer tbody tr.song').size();
updateStatus('#status_Current', countCurrentPlaylist('#CurrentPlaylistContainer'));
if (count > 0) {
$('#currentActions a.button').removeClass('disabled');
}
var songid = $('#CurrentPlaylistContainer tbody tr.playing').attr('childid');
if (songid !== undefined) {
$('#CurrentPlaylist').scrollTo($('#' + songid), 400);
}
break;
case '#tabPlaylists':
if (debug) { console.log("TAG PLAYLIST"); }
loadPlaylists();
loadFolders();
loadAutoPlaylists();
updateStatus('#status_Playlists', countCurrentPlaylist('#TrackContainer'));
break;
case '#tabPodcasts':
if (debug) { console.log("TAG PODCAST"); }
loadPodcasts();
updateStatus('#status_Podcasts', countCurrentPlaylist('#PodcastContainer'));
break;
case '#tabVideos':
if (debug) { console.log("TAG VIDEOS"); }
loadVideos(true);
break;
case '#tabPreferences':
getGenres();
break;
default:
break;
}
$(tab).fadeIn('fast'); //Fade in the active ID content
}

View file

@ -1,17 +1,8 @@
/* Ajax Global Setup */
// Inject Basic Auth
$.ajaxSetup({
beforeSend: function (req) {
req.setRequestHeader('Authorization', auth);
}
//headers: { "Authorization": "Basic " + auth }
});
function ping() { function ping() {
$.ajax({ $.ajax({
url: baseURL + '/ping.view?v=1.6.0&c=' + applicationName + '&f=json', url: baseURL + '/ping.view?' + baseParams + '&v=1.6.0&c=' + applicationName,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (data["subsonic-response"].status == 'ok') { if (data["subsonic-response"].status == 'ok') {
@ -35,11 +26,11 @@ function loadArtists(id, refresh) {
} }
var url; var url;
if (id == "all") { if (id == "all") {
url = baseURL + '/getIndexes.view?v=' + apiVersion + '&c=' + applicationName + '&f=json'; url = baseURL + '/getIndexes.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName;
} else if (id) { } else if (id) {
url = baseURL + '/getIndexes.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&musicFolderId=' + id; url = baseURL + '/getIndexes.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&musicFolderId=' + id;
} else { } else {
url = baseURL + '/getIndexes.view?v=' + apiVersion + '&c=' + applicationName + '&f=json'; url = baseURL + '/getIndexes.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName;
} }
if (debug) { console.log(url); } if (debug) { console.log(url); }
var content = $('#ArtistContainer').html(); var content = $('#ArtistContainer').html();
@ -48,7 +39,7 @@ function loadArtists(id, refresh) {
$.ajax({ $.ajax({
url: url, url: url,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
done: function () { if (debug) { console.log("DONE!"); } }, done: function () { if (debug) { console.log("DONE!"); } },
error: function () { if (debug) { console.log("ERROR!"); } }, error: function () { if (debug) { console.log("ERROR!"); } },
@ -148,13 +139,12 @@ function loadArtists(id, refresh) {
} }
function getMusicFolders() { function getMusicFolders() {
$.ajax({ $.ajax({
url: baseURL + '/getMusicFolders.view?v=' + apiVersion + '&c=' + applicationName + '&f=json', url: baseURL + '/getMusicFolders.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (data["subsonic-response"].musicFolders.musicFolder !== undefined) { if (data["subsonic-response"].musicFolders.musicFolder !== undefined) {
// There is a bug in the API that doesn't return a JSON array for one artist
var folders = []; var folders = [];
if (data["subsonic-response"].musicFolders.musicFolder.length > 0) { if (data["subsonic-response"].musicFolders.musicFolder.length > 0) {
folders = data["subsonic-response"].musicFolders.musicFolder; folders = data["subsonic-response"].musicFolders.musicFolder;
@ -219,9 +209,9 @@ function loadAutoPlaylists(refresh) {
} }
function getAlbums(id, action, appendto) { function getAlbums(id, action, appendto) {
$.ajax({ $.ajax({
url: baseURL + '/getMusicDirectory.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + id, url: baseURL + '/getMusicDirectory.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + id,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (action == '') { if (action == '') {
@ -235,7 +225,6 @@ function getAlbums(id, action, appendto) {
$('#action_tabLibrary').trigger('click'); $('#action_tabLibrary').trigger('click');
} }
if (data["subsonic-response"].directory.child !== undefined) { if (data["subsonic-response"].directory.child !== undefined) {
// There is a bug in the API that doesn't return a JSON array for one artist
var children = []; var children = [];
if (data["subsonic-response"].directory.child.length > 0) { if (data["subsonic-response"].directory.child.length > 0) {
children = data["subsonic-response"].directory.child; children = data["subsonic-response"].directory.child;
@ -278,9 +267,9 @@ function getAlbums(id, action, appendto) {
/* Currently not being used */ /* Currently not being used */
function getArtist(id, action, appendto) { function getArtist(id, action, appendto) {
$.ajax({ $.ajax({
url: baseURL + '/getArtist.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + id, url: baseURL + '/getArtist.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + id,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (action == '') { if (action == '') {
@ -294,7 +283,6 @@ function getArtist(id, action, appendto) {
$('#action_tabLibrary').trigger('click'); $('#action_tabLibrary').trigger('click');
} }
if (data["subsonic-response"].artist !== undefined) { if (data["subsonic-response"].artist !== undefined) {
// There is a bug in the API that doesn't return a JSON array for one artist
var children = []; var children = [];
if (data["subsonic-response"].artist.album.length > 0) { if (data["subsonic-response"].artist.album.length > 0) {
children = data["subsonic-response"].artist.album; children = data["subsonic-response"].artist.album;
@ -332,14 +320,14 @@ function getAlbumListBy(id, offset) {
size = 15; size = 15;
} }
if (offset > 0) { if (offset > 0) {
url = baseURL + '/getAlbumList.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&size=' + size + '&type=' + id + '&offset=' + offset url = baseURL + '/getAlbumList.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&size=' + size + '&type=' + id + '&offset=' + offset
} else { } else {
url = baseURL + '/getAlbumList.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&size=' + size + '&type=' + id url = baseURL + '/getAlbumList.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&size=' + size + '&type=' + id
} }
$.ajax({ $.ajax({
url: url, url: url,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (data["subsonic-response"].status != 'failed') { if (data["subsonic-response"].status != 'failed') {
@ -347,7 +335,6 @@ function getAlbumListBy(id, offset) {
$("#AlbumContainer tbody").empty(); $("#AlbumContainer tbody").empty();
var header = generateAlbumHeaderHTML(); var header = generateAlbumHeaderHTML();
$("#AlbumContainer thead").html(header); $("#AlbumContainer thead").html(header);
// There is a bug in the API that doesn't return a JSON array for one artist
var albums = []; var albums = [];
if (data["subsonic-response"].albumList.album.length > 0) { if (data["subsonic-response"].albumList.album.length > 0) {
albums = data["subsonic-response"].albumList.album; albums = data["subsonic-response"].albumList.album;
@ -417,9 +404,9 @@ function getRandomSongList(action, appendto, genre, folder) {
getStarred(action, appendto, 'song'); getStarred(action, appendto, 'song');
} else { } else {
$.ajax({ $.ajax({
url: baseURL + '/getRandomSongs.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&size=' + size + genreParams + folderParams, url: baseURL + '/getRandomSongs.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&size=' + size + genreParams + folderParams,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (data["subsonic-response"].randomSongs.song !== undefined) { if (data["subsonic-response"].randomSongs.song !== undefined) {
@ -432,7 +419,6 @@ function getRandomSongList(action, appendto, genre, folder) {
$("#TrackContainer tbody").empty(); $("#TrackContainer tbody").empty();
$(appendto).empty(); $(appendto).empty();
} }
// There is a bug in the API that doesn't return a JSON array for one artist
var items = []; var items = [];
if (data["subsonic-response"].randomSongs.song.length > 0) { if (data["subsonic-response"].randomSongs.song.length > 0) {
items = data["subsonic-response"].randomSongs.song; items = data["subsonic-response"].randomSongs.song;
@ -476,9 +462,9 @@ function getStarred(action, appendto, type) {
size = 25; size = 25;
} }
$.ajax({ $.ajax({
url: baseURL + '/getStarred.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&size=' + size, url: baseURL + '/getStarred.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&size=' + size,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (data["subsonic-response"].starred !== undefined) { if (data["subsonic-response"].starred !== undefined) {
@ -491,7 +477,6 @@ function getStarred(action, appendto, type) {
$("#TrackContainer tbody").empty(); $("#TrackContainer tbody").empty();
$(appendto).empty(); $(appendto).empty();
} }
// There is a bug in the API that doesn't return a JSON array for one artist
var items = []; var items = [];
switch (type) { switch (type) {
case 'artist': case 'artist':
@ -567,9 +552,9 @@ function updateNowPlaying(showPopup) {
updaterNowPlaying = $.periodic({ period: 4000, decay: 1.5, max_period: 30000 }, function () { updaterNowPlaying = $.periodic({ period: 4000, decay: 1.5, max_period: 30000 }, function () {
$.ajax({ $.ajax({
periodic: this, periodic: this,
url: baseURL + '/getNowPlaying.view?v=' + apiVersion + '&c=' + applicationName + '&f=json', url: baseURL + '/getNowPlaying.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (data["subsonic-response"].nowPlaying.entry === undefined) { if (data["subsonic-response"].nowPlaying.entry === undefined) {
@ -604,7 +589,7 @@ function updateNowPlaying(showPopup) {
if (msg.coverArt === undefined) { if (msg.coverArt === undefined) {
coverartSrc = 'images/albumdefault_50.jpg'; coverartSrc = 'images/albumdefault_50.jpg';
} else { } else {
coverartSrc = baseURL + '/getCoverArt.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&size=50&id=' + msg.coverArt; coverartSrc = baseURL + '/getCoverArt.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&size=50&id=' + msg.coverArt;
} }
if (getCookie('Notification_NowPlaying')) { if (getCookie('Notification_NowPlaying')) {
var sid = msg.username + '-' + msg.id; var sid = msg.username + '-' + msg.id;
@ -625,9 +610,9 @@ function stopUpdateNowPlaying() {
function search(type, query) { function search(type, query) {
$.ajax({ $.ajax({
url: baseURL + '/search2.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&query=' + query, url: baseURL + '/search2.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&query=' + query,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
$("#AlbumContainer tbody").empty(); $("#AlbumContainer tbody").empty();
@ -685,9 +670,9 @@ function loadFolders(refresh) {
if (content === "") { if (content === "") {
// Load Folders // Load Folders
$.ajax({ $.ajax({
url: baseURL + '/getMusicFolders.view?v=' + apiVersion + '&c=' + applicationName + '&f=json', url: baseURL + '/getMusicFolders.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
var musicFolders = []; var musicFolders = [];
@ -718,9 +703,9 @@ function loadPlaylists(refresh) {
if (content === "") { if (content === "") {
// Load Playlists // Load Playlists
$.ajax({ $.ajax({
url: baseURL + '/getPlaylists.view?v=' + apiVersion + '&c=' + applicationName + '&f=json', url: baseURL + '/getPlaylists.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
var playlists = []; var playlists = [];
@ -756,10 +741,10 @@ function savePlaylist(playlistid) {
if (songs.length > 0) { if (songs.length > 0) {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: baseURL + '/createPlaylist.view', url: baseURL + '/createPlaylist.view?' + baseParams,
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
data: { v: apiVersion, c: applicationName, f: "json", playlistId: playlistid, songId: songs }, data: { v: apiVersion, c: applicationName, playlistId: playlistid, songId: songs },
success: function () { success: function () {
getPlaylist(playlistid); getPlaylist(playlistid);
updateMessage('Playlist Updated!', true); updateMessage('Playlist Updated!', true);
@ -770,9 +755,9 @@ function savePlaylist(playlistid) {
} }
function getPlaylist(id, action, appendto) { function getPlaylist(id, action, appendto) {
$.ajax({ $.ajax({
url: baseURL + '/getPlaylist.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + id, url: baseURL + '/getPlaylist.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + id,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (data["subsonic-response"].playlist.entry !== undefined) { if (data["subsonic-response"].playlist.entry !== undefined) {
@ -784,7 +769,6 @@ function getPlaylist(id, action, appendto) {
if (action === 'autoplay') { if (action === 'autoplay') {
$(appendto).empty(); $(appendto).empty();
} }
// There is a bug in the API that doesn't return a JSON array for one artist
var children = []; var children = [];
var playlist = data["subsonic-response"].playlist; var playlist = data["subsonic-response"].playlist;
if (playlist.entry.length > 0) { if (playlist.entry.length > 0) {
@ -825,9 +809,9 @@ function getPlaylist(id, action, appendto) {
function loadPlaylistsForMenu(menu) { function loadPlaylistsForMenu(menu) {
$('#' + menu).empty(); $('#' + menu).empty();
$.ajax({ $.ajax({
url: baseURL + '/getPlaylists.view?v=' + apiVersion + '&c=' + applicationName + '&f=json', url: baseURL + '/getPlaylists.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
var playlists = []; var playlists = [];
@ -849,9 +833,9 @@ function newPlaylist() {
var reply = prompt("Choose a name for your new playlist.", ""); var reply = prompt("Choose a name for your new playlist.", "");
if (reply != 'null' && reply != null && reply != '') { if (reply != 'null' && reply != null && reply != '') {
$.ajax({ $.ajax({
url: baseURL + '/createPlaylist.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&name=' + reply, url: baseURL + '/createPlaylist.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&name=' + reply,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
loadPlaylists(true); loadPlaylists(true);
@ -861,9 +845,9 @@ function newPlaylist() {
} }
function deletePlaylist(id) { function deletePlaylist(id) {
$.ajax({ $.ajax({
url: baseURL + '/deletePlaylist.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + id, url: baseURL + '/deletePlaylist.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + id,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
loadPlaylists(true); loadPlaylists(true);
@ -887,12 +871,11 @@ function addToPlaylist(playlistid, from) {
// Get songs from playlist // Get songs from playlist
var currentsongs = []; var currentsongs = [];
$.ajax({ $.ajax({
url: baseURL + '/getPlaylist.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + playlistid, url: baseURL + '/getPlaylist.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + playlistid,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
// There is a bug in the API that doesn't return a JSON array for one artist
var children = []; var children = [];
if (data["subsonic-response"].playlist.entry !== undefined) { if (data["subsonic-response"].playlist.entry !== undefined) {
if (data["subsonic-response"].playlist.entry.length > 1) { if (data["subsonic-response"].playlist.entry.length > 1) {
@ -918,10 +901,10 @@ function addToPlaylist(playlistid, from) {
if (checkVersion(runningVersion, minimumVersion)) { // is 1.8.0 or newer if (checkVersion(runningVersion, minimumVersion)) { // is 1.8.0 or newer
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: baseURL + '/updatePlaylist.view', url: baseURL + '/updatePlaylist.view?' + baseParams,
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
data: { v: apiVersion, c: applicationName, f: "json", playlistId: playlistid, songIdToAdd: selected }, data: { v: apiVersion, c: applicationName, playlistId: playlistid, songIdToAdd: selected },
success: function (data) { success: function (data) {
// Add logic to show an error if the playlist update fails // Add logic to show an error if the playlist update fails
// if (data["subsonic-response"].playlist.entry !== undefined) { // if (data["subsonic-response"].playlist.entry !== undefined) {
@ -935,10 +918,10 @@ function addToPlaylist(playlistid, from) {
} else { } else {
$.ajax({ // Depreciated: 11/5/2012 $.ajax({ // Depreciated: 11/5/2012
type: 'GET', type: 'GET',
url: baseURL + '/createPlaylist.view', url: baseURL + '/createPlaylist.view?' + baseParams,
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
data: { v: apiVersion, c: applicationName, f: "json", playlistId: playlistid, songId: currentsongs }, data: { v: apiVersion, c: applicationName, playlistId: playlistid, songId: currentsongs },
success: function () { success: function () {
$('table.songlist tr.song').each(function () { $('table.songlist tr.song').each(function () {
$(this).removeClass('selected'); $(this).removeClass('selected');
@ -956,10 +939,10 @@ function addToPlaylist(playlistid, from) {
if (reply) { if (reply) {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: baseURL + '/createPlaylist.view', url: baseURL + '/createPlaylist.view?' + baseParams,
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
data: { v: apiVersion, c: applicationName, f: "json", name: "" + reply + "", songId: selected }, data: { v: apiVersion, c: applicationName, name: "" + reply + "", songId: selected },
success: function () { success: function () {
$('table.songlist tr.song').each(function () { $('table.songlist tr.song').each(function () {
$(this).removeClass('selected'); $(this).removeClass('selected');
@ -1075,7 +1058,7 @@ function downloadItem(id, type) {
reqDownload = 'playlistUtf8Hex=' + id; reqDownload = 'playlistUtf8Hex=' + id;
} }
if (reqDownload) { if (reqDownload) {
url = baseURL + '/download.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&' + reqDownload; url = baseURL + '/download.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&' + reqDownload;
window.location = url; window.location = url;
} }
} }
@ -1090,9 +1073,9 @@ function loadPodcasts(refresh) {
if (content === "") { if (content === "") {
// Load Podcasts // Load Podcasts
$.ajax({ $.ajax({
url: baseURL + '/getPodcasts.view?v=' + apiVersion + '&c=' + applicationName + '&f=json', url: baseURL + '/getPodcasts.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
var podcasts = []; var podcasts = [];
@ -1124,9 +1107,9 @@ function loadPodcasts(refresh) {
} }
function getPodcast(id, action, appendto) { function getPodcast(id, action, appendto) {
$.ajax({ $.ajax({
url: baseURL + '/getPodcasts.view?v=' + apiVersion + '&c=' + applicationName + '&f=json', url: baseURL + '/getPodcasts.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
var podcasts = []; var podcasts = [];
@ -1197,9 +1180,9 @@ function loadVideos(refresh) {
if (content == "") { if (content == "") {
// Load Videos // Load Videos
$.ajax({ $.ajax({
url: baseURL + '/getVideos.view?v=' + apiVersion + '&c=' + applicationName + '&f=json', url: baseURL + '/getVideos.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (data["subsonic-response"].videos != '') { if (data["subsonic-response"].videos != '') {
@ -1217,7 +1200,7 @@ function loadVideos(refresh) {
} else { } else {
rowcolor = 'odd'; rowcolor = 'odd';
} }
var videoURL = baseURL + '/stream.view?v=' + apiVersion + '&c=' + applicationName + '&id=' + video.id; var videoURL = baseURL + '/stream.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + video.id;
html = '<tr class=\"row video\" childid=\"' + video.id + '\" parentid=\"' + video.parent + '\" bitrate=\"' + video.bitRate + '\" userrating=\"\">'; html = '<tr class=\"row video\" childid=\"' + video.id + '\" parentid=\"' + video.parent + '\" bitrate=\"' + video.bitRate + '\" userrating=\"\">';
html += '<td class=\"itemactions\">'; html += '<td class=\"itemactions\">';
//html += '<a class=\"add\" href=\"\" title=\"Add To Play Queue\"></a>'; //html += '<a class=\"add\" href=\"\" title=\"Add To Play Queue\"></a>';
@ -1232,7 +1215,7 @@ function loadVideos(refresh) {
if (video.coverArt === undefined) { if (video.coverArt === undefined) {
coverartSrc = 'images/albumdefault_25.jpg'; coverartSrc = 'images/albumdefault_25.jpg';
} else { } else {
coverartSrc = baseURL + '/getCoverArt.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&size=25&id=' + video.coverArt; coverartSrc = baseURL + '/getCoverArt.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&size=25&id=' + video.coverArt;
} }
var time = secondsToTime(video.duration); var time = secondsToTime(video.duration);
html += '<td class=\"album\"><img src=\"' + coverartSrc + '\" />' + video.album + '</td>'; html += '<td class=\"album\"><img src=\"' + coverartSrc + '\" />' + video.album + '</td>';
@ -1245,4 +1228,3 @@ function loadVideos(refresh) {
}); });
} }
} }

View file

@ -4,9 +4,9 @@ function updateChatMessages() {
updater = $.periodic({ period: 1000, decay: 1.5, max_period: 1800000 }, function () { updater = $.periodic({ period: 1000, decay: 1.5, max_period: 1800000 }, function () {
$.ajax({ $.ajax({
periodic: this, periodic: this,
url: baseURL + '/getChatMessages.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&since=' + starttime, url: baseURL + '/getChatMessages.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&since=' + starttime,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (data["subsonic-response"].chatMessages.chatMessage === undefined) { if (data["subsonic-response"].chatMessages.chatMessage === undefined) {
@ -49,10 +49,10 @@ function stopUpdateChatMessages() {
function addChatMessage(msg) { function addChatMessage(msg) {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: baseURL + '/addChatMessage.view', url: baseURL + '/addChatMessage.view?' + baseParams,
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
data: { v: apiVersion, c: applicationName, f: "json", message: msg }, data: { v: apiVersion, c: applicationName, message: msg },
success: function () { success: function () {
updater.reset(); updater.reset();
}, },

View file

@ -33,7 +33,7 @@ function generateAlbumHTML(childid, parentid, coverart, title, artist, rating, s
if (coverart == undefined) { if (coverart == undefined) {
html += '<td class=\"albumart\"><img src=\"images/albumdefault_50.jpg\" /></td>'; html += '<td class=\"albumart\"><img src=\"images/albumdefault_50.jpg\" /></td>';
} else { } else {
html += '<td class=\"albumart\"><img src=\"' + baseURL + '/getCoverArt.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&size=50&id=' + coverart + '\" /></td>'; html += '<td class=\"albumart\"><img src=\"' + baseURL + '/getCoverArt.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&size=50&id=' + coverart + '\" /></td>';
} }
html += '<td class=\"album\">' + title + '</td>'; html += '<td class=\"album\">' + title + '</td>';
html += '<td class=\"artist\">' + artist + '</td>'; html += '<td class=\"artist\">' + artist + '</td>';
@ -77,7 +77,7 @@ function generateSongHTML(childid, parentid, track, title, description, artist,
if (coverart == undefined) { if (coverart == undefined) {
coverartSrc = 'images/albumdefault_25.jpg'; coverartSrc = 'images/albumdefault_25.jpg';
} else { } else {
coverartSrc = baseURL + '/getCoverArt.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&size=25&id=' + coverart; coverartSrc = baseURL + '/getCoverArt.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&size=25&id=' + coverart;
} }
html += '<td class=\"album\" data-order-by=\"' + album + '\"><a href="#"><img src=\"' + coverartSrc + '\" />' + album + '</a></td>'; html += '<td class=\"album\" data-order-by=\"' + album + '\"><a href="#"><img src=\"' + coverartSrc + '\" />' + album + '</a></td>';
html += '<td class=\"time\">' + time + '</td>'; html += '<td class=\"time\">' + time + '</td>';

View file

@ -5,16 +5,16 @@ function getSongData(el, songid, albumid, position, loadonly) {
var minimumVersion = parseVersionString('1.8.0'); var minimumVersion = parseVersionString('1.8.0');
if (checkVersion(runningVersion, minimumVersion)) { if (checkVersion(runningVersion, minimumVersion)) {
if (debug) { console.log('apiVersion at or above 1.8.0 using getSong.view'); } if (debug) { console.log('apiVersion at or above 1.8.0 using getSong.view'); }
ajaxUrl = baseURL + '/getSong.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + songid; ajaxUrl = baseURL + '/getSong.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + songid;
} else { } else {
if (debug) { console.log('apiVersion below 1.8.0 using getMusicDirectory.view'); } if (debug) { console.log('apiVersion below 1.8.0 using getMusicDirectory.view'); }
ajaxUrl = baseURL + '/getMusicDirectory.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + albumid; // Deprecated: apiVersion 1.8.0 ajaxUrl = baseURL + '/getMusicDirectory.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + albumid; // Deprecated: apiVersion 1.8.0
} }
if (debug) { console.log(ajaxUrl) } if (debug) { console.log(ajaxUrl) }
$.ajax({ $.ajax({
url: ajaxUrl, url: ajaxUrl,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
var title, artist, album, rating, starred, contenttype, suffix; var title, artist, album, rating, starred, contenttype, suffix;
@ -36,7 +36,6 @@ function getSongData(el, songid, albumid, position, loadonly) {
} }
if (typeof data["subsonic-response"].directory != 'undefined') { // Deprecated: apiVersion 1.8.0 if (typeof data["subsonic-response"].directory != 'undefined') { // Deprecated: apiVersion 1.8.0
if (typeof data["subsonic-response"].directory.child != 'undefined') { if (typeof data["subsonic-response"].directory.child != 'undefined') {
// There is a bug in the API that doesn't return a JSON array for one artist
var children = []; var children = [];
if (data["subsonic-response"].directory.child.length > 0) { if (data["subsonic-response"].directory.child.length > 0) {
children = data["subsonic-response"].directory.child; children = data["subsonic-response"].directory.child;
@ -87,8 +86,8 @@ function playSong(el, songid, albumid, title, artist, album, coverart, rating, s
coverartSrc = 'images/albumdefault_60.jpg'; coverartSrc = 'images/albumdefault_60.jpg';
coverartFullSrc = ''; coverartFullSrc = '';
} else { } else {
coverartSrc = baseURL + '/getCoverArt.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&size=60&id=' + coverart; coverartSrc = baseURL + '/getCoverArt.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&size=60&id=' + coverart;
coverartFullSrc = baseURL + '/getCoverArt.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + coverart; coverartFullSrc = baseURL + '/getCoverArt.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + coverart;
} }
$('#coverartimage').attr('href', coverartFullSrc); $('#coverartimage').attr('href', coverartFullSrc);
$('#coverartimage img').attr('src', coverartSrc); $('#coverartimage img').attr('src', coverartSrc);
@ -125,11 +124,11 @@ function playSong(el, songid, albumid, title, artist, album, coverart, rating, s
ready: function () { ready: function () {
if (suffix == 'oga') { if (suffix == 'oga') {
$(this).jPlayer("setMedia", { $(this).jPlayer("setMedia", {
oga: baseURL + '/stream.view?v=' + apiVersion + '&c=' + applicationName + '&id=' + songid + '&salt=' + salt, oga: baseURL + '/stream.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + songid + '&salt=' + salt,
}); });
} else if (suffix == 'mp3') { } else if (suffix == 'mp3') {
$(this).jPlayer("setMedia", { $(this).jPlayer("setMedia", {
mp3: baseURL + '/stream.view?v=' + apiVersion + '&c=' + applicationName + '&id=' + songid + '&salt=' + salt, mp3: baseURL + '/stream.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + songid + '&salt=' + salt,
}); });
} }
if (!loadonly) { if (!loadonly) {
@ -181,11 +180,11 @@ function playSong(el, songid, albumid, title, artist, album, coverart, rating, s
for (i = 0; i < data.solutions.length; i++) { for (i = 0; i < data.solutions.length; i++) {
var solution = data.solutions[i]; var solution = data.solutions[i];
if (data[solution].used) { if (data[solution].used) {
spechtml += "<strong>" + solution + "</strong> is"; spechtml += "<strong class=\"codesyntax\">" + solution + "</strong> is";
spechtml += " currently being used with<strong>"; spechtml += " currently being used with<strong>";
for (format in data[solution].support) { for (format in data[solution].support) {
if (data[solution].support[format]) { if (data[solution].support[format]) {
spechtml += " " + format; spechtml += " <strong class=\"codesyntax\">" + format + "</strong>";
} }
} }
spechtml += "</strong> support"; spechtml += "</strong> support";
@ -199,7 +198,7 @@ function playSong(el, songid, albumid, title, artist, album, coverart, rating, s
scrobbleSong(false); scrobbleSong(false);
scrobbled = false; scrobbled = false;
if (getCookie('Notification_Song')) { if (getCookie('Notification_Song') && !loadonly) {
showNotification(coverartSrc, toHTML.un(title), toHTML.un(artist + ' - ' + album), 'text', '#NextTrack'); showNotification(coverartSrc, toHTML.un(title), toHTML.un(artist + ' - ' + album), 'text', '#NextTrack');
} }
if (getCookie('ScrollTitle')) { if (getCookie('ScrollTitle')) {
@ -242,9 +241,9 @@ function playVideo(id, bitrate) {
function scrobbleSong(submission) { function scrobbleSong(submission) {
var songid = $('#songdetails_song').attr('childid'); var songid = $('#songdetails_song').attr('childid');
$.ajax({ $.ajax({
url: baseURL + '/scrobble.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + songid + "&submission=" + submission, url: baseURL + '/scrobble.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + songid + "&submission=" + submission,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function () { success: function () {
if (submission) { if (submission) {
@ -255,9 +254,9 @@ function scrobbleSong(submission) {
} }
function rateSong(songid, rating) { function rateSong(songid, rating) {
$.ajax({ $.ajax({
url: baseURL + '/setRating.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + songid + "&rating=" + rating, url: baseURL + '/setRating.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + songid + "&rating=" + rating,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function () { success: function () {
updateMessage('Rating Updated!', true); updateMessage('Rating Updated!', true);
@ -268,14 +267,14 @@ function starItem(itemid, starred) {
var url; var url;
if (itemid !== undefined) { if (itemid !== undefined) {
if (starred) { if (starred) {
url = baseURL + '/star.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + itemid; url = baseURL + '/star.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + itemid;
} else { } else {
url = baseURL + '/unstar.view?v=' + apiVersion + '&c=' + applicationName + '&f=json&id=' + itemid; url = baseURL + '/unstar.view?' + baseParams + '&v=' + apiVersion + '&c=' + applicationName + '&id=' + itemid;
} }
$.ajax({ $.ajax({
url: url, url: url,
method: 'GET', method: 'GET',
dataType: 'json', dataType: protocol,
timeout: 10000, timeout: 10000,
success: function () { success: function () {
updateMessage('Favorite Updated!', true); updateMessage('Favorite Updated!', true);

View file

@ -1,3 +1,36 @@
function getCookie(value) {
if ($.cookie(value)) {
return $.cookie(value);
} else {
return false;
}
/* jQuery.cookies.js
if (browserStorageCheck) {
var item = localStorage.getItem(value);
if (item != '' && item != undefined) {
return true;
} else {
return false;
}
} else {
if (debug) { console.log('HTML5::loadStorage not supported on your browser' + html.length + ' characters'); }
}
*/
}
function setCookie(key, value) {
$.cookie(key, value, { expires: 365 });
/* jQuery.cookies.js
try {
if (debug) { console.log('Saving : ' + key + ':' + value); }
localStorage.setItem(key, value);
} catch (e) {
if (e == QUOTA_EXCEEDED_ERR) {
alert('Quota exceeded!');
}
}
*/
}
/* Reusable Functions */ /* Reusable Functions */
function clickButton(el) { function clickButton(el) {
var el = $(el); var el = $(el);

View file

@ -1,5 +1,14 @@
$(document).ready(function () { $(document).ready(function () {
//User config staff // Inject Basic Auth
/*
$.ajaxSetup({
beforeSend: function (req) {
req.setRequestHeader('Authorization', auth);
}
//headers: { "Authorization": "Basic " + auth }
});
*/
// Fill Preferences from Cookies
if (getCookie('username')) { $('#Username').val(getCookie('username')); } if (getCookie('username')) { $('#Username').val(getCookie('username')); }
//$('#Password').val(getCookie('passwordenc')); //$('#Password').val(getCookie('passwordenc'));
if (getCookie('AutoPlaylists')) { $('#AutoPlaylists').val(getCookie('AutoPlaylists')); } if (getCookie('AutoPlaylists')) { $('#AutoPlaylists').val(getCookie('AutoPlaylists')); }
@ -8,6 +17,10 @@
if (getCookie('Server')) { $('#Server').val(getCookie('Server')); } if (getCookie('Server')) { $('#Server').val(getCookie('Server')); }
if (getCookie('ApplicationName')) { $('#ApplicationName').val(getCookie('ApplicationName')); } if (getCookie('ApplicationName')) { $('#ApplicationName').val(getCookie('ApplicationName')); }
if (getCookie('Server')) {
baseURL = getCookie('Server') + '/rest';
}
// Set Preferences defaults // Set Preferences defaults
if (getCookie('Theme')) { if (getCookie('Theme')) {
$('#Theme').val(getCookie('Theme')); $('#Theme').val(getCookie('Theme'));
@ -45,6 +58,11 @@
} else { } else {
$('#ForceFlash').attr('checked', false); $('#ForceFlash').attr('checked', false);
} }
if (getCookie('Protocol')) {
$('#Protocol').attr('checked', true);
} else {
$('#Protocol').attr('checked', false);
}
if (getCookie('AutoPilot')) { if (getCookie('AutoPilot')) {
setCookie('AutoPilot', null) setCookie('AutoPilot', null)
} }
@ -69,6 +87,61 @@
return false; return false;
}); });
function loadTabContent(tab) {
var tabid = '#action_' + tab.substring(1, tab.length);
$("ul.tabs li a").removeClass("active"); //Remove any "active" class
$(tabid).addClass("active"); //Add "active" class to selected tab
$(".tabcontent").hide(); //Hide all tab content
window.location.hash = tab;
switch (tab) {
case '#tabLibrary':
if (debug) { console.log("TAG LIBRARY"); }
if (getCookie('MusicFolders')) {
loadArtists(getCookie('MusicFolders'), false);
} else {
loadArtists();
}
getMusicFolders();
break;
case '#tabQueue':
if (debug) { console.log("TAG QUEUE"); }
var header = generateSongHeaderHTML();
$('#CurrentPlaylistContainer thead').html(header);
var count = $('#CurrentPlaylistContainer tbody tr.song').size();
updateStatus('#status_Current', countCurrentPlaylist('#CurrentPlaylistContainer'));
if (count > 0) {
$('#currentActions a.button').removeClass('disabled');
}
var songid = $('#CurrentPlaylistContainer tbody tr.playing').attr('childid');
if (songid !== undefined) {
$('#CurrentPlaylist').scrollTo($('#' + songid), 400);
}
break;
case '#tabPlaylists':
if (debug) { console.log("TAG PLAYLIST"); }
loadPlaylists();
loadFolders();
loadAutoPlaylists();
updateStatus('#status_Playlists', countCurrentPlaylist('#TrackContainer'));
break;
case '#tabPodcasts':
if (debug) { console.log("TAG PODCAST"); }
loadPodcasts();
updateStatus('#status_Podcasts', countCurrentPlaylist('#PodcastContainer'));
break;
case '#tabVideos':
if (debug) { console.log("TAG VIDEOS"); }
loadVideos(true);
break;
case '#tabPreferences':
getGenres();
break;
default:
break;
}
$(tab).fadeIn('fast'); //Fade in the active ID content
}
// Tabs // Tabs
$('.tabcontent').hide(); //Hide all content $('.tabcontent').hide(); //Hide all content
if (!getCookie('username') && !getCookie('passwordenc') && !getCookie('Server')) { // Show Preferences if (!getCookie('username') && !getCookie('passwordenc') && !getCookie('Server')) { // Show Preferences
@ -913,7 +986,8 @@
if (applicationname != "") { if (applicationname != "") {
setCookie('ApplicationName', applicationname); setCookie('ApplicationName', applicationname);
} }
location.reload(true); updateMessage('Preferences Saved...', true);
//location.reload(true);
}); });
$('#Theme').live('change', function () { $('#Theme').live('change', function () {
var theme = $(this).val(); var theme = $(this).val();
@ -988,7 +1062,15 @@
} else { } else {
setCookie('ForceFlash', null); setCookie('ForceFlash', null);
} }
location.reload(true); //location.reload(true);
});
$('#Protocol').live('click', function () {
if ($('#Protocol').is(':checked')) {
setCookie('Protocol', '1');
} else {
setCookie('Protocol', null);
}
//location.reload(true);
}); });
$('#SaveTrackPosition').live('click', function () { $('#SaveTrackPosition').live('click', function () {
if ($('#SaveTrackPosition').is(':checked')) { if ($('#SaveTrackPosition').is(':checked')) {
@ -1018,7 +1100,7 @@
setCookie('Server', null); setCookie('Server', null);
setCookie('ApplicationName', null); setCookie('ApplicationName', null);
setCookie('HideAZ', null); setCookie('HideAZ', null);
location.reload(true); //location.reload(true);
}); });
$('#ChangeLogShowMore').live('click', function () { $('#ChangeLogShowMore').live('click', function () {
$('ul#ChangeLog li.log').each(function (i, el) { $('ul#ChangeLog li.log').each(function (i, el) {

View file

@ -2,7 +2,7 @@
"manifest_version": 2, "manifest_version": 2,
"name": "MiniSub", "name": "MiniSub",
"description": "MiniSub - HTML5 Mini Player for Subsonic", "description": "MiniSub - HTML5 Mini Player for Subsonic",
"version": "2.3.5", "version": "2.3.6",
"app": { "app": {
"launch": { "launch": {
"local_path": "index.html" "local_path": "index.html"

View file

@ -309,6 +309,10 @@ fieldset
{ {
border: 1px solid #1d1d1d; border: 1px solid #1d1d1d;
} }
label
{
color: #D6D469;
}
#donate { #donate {
background: #232323; background: #232323;
border: 1px solid #1D1D1D; border: 1px solid #1D1D1D;

View file

@ -15,7 +15,7 @@ img
h3.title h3.title
{ {
font-weight: bold; font-weight: bold;
font-size: 14px; font-size: 16px;
font-variant: small-caps; font-variant: small-caps;
padding: 0; padding: 0;
margin: 5px 0; margin: 5px 0;
@ -48,6 +48,7 @@ span.apiversion
.even { background: #f4f4f4; } .even { background: #f4f4f4; }
*/ */
.red { color: #E64F4C; } .red { color: #E64F4C; }
.codesyntax { font-family: "Courier New"; }
.italic { font-style: italic; } .italic { font-style: italic; }
.beer { font-size: 17px; } .beer { font-size: 17px; }
@ -1365,6 +1366,7 @@ select#MusicFolders
label label
{ {
font-size: 12px; font-size: 12px;
font-weight: bold;
margin: 0 5px; margin: 0 5px;
} }
.inputwrap .inputwrap