From e5d65b513d04be045fa77d49861d15955fa593eb Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 10:52:09 +0100 Subject: [PATCH 01/48] use duration when start or end year missing for absent present vars --- seshat/apps/core/templates/core/world_map.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index c4ee1bed8..0b59007e9 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -626,12 +626,12 @@

Base Map

let startYear = value[0]; let endYear = value[1]; let variable_value = longAbsentPresentVarName(key); - // If startYear or endYear are None, state these as uncoded + // If startYear or endYear are None, set them to the polity start_year or end_year if (startYear == 'None' || startYear == null) { - startYear = '[Year Uncoded]' + startYear = shape.polity_start_year; } if (endYear == 'None' || endYear == null) { - endYear = '[Year Uncoded]' + endYear = shape.polity_end_year; } if (counter == 0) { popupContent = popupContent + ` From 71829871a40d1e484165b35d44dfd2270f001769 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 11:05:05 +0100 Subject: [PATCH 02/48] rename var --- seshat/apps/core/templates/core/world_map.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 0b59007e9..7e214c84d 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -623,28 +623,28 @@

Base Map

// Iterate through key/values in the dictionary var counter = 0; for (const [key, value] of Object.entries(shape[variable + '_dict'])) { - let startYear = value[0]; - let endYear = value[1]; + let variableStartYear = value[0]; + let variableEndYear = value[1]; let variable_value = longAbsentPresentVarName(key); // If startYear or endYear are None, set them to the polity start_year or end_year - if (startYear == 'None' || startYear == null) { - startYear = shape.polity_start_year; + if (variableStartYear == 'None' || variableStartYear == null) { + variableStartYear = displaystart_year; } - if (endYear == 'None' || endYear == null) { - endYear = shape.polity_end_year; + if (variableEndYear == 'None' || variableEndYear == null) { + variableEndYear = displayend_year; } if (counter == 0) { popupContent = popupContent + ` ${variable} - ${variable_value} from ${startYear} to ${endYear} + ${variable_value} from ${variableStartYear} to ${variableEndYear} `; } else { popupContent = popupContent + ` - ${variable_value} from ${startYear} to ${endYear} + ${variable_value} from ${variableStartYear} to ${variableEndYear} `; } From 9f7e513b67e9e17c8d402436b37d5dc0ed43d1a6 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 11:11:42 +0100 Subject: [PATCH 03/48] format BCE/CE correctly --- .../apps/core/templates/core/world_map.html | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 7e214c84d..7fb9ed194 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -626,13 +626,30 @@

Base Map

let variableStartYear = value[0]; let variableEndYear = value[1]; let variable_value = longAbsentPresentVarName(key); - // If startYear or endYear are None, set them to the polity start_year or end_year + // If startYear or endYear are None, set them to the polity start year or end year + // Format the years to BCE/CE if (variableStartYear == 'None' || variableStartYear == null) { variableStartYear = displaystart_year; + } else { + if (variableStartYear < 0) { + variableStartYear = Math.abs(variableStartYear) + ' BCE'; + } else { + variableStartYear = variableStartYear + ' CE'; + } } if (variableEndYear == 'None' || variableEndYear == null) { variableEndYear = displayend_year; - } + } else { + if (variableEndYear == {{ latest_year }}){ + variableEndYear = 'Present'; + } else { + if (variableEndYear < 0) { + variableEndYear = Math.abs(variableEndYear) + ' BCE'; + } else { + variableEndYear = variableEndYear + ' CE'; + } + } + } if (counter == 0) { popupContent = popupContent + ` From 10ecec774a5e5648efb220cdae85cb24ba7e7be4 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 11:39:31 +0100 Subject: [PATCH 04/48] make uncoded and no seshat page the same colour --- seshat/apps/core/static/core/js/map_functions.js | 6 ++++++ seshat/apps/core/templates/core/world_map.html | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/seshat/apps/core/static/core/js/map_functions.js b/seshat/apps/core/static/core/js/map_functions.js index 7a584c893..812930447 100644 --- a/seshat/apps/core/static/core/js/map_functions.js +++ b/seshat/apps/core/static/core/js/map_functions.js @@ -226,6 +226,9 @@ function updateLegend() { legendDiv.appendChild(legendTitle); for (var key in oneLanguageColourMapping) { + if (key === 'No Seshat page') { // Skip the "No Seshat page" key as it's the same colour as "Uncoded" (see world_map.html) + continue; + } var legendItem = document.createElement('p'); var colorBox = document.createElement('span'); @@ -254,6 +257,9 @@ function updateLegend() { legendDiv.appendChild(legendTitle); for (var key in variableColourMapping) { + if (key === 'no seshat page') { // Skip the "No Seshat page" key as it's the same colour as "Uncoded" (see world_map.html) + continue; + } var legendItem = document.createElement('p'); var colorBox = document.createElement('span'); diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 7fb9ed194..ce5d2fca7 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -354,13 +354,15 @@

