OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
new_ui
/
assets
/
js
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
๐
..
-
05/19/2025 10:07:13 AM
rwxr-xr-x
๐
common.js
56.94 KB
05/16/2025 04:32:09 AM
rw-r--r--
๐
genai_func.js
13.81 KB
05/16/2025 04:32:09 AM
rw-r--r--
๐
magnific-popup.min.js
19.74 KB
05/16/2025 04:32:09 AM
rw-r--r--
๐
main.js
4.98 KB
05/16/2025 04:32:09 AM
rw-r--r--
๐
new_social_script.js
27.73 KB
05/16/2025 04:32:09 AM
rw-r--r--
๐
scripts.js
1.49 KB
05/16/2025 04:32:09 AM
rw-r--r--
๐
stream.js
16.86 KB
05/16/2025 04:32:09 AM
rw-r--r--
Editing: new_social_script.js
Close
// Add this to your existing JavaScript at the bottom of the page // document.addEventListener('DOMContentLoaded', function () { // const fabButton = document.getElementById('create-post-fab'); // const postModal = document.getElementById('post-modal'); // const closeModal = document.getElementById('close-modal'); // const submitPost = document.getElementById('submit-post'); // const postTextarea = document.getElementById('post-textarea'); // const privacyDropdownBtn = document.getElementById('privacy-dropdown-btn'); // const privacyDropdownContent = document.getElementById('privacy-dropdown-content'); // const privacyDropdownItems = document.querySelectorAll('.dropdown-item'); // // Open modal when FAB is clicked // fabButton.addEventListener('click', function () { // postModal.classList.add('active'); // }); // // Close modal when close button is clicked // closeModal.addEventListener('click', function () { // postModal.classList.remove('active'); // }); // // Close modal when clicking outside of it // postModal.addEventListener('click', function (e) { // if (e.target === postModal) { // postModal.classList.remove('active'); // } // }); // // Toggle privacy dropdown // privacyDropdownBtn.addEventListener('click', function () { // privacyDropdownContent.classList.toggle('active'); // event.stopPropagation(); // }); // // Close dropdown when clicking elsewhere // document.addEventListener('click', function () { // privacyDropdownContent.classList.remove('active'); // }); // // Prevent dropdown from closing when clicking inside it // privacyDropdownContent.addEventListener('click', function (e) { // e.stopPropagation(); // }); // // Handle privacy selection // privacyDropdownItems.forEach(item => { // item.addEventListener('click', function () { // // Remove active class from all items // privacyDropdownItems.forEach(i => i.classList.remove('active')); // // Add active class to clicked item // this.classList.add('active'); // // Update button text and icon // const icon = this.querySelector('i').cloneNode(true); // const text = this.querySelector('span').textContent; // privacyDropdownBtn.innerHTML = ''; // privacyDropdownBtn.appendChild(icon); // const span = document.createElement('span'); // span.textContent = text; // privacyDropdownBtn.appendChild(span); // const caretIcon = document.createElement('i'); // caretIcon.className = 'fas fa-caret-down'; // privacyDropdownBtn.appendChild(caretIcon); // // Close dropdown // privacyDropdownContent.classList.remove('active'); // }); // }); // // Submit post functionality // submitPost.addEventListener('click', function () { // const postText = postTextarea.value.trim(); // if (postText !== '') { // createNewPost(postText); // postTextarea.value = ''; // postModal.classList.remove('active'); // } // }); // // Create new post function (reuse your existing function) // function createNewPost(text) { // const postsFeed = document.querySelector('.posts-feed'); // const newPost = document.createElement('div'); // newPost.className = 'post-card'; // const timeString = 'Just now'; // newPost.innerHTML = ` // <div class="post-header"> // <div class="user-avatar">J</div> // <div class="post-info"> // <div class="post-author">You</div> // <div class="post-meta">@yourhandle ยท ${timeString}</div> // </div> // <div class="post-menu"> // <i class="fas fa-ellipsis-h"></i> // </div> // </div> // <div class="post-content"> // <div class="post-text">${text}</div> // </div> // <div class="post-stats"> // <div>0 comments</div> // <div>0 shares</div> // </div> // <div class="post-actions-bar"> // <div class="action-button"> // <i class="far fa-heart"></i> // <span>Like</span> // </div> // <div class="action-button"> // <i class="far fa-comment"></i> // <span>Comment</span> // </div> // <div class="action-button"> // <i class="far fa-bookmark"></i> // <span>Bookmark</span> // </div> // <div class="action-button"> // <i class="far fa-share-square"></i> // <span>Share</span> // </div> // </div> // `; // // Insert the new post at the top of the feed // postsFeed.insertBefore(newPost, postsFeed.firstChild); // // Add event listeners to the new post's action buttons // const newActionButtons = newPost.querySelectorAll('.action-button'); // newActionButtons.forEach(button => { // button.addEventListener('click', function () { // if (this.querySelector('.fa-heart')) { // this.classList.toggle('liked'); // const icon = this.querySelector('.fa-heart'); // if (this.classList.contains('liked')) { // icon.classList.remove('far'); // icon.classList.add('fas'); // } else { // icon.classList.remove('fas'); // icon.classList.add('far'); // } // } // }); // }); // } // }); // Mobile Footer Navigation document.addEventListener('DOMContentLoaded', function () { const footerItems = document.querySelectorAll('.footer-item'); footerItems.forEach(item => { item.addEventListener('click', function () { // Remove active class from all items footerItems.forEach(i => i.classList.remove('active')); // Add active class to clicked item this.classList.add('active'); // Add your navigation logic here // For example, if the plus icon is clicked, open the post modal if (this.querySelector('.fa-plus-circle')) { document.getElementById('post-modal').classList.add('active'); } }); }); }); // Dark mode functionality document.addEventListener('DOMContentLoaded', function () { const themeToggle = document.getElementById('theme-toggle'); const themeIcon = themeToggle.querySelector('i'); // Check for saved theme preference or respect OS preference const savedTheme = localStorage.getItem('theme'); const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; // Apply theme based on saved preference or OS preference if (savedTheme === 'dark' || (!savedTheme && prefersDark)) { document.documentElement.setAttribute('data-theme', 'dark'); themeIcon.classList.remove('fa-moon'); themeIcon.classList.add('fa-sun'); } // Theme toggle click handler themeToggle.addEventListener('click', function () { const currentTheme = document.documentElement.getAttribute('data-theme'); let newTheme; if (currentTheme === 'dark') { newTheme = ''; themeIcon.classList.remove('fa-sun'); themeIcon.classList.add('fa-moon'); } else { newTheme = 'dark'; themeIcon.classList.remove('fa-moon'); themeIcon.classList.add('fa-sun'); } document.documentElement.setAttribute('data-theme', newTheme); localStorage.setItem('theme', newTheme); }); // Simple like functionality const actionButtons = document.querySelectorAll('.action-button'); actionButtons.forEach(button => { button.addEventListener('click', function () { if (this.querySelector('.fa-heart')) { this.classList.toggle('liked'); const icon = this.querySelector('.fa-heart'); if (this.classList.contains('liked')) { icon.classList.remove('far'); icon.classList.add('fas'); } else { icon.classList.remove('fas'); icon.classList.add('far'); } } }); }); // Create post functionality const postButton = document.querySelector('.post-button'); const postTextarea = document.querySelector('.post-input textarea'); postButton.addEventListener('click', function () { const postText = postTextarea.value.trim(); if (postText !== '') { createNewPost(postText); postTextarea.value = ''; } }); function createNewPost(text) { const postsFeed = document.querySelector('.posts-feed'); const newPost = document.createElement('div'); newPost.className = 'post-card'; const currentDate = new Date(); const timeString = 'Just now'; newPost.innerHTML = ` <div class="post-header"> <div class="user-avatar">J</div> <div class="post-info"> <div class="post-author">You</div> <div class="post-meta">@yourhandle ยท ${timeString}</div> </div> <div class="post-menu"> <i class="fas fa-ellipsis-h"></i> </div> </div> <div class="post-content"> <div class="post-text">${text}</div> </div> <div class="post-stats"> <div>0 comments</div> <div>0 shares</div> </div> <div class="post-actions-bar"> <div class="action-button"> <i class="far fa-comment"></i> <span>Comment</span> </div> <div class="action-button"> <i class="far fa-bookmark"></i> <span>Bookmark</span> </div> <div class="action-button"> <i class="far fa-heart"></i> <span>Like</span> </div> <div class="action-button"> <i class="far fa-share-square"></i> <span>Share</span> </div> </div> `; // Insert the new post at the top of the feed, after the create-post element const createPostElement = document.querySelector('.create-post'); postsFeed.insertBefore(newPost, createPostElement.nextSibling); // Add event listeners to the new post's action buttons const newActionButtons = newPost.querySelectorAll('.action-button'); newActionButtons.forEach(button => { button.addEventListener('click', function () { if (this.querySelector('.fa-heart')) { this.classList.toggle('liked'); const icon = this.querySelector('.fa-heart'); if (this.classList.contains('liked')) { icon.classList.remove('far'); icon.classList.add('fas'); } else { icon.classList.remove('fas'); icon.classList.add('far'); } } }); }); } }); function toggleFollow(button, userId, targetUserId) { const isFollowing = $(button).text().trim().includes('Following'); // Check if currently following const requestType = isFollowing ? 'unfollow' : 'follow'; // Make the AJAX request to toggle follow/unfollow $.ajax({ url: 'follow_action.php', // Adjust the URL if necessary type: 'POST', contentType: 'application/json', data: JSON.stringify({ request: requestType, followerId: userId, followingId: targetUserId }), success: function (response) { console.log(response); // Log the full response to debug if (response.status === "success") { // Toggle button text and icon based on follow/unfollow status if (requestType === 'follow') { // Change to Following with check icon $(button).html('<i class="fas fa-check"></i> Following'); } else { // Change to Follow with plus icon $(button).html('<i class="fas fa-user-plus"></i> Follow'); } } else { console.error("Error message:", response.message || "Unknown error occurred"); } }, error: function (jqXHR, textStatus, errorThrown) { console.error("Error:", textStatus, errorThrown); } }); } // like function function toggleLike(button, feedId, userId) { var thumbsUpIcon = $(button).find('i'); // The <i> tag with the class indicating the like status var likeCountElement = $(button).find('.likeCount'); // The div where the like count is displayed var isLiked = thumbsUpIcon.hasClass('fa-solid'); var requestType = isLiked ? 'unlike' : 'like'; $.ajax({ url: '/assets/php/handler.php', type: 'POST', contentType: 'application/json', data: JSON.stringify({ request: requestType, userId: userId, feedId: feedId }), success: function (response) { if (response.status === "success") { if (requestType === 'like') { thumbsUpIcon.removeClass('fa-regular').addClass('fa-solid'); } else { thumbsUpIcon.removeClass('fa-solid').addClass('fa-regular'); } var updatedLikeCount = response.likeCount === null ? '' : response.likeCount; likeCountElement.text(updatedLikeCount); } else { console.error("Error message:", response.message); } }, error: function (jqXHR, textStatus, errorThrown) { console.error("Error:", textStatus, errorThrown); } }); } // bookmark function function toggleSave(button, id) { var thumbsUpIcon = $(button).find('i'); // The <i> tag with the class indicating the like status var likeCountElement = $(button).find('.likeCount'); // The div where the like count is displayed var isLiked = thumbsUpIcon.hasClass('fa-solid'); var requestType = isLiked ? 'unsave' : 'save'; $.ajax({ url: '/assets/php/savePost.php', // The PHP page where you want to process the data type: 'POST', data: { id: id, request: requestType }, success: function (response) { if (response.status === "success") { if (requestType === 'save') { thumbsUpIcon.removeClass('fa-regular').addClass('fa-solid'); } else { thumbsUpIcon.removeClass('fa-solid').addClass('fa-regular'); } // var updatedLikeCount = response.likeCount === null ? '' : response.likeCount; // likeCountElement.text(updatedLikeCount); } else { console.error("Error message:", response.message); } }, error: function (jqXHR, textStatus, errorThrown) { console.error("Error:", textStatus, errorThrown); } }); } // readmore toggle function toggleReadMore(postId) { event.preventDefault(); // Prevent default action event.stopPropagation(); // Stop propagation as you had var $truncatedContent = $('#postContent_' + postId); var $fullContent = $('#fullContent_' + postId); var $button = $('button[data-id="' + postId + '"]'); // More specific selector if ($fullContent.is(':visible')) { // If full content is visible, switch to truncated $truncatedContent.show(); $fullContent.hide(); $button.text('Read More'); } else { // If truncated content is visible, switch to full $truncatedContent.hide(); $fullContent.show(); $button.text('Read Less'); } } // dropdown for the three dot function toggleDropcardMenu(postId) { var $menu = $('#dropcardMenu_' + postId); var isVisible = $menu.hasClass('active'); // Close any open dropdown menus before toggling the current one closeAllDropcardMenus(); // Toggle display for the clicked menu if (!isVisible) { $menu.css('display', 'block'); // Use setTimeout to ensure display:block is applied before adding the active class setTimeout(function () { $menu.addClass('active'); }, 10); } else { $menu.removeClass('active'); // Wait for transition to complete before hiding setTimeout(function () { $menu.css('display', 'none'); }, 300); // Match this to the CSS transition time } } function closeAllDropcardMenus() { $('.card-dropdown-menu').each(function () { var $menu = $(this); if ($menu.hasClass('active')) { $menu.removeClass('active'); setTimeout(function () { $menu.css('display', 'none'); }, 300); // Match this to the CSS transition time } }); } // Close menus when clicking outside $(document).on('click', function (e) { if (!$(e.target).closest('.post-menu, .card-dropdown-menu').length) { closeAllDropcardMenus(); } }); // Function to delete a post function deletePost(postId) { if (confirm("Are you sure you want to delete this post?")) { $.ajax({ url: 'assets/php/edit_post.php', type: 'POST', data: { action: 'delete', post_id: postId }, success: function (response) { try { const result = JSON.parse(response); if (result.status === "success") { alert(result.message); location.reload(); } else { alert(result.message || "Failed to delete post."); } } catch (e) { alert("Invalid response received from server."); } }, error: function (xhr, status, error) { alert("An error occurred while deleting the post: " + error); } }); } } // Function to edit a post // function editPost(postId, currentContent) { // // Get references to modal elements // const modal = document.getElementById('editPostModal'); // const $modalTextarea = $('#modalContentTextarea'); // const $saveButton = $('#saveModalEditButton'); // const $closeButton = $('.close-edit-modal'); // const $cancelButton = $('.cancel-edit-btn'); // // Set the content and postId in the textarea and save button data attribute // $modalTextarea.val(currentContent); // $saveButton.data('postId', postId); // // Remove any existing click handlers to prevent duplicates // $saveButton.off('click'); // $closeButton.off('click'); // $cancelButton.off('click'); // // Add click handler for the save button // $saveButton.on('click', function () { // const newContent = $modalTextarea.val(); // savePostEdit(postId, newContent); // }); // // Add click handlers for closing the modal // $closeButton.on('click', function () { // closeEditModal(); // }); // $cancelButton.on('click', function () { // closeEditModal(); // }); // // Set cursor to the end of the text // $modalTextarea.focus(); // setTimeout(() => { // $modalTextarea[0].setSelectionRange($modalTextarea.val().length, $modalTextarea.val().length); // }, 100); // // Open the modal // modal.classList.add('active'); // document.body.style.overflow = 'hidden'; // Prevent scrolling // } // Function to edit a post function editPost(postId) { // Get references to modal elements const modal = document.getElementById('editPostModal'); const $modalTextarea = $('#modalContentTextarea'); const $saveButton = $('#saveModalEditButton'); const $closeButton = $('.close-edit-modal'); const $cancelButton = $('.cancel-edit-btn'); // Remove any existing click handlers to prevent duplicates $saveButton.off('click'); $closeButton.off('click'); $cancelButton.off('click'); // Fetch the post content via AJAX $.ajax({ url: "assets/php/getEditContent.php", type: "POST", data: { action: "getChat", post_id: postId, }, success: function (response) { if (response.chat !== undefined) { // Populate the textarea with the retrieved chat content $modalTextarea.val(response.chat); // Set the postId in the save button's data attribute $saveButton.data('postId', postId); // Set cursor to the end of the text $modalTextarea.focus(); setTimeout(() => { $modalTextarea[0].setSelectionRange($modalTextarea.val().length, $modalTextarea.val().length); }, 100); // Open the modal modal.classList.add('active'); document.body.style.overflow = 'hidden'; // Prevent scrolling // Add click handler for the save button $saveButton.on('click', function () { const newContent = $modalTextarea.val(); savePostEdit(postId, newContent); }); // Add click handlers for closing the modal $closeButton.on('click', function () { closeEditModal(); }); $cancelButton.on('click', function () { closeEditModal(); }); } else { alert("Failed to retrieve chat content."); } }, error: function () { alert("An error occurred while retrieving the post."); } }); } // Function to close the edit modal function closeEditModal() { const modal = document.getElementById('editPostModal'); modal.classList.remove('active'); document.body.style.overflow = ''; // Restore scrolling } // Function to save the edited post content function savePostEdit(postId, content) { $.ajax({ url: 'assets/php/edit_post.php', type: 'POST', data: { action: 'edit', // Changed from 'update' to 'edit' to match your first function post_id: postId, content: content }, success: function(response) { if (response.status === "success") { closeEditModal(); alert(response.message); location.reload(); // Refresh to show the updated post } else { alert(response.message || "Failed to update post."); } }, error: function() { alert("An error occurred while saving the post."); } }); } // Event delegation for escape key to close modal document.addEventListener('keydown', function (event) { if (event.key === 'Escape') { closeEditModal(); } }); // Click outside to close document.addEventListener('click', function (event) { const modal = document.getElementById('editPostModal'); const modalContent = modal.querySelector('.edit-post-modal-content'); if (modal.classList.contains('active') && !modalContent.contains(event.target)) { closeEditModal(); } }); function uploadPost() { const content = document.getElementById('contentTextarea').value; const loadingIcon = document.getElementById('loadingIcon'); loadingIcon.style.display = 'block'; // Create a FormData object to send data const formData = new FormData(); // Conditionally append fields if they have values if (content) formData.append("content", content); // Append each file to the FormData object const fileInput = document.getElementById('fileInput'); if (fileInput.files.length > 0) { for (let i = 0; i < fileInput.files.length; i++) { formData.append("media[]", fileInput.files[i]); // Use an array (media[]) to send multiple files } } if (!content.trim() && !fileInput) { alert('Please enter some content to share.'); return; } // Get values from hidden fields const hiddenTitle = document.getElementById('hiddenTitle').value; const hiddenDesc = document.getElementById('hiddenDesc').value; const hiddenUrl = document.getElementById('hiddenUrl').value; const hiddenImage = document.getElementById('hiddenImage').value; const hiddenDomain = document.getElementById('hiddenDomain').value; const hiddenYTLink = document.getElementById('hiddenYTLink').value; // Get visibility from active dropdown item const visibility = document.querySelector('.media-dropdown-item.active span').textContent === 'Public' ? 'public' : 'private'; // Append hidden fields if they have values if (hiddenTitle) formData.append("hiddenTitle", hiddenTitle); if (hiddenDesc) formData.append("hiddenDesc", hiddenDesc); if (hiddenUrl) formData.append("hiddenUrl", hiddenUrl); if (hiddenImage) formData.append("hiddenImage", hiddenImage); if (hiddenDomain) formData.append("hiddenDomain", hiddenDomain); if (hiddenYTLink) formData.append("hiddenYTLink", hiddenYTLink); if (visibility) formData.append("visibility", visibility); // Send the data to PHP via fetch API fetch('process_data.php', { method: 'POST', body: formData }) .then(response => response.json()) .then(data => { // Hide loading spinner after response loadingIcon.style.display = 'none'; if (data.status === 'success') { // Close modal after successful submission toggleModal(); // Show success message showToast('Your post has been shared successfully!'); // Reload the page after a short delay setTimeout(() => { window.location.reload(); }, 1000); } else { alert("Error: " + data.message); } }) .catch(error => { loadingIcon.style.display = 'none'; alert("An error occurred: " + error); }); }