()
| 1624 | } |
| 1625 | |
| 1626 | function refreshSelection() { |
| 1627 | var helpers = selection.getHelpers(); |
| 1628 | if (!helpers) { |
| 1629 | updateQueueDuration(); |
| 1630 | return; |
| 1631 | } |
| 1632 | Array.prototype.forEach.call(queueItemsDom.getElementsByClassName('pl-item'), removeSelectedAndCursorClasses); |
| 1633 | Array.prototype.forEach.call(libraryArtistsDom.getElementsByClassName('clickable'), removeSelectedAndCursorClasses); |
| 1634 | Array.prototype.forEach.call(playlistsListDom.getElementsByClassName('clickable'), removeSelectedAndCursorClasses); |
| 1635 | |
| 1636 | if (selection.cursorType == null) { |
| 1637 | updateQueueDuration(); |
| 1638 | return; |
| 1639 | } |
| 1640 | for (var selectionType in helpers) { |
| 1641 | var helper = helpers[selectionType]; |
| 1642 | var id; |
| 1643 | // clean out stale ids |
| 1644 | for (id in helper.ids) { |
| 1645 | if (helper.table[id] == null) { |
| 1646 | delete helper.ids[id]; |
| 1647 | } |
| 1648 | } |
| 1649 | for (id in helper.ids) { |
| 1650 | var selectedDomItem = helper.getDiv(id); |
| 1651 | if (selectedDomItem) { |
| 1652 | selectedDomItem.classList.add('selected'); |
| 1653 | } |
| 1654 | } |
| 1655 | if (selection.cursor != null && selectionType === selection.cursorType) { |
| 1656 | var validIds = getValidIds(selectionType); |
| 1657 | if (validIds[selection.cursor] == null) { |
| 1658 | // server just deleted our current cursor item. |
| 1659 | // select another of our ids randomly, if we have any. |
| 1660 | selection.cursor = Object.keys(helper.ids)[0]; |
| 1661 | selection.rangeSelectAnchor = selection.cursor; |
| 1662 | selection.rangeSelectAnchorType = selectionType; |
| 1663 | if (selection.cursor == null) { |
| 1664 | // no selected items |
| 1665 | selection.fullClear(); |
| 1666 | } |
| 1667 | } |
| 1668 | if (selection.cursor != null) { |
| 1669 | var cursorDomItem = helper.getDiv(selection.cursor); |
| 1670 | if (cursorDomItem) { |
| 1671 | cursorDomItem.classList.add('cursor'); |
| 1672 | } |
| 1673 | } |
| 1674 | } |
| 1675 | } |
| 1676 | updateQueueDuration(); |
| 1677 | |
| 1678 | } |
| 1679 | |
| 1680 | function getValidIds(selectionType) { |
| 1681 | switch (selectionType) { |
no test coverage detected