* @type {Object<string, function(HTMLElement, HTMLElement, HTMLElement)>}
*/
const itemActions = {
- move_up(item, shelfBooksList, allBooksList) {
+ move_up(item) {
const list = item.parentNode;
const index = Array.from(list.children).indexOf(item);
const newIndex = Math.max(index - 1, 0);
list.insertBefore(item, list.children[newIndex] || null);
},
- move_down(item, shelfBooksList, allBooksList) {
+ move_down(item) {
const list = item.parentNode;
const index = Array.from(list.children).indexOf(item);
const newIndex = Math.min(index + 2, list.children.length);
remove(item, shelfBooksList, allBooksList) {
allBooksList.appendChild(item);
},
- add(item, shelfBooksList, allBooksList) {
+ add(item, shelfBooksList) {
shelfBooksList.appendChild(item);
},
};
}
});
- this.bookSearchInput.addEventListener('input', event => {
+ this.bookSearchInput.addEventListener('input', () => {
this.filterBooksByName(this.bookSearchInput.value);
});
const bProp = bookB.dataset[sortProperty].toLowerCase();
if (reverse) {
- return aProp < bProp ? (aProp === bProp ? 0 : 1) : -1;
+ return bProp.localeCompare(aProp);
}
- return aProp < bProp ? (aProp === bProp ? 0 : -1) : 1;
+ return aProp.localeCompare(bProp);
});
for (const book of books) {