PageSourceSearch

https://shop.palmspringsairmuseum.org/wp-content/plugins/wpc-name-your-price/assets/js/frontend.js?ver=2.2.5

js palmspringsairmuseum.org collected 2026-09-24 18:37:23 UTC 3,601 bytes, 133 lines download raw bytes

1'use strict';
2
3(function($) {
4  var woonp_timeout = null;
5
6  $(function() {
7    $('.woonp-input').each(function() {
8      woonp_init($(this));
9    });
10  });
11
12  $(document).on('woosq_loaded', function() {
13    woonp_init($('#woosq-popup .woonp-input'));
14  });
15
16  $(document).on('found_variation', function(e, t) {
17    var $input = $(e['target']).
18        closest('.variations_form').
19        find('.woonp-input');
20
21    if ($input.length && woonp_vars.default_value === 'price') {
22      var value = parseFloat($input.val());
23
24      if ($input.data('price') === undefined) {
25        // save the default value to reset
26        $input.data('price', value);
27      }
28
29      if (t['display_price'] !== undefined && t['display_price'] !== '') {
30        $input.val(t['display_price']);
31      }
32
33      woonp_init($input);
34    }
35  });
36
37  $(document).on('reset_data', function(e) {
38    var $input = $(e['target']).
39        closest('.variations_form').
40        find('.woonp-input');
41
42    if ($input.length && woonp_vars.default_value === 'price') {
43      if ($input.data('price') !== undefined) {
44        // restore default value
45        $input.val($input.data('price'));
46      }
47
48      woonp_init($input);
49    }
50  });
51
52  $(document).on('keyup click', '.woonp-input', function() {
53    var $this = $(this);
54
55    if (woonp_timeout != null) clearTimeout(woonp_timeout);
56    woonp_timeout = setTimeout(woonp_init, 1000, $this);
57  });
58
59  function woonp_init($input) {
60    var val = parseFloat($input.val());
61    var min = parseFloat($input.attr('min'));
62    var max = parseFloat($input.attr('max'));
63    var step = parseFloat($input.attr('step'));
64
65    if ((val !== '') && !isNaN(val)) {
66      var fix = Math.pow(10, Number(woonp_decimal_places(step)) + 2);
67
68      if ((step === '') || isNaN(step) || step <= 0) {
69        step = 1;
70      }
71
72      if ((min === '') || isNaN(min) || min < 0) {
73        min = step;
74      }
75
76      if (val < 0 || val < min) {
77        val = min;
78      }
79
80      var remainder_before = woonp_float_remainder(
81          (val * fix - min * fix) / fix, step);
82
83      if (remainder_before > 0) {
84        if (woonp_vars.rounding === 'up') {
85          val = (val * fix - remainder_before * fix + step * fix) / fix;
86        } else {
87          val = (val * fix - remainder_before * fix) / fix;
88        }
89      }
90
91      if (!isNaN(min) && (val < min)) {
92        val = min;
93      }
94
95      if (!isNaN(max) && (val > max)) {
96        val = max;
97      }
98
99      var remainder = woonp_float_remainder((val * fix - min * fix) / fix,
100          step);
101
102      if (remainder > 0) {
103        val = (val * fix - remainder * fix) / fix;
104      }
105
106      $input.val(val.toFixed(woonp_vars.price_decimals)).trigger('change');
107    }
108
109    $(document.body).trigger('woonp_init', [$input, val, min, max, step]);
110  }
111
112  function woonp_decimal_places(num) {
113    var match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
114
115    if (!match) {
116      return 0;
117    }
118
119    return Math.max(0, // Number of digits right of decimal point.
120        (match[1] ? match[1].length : 0)
121        // Adjust for scientific notation.
122        - (match[2] ? +match[2] : 0));
123  }
124
125  function woonp_float_remainder(val, step) {
126    var valDecCount = (val.toString().split('.')[1] || '').length;
127    var stepDecCount = (step.toString().split('.')[1] || '').length;
128    var decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
129    var valInt = parseInt(val.toFixed(decCount).replace('.', ''));
130    var stepInt = parseInt(step.toFixed(decCount).replace('.', ''));
131    return (valInt % stepInt) / Math.pow(10, decCount);
132  }
133})(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.