MediaWiki:Common.js: Difference between revisions

From Helix Project Wiki
No edit summary
No edit summary
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
// Helix Project - Wiki Chat Bubble Debug Version
// Helix Project - Wiki Chat Bubble (Working Version)
console.log('=== Helix Wiki Chat Bubble Debug ===');
console.log('Helix Wiki Chat Bubble: Script loading...');


// Test if script is loading
// Create chat bubble immediately, don't wait for load
console.log('MediaWiki:Common.js is loading...');
function createChatBubble() {
 
    console.log('Creating chat bubble...');
window.addEventListener('load', function() {
   
    console.log('Window load event fired');
    // Remove any existing bubble first
    var existingBubble = document.getElementById('helix-wiki-chat-bubble');
    if (existingBubble) {
        existingBubble.parentNode.removeChild(existingBubble);
    }
      
      
     // Create chat bubble with very obvious styling
     // Create new bubble
     var chatBubble = document.createElement('div');
     var chatBubble = document.createElement('div');
     chatBubble.innerHTML = '💬 WIKI CHAT DEBUG';
     chatBubble.innerHTML = '💬 Wiki Help';
     chatBubble.id = 'helix-wiki-chat-bubble';
     chatBubble.id = 'helix-wiki-chat-bubble';
      
      
     // Make it impossible to miss
     // Style it to be visible and in correct position
     chatBubble.style.position = 'fixed';
     chatBubble.style.position = 'fixed';
     chatBubble.style.bottom = '20px';
     chatBubble.style.bottom = '20px';
     chatBubble.style.right = '20px';
     chatBubble.style.right = '20px';
     chatBubble.style.background = 'red';
     chatBubble.style.background = '#007cba';
     chatBubble.style.color = 'white';
     chatBubble.style.color = 'white';
     chatBubble.style.padding = '15px';
     chatBubble.style.padding = '12px 18px';
     chatBubble.style.borderRadius = '10px';
     chatBubble.style.borderRadius = '20px';
     chatBubble.style.cursor = 'pointer';
     chatBubble.style.cursor = 'pointer';
     chatBubble.style.zIndex = '999999';
     chatBubble.style.zIndex = '100000'; // Very high z-index
     chatBubble.style.fontSize = '16px';
    chatBubble.style.boxShadow = '0 2px 10px rgba(0,0,0,0.2)';
    chatBubble.style.fontFamily = 'sans-serif';
     chatBubble.style.fontSize = '14px';
     chatBubble.style.fontWeight = 'bold';
     chatBubble.style.fontWeight = 'bold';
     chatBubble.style.border = '3px solid yellow';
     chatBubble.style.display = 'block'; // Force display
    chatBubble.style.visibility = 'visible'; // Force visibility
      
      
     // Simple click action
     // Simple click action
     chatBubble.onclick = function() {
     chatBubble.onclick = function() {
         alert('Wiki chat bubble clicked!');
         window.location.href = '/wiki/Help:Contents';
     };
     };
      
      
     // Try to append to body
     // Add hover effect
     console.log('Attempting to append chat bubble to body...');
     chatBubble.onmouseover = function() {
        this.style.background = '#005a87';
        this.style.transform = 'scale(1.05)';
    };
   
    chatBubble.onmouseout = function() {
        this.style.background = '#007cba';
        this.style.transform = 'scale(1)';
    };
   
    // Append to body
     document.body.appendChild(chatBubble);
     document.body.appendChild(chatBubble);
     console.log('Chat bubble appended to body');
     console.log('Chat bubble created and appended');
      
      
     // Verify it's actually in the DOM
     // Verify it's visible
     var checkBubble = document.getElementById('helix-wiki-chat-bubble');
     setTimeout(function() {
    if (checkBubble) {
        var bubble = document.getElementById('helix-wiki-chat-bubble');
        console.log('✅ Chat bubble found in DOM');
        if (bubble) {
    } else {
            console.log('✅ Chat bubble exists in DOM');
        console.log('❌ Chat bubble NOT found in DOM');
            console.log('Computed style display:', window.getComputedStyle(bubble).display);
     }
            console.log('Computed style visibility:', window.getComputedStyle(bubble).visibility);
});
        } else {
            console.log('❌ Chat bubble not found in DOM');
        }
     }, 100);
}
 
// Try multiple ways to ensure the bubble gets created
 
