Takip ediliyor'); } else { button.removeClass("following"); button.html(' Takip et'); } } });});// Voting system for upvote/downvote$(document).on('click', '.like-button, .vote-button-up', function(e) { var button = $(this); var id = button.data('id'); var counter = $('#data-number-' + id); $.ajax({ type: 'POST', url: '/vote', data: { id: id }, success: function(response) { counter.text(response); // Toggle voted class for upvote button if (button.hasClass('voted')) { button.removeClass('voted'); } else { // Remove down-voted class from downvote button if exists $('.vote-button-down[data-id="' + id + '"]').removeClass('down-voted'); button.addClass('voted'); } } }); return false;});// Voting system for downvote$(document).on('click', '.vote-button-down', function(e) { var button = $(this); var id = button.data('id'); var counter = $('#data-number-' + id); $.ajax({ type: 'POST', url: '/vote2', data: { id: id }, success: function(response) { counter.text(response); // Toggle down-voted class for downvote button if (button.hasClass('down-voted')) { button.removeClass('down-voted'); } else { // Remove voted class from upvote button if exists $('.vote-button-up[data-id="' + id + '"], .like-button[data-id="' + id + '"]').removeClass('voted'); button.addClass('down-voted'); } } }); return false;});// Preview uploaded image$(document).ready(function() { $('#home-media-upload').change(function() { if (this.files && this.files[0]) { var reader = new FileReader(); reader.onload = function(e) { $('#home-media-preview').html('
').show(); } reader.readAsDataURL(this.files[0]); } }); // Expand textarea on focus $('textarea[name="summary"]').focus(function() { $(this).attr('rows', '4'); }).blur(function() { if ($(this).val() == '') { $(this).attr('rows', '1'); } }); // Share functionality $(document).on('click', '.share-button', function() { var id = $(this).data('id'); var url = 'https://yokyahu.com/question/' + id; // Check if the Web Share API is available if (navigator.share) { navigator.share({ title: 'Paylaş', url: url }).catch(console.error); } else { // Fallback: copy to clipboard var tempInput = document.createElement('input'); tempInput.value = url; document.body.appendChild(tempInput); tempInput.select(); document.execCommand('copy'); document.body.removeChild(tempInput); alert('Bağlantı kopyalandı: ' + url); } });});