diff --git a/school-pokedex/admin-script.js b/school-pokedex/admin-script.js
deleted file mode 100644
index 11a9710..0000000
--- a/school-pokedex/admin-script.js
+++ /dev/null
@@ -1,114 +0,0 @@
-document.addEventListener('DOMContentLoaded', () => {
- const form = document.getElementById('pokemon-form');
- const pokemonList = document.getElementById('admin-pokemon-list');
-
- const fetchPokemons = () => {
- fetch('/school-pokedex/school-pokedex/api.php')
- .then(response => {
- if (!response.ok) {
- throw new Error('Network response was not ok');
- }
- return response.text().then(text => {
- try {
- return JSON.parse(text);
- } catch (error) {
- console.error('JSON parse error:', error, text);
- throw error;
- }
- });
- })
- .then(pokemons => {
- pokemonList.innerHTML = '';
- pokemons.forEach(pokemon => {
- const card = document.createElement('div');
- card.className = 'pokemon-card';
- card.innerHTML = `
-
-
Type: ${pokemon.type}
-Stats: ${JSON.stringify(pokemon.stats)}
-Info: ${pokemon.info}
- - - `; - pokemonList.appendChild(card); - }); - }) - .catch(error => console.error('Fetch error:', error)); - }; - - form.addEventListener('submit', (e) => { - e.preventDefault(); - const id = document.getElementById('pokemon-id').value; - const name = document.getElementById('name').value; - const type = document.getElementById('type').value; - const image = document.getElementById('image').value; - const stats = JSON.parse(document.getElementById('stats').value); - const info = document.getElementById('info').value; - - const method = id ? 'PUT' : 'POST'; - const url = id ? `/school-pokedex/school-pokedex/api.php/${id}` : '/school-pokedex/school-pokedex/api.php'; - - fetch(url, { - method: method, - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ name, type, image, stats, info }) - }).then(response => { - if (!response.ok) { - throw new Error('Network response was not ok'); - } - return response.text().then(text => { - try { - return JSON.parse(text); - } catch (error) { - console.error('JSON parse error:', error, text); - throw error; - } - }); - }).then(() => { - form.reset(); - fetchPokemons(); - }).catch(error => console.error('Fetch error:', error)); - }); - - window.editPokemon = (id) => { - fetch(`/school-pokedex/school-pokedex/api.php/${id}`) - .then(response => { - if (!response.ok) { - throw new Error('Network response was not ok'); - } - return response.text().then(text => { - try { - return JSON.parse(text); - } catch (error) { - console.error('JSON parse error:', error, text); - throw error; - } - }); - }) - .then(pokemon => { - document.getElementById('pokemon-id').value = pokemon.id; - document.getElementById('name').value = pokemon.name; - document.getElementById('type').value = pokemon.type; - document.getElementById('image').value = pokemon.image; - document.getElementById('stats').value = JSON.stringify(pokemon.stats); - document.getElementById('info').value = pokemon.info; - }) - .catch(error => console.error('Fetch error:', error)); - }; - - window.deletePokemon = (id) => { - fetch(`/school-pokedex/school-pokedex/api.php/${id}`, { method: 'DELETE' }) - .then(response => { - if (!response.ok) { - throw new Error('Network response was not ok'); - } - fetchPokemons(); - }) - .catch(error => console.error('Fetch error:', error)); - }; - - fetchPokemons(); -}); diff --git a/school-pokedex/admin.html b/school-pokedex/admin.html deleted file mode 100644 index ccff0a5..0000000 --- a/school-pokedex/admin.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - -Type: ${pokemon.type}
-Stats: ${JSON.stringify(pokemon.stats)}
-Info: ${pokemon.info}
- `; - pokemonList.appendChild(card); - }); - }) - .catch(error => console.error('Fetch error:', error)); -}); diff --git a/school-pokedex/server.js b/school-pokedex/server.js deleted file mode 100644 index c3ace1e..0000000 --- a/school-pokedex/server.js +++ /dev/null @@ -1,42 +0,0 @@ -const express = require('express'); -const bodyParser = require('body-parser'); -const app = express(); -const port = 3000; - -let pokemons = [ - { id: 1, name: 'Bulbasaur', type: 'Grass/Poison', image: 'https://img.pokemondb.net/artwork/bulbasaur.jpg' }, - // ...add more initial Pokémon data here... -]; - -app.use(bodyParser.json()); -app.use(express.static('school-pokedex')); - -app.get('/api/pokemons', (req, res) => { - res.json(pokemons); -}); - -app.get('/api/pokemons/:id', (req, res) => { - const pokemon = pokemons.find(p => p.id == req.params.id); - res.json(pokemon); -}); - -app.post('/api/pokemons', (req, res) => { - const newPokemon = { id: Date.now(), ...req.body }; - pokemons.push(newPokemon); - res.status(201).json(newPokemon); -}); - -app.put('/api/pokemons/:id', (req, res) => { - const index = pokemons.findIndex(p => p.id == req.params.id); - pokemons[index] = { id: parseInt(req.params.id), ...req.body }; - res.json(pokemons[index]); -}); - -app.delete('/api/pokemons/:id', (req, res) => { - pokemons = pokemons.filter(p => p.id != req.params.id); - res.status(204).end(); -}); - -app.listen(port, () => { - console.log(`Server running at http://localhost:${port}`); -}); diff --git a/school-pokedex/styles.css b/school-pokedex/styles.css deleted file mode 100644 index 25b6f39..0000000 --- a/school-pokedex/styles.css +++ /dev/null @@ -1,32 +0,0 @@ -body { - font-family: Arial, sans-serif; - margin: 0; - padding: 20px; - background-color: #f0f0f0; -} - -h1 { - text-align: center; -} - -#pokemon-list, #admin-pokemon-list { - display: flex; - flex-wrap: wrap; - justify-content: center; -} - -.pokemon-card { - background-color: white; - border: 1px solid #ccc; - border-radius: 8px; - margin: 10px; - padding: 10px; - width: 200px; - text-align: center; -} - -.pokemon-card img { - max-width: 100%; - height: auto; - border-radius: 8px; -} diff --git a/school-pokedex/tutorial.md b/school-pokedex/tutorial.md deleted file mode 100644 index 8b648c7..0000000 --- a/school-pokedex/tutorial.md +++ /dev/null @@ -1,61 +0,0 @@ -# Pokémon Website Setup Tutorial - -Deze tutorial begeleidt je bij het opzetten en uitvoeren van de Pokémon-website en database. - -## Stap 1: Stel de MySQL-database in - -1. **Installeer XAMPP:** - - Download en installeer XAMPP van de officiële website: https://www.apachefriends.org/index.html - - Volg de installatie-instructies. - -2. **Start MySQL:** - - Open het XAMPP Configuratiescherm. - - Start de MySQL-module door op de knop "Start" naast MySQL te klikken. - -3. **Maak de database en tabellen aan:** - - Open phpMyAdmin door op de knop "Admin" naast MySQL in het XAMPP Configuratiescherm te klikken. - - Klik in phpMyAdmin op het tabblad "SQL". - - Voer het SQL-script uit om de database en tabellen aan te maken. - -## Stap 2: Stel de PHP-backend in - -1. **Installeer PHP (indien niet al geïnstalleerd met XAMPP):** - - PHP is inbegrepen bij XAMPP, dus je hoeft het niet apart te installeren. - -2. **Maak het PHP API-bestand:** - - Maak een bestand genaamd `api.php` in de map `/c:/xampp/htdocs/school-pokedex/school-pokedex`. - - Voeg de benodigde code toe om de API te maken die communiceert met de MySQL-database. - -## Stap 3: Stel de frontend in - -1. **Maak de HTML-bestanden:** - - Maak `index.html` en `admin.html` in de map `/c:/xampp/htdocs/school-pokedex/school-pokedex`. - - Voeg de benodigde HTML-code toe om de hoofdpagina en de beheerderspagina te maken. - -2. **Maak het CSS-bestand:** - - Maak een bestand genaamd `styles.css` in de map `/c:/xampp/htdocs/school-pokedex/school-pokedex`. - - Voeg de benodigde CSS-code toe om de pagina's op te maken. - -3. **Maak de JavaScript-bestanden:** - - Maak `script.js` en `admin-script.js` in de map `/c:/xampp/htdocs/school-pokedex/school-pokedex`. - - Voeg de benodigde JavaScript-code toe om de frontend te verbinden met de backend API. - -## Stap 4: Start de PHP-server - -1. **Start de ingebouwde PHP-server:** - - Open een terminal of opdrachtprompt. - - Navigeer naar de map `/c:/xampp/htdocs/school-pokedex/school-pokedex`. - - Voer het volgende commando uit om de ingebouwde PHP-server te starten: - ```sh - php -S localhost:8000 - ``` - -## Stap 5: Open de website - -1. **Open de hoofdpagina:** - - Open een webbrowser en ga naar `http://localhost:8000/index.html` om de hoofdpagina van de Pokédex te bekijken. - -2. **Open de beheerderspagina:** - - Open een webbrowser en ga naar `http://localhost:8000/admin.html` om de Pokémon te beheren. - -Je kunt nu Pokémon bekijken en beheren met de opgegeven frontend- en backend-setup. \ No newline at end of file