config.html: Fix select boxes to reflect actual values in mt-daapd.conf

Handle config.xml default_value for select boxes
This commit is contained in:
Anders Betnér 2006-05-12 10:02:59 +00:00
parent c8b10769a2
commit b150896921

View File

@ -109,10 +109,14 @@ var Config = {
}); });
break; break;
case 'select': case 'select':
var value = Config._getConfigOptionValue(itemId);
if (!value) {
value = Element.textContent(item.getElementsByTagName('default_value')[0]);
}
ret = BuildElement.select(itemId, ret = BuildElement.select(itemId,
Element.textContent(item.getElementsByTagName('name')[0]), Element.textContent(item.getElementsByTagName('name')[0]),
item.getElementsByTagName('option'), item.getElementsByTagName('option'),
Config._getConfigOptionValue(itemId), value,
Element.textContent(item.getElementsByTagName('short_description')[0]) Element.textContent(item.getElementsByTagName('short_description')[0])
); );
break; break;
@ -135,6 +139,7 @@ var BuildElement = {
frag.appendChild(document.createTextNode('\u00a0')); frag.appendChild(document.createTextNode('\u00a0'));
frag.appendChild(document.createTextNode(short_description)); frag.appendChild(document.createTextNode(short_description));
frag.appendChild(Builder.node('br')); frag.appendChild(Builder.node('br'));
return frag; return frag;
}, },
select: function(id,displayName,options,value,short_description,long_description) { select: function(id,displayName,options,value,short_description,long_description) {
@ -149,10 +154,12 @@ var BuildElement = {
select.appendChild(Builder.node('option',{value: option.getAttribute('value')}, select.appendChild(Builder.node('option',{value: option.getAttribute('value')},
Element.textContent(option))); Element.textContent(option)));
}); });
select.value = value;
frag.appendChild(select); frag.appendChild(select);
frag.appendChild(document.createTextNode('\u00a0')); frag.appendChild(document.createTextNode('\u00a0'));
frag.appendChild(document.createTextNode(short_description)); frag.appendChild(document.createTextNode(short_description));
frag.appendChild(Builder.node('br')); frag.appendChild(Builder.node('br'));
return frag; return frag;
} }