webclient/js/GUI/ListSelector.js

25 lines
502 B
JavaScript
Raw Normal View History

import * as Dom from UnitJS.Dom;
function ListSelector(domId, lineOfElement) {
var root = document.getElementById(domId);
var message = root.getElementsByClassName('message')[0];
var list = root.getElementsByTagName('ul')[0];
return {
message: message,
refresh: refresh
};
function refresh(sortedElements) {
Dom.clear(list);
message.textContent = '';
sortedElements.forEach(function(element) {
list.appendChild(lineOfElement(element));
});
}
}
return {
make: ListSelector
};