reconnect

This commit is contained in:
Nasir Anthony Montalvo
2026-01-26 02:25:43 -06:00
parent 6609527c97
commit 0a854da998
135 changed files with 8792 additions and 1 deletions

1057
.github/_includes/js/browse-js.html vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,257 @@
<script>
/* add items */
var items = [
{% for item in items %}
{ {% for f in fields %}{% if item[f.field] %}{{ f.field | escape | jsonify }}:{{ item[f.field] | strip | jsonify }}, {%- endif -%}{%- endfor -%}
{% if item.image_thumb %}"img": {{ item.image_thumb | relative_url | jsonify }}, {%- endif -%}
{% if item.display_template %}"display_template": {{ item.display_template | jsonify }}, {%- endif -%}
{% if item.format %}"format": {{ item.format | jsonify }}, {%- endif -%}
{% if item.image_alt_text %}"alt": {{ item.image_alt_text | escape | jsonify }}, {%- endif -%}
"title":{{ item.title | strip | escape | jsonify }},
{% if item.parentid %}"parent": {{ item.parentid | jsonify }}, {%- endif -%}
"id":{{ item.objectid | jsonify }} }{% unless forloop.last %},{% endunless %}{%- endfor -%}
];
{% include helpers/get-icon.js %}
/* function to create cards for each item */
function makeCard(obj) {
// placeholder image for lazyload
var placeholder = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 2'%3E%3C/svg%3E";
// find item link
var itemHref = `{{ '/items/' | relative_url }}${ obj.parent ? obj.parent + ".html#" + obj.id : obj.id + ".html"}`;
// find image
var imgSrc, thumbIcon;
// if there is a thumb in the csv display it
if(obj.img) {
imgSrc = obj.img;
// else add an icon based on display_template or format
} else {
thumbIcon = getIcon(obj.template,obj.format,"thumb");
}
var imgAlt = obj.alt ? obj.alt : obj.title;
// start card
var card = '<div class="item col-lg-4 col-md-6 mb-2"><div class="card">';
// top image for items with image
if(imgSrc) {
card += '<a href="' + itemHref + '"> <img class="card-img-top lazyload" src="' + placeholder + '" data-src="' + imgSrc + '" alt="' + imgAlt + '"></a>';
}
// title
card += '<div class="card-body text-center"> <h3 class="card-title h4"><a href="' + itemHref + '" class="text-dark">' + obj.title + '</a></h3>';
// icon thumb for item without image
if(thumbIcon){
card += '<p><a href="' + itemHref + '">' + thumbIcon + '</a></p>';
}
// other fields
card += '<p class="card-text">';
{% for f in fields %}{% unless f.hidden == 'true' %}
if(obj[{{ f.field | jsonify }}]){
{% if f.display_name %}card += '<strong>{{ f.display_name }}:</strong> ';{% endif %}
{% if f.btn == 'true' %}
var btns = obj[{{ f.field | jsonify }}].split(";");
for (var i = 0, len = btns.length; i < len; i++) {
if(btns[i] != "") {
card += '<a class="btn btn-sm btn-secondary m-1 text-wrap" href="{{ page.url | relative_url }}#' + encodeURIComponent(btns[i].trim()) + '">' + btns[i].trim() + '</a>';
}
}
{% else %}
card += obj[{{ f.field | jsonify }}];
{% endif %}
{% unless forloop.last %}card += '<br>';{% endunless %}
}
{% endunless %}{% endfor %}
card += '</p>';
// media type
if(obj.template && obj.template != "") {
mediaIcon = getIcon(obj.template,obj.format,"hidden");
card += '<p class="card-text"><small><a class="btn btn-sm btn-outline-secondary" href="{{ page.url | relative_url }}#' + encodeURIComponent(obj.template) + '">' +
obj.template.toUpperCase().replace("_"," ") + ' ' + mediaIcon + '</a></small></p>';
}
// view button
card += '<hr><a href="' + itemHref + '" class="btn btn-sm btn-light" title="link to ' + obj.title + '">View Full Record</a>';
// close divs
card += '</div></div></div>';
// send back big string
return card;
}
/* filter items function */
function filterItems(arr,q,field) {
// show loading icon
loadingIcon.classList.remove("d-none");
// dont filter if no q
if (q=="") {
var filteredItems = arr;
} else {
q = q.trim().toUpperCase();
// js indexOf filter
var filteredItems = [];
for (var i = 0, len = arr.length; i < len; i++) {
var val = "";
// if field is specified, only search that field
if (field && field !== "all" && arr[i][field]) {
val = arr[i][field] + " ";
} else {
// search all fields
for (var k in arr[i]) {
if (k != "img") { val += arr[i][k] + " "; }
}
}
if(val.toUpperCase().indexOf(q) != -1){
filteredItems.push(arr[i]);
}
}
}
// add number
document.querySelector("#numberOf").innerHTML = filteredItems.length + " of {{ items | size }} items";
// add stuff, make cards first in giant var, then add all at once to speed things up
var cards = "";
for (var i = 0, len = filteredItems.length; i < len; i++) {
cards += makeCard(filteredItems[i]);
}
browseItemsDiv.innerHTML = cards;
// finish
if (q != "") {
filterTextBox.focus();
}
loadingIcon.classList.add("d-none");
};
/* Fisher-Yates shuffle https://bost.ocks.org/mike/shuffle/ */
function shuffle(array) {
var m = array.length, t, i;
while (m) {
i = Math.floor(Math.random() * m--);
t = array[m];
array[m] = array[i];
array[i] = t;
}
return array;
}
/* init browse page */
/* set default sort or randomize items once at page load */
{% if site.data.theme.default-sort-field %}
var defaultSort = "{{ site.data.theme.default-sort-field }}".toLowerCase();
// Apply default sort
sorting(items, defaultSort);
// Update UI to show default sort is active
var defaultSortButton = document.querySelector('[data-filter="' + defaultSort + '"]');
if (defaultSortButton) {
defaultSortButton.classList.add("active");
var sortFilter = document.querySelector("#sortFilter");
if (sortFilter) {
sortFilter.innerHTML = defaultSortButton.textContent;
}
}
{% else %}
/* randomize items once at page load */
shuffle(items);
{% endif %}
/* set some elements */
var loadingIcon = document.querySelector("#loadingIcon");
var filterTextBox = document.querySelector('#filterTextBox');
var filterButton = document.querySelector("#filterButton");
var browseItemsDiv = document.querySelector("#browseItems");
/* filter if hash in initial URL */
var query = "";
var searchField = "all";
if(window.location.hash) {
var hashValue = decodeURIComponent(location.hash.substr(1));
if (hashValue != 'maincontent') {
// check if hash contains field:query format
if (hashValue.includes(":")) {
var parts = hashValue.split(":");
searchField = parts[0];
query = parts.slice(1).join(":"); // rejoin in case value contains colons
} else {
query = hashValue;
}
} else {
query = "";
}
filterTextBox.value = query;
filterItems(items,query,searchField);
} else {
query = "";
filterItems(items,query,searchField);
}
/* filter form */
function submitFilter() {
query = filterTextBox.value;
window.location.hash = encodeURIComponent(query);
}
/* reset filters */
function resetFilter() {
query = "";
filterTextBox.value = query;
window.location.hash = encodeURIComponent(query);
}
/* filter if hash changes */
window.addEventListener("hashchange", function() {
// read hash
var hashValue = decodeURIComponent(location.hash.substr(1));
if (hashValue != 'maincontent') {
// check if hash contains field:query format
if (hashValue.includes(":")) {
var parts = hashValue.split(":");
searchField = parts[0];
query = parts.slice(1).join(":"); // rejoin in case value contains colons
} else {
searchField = "all";
query = hashValue;
}
filterTextBox.value = query;
// filter
filterItems(items,query,searchField);
}
});
/* item array sorting function */
function sorting(json_object, key_to_sort_by) {
function sortByKey(a, b) {
var x = a[key_to_sort_by];
var y = b[key_to_sort_by];
if (typeof x === 'string' ) { x = x.toUpperCase(); }
if (typeof y === 'string' ) { y = y.toUpperCase(); }
return ((x==null) ? 1: (y==null) ? -1: (x < y) ? -1 : ((x > y) ? 1 : 0));
}
json_object.sort(sortByKey);
};
/* add sort function on click of sort options */
var sortFilter = document.querySelector("#sortFilter");
var sortOptions = document.querySelectorAll(".browse-sort-item");
sortOptions.forEach((button) => {
button.addEventListener("click", (event) => {
// get the sort field
var field = button.dataset.filter;
var display_name = button.textContent;
// get current filter
var query = filterTextBox.value;
// switch active sort option
sortOptions.forEach((option) => { option.classList.remove("active"); } );
button.classList.add("active");
sortFilter.innerHTML = display_name;
// send to sort and filter
if (field != 'random') {
sorting(items, field);
filterItems(items, query);
}
else {
shuffle(items);
filterItems(items, query);
}
});
});
</script>

