-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
172 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ <h1 class="text-center mt-5">Bitcoin Price</h1> | |
</div> | ||
|
||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.