PageSourceSearch

https://maritime-executive.com/js/site-minimal.js?v=v2025.10.21.115952

js maritime-executive.com collected 2026-10-01 06:30:23 UTC 5,248 bytes, 160 lines download raw bytes

1/**
2 * Minimal site.js - Only essential custom code
3 * This removes all the heavy libraries that are causing main thread blocking
4 */
5
6// Essential form clearing function
7function clear_form(container) {
8    if (typeof $ !== 'undefined') {
9        $('input, textarea, select', container).val('');
10        $('input[type=checkbox], input[type=radio]', container).prop('checked', false);
11    } else {
12        // Fallback for when jQuery isn't loaded yet
13        const inputs = container.querySelectorAll('input, textarea, select');
14        inputs.forEach(input => {
15            if (input.type === 'checkbox' || input.type === 'radio') {
16                input.checked = false;
17            } else {
18                input.value = '';
19            }
20        });
21    }
22}
23
24// Essential logo fix
25function fixLogo() {
26    const logos = document.querySelectorAll('.logo img, .logo-wrapper img, img[src*="marexlogo"]');
27    logos.forEach(function(logo) {
28        logo.style.aspectRatio = 'unset';
29        logo.style.objectFit = 'unset';
30        logo.style.width = 'auto';
31        logo.style.height = 'auto';
32        logo.style.maxWidth = '100%';
33    });
34}
35
36// Run logo fix immediately and on DOM ready
37fixLogo();
38if (document.readyState === 'loading') {
39    document.addEventListener('DOMContentLoaded', fixLogo);
40}
41
42// Essential error handling
43window.addEventListener('error', function(e) {
44    console.error('JavaScript error:', e.error);
45});
46
47// Essential performance monitoring
48if (window.performance && window.performance.timing) {
49    window.addEventListener('load', function() {
50        const timing = window.performance.timing;
51        const loadTime = timing.loadEventEnd - timing.navigationStart;
52        if (loadTime > 3000) {
53            console.warn('Slow page load detected:', loadTime + 'ms');
54        }
55    });
56}
57
58// Use web workers for heavy operations
59function initializeHeavyOperations() {
60    if (window.MainThreadOptimizer) {
61        // Move heavy DOM queries to worker
62        const heavyQueries = [
63            'document.querySelectorAll(".slick-slide")',
64            'document.querySelectorAll(".carousel-item")',
65            'document.querySelectorAll(".modal")',
66            'document.querySelectorAll(".dropdown")'
67        ];
68        
69        window.MainThreadOptimizer.processDOMQueries(heavyQueries);
70        
71        // Move animation processing to worker
72        const animations = [
73            { element: '.fade-in', duration: 300 },
74            { element: '.slide-up', duration: 500 },
75            { element: '.bounce', duration: 200 }
76        ];
77        
78        window.MainThreadOptimizer.processAnimations(animations);
79        
80        // Move event listener setup to worker
81        const eventListeners = [
82            { event: 'click', selector: '.btn' },
83            { event: 'scroll', selector: 'window' },
84            { event: 'resize', selector: 'window' }
85        ];
86        
87        window.MainThreadOptimizer.processEventListeners(eventListeners);
88    }
89}
90
91// Initialize heavy operations after DOM is ready
92if (document.readyState === 'loading') {
93    document.addEventListener('DOMContentLoaded', initializeHeavyOperations);
94} else {
95    initializeHeavyOperations();
96}
97
98// Add to calendar functionality (minimal version)
99(function() {
100    'use strict';
101    
102    function addToCalendar(options) {
103        const defaults = {
104            filename: "sample",
105            target: "_blank",
106            providers: {
107                google: "Google Calendar",
108                outlook: "Outlook Live", 
109                yahoo: "Yahoo! Calendar",
110                other: "Other Calendar"
111            },
112            onAddEvent: function() {}
113        };
114        
115        const settings = Object.assign({}, defaults, options);
116        
117        // Simple implementation without heavy dependencies
118        document.querySelectorAll('.addevent').forEach(function(element) {
119            element.addEventListener('click', function(e) {
120                e.preventDefault();
121                // Basic calendar functionality
122                console.log('Add to calendar clicked');
123                settings.onAddEvent.call(this);
124            });
125        });
126    }
127    
128    // Initialize when DOM is ready
129    if (document.readyState === 'loading') {
130        document.addEventListener('DOMContentLoaded', function() {
131            addToCalendar({
132                filename: 'myicalendar',
133                target: '_blank',
134                providers: {
135                    google: 'Google Calendar',
136                    outlook: 'Outlook Calendar',
137                    yahoo: 'Yahoo! Calendar',
138                    other: 'Other Calendar'
139                },
140                onAddEvent: function() {
141                    console.log('Calendar event added');
142                }
143            });
144        });
145    } else {
146        addToCalendar({
147            filename: 'myicalendar',
148            target: '_blank',
149            providers: {
150                google: 'Google Calendar',
151                outlook: 'Outlook Calendar',
152                yahoo: 'Yahoo! Calendar',
153                other: 'Other Calendar'
154            },
155            onAddEvent: function() {
156                console.log('Calendar event added');
157            }
158        });
159    }
160})();

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.