Skip to content

Commit

Permalink
add timer
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardchalstrey1 committed Jul 18, 2024
1 parent 1db847d commit 9a2fcd8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion seshat/apps/core/templates/core/world_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ <h1 class="text-teal" id="sliderDate"></h1>
<script src="{% static 'core/js/map_functions.js' %}"></script>
<script>

var startTime = performance.now()

function adjustScroll() {
const slider = document.getElementById('dateSlide');
const sliderDiv = document.getElementById('sliderdiv');
Expand Down Expand Up @@ -361,6 +363,8 @@ <h1 class="text-teal" id="sliderDate"></h1>
var tick_years = {{ tick_years }};
setSliderTicks(tick_years);

console.log('Initial time: ' + (performance.now() - startTime) + 'ms');

// Load all polity shapes and modern province/country shapes in background
window.addEventListener('load', function () {
function fetchData(url, displayYear) {
Expand All @@ -379,6 +383,7 @@ <h1 class="text-teal" id="sliderDate"></h1>
plotPolities();
document.getElementById('loadingIndicator').style.display = 'none';
let enteredYear = document.getElementById('enterYear').value;
console.log('One year time: ' + (performance.now() - startTime) + 'ms');
if (displayYear != enteredYear) {
return fetchData('/core/world_map_one_year/', enteredYear);
} else {
Expand All @@ -403,7 +408,7 @@ <h1 class="text-teal" id="sliderDate"></h1>
plotPolities();
allPolitiesLoaded = true;
document.getElementById('loadingIndicator').style.display = 'none';

console.log('All years time: ' + (performance.now() - startTime) + 'ms');
return fetch('/core/provinces_and_countries');
})
.then(response => response.json())
Expand All @@ -426,6 +431,7 @@ <h1 class="text-teal" id="sliderDate"></h1>

document.getElementById('baseMapCurrentLoadingIndicator').style.display = 'none';
document.getElementById('baseMapCurrent').disabled = false;
console.log('Base map time: ' + (performance.now() - startTime) + 'ms');
});
}

Expand Down

0 comments on commit 9a2fcd8

Please sign in to comment.