Jump to content

MediaWiki:Common.js: Difference between revisions

The comprehensive free global encyclopedia of CEOs, corporate leadership, and business excellence
Added 3D rotating tag cloud for Main Page with trending topics and floating animations
Updated to true 3D interactive rotating tag cloud - mouse-controlled sphere rotation, depth-based scaling, interactive movement
Line 44: Line 44:


/**
/**
  * 3D Rotating Tag Cloud for Main Page
  * 3D Interactive Rotating Tag Cloud for Main Page
* True 3D sphere with mouse interaction
  */
  */
(function() {
(function() {
Line 57: Line 58:
         if (!placeholder) return;
         if (!placeholder) return;


         // Popular topics with sizes (representing importance/frequency)
         // Popular topics with importance weights
         var topics = [
         var topics = [
             { text: 'Satya Nadella', url: '/wiki/Satya_Nadella', size: 28 },
             { text: 'Satya Nadella', url: '/wiki/Satya_Nadella', weight: 9 },
             { text: 'Tim Cook', url: '/wiki/Tim_Cook', size: 26 },
             { text: 'Tim Cook', url: '/wiki/Tim_Cook', weight: 8 },
             { text: 'Elon Musk', url: '/wiki/Elon_Musk', size: 30 },
             { text: 'Elon Musk', url: '/wiki/Elon_Musk', weight: 10 },
             { text: 'Mark Zuckerberg', url: '/wiki/Mark_Zuckerberg', size: 24 },
             { text: 'Mark Zuckerberg', url: '/wiki/Mark_Zuckerberg', weight: 7 },
             { text: 'Sundar Pichai', url: '/wiki/Sundar_Pichai', size: 24 },
             { text: 'Sundar Pichai', url: '/wiki/Sundar_Pichai', weight: 7 },
             { text: 'Andy Jassy', url: '/wiki/Andy_Jassy', size: 22 },
             { text: 'Andy Jassy', url: '/wiki/Andy_Jassy', weight: 6 },
             { text: 'Jensen Huang', url: '/wiki/Jensen_Huang', size: 26 },
             { text: 'Jensen Huang', url: '/wiki/Jensen_Huang', weight: 8 },
             { text: 'Lisa Su', url: '/wiki/Lisa_Su', size: 22 },
             { text: 'Lisa Su', url: '/wiki/Lisa_Su', weight: 6 },
             { text: 'Mary Barra', url: '/wiki/Mary_Barra', size: 20 },
             { text: 'Mary Barra', url: '/wiki/Mary_Barra', weight: 5 },
             { text: 'Jamie Dimon', url: '/wiki/Jamie_Dimon', size: 20 },
             { text: 'Jamie Dimon', url: '/wiki/Jamie_Dimon', weight: 5 },
             { text: 'Microsoft', url: '/wiki/Microsoft', size: 18 },
             { text: 'Microsoft', url: '/wiki/Microsoft', weight: 5 },
             { text: 'Apple', url: '/wiki/Apple_Inc.', size: 18 },
             { text: 'Apple', url: '/wiki/Apple_Inc.', weight: 5 },
             { text: 'Amazon', url: '/wiki/Amazon', size: 18 },
             { text: 'Amazon', url: '/wiki/Amazon', weight: 5 },
             { text: 'Google', url: '/wiki/Google', size: 18 },
             { text: 'Google', url: '/wiki/Google', weight: 5 },
             { text: 'Tesla', url: '/wiki/Tesla', size: 18 },
             { text: 'Tesla', url: '/wiki/Tesla', weight: 5 },
             { text: 'Leadership', url: '/wiki/Category:Chief_executive_officers', size: 16 },
             { text: 'Leadership', url: '/wiki/Category:Chief_executive_officers', weight: 4 },
             { text: 'Innovation', url: '/wiki/Category:Business_strategies', size: 16 },
             { text: 'Innovation', url: '/wiki/Category:Business_strategies', weight: 4 },
             { text: 'Technology', url: '/wiki/Category:Companies', size: 16 },
             { text: 'Technology', url: '/wiki/Category:Companies', weight: 4 },
             { text: 'Strategy', url: '/wiki/Category:Business_strategies', size: 15 },
             { text: 'Strategy', url: '/wiki/Category:Business_strategies', weight: 4 },
             { text: 'Cloud Computing', url: '/wiki/Category:Industry_analysis', size: 15 }
             { text: 'Cloud Computing', url: '/wiki/Category:Industry_analysis', weight: 4 }
         ];
         ];


         // Create container
         // Create container
         var container = document.createElement('div');
         var container = document.createElement('div');
         container.id = 'tagcloud-container';
         container.id = 'tagcloud-3d-container';
         container.style.cssText = 'background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%); padding: 30px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); min-height: 300px; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;';
         container.style.cssText = 'background: linear-gradient(135deg, #0a1929 0%, #1a2942 50%, #0d2744 100%); padding: 40px 20px; border-radius: 12px; box-shadow: 0 15px 40px rgba(0,0,0,0.4), inset 0 2px 10px rgba(255,255,255,0.05); min-height: 400px; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; perspective: 1000px;';
 
        // Add animated background pattern
        var bgPattern = document.createElement('div');
        bgPattern.style.cssText = 'position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.1; background-image: radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1) 0%, transparent 50%), radial-gradient(circle at 80% 80%, rgba(255,255,255,0.1) 0%, transparent 50%);';
        container.appendChild(bgPattern);


         // Title
         // Title
         var title = document.createElement('div');
         var title = document.createElement('div');
         title.style.cssText = 'position: absolute; top: 15px; left: 20px; color: white; font-size: 1.3em; font-weight: 600; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); z-index: 10;';
         title.style.cssText = 'position: absolute; top: 20px; left: 50%; transform: translateX(-50%); color: white; font-size: 1.4em; font-weight: 700; text-shadow: 0 4px 10px rgba(0,0,0,0.5), 0 0 20px rgba(255,255,255,0.1); z-index: 10; letter-spacing: 1px;';
         title.textContent = '🔥 Trending Topics';
         title.textContent = 'TRENDING TOPICS';
         container.appendChild(title);
         container.appendChild(title);


         // Cloud container
         // 3D Cloud container
         var cloud = document.createElement('div');
         var cloud = document.createElement('div');
         cloud.style.cssText = 'display: flex; flex-wrap: wrap; gap: 15px; justify-content: center; align-items: center; max-width: 900px; padding: 40px 20px 20px;';
        cloud.id = 'tagcloud-3d';
         cloud.style.cssText = 'position: relative; width: 100%; max-width: 700px; height: 350px; transform-style: preserve-3d;';


         // Add topics
         // Create tags with 3D positioning
         topics.forEach(function(topic) {
        var radius = 180;
        var tags = [];
        var angleX = 0;
        var angleY = 0;
        var speed = 0.3;
        var mouseX = 0;
        var mouseY = 0;
 
         topics.forEach(function(topic, index) {
             var link = document.createElement('a');
             var link = document.createElement('a');
             link.href = topic.url;
             link.href = topic.url;
             link.textContent = topic.text;
             link.textContent = topic.text;
             link.style.cssText = 'color: white; text-decoration: none; font-size: ' + topic.size + 'px; font-weight: 600; padding: 8px 16px; background: rgba(255,255,255,0.15); border-radius: 25px; backdrop-filter: blur(10px); transition: all 0.3s ease; display: inline-block; box-shadow: 0 4px 10px rgba(0,0,0,0.1); border: 1px solid rgba(255,255,255,0.2);';
 
            var fontSize = 14 + (topic.weight * 2);
             link.style.cssText = 'position: absolute; left: 50%; top: 50%; color: white; text-decoration: none; font-size: ' + fontSize + 'px; font-weight: 600; padding: 8px 18px; background: rgba(255,255,255,0.12); border-radius: 25px; backdrop-filter: blur(10px); transition: all 0.3s ease; white-space: nowrap; border: 1px solid rgba(255,255,255,0.2); box-shadow: 0 4px 15px rgba(0,0,0,0.3);';
 
            // Calculate initial 3D position on sphere
            var phi = Math.acos(-1 + (2 * index) / topics.length);
            var theta = Math.sqrt(topics.length * Math.PI) * phi;
 
            link.phi = phi;
            link.theta = theta;


             // Hover effects
             // Hover effects
             link.onmouseenter = function() {
             link.onmouseenter = function() {
                 this.style.transform = 'scale(1.15) translateY(-5px)';
                 this.style.transform = this.style.transform.replace(/scale\([^)]+\)/, '') + ' scale(1.25)';
                 this.style.background = 'rgba(255,255,255,0.3)';
                 this.style.background = 'rgba(255,255,255,0.25)';
                 this.style.boxShadow = '0 8px 20px rgba(0,0,0,0.25)';
                 this.style.boxShadow = '0 8px 25px rgba(0,0,0,0.5), 0 0 30px rgba(255,255,255,0.2)';
                this.style.zIndex = '1000';
             };
             };
             link.onmouseleave = function() {
             link.onmouseleave = function() {
                 this.style.transform = 'scale(1) translateY(0)';
                 this.style.transform = this.style.transform.replace(/scale\([^)]+\)/, '') + ' scale(1)';
                 this.style.background = 'rgba(255,255,255,0.15)';
                 this.style.background = 'rgba(255,255,255,0.12)';
                 this.style.boxShadow = '0 4px 10px rgba(0,0,0,0.1)';
                 this.style.boxShadow = '0 4px 15px rgba(0,0,0,0.3)';
                this.style.zIndex = '';
             };
             };


             cloud.appendChild(link);
             cloud.appendChild(link);
            tags.push(link);
         });
         });


Line 121: Line 148:
         placeholder.appendChild(container);
         placeholder.appendChild(container);


         // Subtle floating animation
         // Mouse tracking for interactive rotation
         var animationStyle = document.createElement('style');
         container.addEventListener('mousemove', function(e) {
         animationStyle.textContent = '@keyframes float { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-10px); } } #tagcloud-container a { animation: float 3s ease-in-out infinite; } #tagcloud-container a:nth-child(2n) { animation-delay: 0.5s; } #tagcloud-container a:nth-child(3n) { animation-delay: 1s; }';
            var rect = container.getBoundingClientRect();
         document.head.appendChild(animationStyle);
            mouseX = (e.clientX - rect.left - rect.width / 2) / (rect.width / 2);
            mouseY = (e.clientY - rect.top - rect.height / 2) / (rect.height / 2);
        });
 
        container.addEventListener('mouseleave', function() {
            mouseX = 0;
            mouseY = 0;
         });
 
        // Animation loop
        function animate() {
            // Update rotation based on mouse position or auto-rotate
            angleY += (mouseX * 2 - angleY) * 0.05 + speed * 0.01;
            angleX += (mouseY * 2 - angleX) * 0.05;
 
            // Update each tag position
            tags.forEach(function(tag) {
                var phi = tag.phi;
                var theta = tag.theta + angleY;
 
                // 3D to 2D projection
                var x = radius * Math.sin(phi) * Math.cos(theta);
                var y = radius * Math.cos(phi) + Math.sin(angleX) * 30;
                var z = radius * Math.sin(phi) * Math.sin(theta);
 
                // Calculate scale based on z-depth
                var scale = (z + radius) / (2 * radius);
                scale = Math.max(0.5, Math.min(1.2, scale));
 
                // Calculate opacity based on z-depth
                var opacity = (z + radius) / (2 * radius);
                opacity = Math.max(0.4, Math.min(1, opacity));
 
                // Apply 3D transform
                var transformStyle = 'translate(-50%, -50%) translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px) scale(' + scale + ')';
                tag.style.transform = transformStyle;
                tag.style.opacity = opacity;
                tag.style.zIndex = Math.floor(z + radius);
            });
 
            requestAnimationFrame(animate);
        }
 
        animate();
 
        // Add instruction text
        var instruction = document.createElement('div');
        instruction.style.cssText = 'position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.6); font-size: 0.9em; text-shadow: 0 2px 5px rgba(0,0,0,0.5); z-index: 10;';
         instruction.textContent = 'Move your mouse to rotate';
        container.appendChild(instruction);
     });
     });
})();
})();

