-
Notifications
You must be signed in to change notification settings - Fork 53
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
1 parent
eb2efb3
commit 227bab6
Showing
5 changed files
with
177 additions
and
93 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
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,31 @@ | ||
// This script connects to the pypi.org server and checks the latest available version of Biogeme | ||
|
||
const CACHE_DURATION = 24 * 60 * 60 * 1000; // 1 day in milliseconds | ||
|
||
function fetchVersion() { | ||
fetch('https://pypi.org/pypi/biogeme/json') | ||
.then(response => response.json()) | ||
.then(data => { | ||
const version = data.info.version; | ||
document.getElementById('version').textContent = version; | ||
|
||
// Cache the version and current timestamp | ||
localStorage.setItem('biogemeVersion', version); | ||
localStorage.setItem('biogemeTimestamp', Date.now()); | ||
}) | ||
.catch(error => { | ||
console.error('Error fetching the version:', error); | ||
document.getElementById('version').textContent = 'Error fetching version'; | ||
}); | ||
} | ||
|
||
// Check if we have a cached version and it's still valid | ||
const cachedVersion = localStorage.getItem('biogemeVersion'); | ||
const cachedTimestamp = localStorage.getItem('biogemeTimestamp'); | ||
if (cachedVersion && cachedTimestamp && Date.now() - cachedTimestamp < CACHE_DURATION) { | ||
// Use the cached version | ||
document.getElementById('version').textContent = cachedVersion; | ||
} else { | ||
// Fetch the latest version | ||
fetchVersion(); | ||
} |
Oops, something went wrong.