mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-26 14:13:18 -05:00
config.html: Possible to add items in the UI, for options of type
<short_text_multiple> and <long_text_multiple>
This commit is contained in:
parent
b150896921
commit
a1d5de6b54
@ -20,6 +20,13 @@ select {
|
|||||||
padding-top: .3em;
|
padding-top: .3em;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
|
.addItemHref {
|
||||||
|
float: left;
|
||||||
|
margin-left: 11em;
|
||||||
|
font: icon;
|
||||||
|
padding-left: 1.5em;
|
||||||
|
margin-bottom: .5em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<h1>Configuration</h1>
|
<h1>Configuration</h1>
|
||||||
|
|
||||||
|
@ -69,9 +69,10 @@ var Config = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_buildItem: function(item) {
|
_buildItem: function(item) {
|
||||||
|
|
||||||
var ret;
|
var ret;
|
||||||
var itemId = item.getAttribute('id');
|
var itemId = item.getAttribute('id');
|
||||||
|
var href;
|
||||||
|
var span;
|
||||||
switch(Element.textContent(item.getElementsByTagName('type')[0])) {
|
switch(Element.textContent(item.getElementsByTagName('type')[0])) {
|
||||||
case 'short_text':
|
case 'short_text':
|
||||||
ret = BuildElement.input(itemId,
|
ret = BuildElement.input(itemId,
|
||||||
@ -90,23 +91,37 @@ var Config = {
|
|||||||
case 'short_text_multiple':
|
case 'short_text_multiple':
|
||||||
ret = document.createDocumentFragment();
|
ret = document.createDocumentFragment();
|
||||||
Config._getConfigOptionValue(itemId,true).each(function (value,i) {
|
Config._getConfigOptionValue(itemId,true).each(function (value,i) {
|
||||||
ret.appendChild(BuildElement.input(itemId+i,
|
var span = document.createElement('span');
|
||||||
|
span.appendChild(BuildElement.input(itemId+i,
|
||||||
Element.textContent(item.getElementsByTagName('name')[0]),
|
Element.textContent(item.getElementsByTagName('name')[0]),
|
||||||
value,20,
|
value,20,
|
||||||
Element.textContent(item.getElementsByTagName('short_description')[0])
|
Element.textContent(item.getElementsByTagName('short_description')[0])
|
||||||
));
|
));
|
||||||
|
ret.appendChild(span);
|
||||||
});
|
});
|
||||||
|
href = Builder.node('a',{href:'javascript://',className:'addItemHref'},
|
||||||
|
Element.textContent(item.getElementsByTagName('add_item_text')[0]));
|
||||||
|
ret.appendChild(href);
|
||||||
|
Event.observe(href,'click',Config._addItem);
|
||||||
|
ret.appendChild(Builder.node('div',{style:'clear: both'}));
|
||||||
break;
|
break;
|
||||||
case 'long_text_multiple':
|
case 'long_text_multiple':
|
||||||
//###TODO Do something smart instead of just copying
|
//###TODO Do something smart instead of just copying
|
||||||
ret = document.createDocumentFragment();
|
ret = document.createDocumentFragment();
|
||||||
Config._getConfigOptionValue(itemId,true).each(function (value,i) {
|
Config._getConfigOptionValue(itemId,true).each(function (value,i) {
|
||||||
ret.appendChild(BuildElement.input(itemId+i,
|
var span = document.createElement('span');
|
||||||
|
span.appendChild(BuildElement.input(itemId+i,
|
||||||
Element.textContent(item.getElementsByTagName('name')[0]),
|
Element.textContent(item.getElementsByTagName('name')[0]),
|
||||||
value,80,
|
value,80,
|
||||||
Element.textContent(item.getElementsByTagName('short_description')[0])
|
Element.textContent(item.getElementsByTagName('short_description')[0])
|
||||||
));
|
));
|
||||||
|
ret.appendChild(span);
|
||||||
});
|
});
|
||||||
|
href = Builder.node('a',{href:'javascript://',className:'addItemHref'},
|
||||||
|
Element.textContent(item.getElementsByTagName('add_item_text')[0]));
|
||||||
|
ret.appendChild(href);
|
||||||
|
Event.observe(href,'click',Config._addItem);
|
||||||
|
ret.appendChild(Builder.node('div',{style:'clear: both'}));
|
||||||
break;
|
break;
|
||||||
case 'select':
|
case 'select':
|
||||||
var value = Config._getConfigOptionValue(itemId);
|
var value = Config._getConfigOptionValue(itemId);
|
||||||
@ -122,6 +137,21 @@ var Config = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
},
|
||||||
|
_addItem: function(e) {
|
||||||
|
var span = Event.element(e);
|
||||||
|
while (span.nodeName.toLowerCase() != 'span') {
|
||||||
|
span = span.previousSibling;
|
||||||
|
}
|
||||||
|
var frag = document.createDocumentFragment();
|
||||||
|
span = span.cloneNode(true);
|
||||||
|
span.getElementsByTagName('label')[0].setAttribute('for','hej');
|
||||||
|
span.getElementsByTagName('input')[0].id = 'hej';
|
||||||
|
span.getElementsByTagName('input')[0].value = '';
|
||||||
|
|
||||||
|
var src = Event.element(e);
|
||||||
|
src.parentNode.insertBefore(span,src);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var BuildElement = {
|
var BuildElement = {
|
||||||
|
@ -84,6 +84,7 @@
|
|||||||
<name>MP3 Directory</name>
|
<name>MP3 Directory</name>
|
||||||
<short_description></short_description>
|
<short_description></short_description>
|
||||||
<type>long_text_multiple</type>
|
<type>long_text_multiple</type>
|
||||||
|
<add_item_text>Add Directory</add_item_text>
|
||||||
</item>
|
</item>
|
||||||
<item id="extensions">
|
<item id="extensions">
|
||||||
<name>Extensions</name>
|
<name>Extensions</name>
|
||||||
@ -109,6 +110,7 @@
|
|||||||
<name>Compilation Directories</name>
|
<name>Compilation Directories</name>
|
||||||
<short_description></short_description>
|
<short_description></short_description>
|
||||||
<type>long_text_multiple</type>
|
<type>long_text_multiple</type>
|
||||||
|
<add_item_text>Add Directory</add_item_text>
|
||||||
</item>
|
</item>
|
||||||
<item id="art_filename">
|
<item id="art_filename">
|
||||||
<name>Art Filename</name>
|
<name>Art Filename</name>
|
||||||
@ -167,6 +169,7 @@
|
|||||||
<name>Plugins</name>
|
<name>Plugins</name>
|
||||||
<short_description></short_description>
|
<short_description></short_description>
|
||||||
<type>short_text_multiple</type>
|
<type>short_text_multiple</type>
|
||||||
|
<add_item_text>Add Plugin</add_item_text>
|
||||||
</item>
|
</item>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user