PageSourceSearch

https://www.iamtcs.org/wp-content/plugins/wp-amo/js/committee-modal.js?ver=1.0

js iamtcs.org collected 2026-10-08 07:56:55 UTC 5,072 bytes, 117 lines download raw bytes

1(function($) {
2    'use strict';
3
4    $(document).ready(function() {
5        // Create modal markup if it doesn't exist
6        function ensureModalExists() {
7            if ($('#amo-committee-modal').length === 0) {
8                var modalHtml =
9                    '<div id="amo-committee-modal" class="amo-modal" style="display:none;">' +
10                        '<div class="amo-modal-overlay"></div>' +
11                        '<div class="amo-modal-content">' +
12                            '<button class="amo-modal-close" aria-label="Close">&times;</button>' +
13                            '<div class="amo-modal-body">' +
14                                '<div class="amo-modal-loading">Loading...</div>' +
15                            '</div>' +
16                        '</div>' +
17                    '</div>';
18                $('body').append(modalHtml);
19            }
20        }
21
22        // Handle View Committee Members link clicks
23        $(document).on('click', '.amo-committee-members-link', function(e) {
24            e.preventDefault();
25
26            // Ensure modal exists in body
27            ensureModalExists();
28
29            var committeeId = $(this).data('committee-id');
30            var modalStyle = $(this).data('modal-style');
31            var modal = $('#amo-committee-modal');
32            var modalBody = modal.find('.amo-modal-body');
33
34            // Get display options from data attributes
35            // Note: jQuery .data() parses "1" as number 1, so we use == instead of ===
36            var displayOptions = {
37                showOrganization: $(this).data('show-organization') == '1',
38                showAddress: $(this).data('show-address') == '1',
39                showPhone: $(this).data('show-phone') == '1',
40                showMobile: $(this).data('show-mobile') == '1',
41                showEmail: $(this).data('show-email') == '1',
42                showWebsite: $(this).data('show-website') == '1'
43            };
44
45            // Show modal with loading state
46            modalBody.html('<div class="amo-modal-loading">Loading...</div>');
47            modal.fadeIn(300);
48            $('body').addClass('amo-modal-open');
49
50            // Fetch committee members with display options
51            var apiUrl = amoCommitteeModal.restUrl + 'committee/' + committeeId +
52                '?show_organization=' + (displayOptions.showOrganization ? '1' : '0') +
53                '&show_address=' + (displayOptions.showAddress ? '1' : '0') +
54                '&show_phone=' + (displayOptions.showPhone ? '1' : '0') +
55                '&show_mobile=' + (displayOptions.showMobile ? '1' : '0') +
56                '&show_email=' + (displayOptions.showEmail ? '1' : '0') +
57                '&show_website=' + (displayOptions.showWebsite ? '1' : '0');
58            console.log('Fetching committee members from:', apiUrl);
59
60            $.ajax({
61                url: apiUrl,
62                method: 'GET',
63                success: function(response) {
64                    console.log('Success response:', response);
65                    if (response && response.html) {
66                        modalBody.html(response.html);
67
68                        // Apply modal styling if provided
69                        if (modalStyle) {
70                            modalBody.attr('style', modalStyle);
71                        }
72                    } else {
73                        console.error('Unexpected response format:', response);
74                        modalBody.html('<p>Error loading committee members. Response format invalid.</p>');
75                    }
76                },
77                error: function(xhr, status, error) {
78                    console.error('Error fetching committee members:', error);
79                    console.error('XHR status:', xhr.status);
80                    console.error('XHR response:', xhr.responseText);
81                    console.error('Status:', status);
82
83                    var errorMsg = '<p>Error loading committee members. Please try again.</p>';
84                    if (xhr.status === 404) {
85                        errorMsg = '<p>Committee members not found.</p>';
86                    } else if (xhr.responseText) {
87                        errorMsg += '<p><small>Error: ' + xhr.responseText + '</small></p>';
88                    }
89                    modalBody.html(errorMsg);
90                }
91            });
92        });
93
94        // Close modal when clicking close button
95        $(document).on('click', '.amo-modal-close', function() {
96            closeModal();
97        });
98
99        // Close modal when clicking overlay
100        $(document).on('click', '.amo-modal-overlay', function() {
101            closeModal();
102        });
103
104        // Close modal on ESC key
105        $(document).on('keydown', function(e) {
106            if (e.key === 'Escape' && $('#amo-committee-modal').is(':visible')) {
107                closeModal();
108            }
109        });
110
111        function closeModal() {
112            $('#amo-committee-modal').fadeOut(300);
113            $('body').removeClass('amo-modal-open');
114        }
115    });
116
117})(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.