|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
<title>OriginDex</title>
|
|
|
|
|
<style>
|
|
|
|
|
body {
|
|
|
|
|
font-family: Arial, sans-serif;
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
background-color: #f0f0f0;
|
|
|
|
|
}
|
|
|
|
|
#main-content {
|
|
|
|
|
padding: 20px;
|
|
|
|
|
transition: margin-right 0.3s ease-in-out;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
.pokemon-box {
|
|
|
|
|
background-color: white;
|
|
|
|
|
border: 2px solid #ccc;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
margin: 0 10px 30px;
|
|
|
|
|
padding: 20px;
|
|
|
|
|
position: relative;
|
|
|
|
|
width: calc(100% - 20px);
|
|
|
|
|
max-width: 800px;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
}
|
|
|
|
|
.box-title {
|
|
|
|
|
background-color: #4CAF50;
|
|
|
|
|
color: white;
|
|
|
|
|
padding: 5px 15px;
|
|
|
|
|
border-radius: 15px 15px 0 0;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: -30px;
|
|
|
|
|
left: 20px;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
.pokemon-grid {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(6, 1fr);
|
|
|
|
|
gap: 10px;
|
|
|
|
|
}
|
|
|
|
|
.pokemon-cell {
|
|
|
|
|
background-color: #f9f9f9;
|
|
|
|
|
border: 1px solid #ddd;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
/*width: 120px;*/ /* Fixed width */
|
|
|
|
|
height: 169.4px; /* Fixed height */
|
|
|
|
|
}
|
|
|
|
|
.pokemon-cell.empty {
|
|
|
|
|
background-color: #e0e0e0;
|
|
|
|
|
cursor: default;
|
|
|
|
|
}
|
|
|
|
|
.pokemon-name {
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
font-size: 0.8em;
|
|
|
|
|
margin-bottom: 5px;
|
|
|
|
|
height: 2.4em; /* Allows for 2 lines of text */
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
.pokemon-image {
|
|
|
|
|
width: 96px;
|
|
|
|
|
height: 96px;
|
|
|
|
|
object-fit: contain;
|
|
|
|
|
background-color: #f9f9f9; /* Light gray background for placeholder */
|
|
|
|
|
}
|
|
|
|
|
.pokemon-form {
|
|
|
|
|
font-style: italic;
|
|
|
|
|
font-size: 0.7em;
|
|
|
|
|
margin-top: 5px;
|
|
|
|
|
height: 1.4em; /* Allows for 1 line of text */
|
|
|
|
|
line-height: 1.4em; /* Vertically centers the text or dashes */
|
|
|
|
|
}
|
|
|
|
|
.pokemon-number {
|
|
|
|
|
color: #777;
|
|
|
|
|
font-size: 0.7em;
|
|
|
|
|
margin-top: 5px;
|
|
|
|
|
}
|
|
|
|
|
#details-panel {
|
|
|
|
|
width: 300px;
|
|
|
|
|
background-color: white;
|
|
|
|
|
padding: 20px;
|
|
|
|
|
box-shadow: -2px 0 5px rgba(0,0,0,0.1);
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
right: -340px;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
transition: right 0.3s ease-in-out;
|
|
|
|
|
}
|
|
|
|
|
#details-panel.open {
|
|
|
|
|
right: 0;
|
|
|
|
|
}
|
|
|
|
|
.main-content-shifted {
|
|
|
|
|
margin-right: 340px;
|
|
|
|
|
}
|
|
|
|
|
.pokemon-info {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 100%;
|
|
|
|
|
margin-top: 5px;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pokemon-number {
|
|
|
|
|
color: #777;
|
|
|
|
|
font-size: 0.7em;
|
|
|
|
|
text-align: center;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.origin-mark {
|
|
|
|
|
width: 20px;
|
|
|
|
|
height: 20px;
|
|
|
|
|
object-fit: contain;
|
|
|
|
|
filter: invert(100%);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Optional: Add a background circle for better visibility */
|
|
|
|
|
.origin-mark-container {
|
|
|
|
|
background-color: rgba(0, 0, 0, 0.1);
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
padding: 2px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pokeball-container {
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pokeball-icon {
|
|
|
|
|
width: 20px;
|
|
|
|
|
height: 20px;
|
|
|
|
|
object-fit: contain;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: filter 0.3s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pokeball-icon.grayscale {
|
|
|
|
|
filter: grayscale(100%);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.game-encounters {
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.collapsible {
|
|
|
|
|
background-color: #f1f1f1;
|
|
|
|
|
color: #444;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
text-align: left;
|
|
|
|
|
outline: none;
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
transition: 0.4s;
|
|
|
|
|
border: none;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.active, .collapsible:hover {
|
|
|
|
|
background-color: #ccc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.encounter-list {
|
|
|
|
|
display: none;
|
|
|
|
|
padding: 0 18px;
|
|
|
|
|
background-color: white;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.toggle-icon {
|
|
|
|
|
float: right;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div id="main-content">
|
|
|
|
|
<h1 style="width: 100%; text-align: center;">OriginDex</h1>
|
|
|
|
|
|
|
|
|
|
{% for group in grouped_pokemon %}
|
|
|
|
|
<div class="pokemon-box">
|
|
|
|
|
<div class="box-title">Box {{ '%03d' | format(loop.index) }}</div>
|
|
|
|
|
<div class="pokemon-grid">
|
|
|
|
|
{% for pokemon in group %}
|
|
|
|
|
{% if pokemon %}
|
|
|
|
|
<div class="pokemon-cell" onclick="showDetails('{{ pokemon.ID }}', '{{ pokemon.Form }}', '{{ pokemon.pfic }}', event)" data-dex-number="{{ pokemon.ID }}">
|
|
|
|
|
<div class="pokemon-name">{{ pokemon.Name }}</div>
|
|
|
|
|
<img data-src="{{ url_for('static', filename=pokemon.Image) }}" alt="{{ pokemon.Name }} {{ pokemon.Form }}" class="pokemon-image lazy-load" src="{{ url_for('static', filename='images/placeholder.png') }}">
|
|
|
|
|
<div class="pokemon-form">
|
|
|
|
|
{% if pokemon.Form != 'Default' %}
|
|
|
|
|
{{ pokemon.Form }}
|
|
|
|
|
{% else %}
|
|
|
|
|
-----
|
|
|
|
|
{% endif %}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="pokemon-info">
|
|
|
|
|
<div class="pokeball-container">
|
|
|
|
|
<img src="{{ url_for('static', filename='images/pokeball_color.png') }}" alt="Pokeball" class="pokeball-icon grayscale" onclick="togglePokeball(event, this)">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="pokemon-number">#{{ '%04d'|format(pokemon.ID) }}</div>
|
|
|
|
|
{% if pokemon.MarkIcon %}
|
|
|
|
|
<div class="origin-mark-container">
|
|
|
|
|
<img src="{{ url_for('static', filename=pokemon.MarkIcon) }}" alt="Origin Mark" class="origin-mark" title="{{ pokemon.EarliestGame }}">
|
|
|
|
|
</div>
|
|
|
|
|
{% endif %}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{% else %}
|
|
|
|
|
<div class="pokemon-cell empty"></div>
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</div>
|
|
|
|
|
<div id="details-panel"></div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
const detailsPanel = document.getElementById('details-panel');
|
|
|
|
|
const mainContent = document.getElementById('main-content');
|
|
|
|
|
|
|
|
|
|
function showDetails(dexNumber, formName, pfic, event) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
fetch(`/pokemon/${pfic}`)
|
|
|
|
|
.then(response => response.json())
|
|
|
|
|
.then(data => {
|
|
|
|
|
const encountersByGame = groupEncountersByGame(data);
|
|
|
|
|
detailsPanel.innerHTML = `
|
|
|
|
|
<h2>Pokémon #${dexNumber} - ${formName} Form</h2>
|
|
|
|
|
<h3>Encounters:</h3>
|
|
|
|
|
${generateEncounterHTML(encountersByGame)}
|
|
|
|
|
`;
|
|
|
|
|
detailsPanel.classList.add('open');
|
|
|
|
|
mainContent.classList.add('main-content-shifted');
|
|
|
|
|
addCollapsibleListeners();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function groupEncountersByGame(encounters) {
|
|
|
|
|
return encounters.reduce((acc, encounter) => {
|
|
|
|
|
if (!acc[encounter.game]) {
|
|
|
|
|
acc[encounter.game] = {
|
|
|
|
|
game_id: encounter.game_id,
|
|
|
|
|
encounters: []
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
acc[encounter.game].encounters.push(encounter);
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function generateEncounterHTML(encountersByGame) {
|
|
|
|
|
return Object.entries(encountersByGame)
|
|
|
|
|
.sort((a, b) => a[1].game_id - b[1].game_id)
|
|
|
|
|
.map(([game, data]) => `
|
|
|
|
|
<div class="game-encounters">
|
|
|
|
|
<h4 class="collapsible">${game} <span class="toggle-icon">▼</span></h4>
|
|
|
|
|
<div class="encounter-list">
|
|
|
|
|
${data.encounters.map(encounter => `
|
|
|
|
|
<p>${encounter.location}
|
|
|
|
|
${encounter.day ? `(${encounter.day})` : ''}
|
|
|
|
|
${encounter.time ? `(${encounter.time})` : ''}
|
|
|
|
|
${encounter.static_encounter ? '(Static)' : ''}
|
|
|
|
|
${encounter.fishing ? '(Fishing)' : ''}
|
|
|
|
|
${encounter.starter ? '(Starter)' : ''}
|
|
|
|
|
</p>
|
|
|
|
|
`).join('')}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
`).join('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addCollapsibleListeners() {
|
|
|
|
|
const collapsibles = document.querySelectorAll('.collapsible');
|
|
|
|
|
collapsibles.forEach(item => {
|
|
|
|
|
item.addEventListener('click', function() {
|
|
|
|
|
this.classList.toggle('active');
|
|
|
|
|
const content = this.nextElementSibling;
|
|
|
|
|
if (content.style.display === 'block') {
|
|
|
|
|
content.style.display = 'none';
|
|
|
|
|
this.querySelector('.toggle-icon').textContent = '▼';
|
|
|
|
|
} else {
|
|
|
|
|
content.style.display = 'block';
|
|
|
|
|
this.querySelector('.toggle-icon').textContent = '▲';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeDetailsPanel() {
|
|
|
|
|
detailsPanel.classList.remove('open');
|
|
|
|
|
mainContent.classList.remove('main-content-shifted');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.body.addEventListener('click', function(event) {
|
|
|
|
|
if (!detailsPanel.contains(event.target) && !event.target.closest('.pokemon-cell')) {
|
|
|
|
|
closeDetailsPanel();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
detailsPanel.addEventListener('click', function(event) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function togglePokeball(event, element) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
element.classList.toggle('grayscale');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Lazy loading for images
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
|
var lazyloadImages;
|
|
|
|
|
|
|
|
|
|
if ("IntersectionObserver" in window) {
|
|
|
|
|
lazyloadImages = document.querySelectorAll(".lazy-load");
|
|
|
|
|
var imageObserver = new IntersectionObserver(function(entries, observer) {
|
|
|
|
|
entries.forEach(function(entry) {
|
|
|
|
|
if (entry.isIntersecting) {
|
|
|
|
|
var image = entry.target;
|
|
|
|
|
image.src = image.dataset.src;
|
|
|
|
|
image.classList.remove("lazy-load");
|
|
|
|
|
imageObserver.unobserve(image);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
lazyloadImages.forEach(function(image) {
|
|
|
|
|
imageObserver.observe(image);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
var lazyloadThrottleTimeout;
|
|
|
|
|
lazyloadImages = document.querySelectorAll(".lazy-load");
|
|
|
|
|
|
|
|
|
|
function lazyload () {
|
|
|
|
|
if(lazyloadThrottleTimeout) {
|
|
|
|
|
clearTimeout(lazyloadThrottleTimeout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lazyloadThrottleTimeout = setTimeout(function() {
|
|
|
|
|
var scrollTop = window.pageYOffset;
|
|
|
|
|
lazyloadImages.forEach(function(img) {
|
|
|
|
|
if(img.offsetTop < (window.innerHeight + scrollTop)) {
|
|
|
|
|
img.src = img.dataset.src;
|
|
|
|
|
img.classList.remove('lazy-load');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if(lazyloadImages.length == 0) {
|
|
|
|
|
document.removeEventListener("scroll", lazyload);
|
|
|
|
|
window.removeEventListener("resize", lazyload);
|
|
|
|
|
window.removeEventListener("orientationChange", lazyload);
|
|
|
|
|
}
|
|
|
|
|
}, 20);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.addEventListener("scroll", lazyload);
|
|
|
|
|
window.addEventListener("resize", lazyload);
|
|
|
|
|
window.addEventListener("orientationChange", lazyload);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|