PageSourceSearch

https://static.sponsr.ru/js/page/project/checkout_past.js

js sponsr.ru collected 2026-10-02 04:09:39 UTC 4,452 bytes, 145 lines download raw bytes

1'use strict';
2
3var CreditCard = require('../../core/credit_card.js');
4var payment = require('/const/payment');
5var Ajax = require('../../core/ajax.js');
6
7calcHistoryMonths(payment.history.months);
8
9$('#pay').click(function(e) {
10    e.preventDefault();
11
12    if ($('#terms_agree').prop('checked')) {
13        if (payment.history.amount > 0) {
14            pay();
15        }
16    }
17}).on('mouseenter', function () {
18
19    var terms = $('#terms_agree'),
20        warning = $('#warning_before_payment');
21
22    terms.removeClass('shake');
23    warning.removeClass('shake');
24
25
26    if (!terms.prop('checked')) {
27        terms.addClass('shake');
28        setTimeout(function () {
29            terms.removeClass('shake')
30        }, 1000);
31    }
32    if (!warning.prop('checked')) {
33        warning.addClass('shake');
34        setTimeout(function () {
35            warning.removeClass('shake')
36        }, 1000);
37    }
38
39});
40
41$('#terms_agree').change(togglePayButton);
42$('#warning_before_payment').change(togglePayButton);
43if ($('#warning_high_level').get(0) ) {
44    $('#warning_high_level').change(togglePayButton);
45}
46$('#months_value').change(function() {
47    if (this.value > parseInt($('#months_value').attr('max'))) {
48        $('#months_value').val($('#months_value').attr('max'));
49    }
50    calcHistoryMonths(this.value);
51});
52
53$('#add-new-card').click(function(e) {
54    e.preventDefault();
55
56    $('#new-card').show();
57    $('#exist-card').hide();
58});
59
60function togglePayButton() {
61    var term = $('#terms_agree').prop('checked'),
62        warningPayment = $('#warning_before_payment').prop('checked'),
63        warningHighLevel = true;
64
65    if ($('#warning_high_level').get(0) ) {
66        warningHighLevel = $('#warning_high_level').prop('checked');
67    }
68
69    $('#pay').toggleClass('disabled', (!term || payment.history.amount <= 0 || !warningPayment || !warningHighLevel));
70}
71
72
73function pay() {
74    $('#card-error').hide();
75    $('body').addClass('show-loader2');
76
77    if (($('#exist-card').length) && ($('#exist-card').is(':visible'))) {
78        createPay({token: '123', pay_id: $('#exist-card select').val()});
79    } else {
80        //CreditCard.getToken(payYandex);
81        createPay({token: '123'});
82    }
83}
84
85function createPay(params) {
86    var term = $('#terms_agree').prop('checked'),
87        warningPayment = $('#warning_before_payment').prop('checked'),
88        warningHighLevel = true;
89
90    if ($('#warning_high_level').get(0) ) {
91        warningHighLevel = $('#warning_high_level').prop('checked');
92    }
93
94    if (!term || payment.history.amount <= 0 || !warningPayment || !warningHighLevel) {
95        togglePayButton();
96        return;
97    }
98
99    var payType = 'yandex';
100
101    if (params.pay_id == 'balance') {
102        payType = 'deposit';
103    } else if (payment.is_mediacube) {
104        payType = 'stripe';
105    }
106
107    params.type = 'history';
108    params.level_id = payment.history.level_id;
109    params.months = payment.history.months;
110    params.sub_date = new Date(payment.history.sub_date).getTime();
111    params.start_date = new Date(payment.history.sub_date).getTime();
112    params.end_date = new Date(payment.history.reg_date).getTime();
113
114    CreditCard.pay('/project/' + payment.level.project_id + '/pay/' + payType, params);
115}
116
117function calcHistoryMonths(months) {
118    Ajax.postJSON('/project/' + payment.level.project_id + '/history/' + payment.history.level_id + '/' + months, { sub_date: new Date(payment.history.sub_date).getTime() }, function(data) {
119        if (!data.response) {
120            console.error((data.error && data.error.message) ? data.error.message : I18n.t('error.try_again'));
121            return;
122        }
123
124        var history = data.response;
125
126        payment.history.new_date = new Date(history.new_date);
127        payment.history.reg_date = new Date(history.reg_date);
128        payment.history.months = history.months;
129        payment.history.price = history.price;
130        payment.history.amount = history.amount;
131        $('#reg_date_text').text(history.reg_date_label);
132        $('#new_date_text').text(history.new_date_label);
133
134        $('.price_text').text(history.amount);
135
136        $('#price').text(history.price);
137        $('.post_counts').text(history.post_counts);
138        $('#publication_text').text(history.publication_text);
139        $('#months').text(history.months);
140        $('#max_months').text(history.max_months_text);
141        $('#months_value').attr('max', history.max_months);
142
143        togglePayButton();
144    });
145}

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.