PageSourceSearch

https://www.galliardhomes.com/themes/custom/galliard/assets/js/calculator.js?tltn2f

js galliardhomes.com collected 2026-10-02 11:34:29 UTC 4,489 bytes, 134 lines download raw bytes

1(function ($) {
2
3    "use strict";
4
5    $(document).ready(function () {
6        $('.js-stt-buyer').click(function () {
7            $('.js-stt-buyer').attr('disabled', 'disabled');
8
9            if ($(this).is(':checked')) {
10                $(this).removeAttr('disabled');
11            } else {
12                $('.js-stt-buyer').removeAttr('disabled');
13            }
14        });
15
16        $('.js-stt-amount').keyup(function () {
17            $('.js-stt-calculate').attr('disabled', 'disabled');
18
19            if ($(this).val() == '') {
20                return false;
21            }
22
23            let formattedValue = parseFloat($(this).val().replace(/[^0-9]/g, ''));
24
25            if (isNaN(formattedValue) || formattedValue == 0) {
26                $(this).val('');
27                return false;
28            }
29
30            $(this).val(numberWithCommas(formattedValue));
31
32            if ($(this).val() > 0 || $(this).val().length > 0) {
33                $('.js-stt-calculate').removeAttr('disabled');
34            }
35        });
36
37        $('.js-stt-calculate').click(function (e) {
38            e.preventDefault()
39
40            let amount = parseInt($('.js-stt-amount').val().replace(/,/g, ''));
41
42            if (amount.length == 0) {
43                return false;
44            }
45
46            $('.calculator-wrap .results-wrap').removeClass('d-none');
47
48            // let standardRate = [0, 0.05, 0.05, 0.05, 0.1, 0.12];
49            // let firstTimeRate = [0, 0.05, 0.05, 0.05, 0.1, 0.12];
50            // let additionalRate = [0.05, 0.1, 0.1, 0.1, 0.15, 0.17];
51
52            let standardRate = [0, 0.02, 0.05, 0.05, 0.05, 0.10, 0.12];
53            let firstTimeRate = [0, 0, 0, 0.05, 0.12, 0.12, 0.12];
54
55            let additionalRate = [0.05, 0.07, 0.10, 0.10, 0.10, 0.15, 0.17];
56                             // 125k 250k    300k   500k    925k    1,5m    > 1.5m
57            let rateSteps = [125000, 125000, 50000, 200000, 425000, 575000, 100000000];
58            //let rateSteps = [250000, 175000, 200000, 300000, 575000, 100000000];
59
60            let rest = amount;
61            let tax = 0;
62            let taxable = 0;
63            let appliedTax = standardRate;
64            let html = '';
65            let thisTax = 0;
66            let taxSurcharge = 0;
67            let thisAppliedTax = 0;
68            let taxBandFrom = 0;
69            let taxBandTo = 0;
70
71
72            if ($('.js-stt-first-time').is(':checked')) {
73                if(amount <= 500000) {
74                    appliedTax = firstTimeRate;
75                }
76
77                if (amount <= 300000) {
78                    firstTimeRate[1] = 0;
79                    // firstTimeRate[2] = 0;
80                }
81
82            } else if ($('.js-stt-second-time').is(':checked')) {
83                appliedTax = additionalRate;
84            }
85
86            if ($('.js-stt-non-uk').is(':checked')) {
87                taxSurcharge = 0.02;
88            }
89
90            for (var i = 0; i < rateSteps.length; i++) {
91
92                if (rest > 0) {
93
94                    if (rest >= rateSteps[i]) {
95                        taxable = rateSteps[i];
96                    } else {
97                        taxable = rest;
98                    }
99
100                    thisAppliedTax = parseFloat(appliedTax[i]) + parseFloat(
101                        taxSurcharge);
102                    thisAppliedTax = thisAppliedTax.toFixed(2)
103
104                    thisTax = taxable * thisAppliedTax;
105
106                    if (i > 0) {
107                        taxBandFrom += rateSteps[i - 1];
108                    }
109
110                    taxBandTo = taxBandFrom + rateSteps[i];
111
112
113                    html += '<tr><td>&pound;' + numberWithCommas(i == 0 ? taxBandFrom : taxBandFrom + 1) + (i == 6 ? '+' : ' - &pound;' + numberWithCommas(taxBandTo)) + '</td><td>' + (thisAppliedTax * 100).toFixed(0) + '%</td><td>&pound;' + numberWithCommas(taxable, 2) + '</td><td>&pound;' + numberWithCommas(thisTax, 2) + '</td></tr>';
114
115                    tax += thisTax;
116                }
117
118                rest -= rateSteps[i];
119            }
120
121            $('.js-stt-table-total-results').html('<tr><td>&pound;' + numberWithCommas(tax, 2) + '</td><td>' + numberWithCommas(((100 / amount) * tax), 1) + '%</td></tr>');
122            $('.js-stt-table-results').html(html);
123        });
124    });
125
126    function numberWithCommas(x, decimals) {
127        decimals = decimals || 0;
128
129        x = parseFloat(x);
130        x = x.toFixed(decimals);
131        return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
132
133    }
134})(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.