Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,37 @@
<button id="copyButton" type="button" class="btn btn-outline-secondary mt-2" onclick="copyUrl()">
Copy to Clipboard
</button>
<p class="text-muted mt-2">Valid for 30 days</p>
<p class="text-muted mt-2">
Expires in <span id="expiryCountdown"></span>
</p>
</div>
</div>
</div>
</div>

<script at="Foot">
const copyButton = document.getElementById('copyButton');
const expireyCountdown = document.getElementById("expiryCountdown");

const expiryDate = new Date("@Model.Link.ExpirationUtc.ToString("o")");
const now = new Date();
const diff = expiryDate - now;

if (diff <= 0) {
expireyCountdown.parentElement.setAttribute('class', 'text-danger mt-2')
expireyCountdown.parentElement.innerText = "Expired";
copyButton.disabled = true;
}
else {
const days = Math.floor(diff / (1000*60*60*24));

expireyCountdown.innerText = `${days} days`;
}

function copyUrl() {
const link = document.getElementById('linkInput').value;
navigator.clipboard.writeText(link);

var copyButton = document.getElementById('copyButton');
copyButton.setAttribute('class', 'btn btn-secondary mt-2');
copyButton.innerText = 'Copied!';
}
Expand Down
Loading