2020-06-17 20:04:59 +00:00
|
|
|
---
|
|
|
|
---
|
|
|
|
|
2020-09-15 13:04:18 +00:00
|
|
|
const loadEvent = () => {
|
|
|
|
try {
|
|
|
|
if (Turbolinks) return 'turbolinks:load'
|
|
|
|
} catch {
|
|
|
|
return 'DOMContentLoaded'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener(loadEvent(), () => {
|
2020-06-17 20:04:59 +00:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
2020-09-15 13:02:50 +00:00
|
|
|
|
|
|
|
document.querySelectorAll("a[href^='http://'],a[href^='https://'],a[href^='//']").forEach(a => {
|
|
|
|
a.rel = "noopener";
|
|
|
|
a.target = "_blank";
|
|
|
|
});
|
2020-06-17 20:04:59 +00:00
|
|
|
});
|