69
.github/_includes/js/cloud-js.html vendored Normal file
View File

@@ -0,0 +1,69 @@
{%- comment -%}
Generates a subject cloud using js to process the terms for display on "cloud" layout.
Requires CB's array_count_uniq.rb plugin!
{%- endcomment -%}
{% if site.data.theme.browse-child-objects == true %}
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid' -%}
{% else %}
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid and item.parentid == nil' -%}
{% endif %}
{%- assign termsMin = include.min | plus: 0 | default: 1 -%}
{%- assign cloud_id = include.id | default: "cloud" -%}
{%- assign cloud-fields = include.fields | split: ";" -%}
{%- comment -%} capture terms from all cloud fields {%- endcomment -%}
{%- assign terms = "" -%}
{%- for c in cloud-fields -%}
{% assign new = items | map: c | compact | join: ";" | split: ";" %}
{% capture field_terms %}{% for n in new %}{{n}}~{{c}};{% endfor %}{% endcapture %}
{% assign terms = terms | append: ";" | append: field_terms %}
{%- endfor -%}
{%- comment -%} find unique terms and counts {%- endcomment -%}
{%- assign uniqTerms = terms | downcase | split: ";" | array_count_uniq | sort | where_exp: 't','t[1] >= termsMin' -%}
<script>
(function(){
/* subject terms + count */
var terms = [
{% for t in uniqTerms %}{% assign term_field = t[0] | split: "~" %}[{{ term_field[0] | jsonify }}, {{ t[1] | jsonify }},{{term_field[1] | jsonify}}]{% unless forloop.last %}, {% endunless %}{% endfor %}
];
{% if include.stopwords %}/* apply stopwords */
var stopWords = {{ include.stopwords | downcase | split: ';' | jsonify }};
terms = terms.filter(function(a) { return stopWords.indexOf(a[0]) < 0;});{% endif %}
/* calculate max size */
var counts = terms.map(function(obj){ return obj[1]; });
var countMax = counts.reduce(function(a, b) { return Math.max(a, b); });
var cloud = document.getElementById("{{ cloud_id }}");
{% if include.shuffle == true %}
/* Fisher-Yates shuffle https://bost.ocks.org/mike/shuffle/ */
function shuffle(array) {
var m = array.length, t, i;
while (m) {
i = Math.floor(Math.random() * m--);
t = array[m];
array[m] = array[i];
array[i] = t;
}
return array;
}
{% endif %}
function mapSize(x) { return Math.round(x * 9 / countMax + 1); }
/* create cloud */
function makeGrid(array) {
var i, size;
var items = "";
{% if include.shuffle == true %}shuffle(array);{% endif %}
for (let i = 0; i < array.length; i++) {
size = mapSize(array[i][1]);
items += '<a class="btn btn-{{ include.button | default: "outline-primary" }} m-2 tagcloud' + size + '" href="{{ "/browse/" | relative_url }}#' + array[i][2] + ':' + encodeURIComponent(array[i][0]) + '" >' + array[i][0] + '</a>';
}
cloud.innerHTML = items;
}
makeGrid(terms);
})();
</script>

