PageSourceSearch

https://croatian.film/wp-content/themes/crofilm/assets/js/devices-manager.js?ver=1.0.0

js croatian.film collected 2026-10-01 13:01:06 UTC 10,096 bytes, 217 lines download raw bytes

1var jwsDeviceManager;
2(function ($) {
3    "use strict";
4    jwsDeviceManager = (function () {
5        return {
6            init: function () {
7                this.loadDevices();
8                this.bindEvents();
9            },
10
11            loadDevices: function () {
12                $('.jws-device-manager-shortcode').addClass('loading');
13
14                $.ajax({
15                    url: jws_script.ajax_url,
16                    type: 'POST',
17                    data: {
18                        action: 'jws_get_devices_html'
19                    },
20                    success: function (response) {
21                        if (response.success) {
22                            // Render current device
23                            if (response.data.current_device) {
24                                $('.current-device-section .device-item').remove();
25                                $('.current-device-section').append(response.data.current_device);
26                            }
27
28                            // Render other devices
29                            $('.device-list').html(response.data.other_devices);
30
31                            // Progressbar logic
32                            var total = response.data.total || 0;
33                            var max = response.data.max || 0;
34                            if ($('.plan-devices .max-count').length) {
35                                max = parseInt($('.plan-devices .max-count').text(), 10) || 5;
36                            }
37                            $('.plan-devices .current-count').text(total);
38                            $('.plan-devices .max-count').text(max);
39                            var percent = Math.round((total / max) * 100);
40                            $('.plan-devices .progressbar-fill').css('width', percent + '%');
41
42                            // Show/hide remove all button
43                            if (response.data.show_remove_all) {
44                                $('.btn-remove-all-devices').show();
45                            } else {
46                                $('.btn-remove-all-devices').hide();
47                            }
48                        } else {
49                            if (typeof jwsThemeModule !== 'undefined') {
50                                jwsThemeModule.show_notification(response.data.message, 'error');
51                            }
52                        }
53                    },
54                    error: function () {
55                        if (typeof jwsThemeModule !== 'undefined') {
56                            jwsThemeModule.show_notification('Cannot load device list', 'error');
57                        }
58                    },
59                    complete: function () {
60                        $('.jws-device-manager-shortcode').removeClass('loading');
61                    }
62                });
63            },
64
65            bindEvents: function () {
66                var self = this;
67
68                // Close popup
69                $(document).on('click', '.close-device-manager', function () {
70                    $('.jws-device-manager-popup').fadeOut();
71                });
72
73                // Remove single device
74                $(document).on('click', '.btn-remove-device', function () {
75
76                    if (!$('.jws-device-manager-popup').is(':visible')) {
77                        if (!confirm(jws_script.device_manager.confirm_remove_device)) {
78                            return;
79                        }
80                    }
81                    var button = $(this);
82                    var deviceId = button.data('device-id');
83
84                    button.prop('disabled', true).addClass('loading');
85
86                    if (!button.find('.loader').length) {
87                        button.append('<div class="loader"><svg class="circular" viewBox="25 25 50 50"><circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/></svg></div>');
88                    }
89                    $.ajax({
90                        url: jws_script.ajax_url,
91                        type: 'POST',
92                        data: {
93                            action: 'jws_remove_user_device',
94                            device_id: deviceId
95                        },
96                        success: function (response) {
97                            if (response.success) {
98
99
100                                // If in popup, resubmit login form after remov
100ing device
101                                if ($('.jws-device-manager-popup').is(':visible')) {
102
103                                    $('.jws-device-manager-popup').hide();
104                                    $('.jws-login-container form[name=loginpopopform]').submit();
105
106                                } else {
107                                    self.loadDevices();
108                                    if (typeof jwsThemeModule !== 'undefined') {
109                                        jwsThemeModule.show_notification(response.data.message, 'success');
110                                    }
111                                }
112                            } else {
113                                if (typeof jwsThemeModule !== 'undefined') {
114                                    jwsThemeModule.show_notification(response.data.message, 'error');
115                                }
116                                button.removeClass('loading').prop('disabled', false);
117                            }
118                        },
119                        error: function () {
120                            if (typeof jwsThemeModule !== 'undefined') {
121                                jwsThemeModule.show_notification('Cannot remove device', 'error');
122                            }
123                            button.removeClass('loading').prop('disabled', false);
124                        }
125                    });
126                });
127
128                // Remove all other devices
129                $(document).on('click', '.btn-remove-all-devices', function () {
130                    if (!confirm(jws_script.device_manager.confirm_logout_all)) {
131                        return;
132                    }
133
134                    var button = $(this);
135
136                    button.prop('disabled', true).addClass('loading');
137
138                    if (!button.find('.loader').length) {
139                        button.append('<div class="loader"><svg class="circular" viewBox="25 25 50 50"><circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/></svg></div>');
140                    }
141                    $.ajax({
142                        url: jws_script.ajax_url,
143                        type: 'POST',
144                        data: {
145                            action: 'jws_remove_all_other_devices'
146                        },
147                        success: function (response) {
148                            if (response.success) {
149                                if (typeof jwsThemeModule !== 'undefined') {
150                                    jwsThemeModule.show_notification(response.data.message, 'success');
151                                }
152                                self.loadDevices();
153
154                                // If in popup, close and resubmit login form
155                                if ($('.jws-device-manager-popup').is(':visible')) {
156                                    setTimeout(function () {
157                                        $('.jws-device-manager-popup').hide();
158                                        $('.jws-login-container form[name=loginpopopform]').submit();
159                                    }, 1000);
160                                }
161                            } else {
162                                if (typeof jwsThemeModule !== 'undefined') {
163                                    jwsThemeModule.show_notification(response.data.message, 'error');
164                                }
165                            }
166                        },
167                        error: function () {
168                            if (typeof jwsThemeModule !== 'undefined') {
169                                jwsThemeModule.show_notification('Cannot remove devices', 'error');
170                            }
171                        },
172                        complete: function () {
173                            button.removeClass('loading').prop('disabled', false);
174                        }
175                    });
176                });
177            },
178
179            showPopup: function (errorMessage) {
180                if ($('.jws-device-manager-popup').length === 0) {
181                    // Load HTML from server
182                    $.ajax({
183                        url: jws_script.ajax_url,
184                        type: 'POST',
185                        data: {
186                            action: 'jws_load_device_manager_popup'
187                        },
188                        success: function (response) {
189                            if (response.success) {
190                                $('body').append(response.data.html);
191                                $('.jws-device-manager-popup .error-message').text(errorMessage);
192                                $('.jws-device-manager-popup').fadeIn();
193                                jwsDeviceManager.init();
194                            }
195                        },
196                        error: function () {
197                            if (typeof jwsThemeModule !== 'undefined') {
198                                jwsThemeModule.show_notification('Cannot load device manager interface', 'error');
199                            }
200                        }
201                    });
202                } else {
203                    $('.jws-device-manager-popup .error-message').text(errorMessage);
204                    $('.jws-device-manager-popup').fadeIn();
205                    jwsDeviceManager.loadDevices();
206                }
207            }
208        };
209    }());
210
211    $(document).ready(function () {
212        // Initialize device manager for shortcode
213        if ($('.jws-device-manager').length > 0) {
214            jwsDeviceManager.init();
215        }
216    });
217})(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.