diff --git a/WIM4.1/tp/tp3/ex2/index.html b/WIM4.1/tp/tp3/ex2/index.html new file mode 100644 index 0000000..f171306 --- /dev/null +++ b/WIM4.1/tp/tp3/ex2/index.html @@ -0,0 +1,38 @@ + + + + + + Ajax + + + + + +
+
+ + + + +
+
+ + + diff --git a/WIM4.1/tp/tp3/ex2/js/helpers.js b/WIM4.1/tp/tp3/ex2/js/helpers.js new file mode 100644 index 0000000..47e7dba --- /dev/null +++ b/WIM4.1/tp/tp3/ex2/js/helpers.js @@ -0,0 +1,19 @@ +function debounce(fn, wait) +{ + let timeout; + return (...args) => { + clearTimeout(timeout); + timeout = setTimeout(() => fn(...args), wait); + } +} +function autocomplete(datalist,communes) +{ + // À compléter + datalist.innerHTML = ''; + + for(let c of communes) { + let option = document.createElement("option"); + option.value = c; + datalist.appendChild(option); + } +} diff --git a/WIM4.1/tp/tp3/ex2/js/serviceAjax.js b/WIM4.1/tp/tp3/ex2/js/serviceAjax.js new file mode 100644 index 0000000..560f68e --- /dev/null +++ b/WIM4.1/tp/tp3/ex2/js/serviceAjax.js @@ -0,0 +1,30 @@ +let http={ + getVilles(nom){ + // À compléter + let final_json; + return fetch('https://geo.api.gouv.fr/communes?nom=' + nom + '&fields=departement&boost=population&limit=7') + .then(readResponseAsJson) + .then(function(body) { + final_json = new Array(); + body.forEach(el => final_json.push(el.nom)); + return final_json + }) + + + + } +} + +function readResponseAsJson(response){ + + if (!response.ok) { + + console.log(response.statusText); + } + + else { + return response.json() + } +} + + diff --git a/WIM4.1/tp/tp3/ex3/chat.html b/WIM4.1/tp/tp3/ex3/chat.html new file mode 100644 index 0000000..645491f --- /dev/null +++ b/WIM4.1/tp/tp3/ex3/chat.html @@ -0,0 +1,27 @@ + + + + + + + + + + +

Chat

+
+ + +
+
+

Messages

+
+ +
+
+
+ +
+
+ + diff --git a/WIM4.1/tp/tp3/ex3/css/style.css b/WIM4.1/tp/tp3/ex3/css/style.css new file mode 100644 index 0000000..50a51ad --- /dev/null +++ b/WIM4.1/tp/tp3/ex3/css/style.css @@ -0,0 +1,5 @@ +#message{ + display:inline-block; + width:100%; + } + diff --git a/WIM4.1/tp/tp3/ex3/php/chat.php b/WIM4.1/tp/tp3/ex3/php/chat.php new file mode 100644 index 0000000..9e81eac --- /dev/null +++ b/WIM4.1/tp/tp3/ex3/php/chat.php @@ -0,0 +1,20 @@ + $id;"); +$retour = []; +foreach($result as $message){ + $retour[]=$message; +} +echo json_encode($retour); +?> diff --git a/WIM4.1/tp/tp3/ex3/sql/message.sql b/WIM4.1/tp/tp3/ex3/sql/message.sql new file mode 100644 index 0000000..d8c1580 --- /dev/null +++ b/WIM4.1/tp/tp3/ex3/sql/message.sql @@ -0,0 +1,60 @@ +-- phpMyAdmin SQL Dump +-- version 4.9.2 +-- https://www.phpmyadmin.net/ +-- +-- Hôte : localhost +-- Généré le : lun. 11 mai 2020 à 15:56 +-- Version du serveur : 10.4.11-MariaDB +-- Version de PHP : 7.4.1 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Base de données : `chat` +-- + +-- -------------------------------------------------------- + +-- +-- Structure de la table `message` +-- + +CREATE TABLE `message` ( + `id` int(11) NOT NULL, + `pseudo` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL, + `message` text COLLATE utf8mb4_unicode_ci NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Index pour les tables déchargées +-- + +-- +-- Index pour la table `message` +-- +ALTER TABLE `message` + ADD PRIMARY KEY (`id`); + +-- +-- AUTO_INCREMENT pour les tables déchargées +-- + +-- +-- AUTO_INCREMENT pour la table `message` +-- +ALTER TABLE `message` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;