File size: 2,683 Bytes
1404c2a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | // Global configuration for MathJax
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
options: {
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
}
};
// Initialize interactive elements
document.addEventListener('DOMContentLoaded', function() {
// Handle algorithm card clicks
document.querySelectorAll('algorithm-card').forEach(card => {
card.addEventListener('click', function() {
const href = this.getAttribute('href');
if (href) {
window.location.href = href;
}
});
});
// Initialize tooltips
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
});
// Utility function for creating interactive graphs
function createInteractiveGraph(canvasId, config, interactiveOptions = {}) {
const ctx = document.getElementById(canvasId).getContext('2d');
const chart = new Chart(ctx, config);
// Add interactive features if specified
if (interactiveOptions.draggablePoints) {
makePointsDraggable(chart);
}
return chart;
}
function makePointsDraggable(chart) {
// Implementation for making chart points draggable
// This would be extended based on specific algorithm needs
}
// Tab switching functionality for algorithm pages
function setupAlgorithmTabs() {
const tabs = document.querySelectorAll('.tab');
if (tabs.length > 0) {
tabs.forEach(tab => {
tab.addEventListener('click', () => {
// Remove active class from all tabs and contents
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
document.querySelectorAll('.tab-content').forEach(c => c.classList.add('hidden'));
// Add active class to clicked tab and corresponding content
tab.classList.add('active');
const tabId = tab.getAttribute('data-tab');
document.getElementById(tabId).classList.remove('hidden');
});
});
}
}
// Initialize page functionality
document.addEventListener('DOMContentLoaded', function() {
setupAlgorithmTabs();
// Handle algorithm card clicks
document.querySelectorAll('algorithm-card').forEach(card => {
card.addEventListener('click', function() {
const href = this.getAttribute('href');
if (href) {
window.location.href = href;
}
});
});
});
|