Revision as of 09:36, 20 October 2025

/**
 * Add statistics banner to account creation page
 */
(function() {
    // Only run on Special:CreateAccount page
    if (mw.config.get('wgCanonicalSpecialPageName') !== 'CreateAccount') {
        return;
    }

    // Get site statistics via API
    var api = new mw.Api();

    api.get({
        action: 'query',
        meta: 'siteinfo',
        siprop: 'statistics',
        format: 'json'
    }).done(function(data) {
        var stats = data.query.statistics;

        // Create statistics banner
        var banner = $('<div>').addClass('createaccount-statistics').html(
            '<div class="createaccount-statistics-title">CEO.wiki is made by people like you.</div>' +
            '<div class="createaccount-statistics-grid">' +
                '<div class="createaccount-stat-item">' +
                    '<div class="createaccount-stat-number">' + stats.edits.toLocaleString() + '</div>' +
                    '<div class="createaccount-stat-label">Edits</div>' +
                '</div>' +
                '<div class="createaccount-stat-item">' +
                    '<div class="createaccount-stat-number">' + stats.pages.toLocaleString() + '</div>' +
                    '<div class="createaccount-stat-label">Pages</div>' +
                '</div>' +
                '<div class="createaccount-stat-item">' +
                    '<div class="createaccount-stat-number">' + stats.activeusers.toLocaleString() + '</div>' +
                    '<div class="createaccount-stat-label">Recent Contributors</div>' +
                '</div>' +
            '</div>'
        );

        // Insert banner before the form
        $('#userloginForm').before(banner);
    });
})();

