This commit is contained in:
girault 2022-04-12 12:34:07 +02:00
parent d41feeffe8
commit e3c07b83d4
11 changed files with 333 additions and 0 deletions

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="http://www.iut-fbleau.fr/css/tacit.css">
<script src="./js/favoris.js"></script>
</head>
<body container>
<h1>Favoris</h1>
</body>
</html>

View File

@ -0,0 +1,34 @@
let favoris = [
{
nom:"Google" ,
url:"www.google.fr",
img:"https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/200px-Google_2015_logo.svg.png"
},
{
nom:"Le Monde",
url:"lemonde.fr",
img:"https://upload.wikimedia.org/wikipedia/commons/thumb/2/22/Lemonde_fr_2005_logo.svg/200px-Lemonde_fr_2005_logo.svg.png?uselang=fr"
},
{
nom:"L'Equipe",
url:"www.lequipe.fr",
img:"https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/L%27%C3%89quipe_wordmark.svg/200px-L%27%C3%89quipe_wordmark.svg.png"
}
]
window.addEventListener("load",()=>{
// TODO
let body = document.body
let ul = document.createElement("ul")
for (f of favoris){
let li = document.createElement("li")
let a = document.createElement("a")
a.href = "http://" + f.url
let txt = document.createTextNode(f.nom)
a.appendChild(txt)
li.appendChild(a)
ul.appendChild(li)
}
body.appendChild(ul)
})

View File

@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>tp dom</title>
<link rel="stylesheet" href="http://www.iut-fbleau.fr/css/tacit.css">
<script src="./js/contacts.js"></script>
<style>
#contacts {
/* width:100%;*/
}
#contacts tbody{
cursor:pointer;
}
#contacts td{
/* width:33%;*/
}
#contacts tbody tr:hover{
background-color:#eeeeee;
}
</style>
<script>
</script>
</head>
<body container>
<h1>TP DOM</h1>
<div grid>
<div column="8">
<h4>Contacts</h4>
<table id="contacts">
<thead>
<tr>
<th>Nom</th>
<th>Prénom</th>
<th>Email</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<button type="submit" id="sauver">Sauver</button>
</div>
<div column="4">
<h4>Saisie</h4>
<form id="form" method="POST">
<fieldset>
<div>
<label for="prenom">Prénom</label><br>
<input id="prenom" name="prenom" placeholder="Prénom" type="text" required>
</div>
<div>
<!-- Text input-->
<label for="nom">Nom</label><br>
<input id="nom" name="nom" placeholder="Nom" type="text" required>
</div>
<div>
<!-- Text input-->
<label for="email">Email</label><br>
<input id="email" name="email" placeholder="Email" type="email" required>
</div>
<!-- Button -->
<div>
<button type="submit" id="ajouter" >Ajouter</button>
</div>
</fieldset>
</form>
<div>Cliquez sur une ligne pour la supprimer.</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,77 @@
window.addEventListener(
"load",
()=>{
let Model = {
getContacts(){
return JSON.parse(localStorage.getItem('ct')) || []
},
saveContacts(arr){
return localStorage.setItem('ct',JSON.stringify(arr))
}
}
let View ={
tableContact : document.querySelector("#contacts"),
formContact : document.getElementById("form"),
saveButton : document.getElementById("sauver"),
getContactForm(){
let data = new FormData(this.formContact)
return {
"nom" : data.get('nom'),
"prenom" : data.get('prenom'),
"email" : data.get("email")
}
},
updateTable(cts){
let fg = document.createElement("tbody")
cts.forEach((ct)=>{
let tr = document.createElement("tr")
for (p in ct){
let td = document.createElement("td")
let txt = document.createTextNode(ct[p])
td.appendChild(txt)
tr.appendChild(td)
}
fg.appendChild(tr)
})
this.tableContact.replaceChild(fg,this.tableContact.querySelector('tbody'))
},
suscribeSubmitForm(f){
this.formContact.addEventListener("submit",(ev)=>{
ev.preventDefault()
f(this.getContactForm())
})
},
suscribeSaveTable(f){
// TODO
},
suscribeClickTable(f){
// TODO
}
}
let Controller = {
cts : [], // les contacts
init(){
View.suscribeSubmitForm((ct)=>{
if (this.cts.find(x=>x.email == ct.email) !== undefined){
this.cts.push(ct)
View.updateTable(this.cts)
}
})
View.suscribeSaveTable(() => Model.saveContacts(this.cts))
View.suscribeClickTable( (ct)=> {
// TODO
})
this.cts = Model.getContacts()
View.updateTable(this.cts)
}
}
Controller.init()
})

View File

@ -0,0 +1,26 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>Cookie clicker</title>
<link rel="stylesheet" href="./css/style.css">
</head>
<body>
<div class="container">
<h1>Cookie clicker</h1>
<figure>
<img src="img/cookie.png" alt="cookie">
<span>0</span>
</figure>
<button>start</button>
<p class="hidden">
<img src="img/memee.png" alt="memee" width="64" height="64">
<span></span>
</p>
</div>
<script type="text/javascript" src="./js/game.js"></script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -0,0 +1,63 @@
@import url(https://fonts.googleapis.com/css?family=Kavoon);
body {
background-image: url("img/bg.jpg");
background-repeat: repeat;
font-family: Kavoon;
font-size: 24px;
text-align: center;
color: white;
}
.container {
max-width: 320px;
margin: auto;
}
h1 {
font-size: 28px;
background-color: rgba(0, 0, 0, 0.25);
padding: 10px 40px 10px 40px;
border-radius: 10px;
}
figure {
position: relative;
margin: 0;
}
figure > span {
position: absolute;
top: 25px;
right: 50px;
border-radius: 21px;
height: 42px;
width: 56px;
background-color: #f4d03f;
box-shadow: 4px 4px 4px black;
padding-top: 9px;
}
button {
display: block;
width: 100%;
font-family: Kavoon;
font-size: 24px;
background-color: white;
padding: 9px;
border-radius: 10px;
border-width: 0;
}
p {
text-align: left;
}
img[alt="GrandMa"] {
float: left;
}
.hidden {
display: none;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,47 @@
// TODO
let numberOfSecond
let id_interval
let btt = document.getElementsByTagName("button")[0]
let p = document.getElementsByTagName("p")[0]
let text_numberOfSecond = document.getElementsByTagName("p")[0].lastElementChild
let figure = document.getElementsByTagName("figure")[0]
let numberOfClick = document.getElementsByTagName("figure")[0].lastElementChild
function Timer(e4) {
numberOfSecond--;
text_numberOfSecond.innerText = numberOfSecond + " seconds left!"
}
function Ending(e3) {
figure.removeEventListener("click", ClickIMG, false)
clearInterval(id_interval)
text_numberOfSecond.innerText = 0 + " second left!"
}
function ClickIMG(e2) {
numberOfClick.innerText = Number(numberOfClick.innerText) + 1
}
function ReponseClick(e1) {
numberOfSecond = 15
btt.classList.add("hidden")
p.classList.remove("hidden")
text_numberOfSecond.innerText = numberOfSecond + " seconds left!"
text_numberOfSecond.style = "color:red"
figure.addEventListener("click", ClickIMG, false)
id_interval = setInterval(Timer, 1000)
setTimeout(Ending, 15000)
}
btt.addEventListener("click", ReponseClick, false)