Skip to content

Commit

Permalink
rename session
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeeppy committed May 1, 2023
1 parent 7cb2f64 commit 09521e7
Show file tree
Hide file tree
Showing 20 changed files with 172 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ <h1 class="text-center mt-5">Bitcoin Price</h1>
</div>

</div>

<script src="script.js"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions session26/bitcoin-prix/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const url = 'https://blockchain.info/ticker'

function recupererPrix() {
let requete = new XMLHttpRequest();
requete.open('GET', url);
requete.responseType = 'json';
requete.send();

requete.onload = function() {
if (requete.readyState === XMLHttpRequest.DONE) {
if (requete.status === 200) {
let reponse = requete.response;
let prixEnEuros = reponse.EUR.last;
document.querySelector('#price_label').textContent = prixEnEuros;
}
else {
console.log('Un problème est survenu, merci de revenir plus tard.');
}
}
}
console.log('Prix actualisé');
}

setInterval(recupererPrix, 5000);
File renamed without changes.
47 changes: 0 additions & 47 deletions session26/index.html

This file was deleted.

12 changes: 12 additions & 0 deletions session26/n/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions session26/n/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const url = "https://lesoublisdelinfo.com/api.php"

let requete = new XMLHttpRequest();
requete.open('POST', url);
requete.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
requete.responseType = 'json';

requete.send('prenom=John');

requete.onload = function() {
if (requete.readyState === XMLHttpRequest.DONE) {
if (requete.status === 200) {
let reponse = requete.response;
console.log(reponse);
}
else {
alert('Un problème est survenu, merci de revenir plus tard.');
}
}
}
File renamed without changes.
34 changes: 0 additions & 34 deletions session26/script.js

This file was deleted.

35 changes: 35 additions & 0 deletions session27/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,43 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">

<div class="row justify-content-center">

<div class="col-md-8">
<!-- Titre -->
<h1 class="text-center mt-5">Météo</h1>

<!-- Ville / Temperature -->
<div class="text-center">
<span id="ville">paris</span>

<div id="temperature">
<span id="temperature_label">
xx.x
</span> °C
</div>
</div>
</div>

</div>

<div class="row justify-content-center">
<div class="col-md-8 text-center">
<!-- Changer de ville -->
<div id="changer" class="mt-2 text-center p-3 text-white font-weight-bold text-uppercase d-inline-block">
Changer de ville
</div>
</div>

</div>

</div>
<script src="script.js"></script>
</body>
</html>
65 changes: 30 additions & 35 deletions session27/script.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@

function chargerScript(script) {
return new Promise((resolve, reject) => {
let element = document.createElement('script');
element.src = script;
document.head.append(element);

element.onload = () => resolve('Fichier ' + script + ' a été chargé');

element.onerror = () => reject(new Error('Opération impossible pour le script ' + script));
});
}

async function resultat() {
try {
const scriptA = await chargerScript('test.js');
console.log(scriptA);
const scriptB = await chargerScript('autre.js');
console.log(scriptB);
}
catch(error) {
console.log(error);
document.head.lastChild.remove();
let ville = "Lille";
let key = '';

function recevoirTemperature(ville) {
const url = 'https://api.openweathermap.org/data/2.5/weather?q=' + ville + '&appid=' + key + '&units=metric';
let requete = new XMLHttpRequest();
requete.open("GET", url);
requete.responseType = 'json';
requete.send();

requete.onload = function() {
if (requete.readyState === XMLHttpRequest.DONE) {
if (requete.status === 200) {
let reponse = requete.response;
let temperature = document.querySelector('#temperature_label');
temperature.textContent = reponse.main.temp;
let elementVille = document.querySelector('#ville')
elementVille.textContent = ville;
console.log(reponse);
}
else {
console.log("Une erreur est survenu, veuillez ressayez plus tard.");
}
}
}
}

resultat();

// async function direBonjour() {
// const promesse = new Promise((resolve, reject) => {
// setTimeout(() => resolve('Promesse tenu !'), 3000);
// });

// let resultat = await promesse;
// console.log(resultat);
// }

recevoirTemperature(ville);

// direBonjour();
let button = document.querySelector("#changer")
button.addEventListener('click', () => {
ville = prompt("Ville ?");
recevoirTemperature(ville);
});
File renamed without changes.
30 changes: 0 additions & 30 deletions session28/axios-get/index.html

This file was deleted.

13 changes: 0 additions & 13 deletions session28/axios-get/script.js

This file was deleted.

17 changes: 0 additions & 17 deletions session28/axios-post/script.js

This file was deleted.

16 changes: 0 additions & 16 deletions session28/fetch-get/script.js

This file was deleted.

7 changes: 0 additions & 7 deletions session28/fetch-get/style.css

This file was deleted.

Loading

0 comments on commit 09521e7

Please sign in to comment.