Al Fawaid al Shakariyah Urdu Sharh Siraji by Mufti Muhammad Shakir Nisar
الفوائد الشاکریہ للفرائض السراجیہ اردو
Share via Facebook
Share via WhatsApp
Share via Gmail
Link copied!
`;
const postTitle = document.title;
const copyLinkButton = document.getElementById('copyLinkBtn');
const shareBookButton = document.getElementById('shareBookBtn');
const shareOptions = document.getElementById('shareOptions');
const toast = document.getElementById('toast');
const downloadButton = document.getElementById('downloadBtn');
// Show custom toast on download click
downloadButton.addEventListener('click', function () {
showToast("Downloading is starting");
});
// Copy Link Button Behavior with Fallback
copyLinkButton.addEventListener('click', function () {
const shareUrl = window.location.href.split('#')[0];
const textToCopy = `${postTitle}\nDownload pdf from this link 👇:\n${shareUrl}`;
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(textToCopy).then(() => {
showToast("Link copied!");
}).catch(err => {
fallbackCopyText(textToCopy);
});
} else {
fallbackCopyText(textToCopy);
}
});
function fallbackCopyText(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
showToast("Link copied!");
} catch (err) {
alert('Copy failed! Please copy manually.');
}
document.body.removeChild(textArea);
}
function showToast(message) {
toast.innerText = message;
toast.className = 'toast show';
setTimeout(() => {
toast.className = toast.className.replace('show', '');
}, 5000);
}
// Share Book Button Toggle
shareBookButton.addEventListener('click', function () {
shareOptions.style.display = shareOptions.style.display === 'block' ? 'none' : 'block';
});
// Share via Facebook
document.getElementById('shareFacebook').addEventListener('click', function () {
const shareUrl = window.location.href.split('#')[0];
const shareText = `${postTitle}\nDownload pdf from this link 👇:\n${shareUrl}`;
const facebookUrl = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}"e=${encodeURIComponent(shareText)}`;
window.open(facebookUrl, '_blank');
});
// Share via WhatsApp
document.getElementById('shareWhatsApp').addEventListener('click', function () {
const shareUrl = window.location.href.split('#')[0];
const shareText = `${postTitle}\nDownload pdf from this link 👇:\n${shareUrl}`;
const whatsappUrl = `https://api.whatsapp.com/send?text=${encodeURIComponent(shareText)}`;
window.open(whatsappUrl, '_blank');
});
// Share via Gmail
document.getElementById('shareGmail').addEventListener('click', function () {
const shareUrl = window.location.href.split('#')[0];
const emailBody = `${postTitle}\nDownload pdf from this link 👇:\n${shareUrl}`;
const gmailUrl = `mailto:?subject=${encodeURIComponent(postTitle)}&body=${encodeURIComponent(emailBody)}`;
window.open(gmailUrl, '_blank');
});
});