2021-09-19 15:56:05 +00:00
|
|
|
import BotDetector from 'device-detector-js/dist/parsers/bot'
|
2021-01-12 17:14:14 +00:00
|
|
|
import { Notifier } from '@airbrake/browser'
|
|
|
|
|
2021-09-20 17:18:31 +00:00
|
|
|
window.bot_detector = new BotDetector
|
|
|
|
const bot = window.bot_detector.parse(navigator.userAgent)
|
2021-01-12 17:14:14 +00:00
|
|
|
|
2021-09-20 17:18:31 +00:00
|
|
|
if (!bot) {
|
|
|
|
window.airbrake = new Notifier({
|
|
|
|
projectId: window.env.AIRBRAKE_PROJECT_ID,
|
|
|
|
projectKey: window.env.AIRBRAKE_PROJECT_KEY,
|
|
|
|
host: 'https://panel.sutty.nl'
|
|
|
|
})
|
2021-09-19 15:56:05 +00:00
|
|
|
|
2021-09-20 17:18:31 +00:00
|
|
|
console.originalError = console.error
|
|
|
|
console.error = (...e) => {
|
|
|
|
window.airbrake.notify(e.join(' '))
|
|
|
|
return console.originalError(...e)
|
2021-09-19 15:56:05 +00:00
|
|
|
}
|
2021-09-17 19:07:10 +00:00
|
|
|
}
|
2021-09-17 18:27:00 +00:00
|
|
|
|
2021-01-12 16:35:23 +00:00
|
|
|
import 'core-js/stable'
|
|
|
|
import 'regenerator-runtime/runtime'
|
|
|
|
|
2021-09-17 18:29:02 +00:00
|
|
|
// Turbo acelera la navegación al no tener que recargar todo el JS y CSS
|
|
|
|
// de la página, con lo que se siente más rápida y "nativa".
|
|
|
|
//
|
|
|
|
// Cambiamos de turbolinks a turbo porque turbo soporta la función
|
|
|
|
// fetch(), que luego es interceptada por el SW para obtener las
|
|
|
|
// direcciones localmente.
|
|
|
|
import * as Turbo from "@hotwired/turbo"
|
|
|
|
Turbo.start()
|
2021-01-12 16:38:32 +00:00
|
|
|
|
2020-11-12 16:28:24 +00:00
|
|
|
import { Application } from 'stimulus'
|
|
|
|
import { definitionsFromContext } from "stimulus/webpack-helpers"
|
|
|
|
|
|
|
|
const application = Application.start()
|
|
|
|
const context = require.context("./controllers", true, /\.js$/)
|
|
|
|
application.load(definitionsFromContext(context))
|
2021-01-12 16:38:32 +00:00
|
|
|
|
2021-02-10 19:32:11 +00:00
|
|
|
try {
|
|
|
|
window.axe = require('axe-core/axe')
|
|
|
|
} catch(e) {}
|
|
|
|
|
|
|
|
if (window.axe) window.axe.configure({ locale: require('axe-core/locales/es.json') })
|
|
|
|
|
2021-09-17 18:41:37 +00:00
|
|
|
document.addEventListener('turbo:load', event => {
|
2021-09-17 18:42:57 +00:00
|
|
|
document.querySelectorAll("a[href^='http://'],a[href^='https://'],a[href^='//']").forEach(a => {
|
|
|
|
a.rel = "noopener"
|
|
|
|
a.target = "_blank"
|
|
|
|
})
|
|
|
|
|
2021-02-10 19:32:11 +00:00
|
|
|
if (!window.axe) return
|
|
|
|
|
|
|
|
window.axe.run().then(results => {
|
|
|
|
results.violations.forEach(violation => {
|
|
|
|
violation.nodes.forEach(node => {
|
|
|
|
node.target.forEach(target => {
|
|
|
|
document.querySelectorAll(target).forEach(element => {
|
|
|
|
element.classList.add('inaccesible')
|
|
|
|
element.ariaLabel = node.failureSummary
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2021-01-12 16:38:32 +00:00
|
|
|
})
|