hackatime/app/javascript/application.js
2025-05-08 20:33:17 -04:00

20 lines
777 B
JavaScript

// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"
function setupCurrentlyHacking() {
const header = document.querySelector('.currently-hacking');
// only if no existing event listener
if (!header) { return }
header.onclick = function() {
const container = document.querySelector('.currently-hacking-container');
if (container) {
container.classList.toggle('visible');
}
}
}
// Handle both initial page load and subsequent Turbo navigations
document.addEventListener('turbo:load', setupCurrentlyHacking);
document.addEventListener('turbo:render', setupCurrentlyHacking);
document.addEventListener('DOMContentLoaded', setupCurrentlyHacking);