75
.github/_includes/js/lunr-js.html vendored Normal file
View File

@@ -0,0 +1,75 @@
{%- assign fields = site.data.config-search -%}
{%- assign index_fields = fields | where: 'index','true' -%}
<script src="{{ site.lib-assets | default: '/assets/lib' | relative_url }}/lunr.min.js"></script>
<script src="{{ '/assets/js/lunr-store.js' | relative_url }}"></script>
<script>
/* initialize lunr */
var idx = lunr(function () {
/* add index fields from config */
this.ref('id')
{% for f in index_fields %}
this.field({{ f.field | jsonify }})
{% endfor %}
//this.pipeline.remove(lunr.trimmer)
for (var item in store) {
this.add({
{% for f in index_fields %}
{{ f.field | jsonify }}: store[item][{{ f.field | jsonify }}],
{% endfor %}
id: item
})
}
});
/* search function */
function lunr_search () {
var resultdiv = document.querySelector('#lunrResults');
var query = document.querySelector('#lunrSearchBox').value;//.toLowerCase();
/* basic search that supports operators */
var result = idx.search(query);
/* more fuzzy search, but doesn't support operators:
var result =
idx.query(function (q) {
query.split(lunr.tokenizer.separator).forEach(function (term) {
q.term(term, { boost: 100 })
if(query.lastIndexOf(" ") != query.length-1){
q.term(term, { usePipeline: false, wildcard: lunr.Query.wildcard.TRAILING, boost: 10 })
}
if (term != ""){
q.term(term, { usePipeline: false, editDistance: 1, boost: 1 })
}
})
});*/
resultdiv.innerHTML = "";
var newresults = '<tr><td><h4 class="mt-3">' + result.length + ' Result(s) found</h4></td></tr>';
for (var item in result) {
var ref = result[item].ref;
var searchitem =
'<tr>'+
'<td>' +
{% assign display = fields | where: 'display','true' %}
{% for d in display %}
{% if forloop.first %}
'<p class="h4"><a href="{{ "/items/" | relative_url }}' + store[ref].id + '">' + store[ref][{{ fields[0].field | jsonify }}] + '</a></p>' +
'<p class="ms-3">';
{% else %}
if(store[ref][{{ d.field | jsonify }}]) {
searchitem += store[ref][{{ d.field | jsonify }}] + '<br> '; }
{% endif %}{% endfor %}
searchitem += '</p></td>' +
'</tr>';
newresults += searchitem;
}
resultdiv.innerHTML = newresults;
}
/* init search box and get query string */
if (window.location.search) {
var queryString = decodeURIComponent(window.location.search.substring(1).split("=")[1]);
document.querySelector('#lunrSearchBox').value = queryString;
lunr_search();
}
</script>