// 1. Try immediately
createChatBubble();
 
// 2. Also try on DOMContentLoaded as backup
document.addEventListener('DOMContentLoaded', createChatBubble);
 
// 3. And try on window.load as another backup
window.addEventListener('load', createChatBubble);
 
// Keep your Chatbase integration
var script = document.createElement('script');
script.src = 'https://www.chatbase.co/embed.min.js';
script.setAttribute('chatbotId', 'i65eBj3COxUlFEU_Lsrw0');
script.setAttribute('domain', 'www.chatbase.co');
script.defer = true;
document.body.appendChild(script);


// Also try without waiting for load
console.log('Helix Wiki Chat Bubble: Setup complete');
console.log('Creating immediate chat bubble...');
var immediateBubble = document.createElement('div');
immediateBubble.innerHTML = 'IMMEDIATE BUBBLE';
immediateBubble.style.cssText = 'position:fixed;top:20px;right:20px;background:green;color:white;padding:10px;z-index:999999;';
document.body.appendChild(immediateBubble);
console.log('Immediate bubble added');

Revision as of 11:52, 7 October 2025

/* Any JavaScript here will be loaded for all users on every page load. */
// Helix Project - Wiki Chat Bubble (Working Version)
console.log('Helix Wiki Chat Bubble: Script loading...');

// Create chat bubble immediately, don't wait for load
function createChatBubble() {
    console.log('Creating chat bubble...');
    
    // Remove any existing bubble first
    var existingBubble = document.getElementById('helix-wiki-chat-bubble');
    if (existingBubble) {
        existingBubble.parentNode.removeChild(existingBubble);
    }
    
    // Create new bubble
    var chatBubble = document.createElement('div');
    chatBubble.innerHTML = '💬 Wiki Help';
    chatBubble.id = 'helix-wiki-chat-bubble';
    
    // Style it to be visible and in correct position
    chatBubble.style.position = 'fixed';
    chatBubble.style.bottom = '20px';
    chatBubble.style.right = '20px';
    chatBubble.style.background = '#007cba';
    chatBubble.style.color = 'white';
    chatBubble.style.padding = '12px 18px';
    chatBubble.style.borderRadius = '20px';
    chatBubble.style.cursor = 'pointer';
    chatBubble.style.zIndex = '100000'; // Very high z-index
    chatBubble.style.boxShadow = '0 2px 10px rgba(0,0,0,0.2)';
    chatBubble.style.fontFamily = 'sans-serif';
    chatBubble.style.fontSize = '14px';
    chatBubble.style.fontWeight = 'bold';
    chatBubble.style.display = 'block'; // Force display
    chatBubble.style.visibility = 'visible'; // Force visibility
    
    // Simple click action
    chatBubble.onclick = function() {
        window.location.href = '/wiki/Help:Contents';
    };
    
    // Add hover effect
    chatBubble.onmouseover = function() {
        this.style.background = '#005a87';
        this.style.transform = 'scale(1.05)';
    };
    
    chatBubble.onmouseout = function() {
        this.style.background = '#007cba';
        this.style.transform = 'scale(1)';
    };
    
    // Append to body
    document.body.appendChild(chatBubble);
    console.log('Chat bubble created and appended');
    
    // Verify it's visible
    setTimeout(function() {
        var bubble = document.getElementById('helix-wiki-chat-bubble');
        if (bubble) {
            console.log('✅ Chat bubble exists in DOM');
            console.log('Computed style display:', window.getComputedStyle(bubble).display);
            console.log('Computed style visibility:', window.getComputedStyle(bubble).visibility);
        } else {
            console.log('❌ Chat bubble not found in DOM');
        }
    }, 100);
}

// Try multiple ways to ensure the bubble gets created

// 1. Try immediately
createChatBubble();

// 2. Also try on DOMContentLoaded as backup
document.addEventListener('DOMContentLoaded', createChatBubble);

// 3. And try on window.load as another backup
window.addEventListener('load', createChatBubble);

// Keep your Chatbase integration
var script = document.createElement('script');
script.src = 'https://www.chatbase.co/embed.min.js';
script.setAttribute('chatbotId', 'i65eBj3COxUlFEU_Lsrw0');
script.setAttribute('domain', 'www.chatbase.co');
script.defer = true;
document.body.appendChild(script);

console.log('Helix Wiki Chat Bubble: Setup complete');