/**
 * 3D Interactive Rotating Tag Cloud for Main Page
 * True 3D sphere with mouse interaction
 */
(function() {
    // Only run on Main Page
    if (mw.config.get('wgPageName') !== 'Main_Page') {
        return;
    }

    // Wait for DOM to be ready
    $(document).ready(function() {
        var placeholder = document.getElementById('ceo-tagcloud-placeholder');
        if (!placeholder) return;

        // Popular topics with importance weights
        var topics = [
            { text: 'Satya Nadella', url: '/wiki/Satya_Nadella', weight: 9 },
            { text: 'Tim Cook', url: '/wiki/Tim_Cook', weight: 8 },
            { text: 'Elon Musk', url: '/wiki/Elon_Musk', weight: 10 },
            { text: 'Mark Zuckerberg', url: '/wiki/Mark_Zuckerberg', weight: 7 },
            { text: 'Sundar Pichai', url: '/wiki/Sundar_Pichai', weight: 7 },
            { text: 'Andy Jassy', url: '/wiki/Andy_Jassy', weight: 6 },
            { text: 'Jensen Huang', url: '/wiki/Jensen_Huang', weight: 8 },
            { text: 'Lisa Su', url: '/wiki/Lisa_Su', weight: 6 },
            { text: 'Mary Barra', url: '/wiki/Mary_Barra', weight: 5 },
            { text: 'Jamie Dimon', url: '/wiki/Jamie_Dimon', weight: 5 },
            { text: 'Microsoft', url: '/wiki/Microsoft', weight: 5 },
            { text: 'Apple', url: '/wiki/Apple_Inc.', weight: 5 },
            { text: 'Amazon', url: '/wiki/Amazon', weight: 5 },
            { text: 'Google', url: '/wiki/Google', weight: 5 },
            { text: 'Tesla', url: '/wiki/Tesla', weight: 5 },
            { text: 'Leadership', url: '/wiki/Category:Chief_executive_officers', weight: 4 },
            { text: 'Innovation', url: '/wiki/Category:Business_strategies', weight: 4 },
            { text: 'Technology', url: '/wiki/Category:Companies', weight: 4 },
            { text: 'Strategy', url: '/wiki/Category:Business_strategies', weight: 4 },
            { text: 'Cloud Computing', url: '/wiki/Category:Industry_analysis', weight: 4 }
        ];

        // Create container
        var container = document.createElement('div');
        container.id = 'tagcloud-3d-container';
        container.style.cssText = 'background: linear-gradient(135deg, #0a1929 0%, #1a2942 50%, #0d2744 100%); padding: 40px 20px; border-radius: 12px; box-shadow: 0 15px 40px rgba(0,0,0,0.4), inset 0 2px 10px rgba(255,255,255,0.05); min-height: 400px; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; perspective: 1000px;';

        // Add animated background pattern
        var bgPattern = document.createElement('div');
        bgPattern.style.cssText = 'position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.1; background-image: radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1) 0%, transparent 50%), radial-gradient(circle at 80% 80%, rgba(255,255,255,0.1) 0%, transparent 50%);';
        container.appendChild(bgPattern);

        // Title
        var title = document.createElement('div');
        title.style.cssText = 'position: absolute; top: 20px; left: 50%; transform: translateX(-50%); color: white; font-size: 1.4em; font-weight: 700; text-shadow: 0 4px 10px rgba(0,0,0,0.5), 0 0 20px rgba(255,255,255,0.1); z-index: 10; letter-spacing: 1px;';
        title.textContent = 'TRENDING TOPICS';
        container.appendChild(title);

        // 3D Cloud container
        var cloud = document.createElement('div');
        cloud.id = 'tagcloud-3d';
        cloud.style.cssText = 'position: relative; width: 100%; max-width: 700px; height: 350px; transform-style: preserve-3d;';

        // Create tags with 3D positioning
        var radius = 180;
        var tags = [];
        var angleX = 0;
        var angleY = 0;
        var speed = 0.3;
        var mouseX = 0;
        var mouseY = 0;

        topics.forEach(function(topic, index) {
            var link = document.createElement('a');
            link.href = topic.url;
            link.textContent = topic.text;

            var fontSize = 14 + (topic.weight * 2);
            link.style.cssText = 'position: absolute; left: 50%; top: 50%; color: white; text-decoration: none; font-size: ' + fontSize + 'px; font-weight: 600; padding: 8px 18px; background: rgba(255,255,255,0.12); border-radius: 25px; backdrop-filter: blur(10px); transition: all 0.3s ease; white-space: nowrap; border: 1px solid rgba(255,255,255,0.2); box-shadow: 0 4px 15px rgba(0,0,0,0.3);';

            // Calculate initial 3D position on sphere
            var phi = Math.acos(-1 + (2 * index) / topics.length);
            var theta = Math.sqrt(topics.length * Math.PI) * phi;

            link.phi = phi;
            link.theta = theta;

            // Hover effects
            link.onmouseenter = function() {
                this.style.transform = this.style.transform.replace(/scale\([^)]+\)/, '') + ' scale(1.25)';
                this.style.background = 'rgba(255,255,255,0.25)';
                this.style.boxShadow = '0 8px 25px rgba(0,0,0,0.5), 0 0 30px rgba(255,255,255,0.2)';
                this.style.zIndex = '1000';
            };
            link.onmouseleave = function() {
                this.style.transform = this.style.transform.replace(/scale\([^)]+\)/, '') + ' scale(1)';
                this.style.background = 'rgba(255,255,255,0.12)';
                this.style.boxShadow = '0 4px 15px rgba(0,0,0,0.3)';
                this.style.zIndex = '';
            };

            cloud.appendChild(link);
            tags.push(link);
        });

        container.appendChild(cloud);
        placeholder.appendChild(container);

        // Mouse tracking for interactive rotation
        container.addEventListener('mousemove', function(e) {
            var rect = container.getBoundingClientRect();
            mouseX = (e.clientX - rect.left - rect.width / 2) / (rect.width / 2);
            mouseY = (e.clientY - rect.top - rect.height / 2) / (rect.height / 2);
        });

        container.addEventListener('mouseleave', function() {
            mouseX = 0;
            mouseY = 0;
        });

        // Animation loop
        function animate() {
            // Update rotation based on mouse position or auto-rotate
            angleY += (mouseX * 2 - angleY) * 0.05 + speed * 0.01;
            angleX += (mouseY * 2 - angleX) * 0.05;

            // Update each tag position
            tags.forEach(function(tag) {
                var phi = tag.phi;
                var theta = tag.theta + angleY;

                // 3D to 2D projection
                var x = radius * Math.sin(phi) * Math.cos(theta);
                var y = radius * Math.cos(phi) + Math.sin(angleX) * 30;
                var z = radius * Math.sin(phi) * Math.sin(theta);

                // Calculate scale based on z-depth
                var scale = (z + radius) / (2 * radius);
                scale = Math.max(0.5, Math.min(1.2, scale));

                // Calculate opacity based on z-depth
                var opacity = (z + radius) / (2 * radius);
                opacity = Math.max(0.4, Math.min(1, opacity));

                // Apply 3D transform
                var transformStyle = 'translate(-50%, -50%) translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px) scale(' + scale + ')';
                tag.style.transform = transformStyle;
                tag.style.opacity = opacity;
                tag.style.zIndex = Math.floor(z + radius);
            });

            requestAnimationFrame(animate);
        }

        animate();

        // Add instruction text
        var instruction = document.createElement('div');
        instruction.style.cssText = 'position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.6); font-size: 0.9em; text-shadow: 0 2px 5px rgba(0,0,0,0.5); z-index: 10;';
        instruction.textContent = 'Move your mouse to rotate';
        container.appendChild(instruction);
    });
})();