@mikezimm/fps-core-v7
Version:
Library of reusable core interfaces, types and constants migrated from fps-library-v2
71 lines • 2.83 kB
JavaScript
/**
* 2024-09-03: Migrated from fps-Pnp2/src/services/sp
*/
import { BannerHelpTricks, CommonUITricks, FPSFetchTricks, OtherMiscTricks } from "../../banner/components/SingleHelpPage/interfaces/ITrickRow";
import { BeakerModeTricksWHeading } from '../../banner/components/SingleHelpPage/interfaces/ITrickRow';
export function check4This(test, exactCase = false) {
// If text does not exist, then return true.
if (!test)
return true;
const compareThis = exactCase === true ? window.location.search : window.location.search.toLowerCase();
const withThis = exactCase === true ? test : test.toLowerCase();
if (compareThis.indexOf(withThis) > -1) {
return true;
}
else if (test.indexOf(`=false`) > -1 && compareThis.indexOf(withThis) > -1) {
// have way to supress this log even if showAllConsole=true below https://github.com/mikezimm/Compliance/issues/178
return false;
}
else if (compareThis.indexOf(Check4.showAllConsole_Eq_true.toLowerCase()) > -1) {
return true;
}
else {
return false;
}
;
}
export const Check4FPSFetchTricks = convertTricksRowsToCheck4Object(FPSFetchTricks);
export const Check4BeakerModeTricks = convertTricksRowsToCheck4Object(BeakerModeTricksWHeading);
export const FullPageBGParams = convertTricksRowsToParamArray(BeakerModeTricksWHeading);
export const Check4CommonUITricks = convertTricksRowsToCheck4Object(CommonUITricks);
export const Check4BannerHelpTricks = convertTricksRowsToCheck4Object(BannerHelpTricks);
export const Check4OtherMiscTricks = convertTricksRowsToCheck4Object(OtherMiscTricks);
export const Check4 = {
...Check4FPSFetchTricks,
...Check4CommonUITricks,
...Check4BannerHelpTricks,
...Check4BeakerModeTricks,
...Check4OtherMiscTricks,
};
/**
* Takes the array of Tricks objects and returns a key/value pair of the Check4 like:
* {
* showFPS_Eq_true: `showFPS=true`,
* }
* @param trickRow
* @returns
*/
export function convertTricksRowsToCheck4Object(trickRow) {
const result = trickRow
.filter(item => item.op !== 'heading') // Remove heading rows
.reduce((acc, item) => {
acc[`${item.param}_Eq_${item.value}`] = `${item.param}=${item.value}`;
return acc;
}, {});
return result;
}
/**
* Takes the array of Tricks objects and returns an array of params like: [ `showFPS=true` ]
* @param trickRow
* @returns
*/
export function convertTricksRowsToParamArray(trickRow) {
const result = trickRow
.filter(item => item.op !== 'heading') // Remove heading rows
.map((item) => {
const str = `${item.param}=${item.value}`;
return str;
});
return result;
}
//# sourceMappingURL=CheckSearch.js.map