const showHideLensUtils = { // showHideLensUtils // lensDivsVisibleCount // showDivForLens // hideLensByLensId lensesToShowCount: function lensesToShowCount() { // unlike lensDivsVisibleCount, which queries div's on the page, // this method queries storage utilities to determine how many lenses // would be shown on the page. // for this reason, this method will return a useful value // even before lenses have been added to the page const logHeader = 'showHideLensUtils.lensesToShowCount: '; log(logHeader + 'enter'); const toFindCount = lensesToFindStorageUtils.count(); log(logHeader + 'toFindCount=' + toFindCount); if (toFindCount > 0) { // if the user has explicitly found any lenses log(logHeader + 'we will return this count as the number to show'); log(logHeader + 'leave'); return toFindCount; } const allLensIds = lensUtils.getLensIds(); // get the ids of all lenses log(logHeader + 'allLensIds.length=' + allLensIds.length); const findAll = findWhichGroupStateUtils.getFindAll(); // did we find all lenses? // true => find all // false => find bookmarked log(logHeader + 'findAll=' + findAll + '(true => all, false => bookmarked)'); const lensIdsToHide = lensesToHideStorageUtils.getLensIds(); // get the ids of the lenses to hide log(logHeader + 'lensIdsToHide.length=' + lensIdsToHide.length); const lensIdsToHideHS = arrayUtils.arrayToHashObject(lensIdsToHide); // create a hash set object of ids of lenses to hide var foundIds = []; if (findAll) { // if we are finding all lenses, not only bookmarked lenses log(logHeader + 'finding ids of ALL lenses minus ids of lenses to hide'); foundIds = allLensIds.filter(i => !lensIdsToHideHS[i]); // get all lens ids minus the ids of the lenses to hide } else { // if we are finding bookmarked lenses log(logHeader + 'finding ids of BOOKMARKED lenses minus ids of lenses to hide'); const bkLensIds = bookmarkStorageUtils.getLensIds(); // get the ids of the bookmarked lenses foundIds = bkLensIds.filter(i => !lensIdsToHideHS[i]); // get the bookmarked lens ids minus the ids of the lenses to hide } const toShowCount = foundIds.length; log(logHeader + 'toShowCount=' + toShowCount); log(logHeader + 'leave'); return toShowCount; }, lensDivsVisibleCount: function lensDivsVisibleCount() { // return the number of lens div elements currently visible (not hidden) on the page const logHeader = 'showHideLensUtils.lensDivsVisibleCount: '; log(logHeader + 'enter'); const lensCount = $('.card').filter(':visible').length; // count the visible lens divs log(logHeader + 'lensCount=' + lensCount); log(logHeader + 'leave'); return lensCount; }, showDivForLens: function showDivForLens(lensId) { log('showDivForLens: enter'); log('showDivForLens: lensId=' + lensId); var divName = 'lens' + lensId; // get the name of the parent div for the lens $('#' + divName).show(); // show the div for the lens log('showDivForLens: leave'); }, hideLensByLensIdAsync: async function hideLensByLensIdAsync(lensId) { log('hideLensByLensIdAsync: enter'); displayCurrentLensesCache.clear(); // clear the entire lens cache noTabsCardExpStorageUtils.removeFromLensIds(lensId); tabsCardExpStorageUtils.removeFromLensIds(lensId); // remove the id from the lists of expanded cards cardWidthUtils.clearCardWidth(lensId); // clear the lens from the list of stored card widths lensUIUtils.clearLensDivWidth(lensId); // remove the width item from the style attribute in the lens div lensesToHideStorageUtils.addToLensIds(lensId); // add the lens to the list of lenses to hide const parentDivId = elemIdUtils.getElemId(lensId, elemIdUtils.CARD_PREFIX, undefined); // get the name of the parent div for the lens log('hideLensByLensIdAsync: parentDivId=' + parentDivId); $('#' + parentDivId).hide(); // hide the div for the lens const byAlpha = displayByStateUtils.getDisplayAlpha(); // are we displaying lenses alphabetically, as opposed to grouped? log('hideLensByLensIdAsync: byAlpha=' + byAlpha); if (!byAlpha) { // if we are displaying grouped lenses const lensesToDisplay = lensUtils.getLensDTOsToDisplay(); // get the DTOs of the lenses to display // start with either all or bookmarked (depending on the current setting) // and remove lenses to hide const lensCount = lensesToDisplay.length; // how many lenses are displayed? const lensDTO = lensUtils.getLensById(lensId); if (lensDTO !== null) { const catId = lensDTO.CategoryId; const findResult = lensesToDisplay.find(x => { return x.CategoryId === catId }); // find the first lens in the set of lenses to display with the same category as the lens we just hid // or undefined if not found if (typeof findResult === "undefined") { // if the lens we hid was the last of its category displayed const catDivId = 'divCategory' + catId; // get the id of the parent div $('#' + catDivId).remove(); // remove the div from the page // it's a bootstrap div, so hiding it won't works const catCaptionId = 'catName' + catId; // get the name of the category name element $('#' + catCaptionId).hide(); // hide the category name const hrId = 'hrCategory' + catId; // get the name of the