forked from amiradp/Dota2_play_time
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
84 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Calc | ||
const urlParams = new URLSearchParams(window.location.search); | ||
let total_hours = urlParams.get('total_hours'); | ||
|
||
var | ||
days = total_hours / 24, | ||
months = 0, | ||
years = 0, | ||
remainingDays = days, | ||
resultElement = document.getElementById('Result') | ||
|
||
// Years | ||
while(remainingDays >= 365) | ||
{ | ||
years++ | ||
remainingDays -= 365 | ||
} | ||
|
||
// Months | ||
while (remainingDays >= 30) { | ||
months++; | ||
remainingDays -= 30; | ||
} | ||
if(years==0) | ||
resultElement.innerHTML = `${Math.floor(months)} ماه و ${Math.floor(remainingDays)} روز`; | ||
else if(years==0 && months==0) | ||
resultElement.innerHTML = `${Math.floor(remainingDays)} روز`; | ||
else if(remainingDays==0) | ||
resultElement.innerHTML = `${Math.floor(years)} سال و ${Math.floor(months)} ماه`; | ||
else | ||
resultElement.innerHTML = `${Math.floor(years)} سال و ${Math.floor(months)} ماه و ${Math.floor(remainingDays)} روز`; | ||
|
||
|
||
|
||
|
||
|
||
|
||
// Copy Link Button | ||
const copyButton = document.getElementById('copy-button'); | ||
const urlTextField = document.getElementById('url-text-field'); | ||
|
||
copyButton.addEventListener('click', () => { | ||
// Get the URL from the text field | ||
const urlToCopy = urlTextField.value; | ||
|
||
// Copy the URL to clipboard (using Clipboard API) | ||
navigator.clipboard.writeText(urlToCopy) | ||
.then(() => { | ||
// URL copied successfully | ||
alert("لینک در صفحه کلید شما ذخیره شد!"); | ||
}) | ||
.catch(err => { | ||
// Clipboard write failed | ||
console.error('لینک کپی نشد!:', err); | ||
alert("خطا در کپی کردن لینک"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
@import url(variables.css); | ||
@import url(typography.css); | ||
@import url(components.css); | ||
@import url(responsive.css); | ||
@import url(components.css); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const form = document.getElementById('submitData'); | ||
|
||
form.addEventListener('submit', (e) => { | ||
e.preventDefault(); | ||
const defaultURL = window.location.href | ||
const total_hours = document.getElementById('playtime_number').value; | ||
const url = new URL('./result.html', defaultURL); | ||
url.searchParams.append('total_hours', total_hours); | ||
|
||
window.location.href = url.toString(); | ||
}); |