1.9.4 Querystring support for required parameters

This commit is contained in:
Trevor Squillario 2012-04-03 11:26:03 -04:00
parent c3d7435c43
commit a0df9b6197
3 changed files with 39 additions and 2 deletions

View file

@ -216,6 +216,11 @@
<span class="changes"></span> <span class="changes"></span>
</li> </li>
--> -->
<li class="log"><span class="version">4/3/2012 - 1.9.4</span>
<span class="changes">URL Querystring support for setting of variables</span>
<span class="changes">Added legacy support for Subsonic 4.5</span>
<span class="changes">Fixed Chrome audio bugs</span>
</li>
<li class="log"><span class="version">3/31/2012 - 1.9</span> <li class="log"><span class="version">3/31/2012 - 1.9</span>
<span class="changes">Switched to SoundManager2 audio library (changing track position currently not functional, next update)</span> <span class="changes">Switched to SoundManager2 audio library (changing track position currently not functional, next update)</span>
<span class="changes">Other minor bug fixes</span> <span class="changes">Other minor bug fixes</span>

View file

@ -3,6 +3,23 @@ var debug = false;
var audio; var audio;
var hostURL = location.href; var hostURL = location.href;
var baseURL; var baseURL;
// Set auth cookies if specified in URL on launch
var u = getParameterByName('u');
var p = getParameterByName('p');
var s = getParameterByName('s');
if (u && p && s) {
if (!$.cookie('username')) {
$.cookie('username', u, { expires: 365 });
}
if (!$.cookie('password')) {
$.cookie('password', p, { expires: 365 });
}
if (!$.cookie('Server')) {
$.cookie('Server', s, { expires: 365 });
}
window.location.href = getPathFromUrl(window.location);
}
if ($.cookie('Server')) { if ($.cookie('Server')) {
baseURL = $.cookie('Server') + '/rest'; baseURL = $.cookie('Server') + '/rest';
} }
@ -468,7 +485,7 @@ function playSong(el, songid, albumid) {
scrobbled = false; scrobbled = false;
if ($.cookie('EnableNotifications')) { if ($.cookie('EnableNotifications')) {
showNotification(baseURL + '/getCoverArt.view?v=' + version + '&c=' + applicationName + '&f=jsonp&size=50&id=' + coverart, title, artist + ' - ' + album); showNotification(baseURL + '/getCoverArt.view?v=' + version + '&c=' + applicationName + '&f=jsonp&size=50&id=' + coverart, toHTML.un(title), toHTML.un(artist + ' - ' + album));
} }
if ($.cookie('ScrollTitle')) { if ($.cookie('ScrollTitle')) {
scrollTitle(toHTML.un(artist) + ' - ' + toHTML.un(title)); scrollTitle(toHTML.un(artist) + ' - ' + toHTML.un(title));
@ -1121,6 +1138,21 @@ var toHTML = {
}) })
} }
}; };
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if (results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
function getPathFromUrl(url) {
var strurl = url.toString();
var u = strurl.substring(0, strurl.indexOf('?'));
return u
}
function setTitle(text) { function setTitle(text) {
if (text != "") { if (text != "") {
document.title = text; document.title = text;

View file

@ -1,7 +1,7 @@
$(document).ready(function () { $(document).ready(function () {
// Tabs // Tabs
$(".tabcontent").hide(); //Hide all content $(".tabcontent").hide(); //Hide all content
if ($.cookie('username') == null) { if (!$.cookie('username') && !$.cookie('password') && !$.cookie('Server')) {
$('ul.tabs li a').each(function () { $('ul.tabs li a').each(function () {
if ($(this).attr("href") == '#tabPreferences') { if ($(this).attr("href") == '#tabPreferences') {
$(this).addClass("active"); //Add "active" class to selected tab $(this).addClass("active"); //Add "active" class to selected tab