UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

57 lines 2.3 kB
import { EmptyMINEasyIconGroup } from "../interfaces/eiTypes"; import { check4This, Check4 } from "../../../../logic/Links/CheckSearch"; export function getFPSEasyIconSummary(maxResults = 10) { const thisWindow = window; let didThis = 'Did not do anything this time'; if (!thisWindow.FPSEasyIcons) { didThis = 'Adding FPSEasyIcons to page'; const EasyIconUsage = { Groups: [], FoldersFound: [], }; thisWindow.FPSEasyIcons = EasyIconUsage; // https://github.com/mikezimm/fps-library-v2/issues/39 if (check4This(Check4.fpsInitRender_Eq_true) === true) console.log('winFPS createWinProps', didThis, thisWindow.FPSEasyIcons); } else { } return thisWindow.FPSEasyIcons; } /** * https://github.com/mikezimm/pivottiles7/issues/384 * * @param Group * @param Icon * @param Details */ export function updateFPSEasyIconSummary(Group, Icon, Details) { const FPSEasyIcons = getFPSEasyIconSummary(); let CurrentGroup = EmptyMINEasyIconGroup; let isNew = false; // Find or Create the Group/Folder if (FPSEasyIcons.FoldersFound.indexOf(Group) < 0) { FPSEasyIcons.FoldersFound.push(Group); CurrentGroup = { Folder: Group, Icons: [], IconItems: [] }; FPSEasyIcons.Groups.push(CurrentGroup); isNew = true; } else { CurrentGroup = FPSEasyIcons.Groups.filter((group) => group.Folder === Group)[0]; } // Add the Icon to the Folder Icons if (CurrentGroup.Icons.indexOf(Icon) < 0) { CurrentGroup.Icons.push(Icon); // 2024-09-06: Had to add this Array check to pass linting errors if (Array.isArray(CurrentGroup.IconItems)) CurrentGroup.IconItems.push({ Icon: Icon, items: [Details] }); // OR Update the IconItems } else { // 2024-09-06: Had to add this Array check to pass linting errors const CurrentIconItem = Array.isArray(CurrentGroup.IconItems) ? CurrentGroup.IconItems.filter(item => item.Icon === Icon)[0] : null; if (CurrentIconItem && CurrentIconItem.items.indexOf(Details) < 0) CurrentIconItem.items.push(Details); } } //# sourceMappingURL=windowEasyIcons.js.map