PageSourceSearch

https://nam.org/wp-content/themes/wdg-nam/template-parts/blocks/card-grid/card-grid.js?ver=1790238659

js nam.org collected 2026-09-24 08:32:55 UTC 3,328 bytes, 93 lines download raw bytes

1(function($) {
2    $(document).ready(function() {
3        $('.card-grid-headline-text').each(function() {
4            var $this = $(this),
5                rawText = $this.attr('data-count');
6
7   // Check if rawText is a fraction (e.g., "1/3")
8   if (rawText.includes('/')) {
9    var parts = rawText.split('/');
10    if (parts.length === 2) {
11      var targetNumerator = parseFloat(parts[0].replace(/[^0-9.-]/g, ''));
12      var denominator = parts[1].trim();
13      $({ countNum: 0 }).animate(
14        { countNum: targetNumerator },
15        {
16          duration: 3000,
17          easing: 'linear',
18          step: function() {
19            var currentNumerator = Math.floor(this.countNum);
20            $this.text(currentNumerator + '/' + denominator);
21          },
22          complete: function() {
23            $this.text(targetNumerator + '/' + denominator);
24          }
25        }
26      );
27    } else {
28      // Fallback: output the raw value if split doesn't work.
29      $this.text(rawText);
30    }
31  } else {
32    // Normal number animation
33    var countTo = parseNumber(rawText);
34    $({ countNum: 0 }).animate(
35      { countNum: countTo },
36      {
37        duration: 3000,
38        easing: 'linear',
39        step: function() {
40          $this.text(formatNumber(Math.floor(this.countNum), rawText));
41        },
42        complete: function() {
43          $this.text(formatNumber(this.countNum, rawText));
44        }
45      }
46    );
47  }
48});
49    
50        function parseNumber(text) {
51            // Ensure text is defined and is a string
52            if (typeof text !== 'string') {
53                return 0;
54            }
55            var num = text.replace(/[^0-9.-]/g, '');
56            return parseFloat(num);
57        }
58    
59        function formatNumber(num, rawText) {
60            if (typeof rawText !== 'string') {
61                return num;
62            }
63            var hasPlus = /\+\s*$/.test(rawText);
64            var rawTextLower = rawText.toLowerCase();
65            // Strip the trailing '+' so suffix checks below (M, B, K, %, etc.) still match for inputs like "100M+".
66            var rawTextTrimmed = rawText.trim().replace(/\+$/, '');
67            var hasPrefix = rawText.includes('$');
68            var prefix = hasPrefix ? '$' : '';
69            var formatted = num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
70            var plus = hasPlus ? '+' : '';
71
72            if (/[tT]$/.test(rawTextTrimmed)) {
73                return prefix + num + 'T' + plus;
74            } else if (/[bB]$/.test(rawTextTrimmed)) {
75                return prefix + num + 'B' + plus;
76            } else if (/[mM]$/.test(rawTextTrimmed)) {
77                return prefix + num + 'M' + plus;
78            } else if (rawTextLower.includes('trillion')) {
79                return prefix + num + ' Trillion' + plus;
80            } else if (rawTextLower.includes('billion')) {
81                return prefix + num + ' Billion' + plus;
82            } else if (rawTextLower.includes('million')) {
83                return prefix + num + ' Million' + plus;
84            } else if (/[kK]$/.test(rawTextTrimmed)) {
85                return prefix + num + 'K' + plus;
86            } else if (rawText.includes('%')) {
87                return num + '%' + plus;
88            } else {
89                return prefix + formatted + plus;
90            }
91        }
92    });
93})(jQuery);

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.