PageSourceSearch

https://tirexl2.ru/src/template/logan22/assets/sphere/js/pay.js

js tirexl2.ru collected 2026-10-06 07:17:42 UTC 5,644 bytes, 177 lines download raw bytes

1$(document).ready(function() {
2    if (!$('input[name="paysystem"]:checked').length) {
3        $('input[name="paysystem"]:first').prop('checked', true);
4    }
5});
6$("#countValue").val( ( currency_exchange.min_donate_bonus_coin+currency_exchange.max_donate_bonus_coin)/2 );
7
8
9$(".count").change(function () {
10    let id = $(this).data("id");
11    let item_id = $(this).data("item-id");
12    let default_count = $(this).data("default_count");
13    let default_cost = $(this).data("default_cost");
14    let user_value = $(this).val();
15    if (user_value <= 0) {
16        $(this).val(1);
17        return;
18    }
19    let count = default_count * user_value;
20    let cost = default_cost * user_value;
21    if (currency_exchange.DONATE_DISCOUNT_COUNT_ENABLE) {
22        let obj = currency_exchange.discount_count_product.table;
23        let items = currency_exchange.discount_count_product.items;
24
25        if (items.length === 0 || items.includes(item_id)) {
26            let discount = findValueForN(user_value, obj);
27
28            if (discount) {
29                cost = reduceByPercentage(cost, discount);
30                $("#discount_item_" + id).text("(-" + discount + "%)");
31            } else {
32                $("#discount_item_" + id).text("");
33            }
34        }
35    }
36
37    $("#product_count_" + id).text(count);
38    $("#product_cost_" + id).text(Math.floor(cost));
39});
40
41function reduceByPercentage(number, percentage) {
42    if (percentage >= 0 && percentage <= 100) {
43        return number * (1 - percentage / 100);
44    } else {
45        console.log('Error: Percentage should be in the range from 0 to 100.');
46        return number;
47    }
48}
49
50function findValueForN(inputN, keyValueObject) {
51    let result = null;
52    for (const key in keyValueObject) {
53        const currentKey = parseInt(key);
54        if (currentKey > inputN) {
55            break;
56        }
57        result = keyValueObject[key];
58    }
59    return result;
60}
61
62
63$(document).on("click", ".openWindowBuy", function () {
64    id = $(this).data("product-id");
65    let item_id = $(this).data("item-id");
66
67    name = $(this).data("product-name");
68    count = $(this).data("product-count");
69    cost = $(this).data("product-cost");
70
71    product_count = $("#product_count_" + id).text();
72
73    user_value = $("#user_value_" + id).text();
74    if (user_value == 0) {
75        user_value = $("#user_value_" + id).val();
76    }
77
78    if (currency_exchange.DONATE_DISCOUNT_COUNT_ENABLE) {
79        let obj = currency_exchange.discount_count_product.table;
80        let items = currency_exchange.discount_count_product.items;
81
82        if (items.length === 0 || items.includes(item_id)) {
83            let discount = findValueForN(user_value, obj);
84
85            if (discount) {
86                cost = reduceByPercentage(cost, discount);
87                $("#discount_item_" + id).text("(-" + discount + "%)");
88            } else {
89                $("#discount_item_" + id).text("");
90            }
91        }
92    }
93
94
95    $("#user_count_buy").text(count*user_value);
96    $("#user_worth_buy").text(cost*user_value);
97
98    $("#user_name_buy").text(name);
99
100    $('#buy').attr('data-product-id', id);
101    $('#buy').attr('data-user_value', user_value);
102
103});
104
105
106$(document).on("click", "#buy", function (event) {
107    event.preventDefault();
108    count = $("#user_count_buy").text();
109    name = $("#user_name_buy").text();
110    $.ajax({
111        type: "POST",
112        url: baseHref + "/donate/transaction",
113        data: {
114            server_id: $(this).attr("data-server_id"),
115            id: $(this).attr("data-product-id"),
116            user_value: $("#buy").attr("data-user_value"),
117            char_name: $("#char_name").val(),
118        },
119        dataType: "json",
120        encode: true,
121    }).done(function (data) {
122        if (data.ok) {
123            notify_success(data.message + " " + name + " (" + count +")");
124            $('#modal_panel_apply').modal('toggle');
125            $(".header_donate_point_count").text(data.donate_bonus);
126        } else {
127            notify_error(data.message);
128        }
129    });
130
131});
132
133
134function currency(val) {
135    const currencies = ['RUB', 'UAH', 'USD', 'EUR'];
136
137    currencies.forEach((currency) => {
138        let amount = (val * currency_exchange.coefficient[currency]) / currency_exchange.quantity;
139        if (isNaN(amount)) {
140            amount = 0;
141        }
142        $(`[data-count="${currency.toLowerCase()}"]`).text(amount.toFixed(1));
143    });
144}
145
146
147$(document).on('input', '#countPayUser', function () {
148    currency($(this).val());
149});
150
151$(document).on('click', '#paynext', function () {
152    paysystem = $('input[name=paysystem]:checked').val();
153    // if (typeof paysystem === 'undefined') {
154    //     notify_error("Выберите платежную систему");
155    //     return;
156    // }
157    var count = $("#countPayUser").val();
158    // if(count < currency_exchange.min_donate_bonus_coin || count > currency_exchange.max_donate_bonus_coin){
159    //     notify_error("Минимальное количество "+currency_exchange.min_donate_bonus_coin+" максимальное "+currency_exchange.max_donate_bonus_coin);
160    //     return;
161    // }
162    $.ajax(
163        {
164            type: "POST",
165            url: baseHref + "/donate/transfer/" + paysystem + "/createlink",
166            data: ({"count": count}),
167            async: false,
168            success: function (redirectLink) {
169                console.log(redirectLink)
170                if (redirectLink['ok'] === false) {
171                    notify_error(redirectLink['message'])
172                    return;
173                }
174                window.open(redirectLink, '_blank');
175            }
176        });
177});

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.