Spaces:
Running
Running
File size: 2,531 Bytes
380b3d6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | // Persian (RTL) script for ScamShield
document.addEventListener('DOMContentLoaded', function() {
// Initialize tooltips for icons
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// Mobile menu toggle functionality
const mobileMenuButton = document.querySelector('.mobile-menu-button');
const mobileMenu = document.querySelector('.mobile-menu');
if (mobileMenuButton && mobileMenu) {
mobileMenuButton.addEventListener('click', function() {
mobileMenu.classList.toggle('hidden');
});
}
// Search functionality
const searchForm = document.querySelector('#search-form');
if (searchForm) {
searchForm.addEventListener('submit', function(e) {
e.preventDefault();
const searchQuery = document.querySelector('#search-input').value.trim();
if (searchQuery) {
window.location.href = `/search.html?q=${encodeURIComponent(searchQuery)}`;
}
});
}
// Report modal functionality
const reportModal = document.getElementById('report-modal');
if (reportModal) {
const openModalButtons = document.querySelectorAll('.open-report-modal');
const closeModalButton = document.querySelector('.close-report-modal');
openModalButtons.forEach(button => {
button.addEventListener('click', function() {
reportModal.classList.remove('hidden');
});
});
if (closeModalButton) {
closeModalButton.addEventListener('click', function() {
reportModal.classList.add('hidden');
});
}
}
// Initialize Persian date picker if needed
if (typeof persianDate !== 'undefined') {
const datePickers = document.querySelectorAll('.persian-date-picker');
datePickers.forEach(picker => {
new persianDate(picker, {
observer: true,
format: 'YYYY/MM/DD'
});
});
}
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Initialize Persian number input formatters
document.querySelectorAll('.persian-number').forEach(element => {
element.addEventListener('input', function() {
this.value = this.value.replace(/[^۰-۹]/g, '');
});
});
}); |