1document.addEventListener('DOMContentLoaded', function () { 2 // Get all elements with the class 'digr_btn' 3 var buttons = document.querySelectorAll('.digr_btn'); 4 5 // Check for touch support 6 var isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints; 7 8 // Use pointer events for modern browsers, fallback to click for older ones 9 var eventName = isTouchDevice ? 'pointerdown' : 'click'; 10 11 // Iterate through each button 12 buttons.forEach(function (btn) { 13 // Attach the appropriate event listener 14 btn.addEventListener(eventName, handleEvent); 15 }); 16 17 // Common function to handle both click and touch events 18 function handleEvent(event) { 19 // Prevent the default touch behavior for touch devices 20 if (isTouchDevice && event.pointerType === 'touch') { 21 event.preventDefault(); 22 } 23 24 // Get the href attribute value of the clicked/touched button 25 var href = event.currentTarget.getAttribute('href'); 26 27 // Check if the href points to a downloadable file (you can customize the file types as needed) 28 if (href.endsWith('.jpg') || href.endsWith('.png') || href.endsWith('.jpeg') || 29 href.endsWith('.zip') || href.endsWith('.gif') || 30 href.endsWith('.doc') || href.endsWith('.xls') || href.endsWith('.psd') || 31 href.endsWith('.mp4') || href.endsWith('.webm') || href.endsWith('.avi') || 32 href.endsWith('.wmv') || href.endsWith('.eps') || href.endsWith('.ai') || 33 href.endsWith('.mp3') || href.endsWith('.rar') 34 ) { 35 // If it's a downloadable file, prevent the default behavior 36 event.preventDefault(); 37 38 // Trigger the download 39 downloadFile(href); 40 } else if (href.endsWith('.pdf')) { 41 // If it's a PDF file, open in a new window 42 event.preventDefault(); 43 44 // Get the URL for the PDF file 45 var pdfUrl = href; 46 47 // Open the PDF file in a new window 48 window.open(pdfUrl, '_blank'); 49 } 50 // else, let the default behavior happen (open the link) 51 } 52 53 // Function to trigger the download 54 function downloadFile(url) { 55 // You can customize this behavior based on your needs 56 alert('Downloading file: ' + url); 57 // Here you can use additional code to initiate the download, like creating a hidden link and clicking it 58 var link = document.createElement('a'); 59 link.href = url; 60 link.download = url.split('/').pop(); // Use the last part of the URL as the file name 61 document.body.appendChild(link); 62 link.click(); 63 document.body.removeChild(link); 64 } 65}); 66 67 68 69 70 71 72 73 74 75// document.addEventListener('DOMContentLoaded', function () { 76// // Get all elements with the class 'digr_btn' 77// var buttons = document.querySelectorAll('.digr_btn'); 78 79// // Check for touch support 80// var isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints; 81 82// // Use pointer events for modern browsers, fallback to click for older ones 83// var eventName = isTouchDevice ? 'pointerdown' : 'click'; 84 85// // Iterate through each button 86// buttons.forEach(function (btn) { 87// // Attach the appropriate event listener 88// btn.addEventListener(eventName, handleEvent); 89// }); 90 91// // Common function to handle both click and touch events 92// function handleEvent(event) { 93// // Prevent the default touch behavior for touch devices 94// if (isTouchDevice && event.pointerType === 'touch') { 95// event.preventDefault(); 96// } 97 98// // Get the href attribute value of the clicked/touched button 99// var href = event.currentTarget.getAttribute('href'); 100 101// // Check if the href points to a downloadable file (you can customize the file types as needed) 102// if (href.endsWith('.jpg') || href.endsWith('.png') || href.endsWith('.jpeg') || 103// href.endsWith('.pdf') || href.endsWith('.zip') || href.endsWith('.gif') || 104// href.endsWith('.doc') || href.endsWith('.xls') || href.endsWith('.psd') || 105// href.endsWith('.mp4') || href.endsWith('.webm') || href.endsWith('.avi') || 106// href.endsWith('.wmv') || href.endsWith('.eps') || href.endsWith('.ai') || 107// href.endsWith('.mp3') || href.endsWith('.rar') 108// ) { 109// // If it's a downloadable file, prevent the default behavior 110// event.preventDefault(); 111 112// // Trigger the download 113// downloadFile(href); 114// } 115// // else, let the default behavior happen (open the link) 116// } 117 118// // Function to trigger the download 119// function downloadFile(url) { 120// // You can customize this behavior based on your needs 121// alert('Downloading file: ' + url); 122// // Here you can use additional code to initiate the download, like creating a hidden link and clicking it 123// var link = document.createElement('a'); 124// link.href = url; 125// link.download = url.split('/').pop(); // Use the last part of the URL as the file name 126// document.body.appendChild(link); 127// link.click();
128// document.body.removeChild(link); 129// } 130// });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.