mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-08 21:24:57 -05:00
Make the select boxes remember their selections when browsing, just like
iTunes does. Moved some javascript around.
This commit is contained in:
@@ -15,8 +15,9 @@ function initPlaylist() {
|
|||||||
// Firefox remebers the search box value on page reload
|
// Firefox remebers the search box value on page reload
|
||||||
Field.clear('search');
|
Field.clear('search');
|
||||||
}
|
}
|
||||||
// TODO busy message
|
// TODO
|
||||||
// timeout on search box
|
// Find a decent spinner instad of the busy text
|
||||||
|
// Handle 'all' in select boxes
|
||||||
// move stuff to responsehandler
|
// move stuff to responsehandler
|
||||||
// handle source change events
|
// handle source change events
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ var EventHandler = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var Query = {
|
var Query = {
|
||||||
genres: [],
|
genres: [],
|
||||||
artists:[],
|
artists:[],
|
||||||
@@ -178,9 +180,14 @@ var ResponseHandler = {
|
|||||||
o.value = 'all';
|
o.value = 'all';
|
||||||
o.appendChild(document.createTextNode('All (' + items.length + ' ' + type + ')'));
|
o.appendChild(document.createTextNode('All (' + items.length + ' ' + type + ')'));
|
||||||
select.appendChild(o);
|
select.appendChild(o);
|
||||||
|
var selected = {};
|
||||||
|
Query[type].each(function(item) {
|
||||||
|
selected[item] = true;
|
||||||
|
});
|
||||||
Query.clearSelection(type);
|
Query.clearSelection(type);
|
||||||
addOptions(select,items);
|
if (addOptions(type,items,selected)) {
|
||||||
select.value='all';
|
select.value='all';
|
||||||
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'genres':
|
case 'genres':
|
||||||
Query.send('artists');
|
Query.send('artists');
|
||||||
@@ -194,6 +201,33 @@ var ResponseHandler = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function addOptions(type,options,selected) {
|
||||||
|
el = $(type);
|
||||||
|
var nothingSelected = true;
|
||||||
|
options.each(function (option) {
|
||||||
|
var node;
|
||||||
|
//###FIXME I have no idea why the Builder.node can't create options
|
||||||
|
// with the selected state I want.
|
||||||
|
var o = document.createElement('option');
|
||||||
|
o.value = option;
|
||||||
|
var text = option.truncate(BROWSE_TEXT_LEN);
|
||||||
|
if (option.length != text.length) {
|
||||||
|
o.title = option;
|
||||||
|
o.appendChild(document.createTextNode(text));
|
||||||
|
} else {
|
||||||
|
o.appendChild(document.createTextNode(option));
|
||||||
|
}
|
||||||
|
if (selected[option]) {
|
||||||
|
o.selected = true;
|
||||||
|
nothingSelected = false;
|
||||||
|
Query.addSelection(type,option);
|
||||||
|
} else {
|
||||||
|
o.selected = false;
|
||||||
|
}
|
||||||
|
el.appendChild(o);
|
||||||
|
});
|
||||||
|
return nothingSelected;
|
||||||
|
}
|
||||||
|
|
||||||
function rsSource(request) {
|
function rsSource(request) {
|
||||||
var items = $A(request.responseXML.getElementsByTagName('dmap.listingitem'));
|
var items = $A(request.responseXML.getElementsByTagName('dmap.listingitem'));
|
||||||
@@ -260,19 +294,7 @@ function rsSongs(request) {
|
|||||||
});
|
});
|
||||||
Query.busy = false;
|
Query.busy = false;
|
||||||
}
|
}
|
||||||
function addOptions(element,options) {
|
|
||||||
options.each(function (option) {
|
|
||||||
var node;
|
|
||||||
var text = option.truncate(BROWSE_TEXT_LEN);
|
|
||||||
if (option.length != text.length) {
|
|
||||||
node = Builder.node('option',{value: option, title: option},text);
|
|
||||||
} else {
|
|
||||||
node = Builder.node('option',{value: option},text);
|
|
||||||
}
|
|
||||||
node.selected = false;
|
|
||||||
element.appendChild(node);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Object.extend(Element, {
|
Object.extend(Element, {
|
||||||
removeChildren: function(element) {
|
removeChildren: function(element) {
|
||||||
while(element.hasChildNodes()) {
|
while(element.hasChildNodes()) {
|
||||||
@@ -297,7 +319,7 @@ Object.extend(Element, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
String.prototype.encode = function () {
|
String.prototype.encode = function () {
|
||||||
return encodeURIComponent(this).replace(/\'/,"\\'");
|
return encodeURIComponent(this).replace(/\'/g,"\\'");
|
||||||
};
|
};
|
||||||
// Stolen from prototype 1.5
|
// Stolen from prototype 1.5
|
||||||
String.prototype.truncate = function(length, truncation) {
|
String.prototype.truncate = function(length, truncation) {
|
||||||
|
|||||||
Reference in New Issue
Block a user