if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(value).then(markCopied);
return;
}
var textarea = document.createElement("textarea");
textarea.value = value;
textarea.setAttribute("readonly", "");
textarea.style.position = "fixed";
textarea.style.left = "-9999px";
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
markCopied();
}
ready(function () {
var articles = document.querySelectorAll(".baiq-article-template");
if (!articles.length) return;
var pageUrl = window.location.href.split("#")[0];
var pageTitle =
getMetaContent('meta[property="og:title"]') ||
getMetaContent('meta[name="twitter:title"]') ||
document.title;
var cleanTitle = pageTitle
.replace(/\s+[-|]\s+Build AIQ\s*$/i, "")
.trim();
var publishedDate = formatDate(getMetaContent('meta[itemprop="datePublished"]'));
var updatedDate = formatDate(getMetaContent('meta[itemprop="dateModified"]'));
articles.forEach(function (article) {
article.querySelectorAll("[data-baiq-date='published']").forEach(function (element) {
if (publishedDate) element.textContent = publishedDate;
});
article.querySelectorAll("[data-baiq-date='updated']").forEach(function (element) {
if (updatedDate) element.textContent = updatedDate;
});
article.querySelectorAll("[data-baiq-share='linkedin']").forEach(function (link) {
link.href =
"https://www.linkedin.com/shareArticle?mini=true&url=" +
encodeURIComponent(pageUrl);
});
article.querySelectorAll("[data-baiq-share='x']").forEach(function (link) {
link.href =
"https://twitter.com/intent/tweet?url=" +
encodeURIComponent(pageUrl) +
"&text=" +
encodeURIComponent(cleanTitle);
});
article.querySelectorAll("[data-baiq-copy-link]").forEach(function (button) {
button.addEventListener("click", function () {
copyText(pageUrl, button);
});
});
});
});
})();