24 lines
502 B
JavaScript
24 lines
502 B
JavaScript
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
|
|
};
|