Skip to content

Commit

Permalink
update nav
Browse files Browse the repository at this point in the history
  • Loading branch information
rikkix committed Nov 15, 2024
1 parent 4eba56e commit a43963a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 52 deletions.
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<a class="nav-link" href="/shorten">Shorten</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/dashboard">List</a>
<a class="nav-link" href="/files">Files</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/access">Access</a>
<a class="nav-link" href="/links">Links</a>
</li>
</div>
</div>
Expand Down
101 changes: 51 additions & 50 deletions public/shorten.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
<a class="nav-link active" aria-current="page" href="/shorten">Shorten</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/list">List</a>
<a class="nav-link" href="/files">Files</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/access">Access</a>
<a class="nav-link" href="/links">Links</a>
</li>
</div>
</div>
Expand Down Expand Up @@ -111,60 +111,61 @@ <h5 class="card-title ">URL Shorten</h5>
</div>
</div>
</div>
</div>


<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>

<script>
document.getElementById('submit-shorten').addEventListener('click', async () => {
// disable the button
document.getElementById('submit-shorten').disabled = true;
<script>
document.getElementById('submit-shorten').addEventListener('click', async () => {
// disable the button
document.getElementById('submit-shorten').disabled = true;

const url = document.getElementById('urlInput').value;
const urlExp = document.querySelector('input[name="urlExp"]:checked').value;
const response = await fetch('/api/links/create?d='+urlExp, {
method: 'POST',
body: url
const url = document.getElementById('urlInput').value;
const urlExp = document.querySelector('input[name="urlExp"]:checked').value;
const response = await fetch('/api/links/create?d=' + urlExp, {
method: 'POST',
body: url
});
const data = await response.json();

// enable the button and clear the input
document.getElementById('submit-shorten').disabled = false;
document.getElementById('urlInput').value = '';

if (response.ok) {
const shortenList = document.getElementById('shorten-list');
const template = document.getElementById('template');
const clone = template.cloneNode(true);
clone.classList.remove('d-none');
clone.id = '';
const name = clone.querySelector('.name');
const fileurl = clone.querySelector('.fileurl');
const filekey = clone.querySelector('.filekey');
const copy = clone.querySelector('.copy');
const del = clone.querySelector('.delete');

name.textContent = url;
fileurl.value = data.access_url;
filekey.value = data.key;
copy.addEventListener('click', () => {
fileurl.select();
document.execCommand('copy');
});
const data = await response.json();

// enable the button and clear the input
document.getElementById('submit-shorten').disabled = false;
document.getElementById('urlInput').value = '';

if (response.ok) {
const shortenList = document.getElementById('shorten-list');
const template = document.getElementById('template');
const clone = template.cloneNode(true);
clone.classList.remove('d-none');
clone.id = '';
const name = clone.querySelector('.name');
const fileurl = clone.querySelector('.fileurl');
const filekey = clone.querySelector('.filekey');
const copy = clone.querySelector('.copy');
const del = clone.querySelector('.delete');

name.textContent = url;
fileurl.value = data.access_url;
filekey.value = data.key;
copy.addEventListener('click', () => {
fileurl.select();
document.execCommand('copy');
del.addEventListener('click', async () => {
const response = await fetch(`/api/links/delete/${data.key}`, {
method: 'DELETE'
});
del.addEventListener('click', async () => {
const response = await fetch(`/api/links/delete/${data.key}`, {
method: 'DELETE'
});
if (response.ok) {
shortenList.removeChild(clone);
}
});
shortenList.appendChild(clone);
}
});
</script>
if (response.ok) {
shortenList.removeChild(clone);
}
});
shortenList.appendChild(clone);
}
});
</script>

</body>

Expand Down

0 comments on commit a43963a

Please sign in to comment.