PageSourceSearch

https://www.scholaro.com/db/_content/ScholaroWeb/js/profile-dropdo…Y6IhD5GZL4hNN5uC5650icYfGTkFjqkmgR7LuJjVxkU

js scholaro.com collected 2026-09-24 09:45:34 UTC 4,720 bytes, 144 lines download raw bytes

1
2$(document).ready(function () {
3    function adjustDropdown() {
4        if (window.innerWidth < 992) {
5            $(".profile-info").css("display", "none");
6            $(".dropdown-arrow").css("display", "none");
7
8            $(".profile-email").css("max-width", "100px");
9
10        } else {
11            $(".profile-info").css("display", "");
12            $(".dropdown-arrow").css("display", "");
13            $(".profile-email").css("max-width", "160px");
14        }
15    }
16
17    setTimeout(adjustDropdown, 100);
18    $(window).resize(function() {
19        adjustDropdown();
20        if (window.innerWidth >= 768) {
21            // Close modal when resizing to non-mobile view
22            const modal = document.getElementById('profileModal');
23            if (modal && modal.open) {
24                modal.close();
25            }
26        } else {
27            // Close dropdown when resizing to mobile view
28            const dropdown = document.getElementById('profileDropdown');
29            const dropdownArrow = document.getElementById('dropdownArrow');
30            if (dropdown && isProfileDropdownOpen) {
31                dropdown.style.display = 'none';
32                if (dropdownArrow) {
33                    dropdownArrow.classList.remove('open');
34                }
35                isProfileDropdownOpen = false;
36            }
37        }
38    });
39});
40
41document.addEventListener('click', function (e) {
42    if (e.target.closest('#profileButton')) {
43        setTimeout(function () {
44            const currentUrl = window.location.pathname + window.location.search;
45            const encodedUrl = encodeURIComponent(currentUrl);
46
47            // Update links in both dropdown and modal
48            const containers = [document.getElementById('profileDropdown'), document.getElementById('profileModal')];
49            for (const container of containers) {
50                if (container) {
51                    const loginLink = container.querySelector('.login-link');
52                    if (loginLink) {
53                        loginLink.href = '/Login/Identity/Account/Login?ReturnUrl=' + encodedUrl;
54                    }
55                    const registerLink = container.querySelector('.register-link');
56                    if (registerLink) {
57                        registerLink.href = '/Login/Identity/Account/Login?register=true&ReturnUrl=' + encodedUrl;
58                    }
59                }
60            }
61        }, 50);
62    }
63});
64
65
66async function handleLogout() {
67    try {
68        const response = await fetch('/api/auth/SignOut', {
69            method: 'POST',
70            headers: {
71                'Content-Type': 'application/json',
72            }
73        });
74        if (response.ok) {
75            window.location.href = '/';
76        } else {
77            console.error('Logout failed');
78        }
79    } catch (error) {
80        console.error('Logout error:', error);
81        window.location.href = '/';
82    }
83}
84
85let isProfileDropdownOpen = false;
86
87function isMobileView() {
88    return window.innerWidth < 768;
89}
90
91function toggleProfileDropdown() {
92    // On mobile, show modal instead of dropdown
93    if (isMobileView()) {
94        const modal = document.getElementById('profileModal');
95        if (modal) {
96            modal.showModal();
97        }
98        return;
99    }
100
101    const dropdown = document.getElementById('profileDropdown');
102    const dropdownArrow = document.getElementById('dropdownArrow');
103
104    isProfileDropdownOpen = !isProfileDropdownOpen;
105
106    if (isProfileDropdownOpen) {
107        dropdown.style.display = 'block';
108        if (dropdownArrow) {
109            dropdownArrow.classList.add('open');
110        }
111    } else {
112        dropdown.style.display = 'none';
113        if (dropdownArrow) {
114            dropdownArrow.classList.remove('open');
115        }
116    }
117}
118
119function closeProfileModal() {
120    const modal = document.getElementById('profileModal');
121    if (modal) {
122        modal.close();
123    }
124}
125
126// Close dropdown when clicking outside
127document.addEventListener('click', function (event) {
128    const profileContainer = document.querySelector('.profile-container');
129    if (profileContainer && !profileContainer.contains(event.target) && isProfileDropdownOpen) {
130        toggleProfileDropdown();
131    }
132});
133
134// Prevent dropdown from closing when clicking inside it
135document.addEventListener('DOMContentLoaded', function () {
136    const profileDropdown = document.getElementById('profileDropdown');
137    if (profileDropdown) {
138        profileDropdown.addEventListener('click', function (event) {
139            event.stopPropagation();
140        });
141    }
142
143});
144

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.