MCPcopy
hub / github.com/andrewrk/groovebasin / refreshSelection

Function refreshSelection

src/client/app.js:1626–1678  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1624}
1625
1626function 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
1680function getValidIds(selectionType) {
1681 switch (selectionType) {

Callers 12

app.jsFile · 0.85
upDownHandlerFunction · 0.85
renderQueueFunction · 0.85
renderPlaylistsFunction · 0.85
renderLibraryFunction · 0.85
genericToggleExpansionFunction · 0.85
onQueueItemsMouseDownFunction · 0.85
onNewPlaylistNameKeyDownFunction · 0.85
onLibFilterKeyDownFunction · 0.85
leftMouseDownFunction · 0.85
rightMouseDownFunction · 0.85

Calls 2

updateQueueDurationFunction · 0.85
getValidIdsFunction · 0.85

Tested by

no test coverage detected