This commit is contained in:
2025-02-05 15:50:04 +05:30
parent 7f15dbfc08
commit 55448e34c6
38 changed files with 449 additions and 663 deletions

View File

@@ -3,7 +3,6 @@ const form = document.querySelector(".shorten-form"),
shortenBtn = document.querySelector("#shorten-btn"),
linksList = document.querySelector("#links-list");
// Clear the list and show the "You don't have any shortened links" message
function resetLinksList() {
linksList.innerHTML = `
<li id="default-message">
@@ -18,7 +17,6 @@ function resetLinksList() {
`;
}
// Check session storage for existing links on page load
document.addEventListener("DOMContentLoaded", () => {
const savedLinks = sessionStorage.getItem("shortenedLinks");
if (savedLinks) {
@@ -35,17 +33,15 @@ shortenBtn.onclick = () => {
if (xhr.readyState == 4 && xhr.status == 200) {
let data = xhr.response;
if (data.length <= 5) {
//This is your domain name
const domain = "xeorl.buzz/";
// This is your shoeten domain name
const domain = "http://localhost/Php-Projects/xeorl/htdocs//";
let shortenURL = domain + data;
// Remove the default message if it exists
const defaultMessage = document.getElementById("default-message");
if (defaultMessage) {
defaultMessage.remove();
}
// Add the new link to the list
let newRow = `
<li>
<div class="link-icon"><img src="assets/images/url.png" class="logo-img"></div>
@@ -58,12 +54,9 @@ shortenBtn.onclick = () => {
</li>
`;
// Append the new link to the list and update session storage
linksList.insertAdjacentHTML('afterbegin', newRow);
sessionStorage.setItem("shortenedLinks", linksList.innerHTML);
// Clear the input field
urlInput.value = "";
urlInput.value = "";
} else {
alert(data);
}
@@ -74,7 +67,6 @@ shortenBtn.onclick = () => {
xhr.send(formData);
};
// Handle copy button clicks
document.addEventListener('click', function(e) {
if (e.target.closest('.copy-btn')) {
const linkInfo = e.target.closest('li').querySelector('.short-link').textContent;
@@ -84,13 +76,13 @@ document.addEventListener('click', function(e) {
}
});
// Handle members only delete button clicks!!
document.addEventListener('click', function(e) {
if (e.target.closest('.delete-btn')) {
alert("This feature is available for members only.");
}
});
// Handle delete button clicks
/*
document.addEventListener('click', function(e) {
@@ -118,5 +110,3 @@ document.addEventListener('click', function(e) {
}
});*/