PageSourceSearch

https://www.jhrl.com/sites/all/modules/rescms/rc_riot/js/mixins/RCRiotUtils.js?tlse4v

js jhrl.com collected 2026-10-06 13:18:18 UTC 3,319 bytes, 108 lines download raw bytes

1var LDRCCurrencySymbols = {
2  'USD': '$', // US Dollar
3  'CAD': '$', // US Dollar
4  'EUR': '€' // Euro
5};
6
7(function($) {
8  var RCRiotUtils = {
9    RCRiotUtils: {
10      formatTimestamp: function(ts, opts) {
11        return new Date(ts).toLocaleString(window.navigator.language, Object.assign({
12          weekday: 'short',
13          day: 'numeric',
14          month: 'short'
15        }, opts || {}))
16      },
17      formatSavings: function(price, precision, format) {
18        var amt = parseFloat(price.s);
19        return this.formatHelper(amt, price, precision, format);
20      },
21      formatOriginalPrice: function(price, precision, format) {
22        var amt = parseFloat(price.p) + parseFloat(price.s);
23        return this.formatHelper(amt, price, precision, format);
24      },
25      formatPrice: function(price, precision, format) {
26        var amt = parseFloat(price.p);
27        return this.formatHelper(amt, price, precision, format);
28      },
29      formatHelper: function(amt, price, precision, format) {
30        var suffix = '';
31
32        switch(parseInt(format)) {
33          case 8:
34            amt = amt / this.nightsBetween(price.bt, price.et);
35            suffix = '/nt';
36            break;
37        }
38
39        return '' + this.formatCurrency(amt, price.c, precision) + suffix;
40      },
41      formatCurrency: function (amt, cur, precision) {
42        amt = parseFloat(amt);
43        if(typeof precision === 'undefined') {
44          precision = 0;
45        }
46        if (this.toLocaleStringSupportsOptions()) {
47          return amt.toLocaleString('en', {
48            style: 'currency',
49            currencyDisplay: 'symbol',
50            currency: cur,
51            minimumFractionDigits: precision,
52            maximumFractionDigits: precision
53          })
54        }
55
56        amt.toFixed(precision).replace(/./g, function(c, i, a) {
57          return i && c !== "." && ((a.length - i) % 3 === 0) ? ',' + c : c;
58        });
59
60        if(typeof LDRCCurrencySymbols[cur] !== 'undefined') {
61          return LDRCCurrencySymbols[cur] + amt;
62        }
63
64        return amt;
65      },
66
67      toLocaleStringSupportsOptions: function () {
68        return !!(typeof Intl == 'object' && Intl && typeof Intl.NumberFormat == 'function');
69      },
70
71      parseQueryParams: function () {
72        var query = window.location.search.substring(1),
73          vars = query.split('&'),
74          ret = {};
75        for (var i = 0; i < vars.length; i++) {
76          (function () {
77            var pair = vars[i].split('=');
78            ret[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
79          })();
80        }
81        return ret;
82      },
83
84      parseHash: function () {
85        var query = window.location.hash.substring(1),
86          vars = query.split('&'),
87          ret = {};
88        for (var i = 0; i < vars.length; i++) {
89          (function () {
90            var pair = vars[i].split('=');
91            ret[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
92          })();
93        }
94        return ret;
95      },
96
97      nightsBetween: function(a, b) {
98        var ret = Math.round((b - a) / 86400 / 1000)
99        return ret
100      },
101
102      getBuyUrl: function(price) {
103        return '/rescms/item/' + price.eid + '/buy?' + $.param(price.qp);
104      }
105    }
106  }
107  riot.mixin('RCRiotUtils', RCRiotUtils);
108})(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.