forked from jojomuller27/Projet_Pubnum2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojet.html
216 lines (176 loc) · 6.87 KB
/
projet.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.bleu{
background-color:blue;
color: white;
}
.rouge{
background-color: red;
color: white;
}
.vert{
background-color: green;
color: white;
}
.cache{
display:none;
}
.valider {
background-color:blue;
color:white;
border-radius: 70px;
}
.indice{
background-color:blue;
color:white;
border-radius: 70px;
}
.portrait{
height: 400px;
}
.landscape{
width: 400px;
}
#cadre{
width:400px;
height:405px;
display:table-cell;
vertical-align: middle;
}
@media handheld {
#btArtiste, #btTitre, #btDate, #btLieu , #btIndice {
font-size:1rem;
}
}
@media screen {
#btArtiste, #btTitre, #btDate, #btLieu, #btValider, #btIndice {
font-size:80%;
}
}
</style>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript" language="javascript" src="catalogue.json"></script>
<title>Document</title>
</head>
<body>
<h3><center>Lecture d'œuvres</center></h3>
<center><input type="button" id="btIndice" value="Indices" class="indice">
<textarea id="txtAreaNote" class="cache">
</textarea>
<div>
<div id="cadre">
<img id= "imageOeuvre" alt="Miniature"/></a>
</div>
<div>
<input type="button" id="btArtiste" value="Artiste" class="bleu" onclick="fnChangeCouleur(this);">
<input type="button" id="btTitre" value="Titre" class="bleu" onclick="fnChangeCouleur(this);">
<input type="button" id="btDate" value="Date" class="bleu" onclick="fnChangeCouleur(this);">
<input type="button" id="btLieu" value="Lieu" class="bleu" onclick="fnChangeCouleur(this);">
</br>
</br>
<input type="button" id="btValider" value="Valider" class="valider" onclick="verifieReponse();">
</center>
</div>
<script>
// récupérer les tons titre,dat, Lieu et artise
let btArtiste= document.getElementById("btArtiste");
let btTitre= document.getElementById("btTitre");
let btDate= document.getElementById("btDate");
let btLieu= document.getElementById("btLieu");
let btIndice= document.getElementById("btIndice");
let btValider= document.getElementById("btValider");
let txtAreaNote= document.getElementById("txtAreaNote");
let imageOeuvre = document.getElementById("imageOeuvre");
let pageQuestion=true;
let click = 0;
let oeuvres=[];
//création de constante
const TITRE_BT_ARTISTE=btArtiste.value;
const TITRE_BT_TITRE=btTitre.value;
const TITRE_BT_DATE=btDate.value;
const TITRE_BT_Lieu=btLieu.value;
// couleur des boutons
function fnChangeCouleur (btn){
if(btn.className=="bleu"){
btn.className="rouge";
}
else if (btn.className=="rouge"){
btn.className="vert";
}
else{
btn.className="rouge";
}
};
//réinitialiser
function init()
{
click=0;
//random
tirage = Math.floor(Math.random() * catalogue.length);
// récupérer les données du JSON relativement au tirage
oeuvres["Artiste"] = catalogue[tirage].Artiste;
oeuvres["Titre"] = catalogue[tirage].Titre;
oeuvres["Date"] = catalogue[tirage].Date;
oeuvres["IndiceDate"] = catalogue[tirage].IndiceDate;
oeuvres["Lieu"] = catalogue[tirage].Lieu;
oeuvres["IndiceLieu"] = catalogue[tirage].IndiceLieu;
oeuvres["Image"] = catalogue[tirage].Image;
oeuvres["Note"] = catalogue[tirage].Note;
oeuvres["Orientation"] = catalogue[tirage].Orientation;
//changer la classe suivant portrait ou landscape
imageOeuvre.className = catalogue[tirage].Orientation;
btArtiste.className="bleu";
btTitre.className="bleu";
btLieu.className="bleu";
btDate.className="bleu";
btArtiste.value=TITRE_BT_ARTISTE;
btTitre.value=TITRE_BT_TITRE;
btLieu.value=TITRE_BT_Lieu;
btDate.value=TITRE_BT_DATE;
btValider.value="Valider";
imageOeuvre.src=oeuvres["Image"];
//passage d'une page à l'autre
}
function verifieReponse (){
// document.getElementById("#txtAreaNote").style.display = "inline";
if(pageQuestion)
{
if (btLieu.className!="bleu"&btDate.className!="bleu"&btTitre.className!="bleu"&btArtiste.className!="bleu"){
txtAreaNote.classList.toggle("cache");
btIndice.classList.toggle("cache");
btArtiste.value=oeuvres["Artiste"] ;
btTitre.value = oeuvres["Titre"];
btLieu.value= oeuvres["Lieu"] ;
btDate.value=oeuvres["Date"]
btValider.value="Suivant";
pageQuestion=false;
}
}
else{
click=0;
txtAreaNote.classList.toggle("cache");
btIndice.classList.toggle("cache");
init();
pageQuestion=true;
}
}
//function bouton indice
btIndice.addEventListener("click", function(){
click++;
if (click==1)
{
document.getElementById("btLieu").value = oeuvres["IndiceLieu"]}
else if (click==2){
document.getElementById("btDate").value = oeuvres["IndiceDate"];
}
})
// appelle de la fonction init
init();
</script>
</div>
</body>
</html>