PageSourceSearch

https://dmcnews.org/app/themes/dmcnews/assets/js/glossary-tips.js?ver=1779088668

js dmcnews.org collected 2026-10-02 04:22:02 UTC 5,752 bytes, 78 lines download raw bytes

1/**
2 * Glossary tooltips — auto-attach to common crypto/finance jargon.
3 *
4 * Scans the page for label text and wraps matches in <abbr> with a tooltip.
5 * Plus exposes a CSS-driven hover/focus tooltip for any `[data-tip]` element.
6 */
7(function () {
8  // Definitions kept short — full glossary lives at /glossary/
9  var GLOSSARY = {
10    'Market cap':           'Total dollar value of all circulating coins. Calculated as price × circulating supply.',
11    'Market Cap':           'Total dollar value of all circulating coins. Calculated as price × circulating supply.',
12    'FDV':                  'Fully Diluted Valuation: market cap if all coins (including not-yet-issued) were in circulation today.',
13    '24h volume':           'Total dollar value of trades across all exchanges in the last 24 hours. Indicates liquidity.',
14    '24h Volume':           'Total dollar value of trades across all exchanges in the last 24 hours. Indicates liquidity.',
15    'Circ. supply':         'Coins currently in public circulation. Excludes locked, treasury, and burned tokens.',
16    'Circulating':          'Coins currently in public circulation. Excludes locked, treasury, and burned tokens.',
17    'Max supply':           'The hard cap on how many of this coin can ever exist. ∞ means no cap.',
18    'All-time high':        'The highest price ever recorded for this coin (in USD).',
19    'All-time low':         'The lowest price recorded since the coin started trading.',
20    'From ATH':             'Distance from the all-time high price, as a percentage.',
21    'From ATL':             'Distance from the all-time low price, as a percentage.',
22    'Vol / Cap':            'Volume divided by market cap. Higher = more trading relative to size. >5% suggests high turnover.',
23    'RSI':                  'Relative Strength Index. 0–100 momentum oscillator. <30 = oversold, >70 = overbought (Wilder 14-day).',
24    'Bull-Bear Score':      'Composite 0-100 momentum score blending RSI, moving-average position, and volatility.',
25    'Moving Avg Signal':    'Crossover state of 50-day vs 200-day simple moving averages. Bull = upward trend, Bear = downward.',
26    'Volatility':           'Standard deviation of daily log returns, annualised. Higher = larger price swings.',
27    'Hashrate':             'Total computational power securing the Bitcoin network. Higher = harder to attack.',
28    'Difficulty':           'Algorithmic measure of how hard it is to mine a new block. Auto-adjusts every 2,016 blocks.',
29    'Mempool':              'Pool of unconfirmed Bitcoin transactions waiting to be included in a block.',
30    'sat/vB':               'Fee unit: satoshis per virtual byte. Higher = faster confirmation. 1 BTC = 100M satoshis.',
31    'gwei':                 'Fee unit for Ethereum: 1 gwei = 0.000000001 ETH. Gas fee = gas units × gas price (gwei).',
32    'Bullish votes':        'Percentage of CoinGecko community voters who feel bullish about this coin in the last 24h.',
33    'Trust':                'CoinGecko exchange trust score: liquidity, order-book depth, and scale. Green = highest confidence.'
34  };
35
36  // CSS injection — once
37  if (!document.getElementById('dmc-tip-style')) {
38    var st = document.createElement('style');
39    st.id = 'dmc-tip-style';
40    st.textContent = ''
41      + '[data-tip]{position:relative;cursor:help;text-decoration:underline dotted;text-decoration-thickness:1px;text-underline-offset:2px;text-decoration-color:var(--ink2,#94a3b8)}
41'
42      + '[data-tip]:hover, [data-tip]:focus-visible{outline:none}'
43      + '[data-tip]:hover::after, [data-tip]:focus-visible::after{content:attr(data-tip);position:absolute;left:50%;bottom:calc(100% + 8px);transform:translateX(-50%);background:var(--surface, #1a1a2e);color:var(--ink, #fff);border:1px solid var(--border, #333);border-radius:6px;padding:6px 10px;font-size:11px;font-weight:400;line-height:1.4;width:max-content;max-width:280px;white-space:normal;text-decoration:none;z-index:1000;box-shadow:0 6px 16px rgba(0,0,0,.25);pointer-events:none}'
44      + '[data-tip]:hover::before, [data-tip]:focus-visible::before{content:"";position:absolute;left:50%;bottom:calc(100% + 4px);transform:translateX(-50%);border:4px solid transparent;border-top-color:var(--border, #333);z-index:1000}'
45      + 'html.theme-light [data-tip]:hover::after, html.theme-light [data-tip]:focus-visible::after{background:#fff;color:#0A0E1A;border-color:#E2E6EE}'
46      + 'html.theme-light [data-tip]:hover::before, html.theme-light [data-tip]:focus-visible::before{border-top-color:#E2E6EE}'
47      ;
48    document.head.appendChild(st);
49  }
50
51  // Auto-wrap labels in `dt`, `th`, `.section-title h2`, label spans
52  var selectors = [
53    'main dt',                                  // Key facts labels
54    'main th',                                  // Table headers
55    'main .text-[10px].uppercase',              // Mini-card labels
56    'main label > span:first-child',            // Form labels
57  ];
58  var nodes = document.querySelectorAll(selectors.join(','));
59  nodes.forEach(function(node) {
60    if (node.dataset.tipped) return;
61    var txt = node.textContent.trim();
62    // Match exact, case-sensitive first then case-insensitive
63    var def = GLOSSARY[txt];
64    if (!def) {
65      // Try matching by stripping inline data values like "BTC · 24h range" -> match "24h range"
66      var key = Object.keys(GLOSSARY).find(function(k){
67        return txt === k || txt.endsWith(' ' + k) || txt.startsWith(k + ' ');
68      });
69      if (key) def = GLOSSARY[key];
70    }
71    if (def) {
72      node.setAttribute('data-tip', def);
73      node.dataset.tipped = '1';
74      // Make it focusable for keyboard users
75      if (!node.hasAttribute('tabindex')) node.setAttribute('tabindex', '0');
76    }
77  });
78})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.