From 5be70267cb962a0e4f0bb4a9503eab1b31b4d9d6 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 17 Sep 2021 15:42:57 -0300 Subject: [PATCH] Yapa: Eliminar JavaScript extra --- _packs/entry.js | 5 +++++ assets/js/script.js | 44 -------------------------------------------- 2 files changed, 5 insertions(+), 44 deletions(-) delete mode 100644 assets/js/script.js diff --git a/_packs/entry.js b/_packs/entry.js index 8a4d710..aac43aa 100644 --- a/_packs/entry.js +++ b/_packs/entry.js @@ -32,6 +32,11 @@ try { if (window.axe) window.axe.configure({ locale: require('axe-core/locales/es.json') }) document.addEventListener('turbo:load', event => { + document.querySelectorAll("a[href^='http://'],a[href^='https://'],a[href^='//']").forEach(a => { + a.rel = "noopener" + a.target = "_blank" + }) + if (!window.axe) return window.axe.run().then(results => { diff --git a/assets/js/script.js b/assets/js/script.js deleted file mode 100644 index bf5f470..0000000 --- a/assets/js/script.js +++ /dev/null @@ -1,44 +0,0 @@ ---- ---- - -const loadEvent = () => { - try { - if (Turbolinks) return 'turbolinks:load' - } catch { - return 'DOMContentLoaded' - } -} - -document.addEventListener(loadEvent(), () => { - document.querySelectorAll('.share').forEach(share => { - share.addEventListener('click', event => { - if (!Navigator.share) return; - - event.preventDefault(); - event.stopPropagation(); - - const title = document.querySelector('title').text; - - try { - const text = document.querySelector('meta[property="og:description"]').content; - } catch { - const text = ''; - } - - try { - const url = document.querySelector('link[rel=canonical]').href; - } catch { - const url = document.location.href; - } - - const data = { title: title, text: text, url: url }; - - if (Navigator.canShare(data)) Navigator.share(data).then(); - }); - }); - - document.querySelectorAll("a[href^='http://'],a[href^='https://'],a[href^='//']").forEach(a => { - a.rel = "noopener"; - a.target = "_blank"; - }); -});