PageSourceSearch

https://www.snafu.de/wp-content/plugins/subscribe-to-download/js/std-frontend.js?ver=2.0.2

js snafu.de collected 2026-09-24 07:26:47 UTC 5,788 bytes, 173 lines download raw bytes

1function std_setCookie(cname, cvalue, exdays) {
2    const d = new Date();
3    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
4    let expires = "expires=" + d.toUTCString();
5    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
6}
7function std_getCookie(cname) {
8    let name = cname + "=";
9    let decodedCookie = decodeURIComponent(document.cookie);
10    let ca = decodedCookie.split(';');
11    for (let i = 0; i < ca.length; i++) {
12        let c = ca[i];
13        while (c.charAt(0) == ' ') {
14            c = c.substring(1);
15        }
16        if (c.indexOf(name) == 0) {
17            return c.substring(name.length, c.length);
18        }
19    }
20    return "";
21}
22jQuery(document).ready(function ($) {
23    "use strict";
24
25    /**
26     * Scrolls to the first error of the form
27     *
28     */
29    function std_scroll_to_error(form) {
30        form.find('.std-error-highlight').each(function () {
31            var in_selector = $(this);
32            $('html,body').animate({
33                scrollTop: in_selector.closest('div').offset().top - 150
34            },
35                'slow');
36            return false;
37
38        });
39
40    }
41
42    $(document).on('focus', '.std-front-datepicker', function () {
43        $(this).datepicker({
44            todayHighlight: true,
45            format: $(this).data('date-format'),
46            autoclose: true
47        })
48    });
49
50    /**
51     * Form Submission
52     * 
53     * @since 1.0.0
54     */
55    $('body').on('submit', '.std-subscription-form', function (e) {
56        e.preventDefault();
57        var selector = $(this);
58        var form_alias = $(this).data('form-alias');
59        var form_data = $(this).serialize();
60        $.ajax({
61            type: 'post',
62            url: std_frontend_obj.ajax_url,
63            data: {
64                form_data: form_data,
65                _wpnonce: std_frontend_obj.ajax_nonce,
66                action: 'std_form_process_action',
67                form_alias: form_alias
68            },
69            beforeSend: function (xhr) {
70                selector.find('.std-form-message').slideUp(500);
71                selector.find('.std-form-loader-wraper').show();
72            },
73            success: function (res) {
74                selector.find('.std-form-loader-wraper').hide();
75                res = $.parseJSON(res);
76                if (res.status == 200) {
77                    selector[0].reset();
78                    selector.find('.std-form-message').removeClass('std-error').addClass('std-success').html(res.message).slideDown(500, function () {
79                        if (res.instant_download_button) {
80                            setTimeout(function () {
81                                selector.find('.std-form-message').after(res.instant_download_button);
82                            }, 500);
83                        } else {
84                            if (res.redirection_url) {
85                                setTimeout(function () {
86                                    window.location = res.redirection_url;
87                                    exit;
88                                }, 500);
89                            }
90                        }
91                    });
92
93                } else {
94                    selector.find('.std-form-message').removeClass('std-success').addClass('std-error').html(res.message).slideDown(500);
95                    if (res.hasOwnProperty('data') && res.data.hasOwnProperty('error_keys')) {
96
97                        var error_keys = res.data.error_keys;
98                        for (var i = 0; i <= error_keys.length; i++) {
99                            selector.find('*[data-field-key="' + error_keys[i] + '"]').addClass('std-error-highlight');
100                            setTimeout(function () {
101                                std_scroll_to_error(selector);
102                            }, 1000);
103
104                        }
105                    }
106
107                }
108            }
109        });
110    });
111
112    /**
113     * Popup Trigger
114     * 
115     * @since 1.0.0
116     */
117    $('body').on('click', '.std-popup-trigger', function (e) {
118        var temp_popup_html = $(this).next('.std-popup-innerwrap').clone();
119        $('.std-temp-popup-wrapper').append(temp_popup_html);
120        $('.std-temp-popup-wrapper .std-popup-innerwrap').fadeIn(500);
121        e.stopPropagation();
122    });
123    /**
124     * Popup Trigger
125     * 
126     * @since 1.0.0
127     */
128    $('body').on('click', '.std-popup-close, .std-overlay', function () {
129        $('.std-popup-innerwrap').fadeOut(500, function () {
130            $('.std-temp-popup-wrapper').html('');
131        });
132
133    });
134
135    /**
136     * Delay popup display trigger
137     * 
138     * @since 1.0.0
139     */
140    if ($('.std-delay-popup').length > 0) {
141        var delay = $('.std-delay-popup').data('delay');
142        if (delay == 0 || delay == '') {
143            $('.std-delay-popup').fadeIn(500);
144        } else {
145            setTimeout(function () {
146                $('.std-delay-popup').fadeIn(500);
147            }, delay * 1000);
148        }
149    }
150    /**
151     * Prevents popup from being closed
152     * 
153     * @since 1.0.0
154     */
155    $('body').on('click', '.std-form-wrap', function (e) {
156        e.stopPropagation();
157    });
158
159
160
161    $('body').on('click', '.std-error-highlight', function () {
162        $(this).removeClass('std-error-highlight');
163    });
164
165    $('body').on('click', '.std-disable-when-closed-trigger', function () {
166        var alias = $(this).data('alias');
167        var hide_days = $(this).data('hide-days');
168        var hide_cookie_name = 'std_popup_hide_flag_' + alias;
169        std_setCookie(hide_cookie_name, 1, hide_days);
170    });
171
172
173});

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.