PageSourceSearch

https://www.waterforpeople.org/wp-content/plugins/water-for-people…/js/impact-calculator.js?ver=1790907274

js waterforpeople.org collected 2026-10-02 03:58:12 UTC 2,574 bytes, 98 lines download raw bytes

1(function ($) {
2
3    var input = $('input.calculator-input'),
4        output = $('input.output'),
5        form = $('form#calculator'),
6        base = $('.box-a .dollar-top, .box-a .dollar, .box-b .dollar, .box-e .dollar-base'),
7        leveraged = $('.box-c .dollar-top, .box-c .dollar'),
8        impact = $('.box-e .dollar, .box-e .dollar-top');
9
10    if ( ! input.length ) {
11        return;
12    }
13
14    function keypress(e) {
15        var allowed_keys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'enter', 'return', 'backspace'];
16        if ( 'Enter' === e.key ) {
17            //calculate();
18        }
19        return -1 !== allowed_keys.indexOf( e.key.toLowerCase() );
20    }
21
22    function validateInput() {
23        var limit = 1000000;
24        var value = input.val(),
25            cleaned = value.replace(/\D/g,'');
26        if ( cleaned != value ) {
27            input.val(cleaned);
28        }
29        cleaned = Number( cleaned );
30        if ( cleaned > limit ) {
31            cleaned = limit;
32            input.val(cleaned);
33        }
34    }
35
36    var current = {
37        a: 0,
38        b: 0,
39        c: 0,
40    };
41
42    var tweens = [];
43
44    function calculate() {
45
46        validateInput();
47
48        var _base = Number( input.val() ),
49            _leveraged = _base * 1.535,
50            _impact = _leveraged * 7;
51
52        var a = {val: current.a},
53            b = {val: current.b},
54            c = {val: current.c};
55
56        current.a = _base;
57        current.b = _leveraged;
58        current.c = _impact;
59
60        for( var i in tweens ) {
61            var tween = tweens[i];
62            tween.kill();
63        }
64        tweens = [];
65
66        var time = 3;
67
68        tweens.push(TweenLite.to(a, time, {
69            val: _base,
70            onUpdate: function () {
71                base.text('$' + a.val.toFixed(2));
72            }
73        }));
74
75        tweens.push(TweenLite.to(b, time, {
76            val: _leveraged,
77            onUpdate: function () {
78                leveraged.text('$' + b.val.toFixed(2));
79            }
80        }));
81
82        tweens.push(TweenLite.to(c, time, {
83            val: _impact,
84            onUpdate: function () {
85                impact.text('$' + c.val.toFixed(2));
86                $('input.output').val( '$' +  c.val.toFixed(2) );
87            }
88        }));
89    }
90
91    // Calculation triggers.
92    input.on('keypress', keypress);
93    //input.on('keyup', calculate);
94    input.on('change', calculate);
95    input.val('0' );
96    calculate();
97
98})(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.