2022-02-22 21:58:21 +01:00
|
|
|
/* eslint-disable require-unicode-regexp */
|
|
|
|
import {
|
|
|
|
ALERTS_ROUTE,
|
|
|
|
ADVANCED_ROUTE,
|
|
|
|
SECURITY_ROUTE,
|
|
|
|
GENERAL_ROUTE,
|
|
|
|
ABOUT_US_ROUTE,
|
|
|
|
NETWORKS_ROUTE,
|
|
|
|
CONTACT_LIST_ROUTE,
|
|
|
|
EXPERIMENTAL_ROUTE,
|
2022-03-23 17:47:54 +01:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
|
|
|
SNAPS_LIST_ROUTE,
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2022-02-22 21:58:21 +01:00
|
|
|
} from '../constants/routes';
|
|
|
|
|
|
|
|
function showHideSettings(t, settings) {
|
2022-03-23 17:47:54 +01:00
|
|
|
if (process.env.COLLECTIBLES_V1) {
|
|
|
|
return [
|
|
|
|
...settings,
|
|
|
|
{
|
|
|
|
tab: t('experimental'),
|
|
|
|
section: t('enableOpenSeaAPI'),
|
|
|
|
description: t('enableOpenSeaAPIDescription'),
|
|
|
|
route: `${EXPERIMENTAL_ROUTE}#opensea-api`,
|
|
|
|
icon: 'fa fa-flask',
|
|
|
|
id: settings.length + 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('experimental'),
|
|
|
|
section: t('useCollectibleDetection'),
|
|
|
|
description: t('useCollectibleDetectionDescription'),
|
|
|
|
route: `${EXPERIMENTAL_ROUTE}#autodetect-nfts`,
|
|
|
|
icon: 'fa fa-flask',
|
|
|
|
id: settings.length + 2,
|
|
|
|
},
|
|
|
|
];
|
2022-02-22 21:58:21 +01:00
|
|
|
}
|
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getSettingsRoutes(t) {
|
2022-03-22 20:14:59 +01:00
|
|
|
let settingsRoutesList = [
|
2022-02-22 21:58:21 +01:00
|
|
|
{
|
|
|
|
tab: t('general'),
|
|
|
|
section: t('currencyConversion'),
|
|
|
|
description: '',
|
|
|
|
route: `${GENERAL_ROUTE}#currency-conversion`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-cog',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('general'),
|
|
|
|
section: t('primaryCurrencySetting'),
|
|
|
|
description: t('primaryCurrencySettingDescription'),
|
|
|
|
route: `${GENERAL_ROUTE}#primary-currency`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-cog',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('general'),
|
|
|
|
section: t('currentLanguage'),
|
|
|
|
description: '',
|
|
|
|
route: `${GENERAL_ROUTE}#current-language`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-cog',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('general'),
|
|
|
|
section: t('accountIdenticon'),
|
|
|
|
description: '',
|
|
|
|
route: `${GENERAL_ROUTE}#account-identicon`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-cog',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('general'),
|
|
|
|
section: t('hideZeroBalanceTokens'),
|
|
|
|
description: '',
|
|
|
|
route: `${GENERAL_ROUTE}#zero-balancetokens`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-cog',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('stateLogs'),
|
|
|
|
description: t('stateLogsDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#state-logs`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('syncWithMobile'),
|
|
|
|
description: '',
|
|
|
|
route: `${ADVANCED_ROUTE}#sync-withmobile`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('resetAccount'),
|
|
|
|
description: t('resetAccountDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#reset-account`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('showAdvancedGasInline'),
|
|
|
|
description: t('showAdvancedGasInlineDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#advanced-gascontrols`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('showHexData'),
|
|
|
|
description: t('showHexDataDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#show-hexdata`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('showFiatConversionInTestnets'),
|
|
|
|
description: t('showFiatConversionInTestnetsDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#conversion-testnetworks`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('showTestnetNetworks'),
|
|
|
|
description: t('showTestnetNetworksDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#show-testnets`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('nonceField'),
|
|
|
|
description: t('nonceFieldDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#customize-nonce`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('autoLockTimeLimit'),
|
|
|
|
description: t('autoLockTimeLimitDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#autolock-timer`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('syncWithThreeBox'),
|
|
|
|
description: t('syncWithThreeBoxDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#sync-with3box`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('ipfsGateway'),
|
|
|
|
description: t('ipfsGatewayDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#ipfs-gateway`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('preferredLedgerConnectionType'),
|
|
|
|
description: t('preferredLedgerConnectionType'),
|
|
|
|
route: `${ADVANCED_ROUTE}#ledger-connection`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('dismissReminderField'),
|
|
|
|
description: t('dismissReminderDescriptionField'),
|
|
|
|
route: `${ADVANCED_ROUTE}#dimiss-secretrecovery`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('contacts'),
|
|
|
|
section: t('contacts'),
|
|
|
|
description: t('contacts'),
|
|
|
|
route: CONTACT_LIST_ROUTE,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-address-book',
|
|
|
|
},
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
|
|
|
{
|
|
|
|
tab: t('snaps'),
|
|
|
|
section: t('snaps'),
|
|
|
|
description: t('snaps'),
|
|
|
|
route: SNAPS_LIST_ROUTE,
|
|
|
|
icon: 'fa fa-flask',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
2022-03-23 17:47:54 +01:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
2022-02-22 21:58:21 +01:00
|
|
|
{
|
|
|
|
tab: t('securityAndPrivacy'),
|
|
|
|
section: t('revealSeedWords'),
|
|
|
|
description: t('revealSeedWords'),
|
|
|
|
route: `${SECURITY_ROUTE}#reveal-secretrecovery`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-lock',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('securityAndPrivacy'),
|
|
|
|
section: t('showIncomingTransactions'),
|
|
|
|
description: t('showIncomingTransactionsDescription'),
|
|
|
|
route: `${SECURITY_ROUTE}#incoming-transaction`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-lock',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('securityAndPrivacy'),
|
|
|
|
section: t('usePhishingDetection'),
|
|
|
|
description: t('usePhishingDetectionDescription'),
|
|
|
|
route: `${SECURITY_ROUTE}#phishing-detection`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-lock',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('securityAndPrivacy'),
|
|
|
|
section: t('participateInMetaMetrics'),
|
|
|
|
description: t('participateInMetaMetricsDescription'),
|
|
|
|
route: `${SECURITY_ROUTE}#metrametrics`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-lock',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('alerts'),
|
|
|
|
section: t('alertSettingsUnconnectedAccount'),
|
|
|
|
description: t('alertSettingsUnconnectedAccount'),
|
|
|
|
route: `${ALERTS_ROUTE}#unconnected-account`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-bell',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('alerts'),
|
|
|
|
section: t('alertSettingsWeb3ShimUsage'),
|
|
|
|
description: t('alertSettingsWeb3ShimUsage'),
|
|
|
|
route: `${ALERTS_ROUTE}#web3-shimusage`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-bell',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('networks'),
|
|
|
|
section: t('mainnet'),
|
|
|
|
description: t('mainnet'),
|
|
|
|
route: `${NETWORKS_ROUTE}#networks-mainnet`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-plug',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('networks'),
|
|
|
|
section: t('ropsten'),
|
|
|
|
description: t('ropsten'),
|
|
|
|
route: `${NETWORKS_ROUTE}#networks-ropsten`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-plug',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('networks'),
|
|
|
|
section: t('rinkeby'),
|
|
|
|
description: t('rinkeby'),
|
|
|
|
route: `${NETWORKS_ROUTE}#networks-rinkeby`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-plug',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('networks'),
|
|
|
|
section: t('goerli'),
|
|
|
|
description: t('goerli'),
|
|
|
|
route: `${NETWORKS_ROUTE}#networks-goerli`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-plug',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('networks'),
|
|
|
|
section: t('kovan'),
|
|
|
|
description: t('kovan'),
|
2022-03-23 17:47:54 +01:00
|
|
|
route: `${NETWORKS_ROUTE}#networks-kovan`,
|
|
|
|
icon: 'fa fa-plug',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('networks'),
|
|
|
|
section: t('localhost'),
|
|
|
|
description: t('localhost'),
|
2022-03-23 17:47:54 +01:00
|
|
|
route: `${NETWORKS_ROUTE}#networks-localhost`,
|
|
|
|
icon: 'fa fa-plug',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('about'),
|
|
|
|
section: t('metamaskVersion'),
|
|
|
|
description: t('builtAroundTheWorld'),
|
|
|
|
route: `${ABOUT_US_ROUTE}#version`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-info-circle',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('about'),
|
|
|
|
section: t('links'),
|
|
|
|
description: '',
|
|
|
|
route: `${ABOUT_US_ROUTE}#links`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-info-circle',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('about'),
|
|
|
|
section: t('privacyMsg'),
|
|
|
|
description: t('privacyMsg'),
|
|
|
|
route: `${ABOUT_US_ROUTE}#privacy-policy`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-info-circle',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
tab: t('about'),
|
|
|
|
section: t('terms'),
|
|
|
|
description: t('terms'),
|
|
|
|
route: `${ABOUT_US_ROUTE}#terms`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-info-circle',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
tab: t('about'),
|
|
|
|
section: t('attributions'),
|
|
|
|
description: t('attributions'),
|
|
|
|
route: `${ABOUT_US_ROUTE}#attributions`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-info-circle',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
tab: t('about'),
|
|
|
|
section: t('supportCenter'),
|
|
|
|
description: t('supportCenter'),
|
|
|
|
route: `${ABOUT_US_ROUTE}#supportcenter`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-info-circle',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
tab: t('about'),
|
|
|
|
section: t('visitWebSite'),
|
|
|
|
description: t('visitWebSite'),
|
|
|
|
route: `${ABOUT_US_ROUTE}#visitwebsite`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-info-circle',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
tab: t('about'),
|
|
|
|
section: t('contactUs'),
|
|
|
|
description: t('contactUs'),
|
|
|
|
route: `${ABOUT_US_ROUTE}#contactus`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-info-circle',
|
2022-02-22 21:58:21 +01:00
|
|
|
},
|
2022-03-28 16:50:32 +02:00
|
|
|
{
|
|
|
|
tab: t('experimental'),
|
|
|
|
section: t('enableEIP1559V2'),
|
|
|
|
description: t('enableEIP1559V2Description'),
|
|
|
|
route: `${EXPERIMENTAL_ROUTE}#enable-advanced-gas`,
|
|
|
|
icon: 'fa fa-flask',
|
|
|
|
},
|
2022-02-22 21:58:21 +01:00
|
|
|
];
|
2022-03-22 20:14:59 +01:00
|
|
|
if (process.env.TOKEN_DETECTION_V2) {
|
|
|
|
settingsRoutesList = [
|
|
|
|
...settingsRoutesList,
|
|
|
|
{
|
|
|
|
/** TODO: Remove during TOKEN_DETECTION_V2 feature flag clean up */
|
|
|
|
tab: t('advanced'),
|
|
|
|
section: t('tokenDetection'),
|
|
|
|
description: t('tokenDetectionToggleDescription'),
|
|
|
|
route: `${ADVANCED_ROUTE}#token-description`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fas fa-sliders-h',
|
2022-03-22 20:14:59 +01:00
|
|
|
},
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
settingsRoutesList = [
|
|
|
|
...settingsRoutesList,
|
|
|
|
{
|
|
|
|
/** TODO: Remove during TOKEN_DETECTION_V2 feature flag clean up */
|
|
|
|
tab: t('experimental'),
|
|
|
|
section: t('useTokenDetection'),
|
|
|
|
description: t('useTokenDetectionDescription'),
|
|
|
|
route: `${EXPERIMENTAL_ROUTE}#token-description`,
|
2022-03-23 17:47:54 +01:00
|
|
|
icon: 'fa fa-flask',
|
2022-03-22 20:14:59 +01:00
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
2022-03-23 17:47:54 +01:00
|
|
|
for (let i = 0; i < settingsRoutesList.length; i++) {
|
|
|
|
settingsRoutesList[i].id = i + 1;
|
|
|
|
}
|
2022-02-22 21:58:21 +01:00
|
|
|
// TODO: write to json file?
|
|
|
|
return showHideSettings(t, settingsRoutesList);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFilteredSettingsRoutes(t, tabName) {
|
|
|
|
return getSettingsRoutes(t).filter((s) => s.tab === tabName);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getSettingsSectionNumber(t, tabName) {
|
|
|
|
return getSettingsRoutes(t).filter((s) => s.tab === tabName).length;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function handleSettingsRefs(t, tabName, settingsRefs) {
|
|
|
|
const settingsSearchJsonFiltered = getFilteredSettingsRoutes(t, tabName);
|
|
|
|
const settingsRefsIndex = settingsSearchJsonFiltered.findIndex(
|
|
|
|
(s) => s.route.substring(1) === window.location.hash.substring(1),
|
|
|
|
);
|
|
|
|
if (
|
|
|
|
settingsRefsIndex !== -1 &&
|
|
|
|
settingsRefs[settingsRefsIndex].current !== null
|
|
|
|
) {
|
|
|
|
settingsRefs[settingsRefsIndex].current.scrollIntoView({
|
|
|
|
behavior: 'smooth',
|
|
|
|
});
|
|
|
|
settingsRefs[settingsRefsIndex].current.focus();
|
|
|
|
const historySettingsUrl = window.location.hash.split('#')[1];
|
|
|
|
window.location.hash = historySettingsUrl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function handleHooksSettingsRefs(t, tabName, settingsRefs, itemIndex) {
|
|
|
|
const settingsSearchJsonFiltered = getFilteredSettingsRoutes(t, tabName);
|
|
|
|
const settingsRefsIndex = settingsSearchJsonFiltered.findIndex(
|
|
|
|
(s) => s.route.substring(1) === window.location.hash.substring(1),
|
|
|
|
);
|
|
|
|
|
|
|
|
if (
|
|
|
|
settingsRefsIndex !== -1 &&
|
|
|
|
settingsRefs !== null &&
|
|
|
|
itemIndex === settingsRefsIndex
|
|
|
|
) {
|
|
|
|
settingsRefs.current.scrollIntoView({
|
|
|
|
behavior: 'smooth',
|
|
|
|
});
|
|
|
|
settingsRefs.current.focus();
|
|
|
|
const historySettingsUrl = window.location.hash.split('#')[1];
|
|
|
|
window.location.hash = historySettingsUrl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function colorText(menuElement, regex) {
|
|
|
|
if (menuElement !== null) {
|
|
|
|
let elemText = menuElement?.innerHTML;
|
|
|
|
elemText = elemText.replace('&', '&');
|
|
|
|
elemText = elemText.replace(
|
|
|
|
/(<span style="background:#ffd33d">|<\/span>)/gim,
|
|
|
|
'',
|
|
|
|
);
|
|
|
|
menuElement.innerHTML = elemText.replace(
|
|
|
|
regex,
|
|
|
|
'<span style="background:#ffd33d">$&</span>',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2022-02-24 20:06:30 +01:00
|
|
|
export function highlightSearchedText() {
|
|
|
|
const searchElem = document.getElementById('search-settings');
|
|
|
|
const searchRegex = new RegExp(searchElem.value, 'gi');
|
|
|
|
const results = document.querySelectorAll(
|
|
|
|
'.settings-page__header__search__list__item',
|
2022-02-22 21:58:21 +01:00
|
|
|
);
|
|
|
|
|
2022-02-24 20:06:30 +01:00
|
|
|
[...results].forEach((element) => {
|
|
|
|
const menuTabElement = element.querySelector(
|
|
|
|
'.settings-page__header__search__list__item__tab',
|
|
|
|
);
|
|
|
|
const menuSectionElement = element.querySelector(
|
|
|
|
'.settings-page__header__search__list__item__section',
|
|
|
|
);
|
|
|
|
|
2022-02-22 21:58:21 +01:00
|
|
|
colorText(menuTabElement, searchRegex);
|
|
|
|
colorText(menuSectionElement, searchRegex);
|
|
|
|
});
|
|
|
|
}
|