205
.github/_includes/js/map-js.html vendored Normal file
View File

@@ -0,0 +1,205 @@
{% if site.data.theme.map-child-objects == true %}
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid' -%}
{% else %}
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid and item.parentid == nil' -%}
{% endif %}
{%- assign items = items | where_exp: 'item','item.latitude != nil and item.longitude != nil' -%}
{%- assign fields = site.data.config-map -%}
<!-- load leaflet dependencies -->
<script src="{{ site.lib-assets | default: '/assets/lib' | relative_url }}/leaflet/leaflet.js"></script>
<script src="{{ site.lib-assets | default: '/assets/lib' | relative_url }}/leaflet/Leaflet.fullscreen.min.js"></script>
{% if site.data.theme.map-search == true %}<script src="{{ site.lib-assets | default: '/assets/lib' | relative_url }}/leaflet/fuse.min.js"></script>
<script src="{{ site.lib-assets | default: '/assets/lib' | relative_url }}/leaflet/leaflet.fusesearch.js"></script>{% endif %}
{% if site.data.theme.map-cluster == true %}<script src="{{ site.lib-assets | default: '/assets/lib' | relative_url }}/leaflet/leaflet.markercluster.js"></script>{% endif %}
{% if site.data.theme.map-search == true and site.data.theme.map-cluster == true %}<script src="{{ site.lib-assets | default: '/assets/lib' | relative_url }}/leaflet/leaflet.markercluster.freezable.js"></script>{% endif %}
<script>
(function(){
/* add collection map data */
var geodata = { "type": "FeatureCollection", "features": [
{% for item in items %}
{ "type":"Feature", "geometry":{ "type":"Point", "coordinates":[{{ item.longitude | strip }},{{ item.latitude | strip }}] }, "properties":
{
{% for f in fields %}{% if item[f.field] %}{{ f.field | escape | jsonify }}:{{ item[f.field] | strip | escape | jsonify }}, {%- endif -%}{%- endfor -%}
{% if item.image_thumb %}"img": {{ item.image_thumb | relative_url | jsonify }},{% endif %}
{% if item.display_template %}"template": {{ item.display_template | escape | jsonify }}, {%- endif -%}
{% if item.format %}"format": {{ item.format | escape | jsonify }}, {%- endif -%}
{% if item.image_alt_text %}"alt": {{ item.image_alt_text | escape | jsonify }}, {%- endif -%}
{% if item.parentid %}"parent": {{ item.parentid | jsonify }}, {%- endif -%}
"title": {{ item.title | escape | jsonify }},
"id": {{ item.objectid | jsonify }}
} }{% unless forloop.last %}, {% endunless %}{% endfor %}
]};
/* check for url parameters and setup initial view options */
let url = new URL(window.location);
const locationSearchParams = url.searchParams.get('location');
var mapCenter = locationSearchParams ? locationSearchParams.split(',') : [{{ site.data.theme.latitude | default: 46.727485 }}, {{ site.data.theme.longitude | default: -117.014185 }}];
var mapZoom = locationSearchParams ? 16 : {{ site.data.theme.zoom-level | default: 5 }};
var markerFilter = url.searchParams.get('marker') ? url.searchParams.get('marker') : "";
/* init map */
var map = L.map('mapContainer');
/* add map layer options */
var Esri_WorldStreetMap = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles &copy; Esri &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012'
});
var Esri_NatGeoWorldMap = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles &copy; Esri &mdash; National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC',
maxZoom: 16
});
var Esri_WorldImagery = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
});
var OpenStreetMap_Mapnik = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
});
/* add base map switcher */
var baseMaps = {
"Esri World StreetMap": Esri_WorldStreetMap,
"Esri National Geo": Esri_NatGeoWorldMap,
"Esri Imagery": Esri_WorldImagery,
"Open Street Map": OpenStreetMap_Mapnik
};
L.control.layers(baseMaps).addTo(map);
/* load base map */
{{ site.data.theme.map-base | default: 'Esri_WorldStreetMap' }}.addTo(map);
{% if site.data.theme.map-search == true %}
/* add search, https://github.com/naomap/leaflet-fusesearch */
var options = {
title: 'Search Map Items',
placeholder: 'Search map items...',
threshold: {{ site.data.theme.map-search-fuzziness | default: 0.35 }},
showResultFct: function(feature, container) {
var result = `<strong>${feature.properties.title}</strong><br>`;
{% for f in fields %}
if(feature.properties[{{ f.field | jsonify }}]) { result += feature.properties[{{ f.field | jsonify }}] + `<br>`; }
{% endfor %}
container.innerHTML = result;
}
};
var searchCtrl = L.control.fuseSearch(options);
searchCtrl.addTo(map);
searchCtrl.indexFeatures(geodata.features, {{ fields | where: 'search','true' | map: 'field' | unshift: 'title' | jsonify }});{% endif %}
/* add fullscreen control */
map.addControl(new L.Control.Fullscreen());
{% if site.data.theme.map-cluster == true %}
/* create cluster group */
var markers = L.markerClusterGroup({
maxClusterRadius: {{ site.data.theme.map-cluster-radius | default: 15 }},
singleMarkerMode: true,
iconCreateFunction: function(cluster) {
/* custom icon function, tweak default to add more alt text */
var childCount = cluster.getChildCount();
var csize;
if (childCount < 10) {
csize = 'small';
} else if (childCount < 100) {
csize = 'medium';
} else {
csize = 'large';
}
var c = ' marker-cluster-' + csize;
return new L.DivIcon({ html: '<div><span class="visually-hidden">' + csize +' cluster of </span><span>' + childCount + '</span><span class="visually-hidden"> items</span></div>', className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) });
}
{% if site.data.theme.map-search == true %}, removeOutsideVisibleBounds: false{% endif %}
});{% endif %}
/* get icons function */
{% include helpers/get-icon.js %}
/* object popup function */
function objectPopups(feature, layer) {
{% if site.data.theme.map-search == true %}/* bind feature for search */
feature.layer = layer;{% endif %}
// find item link
var itemHref = `{{ '/items/' | relative_url }}${ feature.properties.parent ? feature.properties.parent + ".html#" + feature.properties.id : feature.properties.id + ".html"}`;
// find image
var imgAlt = feature.properties.alt ? feature.properties.alt : feature.properties.title;
var thumbImg;
if (feature.properties.img) {
thumbImg = '<img class="map-thumb" src="' + feature.properties.img + '" alt="' + imgAlt + '">';
} else {
thumbImg = getIcon(feature.properties.template,feature.properties.format,"thumb")
}
// set up popup content
var popupTemplate = '<h2 class="h4"><a class="text-dark" href="' + itemHref + '">' +
feature.properties.title + '</a></h2><div class="text-center"><a href="' + itemHref +
'" >' + thumbImg + '</a></div><p>';
{% for f in fields %}{% if f.display_name %}
if (feature.properties[{{ f.field | escape | jsonify }}]) {
popupTemplate += '<strong>{{ f.display_name }}:</strong> ' + feature.properties[{{ f.field | escape | jsonify }}] + '<br>';
}
{% endif %}{% endfor %}
popupTemplate += '</p><div class="text-center"><a class="btn btn-light" href="' + itemHref + '" >View Item</a></div>';
layer.bindPopup(popupTemplate);
}
function objectMarkers(feature,latlng) {
var marker = L.marker(latlng, {alt: feature.properties.title});
{% if site.data.theme.map-cluster == true %}markers.addLayer(marker);{% endif %}
return marker;
}
/* add objects from geoJson features */
var mapFeatures = L.geoJson(geodata, {
onEachFeature: objectPopups,
pointToLayer: objectMarkers
}){% if site.data.theme.map-cluster != true %}.addTo(map);{% else %};
map.addLayer(markers);{% endif %}
{% if site.data.theme.auto-center-map == true %}
/* if no location was specified in the URL query parameters, auto center the map */
if (locationSearchParams === null) {
const featureBounds = mapFeatures.getBounds()
if (featureBounds?.isValid()) {
map.fitBounds(featureBounds);
}
} else {
/* set map view based on URL parameters */
map.setView(mapCenter, mapZoom);
}
{% else %}
/* set map view based on configuration or URL parameters */
map.setView(mapCenter, mapZoom);
{% endif %}
{% if site.data.theme.map-cluster == true and site.data.theme.map-search == true %}
/* uncluster when search is clicked */
document.querySelector('a.button').addEventListener("click", function() {
markers.disableClustering();
});
/* recluster when search is closed */
document.querySelector('a.close').addEventListener("click", function() {
markers.enableClustering();
document.querySelector('input.search-input').value = "";
});{% endif %}
/* show popup if id in URL query */
if (markerFilter != "") {
{% if site.data.theme.map-cluster == true %}
markers.eachLayer(layer => {
if (layer.feature.properties.id === markerFilter) {
/* uncluster clusters, then show */
if (markers.getVisibleParent(layer)["_childCount"]) {
markers.getVisibleParent(layer).spiderfy();
}
layer.openPopup();
}
});
{% else %}
mapFeatures.eachLayer(layer => {
if (layer.feature.properties.id === markerFilter) {
layer.openPopup();
}
});
{% endif %}
}
})();
</script>

