MediaWiki:Common.js: Difference between revisions
From Helix Project Wiki
Steve Helix (talk | contribs) No edit summary |
Steve Helix (talk | contribs) 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 | // Helix Project - Wiki Chat Bubble (Working Version) | ||
console.log(' | console.log('Helix Wiki Chat Bubble: Script loading...'); | ||
// | // Create chat bubble immediately, don't wait for load | ||
console.log(' | 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 | // Create new bubble | ||
var chatBubble = document.createElement('div'); | var chatBubble = document.createElement('div'); | ||
chatBubble.innerHTML = '💬 | chatBubble.innerHTML = '💬 Wiki Help'; | ||
chatBubble.id = 'helix-wiki-chat-bubble'; | chatBubble.id = 'helix-wiki-chat-bubble'; | ||
// | // 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 = ' | chatBubble.style.background = '#007cba'; | ||
chatBubble.style.color = 'white'; | chatBubble.style.color = 'white'; | ||
chatBubble.style.padding = ' | chatBubble.style.padding = '12px 18px'; | ||
chatBubble.style.borderRadius = ' | chatBubble.style.borderRadius = '20px'; | ||
chatBubble.style.cursor = 'pointer'; | chatBubble.style.cursor = 'pointer'; | ||
chatBubble.style.zIndex = ' | chatBubble.style.zIndex = '100000'; // Very high z-index | ||
chatBubble.style.fontSize = ' | 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. | chatBubble.style.display = 'block'; // Force display | ||
chatBubble.style.visibility = 'visible'; // Force visibility | |||
// Simple click action | // Simple click action | ||
chatBubble.onclick = function() { | 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); | document.body.appendChild(chatBubble); | ||
console.log('Chat bubble appended | console.log('Chat bubble created and appended'); | ||
// Verify it's | // Verify it's visible | ||
var | 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'); | |||
console.log(' | |||
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');
