No edit summary |
No edit summary |
||
| Line 162: | Line 162: | ||
// Create the form HTML | // Create the form HTML | ||
var formHTML = '<form method="POST" action="https://script.google.com/macros/s/AKfycbzGYYHbCtVTjXPjTcYKA3wuK6ZAfKIiluw6sZKuWTZzVFnlnl-V9UYsVEroi1MzyIoUhg/exec">' + | var formHTML = '<form method="POST" action="https://script.google.com/macros/s/AKfycbzGYYHbCtVTjXPjTcYKA3wuK6ZAfKIiluw6sZKuWTZzVFnlnl-V9UYsVEroi1MzyIoUhg/exec">' + | ||
'<input name="Email" type="email" placeholder="Email" required>' + | '<input name="Email" type="email" placeholder="Email" required>' + '<br>' + | ||
'<input name="Name" type="text" placeholder="Name" required>' + | '<input name="Name" type="text" placeholder="Name" required>' + '<br>' + '<input name="Comment" type="text" placeholder="Comment" required>' + | ||
'<button type="submit">Send</button>' + | '<button type="submit">Send</button>' + | ||
'</form>'; | '</form>'; | ||
Revision as of 22:32, 15 August 2025
function fixViewport() {
// Remove all viewport tags except the responsive one
var viewportTags = document.querySelectorAll('meta[name="viewport"]');
for (var i = 0; i < viewportTags.length; i++) {
var tag = viewportTags[i];
if (tag.content.indexOf('width=device-width') === -1) {
tag.parentNode.removeChild(tag);
}
}
// Force browser to reprocess the remaining viewport tag
var goodViewport = document.querySelector('meta[name="viewport"]');
if (goodViewport) {
var content = goodViewport.getAttribute('content');
goodViewport.setAttribute('content', '');
goodViewport.setAttribute('content', content);
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', fixViewport);
} else {
fixViewport();
}
document.addEventListener('DOMContentLoaded', function() {
// Remove the viewport tag with width=1000
const badViewport = document.querySelector('meta[name="viewport"][content*="width=1000"]');
if (badViewport) {
badViewport.remove();
}
});
// MediaWiki Audio Player Controller
(function() {
function initGallery() {
var galleries = document.querySelectorAll('.collapsible-gallery');
galleries.forEach(function(gallery) {
// Skip if already initialized
if (gallery.dataset.initialized) return;
gallery.dataset.initialized = 'true';
var slides = gallery.querySelectorAll('.gallery-slide');
var container = gallery.querySelector('.gallery-container');
var currentIndex = 0;
// Create navigation controls using JavaScript
var controls = document.createElement('div');
controls.className = 'gallery-controls';
var prevBtn = document.createElement('div');
prevBtn.className = 'gallery-btn gallery-prev';
prevBtn.innerHTML = '< Previous';
prevBtn.setAttribute('role', 'button');
prevBtn.setAttribute('tabindex', '0');
var counter = document.createElement('div');
counter.className = 'gallery-counter';
var nextBtn = document.createElement('div');
nextBtn.className = 'gallery-btn gallery-next';
nextBtn.innerHTML = 'Next >';
nextBtn.setAttribute('role', 'button');
nextBtn.setAttribute('tabindex', '0');
controls.appendChild(prevBtn);
controls.appendChild(counter);
controls.appendChild(nextBtn);
// Insert controls before the container
gallery.insertBefore(controls, container);
// Initialize counter
updateCounter();
// Set up event listeners
prevBtn.addEventListener('click', showPreviousSlide);
nextBtn.addEventListener('click', showNextSlide);
// Keyboard support
prevBtn.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
showPreviousSlide();
}
});
nextBtn.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
showNextSlide();
}
});
function showSlide(index) {
// Hide all slides
slides.forEach(function(slide) {
slide.classList.remove('showing');
});
// Show the selected slide
slides[index].classList.add('showing');
// Update counter
updateCounter();
}
function showNextSlide() {
currentIndex = (currentIndex + 1) % slides.length;
showSlide(currentIndex);
}
function showPreviousSlide() {
currentIndex = (currentIndex - 1 + slides.length) % slides.length;
showSlide(currentIndex);
}
function updateCounter() {
counter.textContent = (currentIndex + 1) + ' / ' + slides.length;
}
});
}
// Handle MediaWiki specific environment
if (window.mw && window.mw.hook) {
mw.hook('wikipage.content').add(initGallery);
} else {
document.addEventListener('DOMContentLoaded', initGallery);
}
// Handle collapsibles being expanded
document.addEventListener('click', function(e) {
if (e.target.classList.contains('mw-collapsible-toggle') ||
e.target.closest('.mw-collapsible-toggle')) {
setTimeout(initGallery, 150);
}
});
// Also try to initialize on any content changes
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'attributes' &&
mutation.attributeName === 'class' &&
mutation.target.classList.contains('mw-collapsible')) {
setTimeout(initGallery, 100);
}
});
});
observer.observe(document.body, {
attributes: true,
subtree: true,
attributeFilter: ['class']
});
})();
// Contact Form Handler
$(document).ready(function () {
$('.contact-form-container').each(function() {
// Create the form HTML
var formHTML = '<form method="POST" action="https://script.google.com/macros/s/AKfycbzGYYHbCtVTjXPjTcYKA3wuK6ZAfKIiluw6sZKuWTZzVFnlnl-V9UYsVEroi1MzyIoUhg/exec">' +
'<input name="Email" type="email" placeholder="Email" required>' + '<br>' +
'<input name="Name" type="text" placeholder="Name" required>' + '<br>' + '<input name="Comment" type="text" placeholder="Comment" required>' +
'<button type="submit">Send</button>' +
'</form>';
// Insert the form HTML into the div
$(this).html(formHTML);
// Optional: Add event listener for form submission if you want to handle it with JS
$(this).find('form').on('submit', function(e) {
// You can add custom submission handling here if needed
console.log('Form submitted');
// If you want to handle the submission yourself, uncomment the next line
// e.preventDefault();
});
});
});
// IFRAME COMMUNICATION
(function() {
'use strict';
// Only run if we're in an iframe
if (window.parent !== window) {
// Wait for the page to load
$(function() {
// Configuration
var PARENT_ORIGIN = 'http://127.0.0.1:5500';
var CLICKABLE_ELEMENTS = [
'a', // Category links
'.audio-ref'
];
// Add click handlers to the specified elements
$(CLICKABLE_ELEMENTS.join(', ')).on('click', function(e) {
// Get element information
var elementInfo = {
type: 'elementClicked',
elementId: this.id || 'unnamed-element',
elementTag: this.tagName.toLowerCase(),
elementClass: this.className,
elementText: $(this).text().trim(),
timestamp: Date.now()
};
// Send message to parent React app
window.parent.postMessage(elementInfo, PARENT_ORIGIN);
console.log('Click detected and reported:', elementInfo);
});
console.log('Click detection initialized for iframe communication');
});
}
})();
// Symbol replacement hook
mw.hook('wikipage.content').add(function ($content) {
// Find all links in the content
var links = $content.find('a');
// Iterate through each link
links.each(function() {
var $link = $(this);
var html = $link.html();
// Check if the link contains the symbol (including variant selectors)
if (html && html.indexOf('▶') !== -1) {
// Replace the symbol with a span that has white color
var newHtml = html.replace(/▶[\uFE0E\uFE0F]?/g, '<span class="symbol-container" style="color: white;">▶</span>');
$link.html(newHtml);
}
});
});
// VideoJS initialization
function initializeAllVideoJS() {
var players = document.querySelectorAll('audio.video-js, video.video-js');
players.forEach(function(player) {
if (!player.player) { // Prevent double init
videojs(player);
}
});
}
$(document).ready(function() {
initializeAllVideoJS();
});