11
.github/_includes/js/modal-hash-js.html vendored Normal file
View File

@@ -0,0 +1,11 @@
<script>
window.addEventListener('load', function () {
if (window.location.hash) {
/* if url has a hash, open the related item modal */
var hashModal = decodeURIComponent(location.hash.substr(1));
if (document.querySelector('#' + hashModal + 'Card a')) {
document.querySelector('#' + hashModal + 'Card a').click();
}
}
});
</script>

32
.github/_includes/js/table-js.html vendored Normal file
View File

@@ -0,0 +1,32 @@
{% assign fcount = site.data.config-table | size %}
<!-- load DataTables with jquery bundled -->
<script type="text/javascript" language="javascript" src="{{ site.lib-assets | default: '/assets/lib' | relative_url }}/datatables/datatables.min.js"></script>
<script>
/* use jquery to initialize DataTables and load collection data */
$(document).ready( function () {
$('#item-table').DataTable( {
// use DataTables ajax load
ajax: { url: '{{ "/assets/js/metadata.min.json" | relative_url }}', dataSrc: 'objects' },
// defer render to speed up large sets
"deferRender": true,
// enable pagination
"paging": true,
"lengthMenu": [[ 25, 50, 100, -1], [ 25, 50, 100, "All"]],
// add download features
dom: 'B<"row mt-2"<"col-md-6"l><"col-md-6"f>>t<"row"<"col-md-6"i><"col-md-6"p>>',
buttons: [ 'excelHtml5', 'csvHtml5' ],
// get the data from json
columns: [ {% for i in (0..fcount) %}{ data: '{{ i }}' }{% unless forloop.last %},{% endunless %}{% endfor %} ],
columnDefs: [
// turn relative link into absolute
{ "render": function ( data ) { return '{{ "/" | relative_url }}' + data; },"targets": {{ fcount }} },
// combine link with first column
{ "render": function ( data, type, row ) { return '<a href="' + row['{{ fcount }}'] +'">'+ data +'</a>'; },"targets": 0 },
// hide the link column
{ "visible": false, "targets": [ {{ fcount }} ] }
],
// sort based on the second column
order: [[ 1, "asc" ]]
});
});
</script>

21
.github/_includes/js/timeline-js.html vendored Normal file
View File

@@ -0,0 +1,21 @@
<script>
(function(){
// init bootstrap tooltips
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
});
// highlight active year row
function highlightYear() {
var hashfilter = "tr#" + decodeURIComponent(location.hash.substr(1));
document.querySelectorAll("table#timeline tr").forEach(row => { row.classList.remove('table-info'); });
if (document.querySelector(hashfilter)) { document.querySelector(hashfilter).classList.add("table-info"); }
}
// if in initial hash
if (window.location.hash) { highlightYear(); }
// on hash change
window.addEventListener("hashchange", highlightYear);
})();
</script>