$(document).ready(function() { let offset = 0; const limit = 6; // Should match the limit in your PHP script let searchValue = document.getElementById("search_cont").value; const get_ids = document.getElementById('get_id').value; function loadMoreItems() { $('#loader').show(); $.ajax({ url: 'video_data_load.php', type: 'POST', data: { offset: offset , search_cont:searchValue, get_id:get_ids }, dataType: 'json', success: function(data) { if (data.length > 0) { data.forEach(item => { $('#items-container').append(item); // Directly append the HTML content }); offset += limit; $('#load-more').prop('disabled', false).empty().text('Load More'); $('#loader').hide(); } else { $('#load-more').prop('disabled', true).empty().text('No more Videos to load'); $('#loader').hide(); } }, error: function(xhr, status, error) { console.error('Error: ' + error); } }); } $('#load-more').click(function() { loadMoreItems(); }); // Initial load loadMoreItems(); }); function search_function() { let offset = 0; const limit = 6; // Should match the limit in your PHP script let searchValue = document.getElementById("search_cont").value; const get_ids = document.getElementById('get_id').value; function loadMoreItems() { $('#loader1').show(); $.ajax({ url: 'video_data_load.php', type: 'POST', data: { offset: offset , search_cont:searchValue, get_id:get_ids }, dataType: 'json', success: function(data) { $('#items-container').empty(); if (data.length > 0) { data.forEach(item => { $('#items-container').append(item); // Directly append the HTML content }); offset += limit; $('#load-more').prop('disabled', false).empty().text('Load More'); $('#loader1').hide(); } else { $('#load-more').prop('disabled', true).empty().text('No more Videos to load'); $('#loader1').hide(); } }, error: function(xhr, status, error) { console.error('Error: ' + error); } }); } $('#load-more').click(function() { loadMoreItems(); }); // Initial load loadMoreItems(); } function shareViaFacebook(videoUrl) { var facebookLink = 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(videoUrl); window.open(facebookLink, '_blank'); } function shareViaWhatsApp(videoUrl) { var message = " Please vote for me as a singer in Aikat Mozo Tavo and ask others to vote as well!!!"; var whatsappLink = 'whatsapp://send?text=' + encodeURIComponent(videoUrl + '\n\n' + message); window.open(whatsappLink, '_blank'); } function copyLink(videoUrl) { var message = " Please vote for me as a singer in Aikat Mozo Tavo and ask others to vote as well!!!"; var textField = document.createElement('textarea'); textField.innerText = videoUrl + '\n\n' + message; document.body.appendChild(textField); textField.select(); document.execCommand('copy'); textField.remove(); // Show SweetAlert to notify the user Swal.fire({ title: 'Link Copied', text: 'The link with message has been copied to your clipboard.', icon: 'success', showConfirmButton: false, timer: 1500 }); } function shareViaInstagramDM(videoUrl) { var message = "Please vote for me as a singer in Aikat Mozo Tavo and encourage others to vote as well!"; // Copy message to clipboard var textField = document.createElement('textarea'); textField.innerText = videoUrl + '\n\n' + message; document.body.appendChild(textField); textField.select(); document.execCommand('copy'); textField.remove(); // Show Swal alert Swal.fire({ title: 'Link Copied', text: 'The link with your message has been copied to your clipboard. Paste and share it in your Instagram DM.', icon: 'success', confirmButtonText: 'OK' }).then((result) => { if (result.isConfirmed) { // Redirect to Instagram DM var instagramLink = 'https://www.instagram.com/direct/new/?text=' + encodeURIComponent(message); window.open(instagramLink, '_blank'); } }); }