Base Map

var provinceLayers = []; // Keep track of province layers to remove them later // Note: these are the choices for the variable values as encoded in sc.models + // Note: uncoded and no seshat page are both now set to the same colour + // Note: if you modify this, you should check that updateLegend() is consistent (found in map_functions.js) let variableColourMapping = { 'present': 'green', 'absent': 'red', 'P~A': 'orange', 'A~P': 'blue', 'unknown': 'yellow', - 'uncoded': '#ffa2a1', + 'uncoded': 'grey', 'no seshat page': 'grey' }; @@ -369,7 +371,7 @@

Base Map

'Present': '#13d446', 'Absent': 'red', 'Unknown': 'yellow', - 'Uncoded': '#ffa2a1', + 'Uncoded': 'grey', 'No Seshat page': 'grey' }; From 434f886ac0431885ecfed9cf5bb5eb2d1671d748 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 11:56:13 +0100 Subject: [PATCH 05/48] make switch variable button consistent --- .../apps/core/templates/core/world_map.html | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index ce5d2fca7..a4b6880ff 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -127,8 +127,8 @@

Polities

{% endfor %}
@@ -404,12 +404,16 @@

Base Map

if (localStorage.getItem('variable') != variable) { // Update previously selected variable button document.getElementById('previouslySelectedVariable').setAttribute('variableSelection', localStorage.getItem('variable')); - if (localStorage.getItem('variable') in categorical_variables || localStorage.getItem('variable') == 'polity'){ - // Categorical variables don't have a full name so we need to modify TODO: Make this more consistent - document.getElementById('previouslySelectedVariable').innerHTML = localStorage.getItem('variable').replace(/_/g, ' ').split(' ').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' '); - } else { - document.getElementById('previouslySelectedVariable').innerHTML = localStorage.getItem('variable') - } + + // Set the text of the previously selected variable button + // Note: we decided to not use the variabled name and instead keep the button text consistent + // if (localStorage.getItem('variable') in categorical_variables || localStorage.getItem('variable') == 'polity'){ + // // Categorical variables don't have a full name so we need to modify TODO: Make this more consistent + // document.getElementById('previouslySelectedVariable').innerHTML = localStorage.getItem('variable').replace(/_/g, ' ').split(' ').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' '); + // } else { + // document.getElementById('previouslySelectedVariable').innerHTML = localStorage.getItem('variable') + // } + document.getElementById('previouslySelectedVariableFieldset').style.display = 'block'; } From dbbbc13ea092f8498e018125fb5ec5b949497088 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 14:14:09 +0100 Subject: [PATCH 06/48] add speed in y/s --- .../apps/core/static/core/js/map_functions.js | 22 +++++++++++++++++++ .../apps/core/templates/core/world_map.html | 13 +++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/seshat/apps/core/static/core/js/map_functions.js b/seshat/apps/core/static/core/js/map_functions.js index 812930447..6e86468d7 100644 --- a/seshat/apps/core/static/core/js/map_functions.js +++ b/seshat/apps/core/static/core/js/map_functions.js @@ -20,6 +20,28 @@ function adjustSliderDown() { plotPolities(); // This function is defined differently in the world_map and polity_map templates } +function updateSliderValue(value) { + var sliderValue = document.getElementById('sliderValue'); + switch (value) { + case '1': + sliderValue.textContent = '1 y/s'; // See the values in the startPlay function below + break; + case '2': + sliderValue.textContent = '5 y/s'; + break; + case '3': + sliderValue.textContent = '20 y/s'; + break; + case '4': + sliderValue.textContent = '50 y/s'; + break; + case '5': + sliderValue.textContent = '100 y/s'; + break; + } + plotPolities(); +} + function startPlay() { stopPlay(); // Clear existing interval before starting a new one diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index a4b6880ff..8965f979f 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -144,8 +144,17 @@

Polities


- -
+ + + + + + + + + + 5 y/s



From 0e662f36a0d8d074e9c838754e67fa597ae0a982 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 14:31:27 +0100 Subject: [PATCH 07/48] simplify instructions --- .../apps/core/templates/core/world_map.html | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 8965f979f..2a8b48da2 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -162,18 +162,7 @@

Polities



-->
-
    -
  • Choose the variable to view.
  • -
  • Click shape for polity info.
  • -
    -
  • Click shape to update legend.
  • -
  • Click again to remove from legend.
  • -
    -
  • Double click to reach Seshat page.
  • -
  • Change the year or play animation.
  • - -
  • Try different base maps.
  • -
+

🗣️ Double clicks open Seshat pages.

Base Map

@@ -402,13 +391,6 @@

Base Map

var selectedYear = document.getElementById('dateSlide').value; var opacity = document.getElementById('opacitySlide').value; - // Show or hide the polity-specific info fieldset - if (variable == 'polity') { - document.getElementById('politySpecificInfo').style.display = 'block'; - } else { - document.getElementById('politySpecificInfo').style.display = 'none'; - } - // If variable has changed from the previous selection if (localStorage.getItem('variable') != variable) { // Update previously selected variable button From a03693f120a60eba08e4553f7e898cddaf389a98 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 14:39:21 +0100 Subject: [PATCH 08/48] update polity map playRate to be same as world map --- seshat/apps/core/templates/core/polity_map.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/seshat/apps/core/templates/core/polity_map.html b/seshat/apps/core/templates/core/polity_map.html index c7b2695f1..a038f05f8 100644 --- a/seshat/apps/core/templates/core/polity_map.html +++ b/seshat/apps/core/templates/core/polity_map.html @@ -28,8 +28,17 @@
- -
+ + + + + + + + + + 5 y/s
From 6066bb1b273be1ae29e18a76eb88c5b9f8d5889d Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 14:45:58 +0100 Subject: [PATCH 09/48] set minZoom --- seshat/apps/core/templates/core/polity_map.html | 4 +++- seshat/apps/core/templates/core/world_map.html | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/seshat/apps/core/templates/core/polity_map.html b/seshat/apps/core/templates/core/polity_map.html index a038f05f8..3a2c93a62 100644 --- a/seshat/apps/core/templates/core/polity_map.html +++ b/seshat/apps/core/templates/core/polity_map.html @@ -126,7 +126,9 @@
Base Map:
}); }); - var map = L.map('map').setView([0, 0], 2); + var map = L.map('map', { + minZoom: 2, + }).setView([0, 0], 2); var baseLayers = { "carto": L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png'), diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 2a8b48da2..002137924 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -340,7 +340,9 @@

Base Map

fetchData('/core/world_map_one_year/', displayYear); }); - var map = L.map('map').setView([0, 0], 2); + var map = L.map('map', { + minZoom: 2, + }).setView([0, 0], 2); var baseLayers = { "carto": L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png'), From cfb886e4141c21b3a2548af9c004606601fc9f65 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 14:48:59 +0100 Subject: [PATCH 10/48] restrict map bounds --- seshat/apps/core/templates/core/polity_map.html | 6 ++++++ seshat/apps/core/templates/core/world_map.html | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/seshat/apps/core/templates/core/polity_map.html b/seshat/apps/core/templates/core/polity_map.html index 3a2c93a62..55f1d3f68 100644 --- a/seshat/apps/core/templates/core/polity_map.html +++ b/seshat/apps/core/templates/core/polity_map.html @@ -126,8 +126,14 @@
Base Map:
}); }); + var southWest = L.latLng(-89.98155760646617, -180), + northEast = L.latLng(89.99346179538875, 180), + bounds = L.latLngBounds(southWest, northEast); + var map = L.map('map', { minZoom: 2, + maxBounds: bounds, + maxBoundsViscosity: 1.0 }).setView([0, 0], 2); var baseLayers = { diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 002137924..cec245e02 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -340,8 +340,14 @@

Base Map

fetchData('/core/world_map_one_year/', displayYear); }); + var southWest = L.latLng(-89.98155760646617, -180), + northEast = L.latLng(89.99346179538875, 180), + bounds = L.latLngBounds(southWest, northEast); + var map = L.map('map', { minZoom: 2, + maxBounds: bounds, + maxBoundsViscosity: 1.0 }).setView([0, 0], 2); var baseLayers = { From 3dba1459adc9ac6d15cfd298aa951042dbbcb213 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Jun 2024 15:25:48 +0100 Subject: [PATCH 11/48] move year slider to bottom of polity map --- .../apps/core/templates/core/polity_map.html | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/seshat/apps/core/templates/core/polity_map.html b/seshat/apps/core/templates/core/polity_map.html index 55f1d3f68..4e6a30167 100644 --- a/seshat/apps/core/templates/core/polity_map.html +++ b/seshat/apps/core/templates/core/polity_map.html @@ -16,15 +16,6 @@
- - - -
-
- -


@@ -73,6 +64,19 @@
Base Map:

+
+
+ + + + + +
+
+
+