mirror of
https://github.com/plausible/analytics.git
synced 2024-12-22 09:01:40 +03:00
e8f20e67cc
* Load dashboard with react * Rename stast2 to dashboard * Save timeframe on the frontend * Implement current visitors * Implement comparisons * React to route changes * Add modals * Show number of visitors on hover * Show 'Today' for today * Add 30 days * Show referrer drilldown * Arrow keys to go back and forward * Improve comparisons UI * Fix dropdown when clicking on it * Verify API access in a memoized fashion * Test API access * Test stats through controller * Move map formatting from stats controller to stats * Remove unused code * Remove dead code from query * Remove dead code from stats templates * Add stats view test back in * Render modal inside the modal component * Implement google search terms * Add explanation for screen sizes * Separate dashboard JS from the app js
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
import css from "../css/app.css"
|
|
import "./polyfills/closest"
|
|
import "phoenix_html"
|
|
|
|
const triggers = document.querySelectorAll('[data-dropdown-trigger]')
|
|
|
|
for (const trigger of triggers) {
|
|
trigger.addEventListener('click', function(e) {
|
|
e.stopPropagation()
|
|
e.currentTarget.nextElementSibling.classList.remove('hidden')
|
|
})
|
|
}
|
|
|
|
if (triggers.length > 0) {
|
|
document.addEventListener('click', function(e) {
|
|
const dropdown = e.target.closest('[data-dropdown]')
|
|
|
|
if (dropdown && e.target.tagName === 'A') {
|
|
dropdown.classList.add('hidden')
|
|
}
|
|
})
|
|
|
|
document.addEventListener('click', function(e) {
|
|
const clickedInDropdown = e.target.closest('[data-dropdown]')
|
|
|
|
if (!clickedInDropdown) {
|
|
for (const dropdown of document.querySelectorAll('[data-dropdown]')) {
|
|
dropdown.classList.add('hidden')
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
const flash = document.getElementById('flash')
|
|
|
|
if (flash) {
|
|
setTimeout(function() {
|
|
flash.style.display = 'none'
|
|
}, 2500)
|
|
}
|
|
|
|
const registerForm = document.getElementById('register-form')
|
|
|
|
if (registerForm) {
|
|
registerForm.addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
setTimeout(submitForm, 1000);
|
|
var formSubmitted = false;
|
|
|
|
function submitForm() {
|
|
if (!formSubmitted) {
|
|
formSubmitted = true;
|
|
registerForm.submit();
|
|
}
|
|
}
|
|
|
|
plausible('trigger', 'Signup', {callback: submitForm});
|
|
})
|
|
}
|