Skip to content

Commit bf52ea7

Browse files
committed
les 01/02
1 parent 6abf4dd commit bf52ea7

File tree

22 files changed

+16452
-24461
lines changed

22 files changed

+16452
-24461
lines changed

les01/cards/code.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const jokerImg = "img/black_joker.png";
99
const backcoverImg = "img/cover_card.jpg";
1010

1111

12-
newGame = function(){
12+
function newGame(){
1313

1414
gameFinished = false;
1515
firstChoice = null;
@@ -18,16 +18,16 @@ newGame = function(){
1818
showBackCover(0);
1919
showBackCover(1);
2020
showBackCover(2);
21-
};
21+
}
2222

2323

24-
clickCard = function(index){
24+
function clickCard(index){
2525

2626
if(gameFinished){
2727
return;
2828
}
2929

30-
document.getElementById("img"+index).classList.add("selectedCard")
30+
document.getElementById("img"+index).classList.add("selectedCard");
3131

3232
if(firstChoice === null){
3333
//New game
@@ -58,69 +58,69 @@ clickCard = function(index){
5858
}
5959

6060
}
61-
};
61+
}
6262

63-
hideParagraphs = function(){
63+
function hideParagraphs(){
6464
document.getElementById("firstSelectId").style.display="none";
6565
document.getElementById("secondSelectId").style.display="none";
6666
document.getElementById("victoryId").style.display="none";
6767
document.getElementById("defeatId").style.display="none";
68-
};
68+
}
6969

70-
showFirstMessage = function(){
70+
function showFirstMessage(){
7171
hideParagraphs();
7272
document.getElementById("firstSelectId").style.display="block";
73-
};
73+
}
7474

75-
showSecondMessage = function(){
75+
function showSecondMessage(){
7676
hideParagraphs();
7777
document.getElementById("secondSelectId").style.display="block";
78-
};
78+
}
7979

80-
showVictory = function(){
80+
function showVictory(){
8181
hideParagraphs();
8282
document.getElementById("victoryId").style.display="block";
83-
};
83+
}
8484

85-
showDefeat = function(){
85+
function showDefeat(){
8686
hideParagraphs();
8787
document.getElementById("defeatId").style.display="block";
88-
};
88+
}
8989

9090

91-
showSpades = function (index) {
91+
function showSpades(index) {
9292
const img = document.getElementById("img"+index);
9393
img.src = spadesImg;
9494
img.style.cursor = "default";
9595
img.classList.remove("backcover")
96-
};
96+
}
9797

98-
showJoker = function (index) {
98+
function showJoker(index) {
9999
const img = document.getElementById("img"+index);
100100
img.src = jokerImg;
101101
img.style.cursor = "default";
102102
img.classList.remove("backcover")
103-
};
103+
}
104104

105-
showAll = function(){
105+
function showAll(){
106106
for(let i=0; i< positions.length; i++){
107107
if(i === jokerPosition){
108108
showJoker(i);
109109
} else {
110110
showSpades(i);
111111
}
112112
}
113-
};
113+
}
114114

115-
showBackCover = function (index) {
115+
function showBackCover(index) {
116116
const img = document.getElementById("img"+index);
117117
img.src = backcoverImg;
118118
img.style.cursor = "pointer";
119119
if(! img.classList.contains("backcover")) {
120120
img.classList.add("backcover")
121121
}
122122
img.classList.remove("selectedCard")
123-
};
123+
}
124124

125125

126126

les01/quiz/code.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const quizzes = [
2727

2828
let currentQuizIndex = 0;
2929

30-
answerTag = function (prefix, answer, correct) {
30+
function answerTag(prefix, answer, correct) {
3131

3232
let onclick;
3333

@@ -37,12 +37,12 @@ answerTag = function (prefix, answer, correct) {
3737
onclick = "alert('Wrong answer');";
3838
}
3939

40-
let html = "<div class='gameBtn' onclick=\""+onclick+"\">" + prefix + answer + "</div>";
40+
const html = "<div class='gameBtn' onclick=\""+onclick+"\">" + prefix + answer + "</div>";
4141

4242
return html;
43-
};
43+
}
4444

45-
displayQuiz = function (quiz) {
45+
function displayQuiz (quiz) {
4646

4747
let html = "<p class='question'>Question: \"" + quiz.question + "\"</p>";
4848
html += answerTag("A: ", quiz.answer_0, quiz.indexOfRightAnswer === 0);
@@ -53,9 +53,9 @@ displayQuiz = function (quiz) {
5353
const quizDiv = document.getElementById("quizDivId");
5454

5555
quizDiv.innerHTML = html;
56-
};
56+
}
5757

58-
displayNewQuiz = function(){
58+
function displayNewQuiz(){
5959

6060
let index = Math.floor(Math.random() * quizzes.length);
6161

@@ -67,4 +67,4 @@ displayNewQuiz = function(){
6767
currentQuizIndex = index;
6868

6969
displayQuiz(quiz);
70-
};
70+
}

les01/silly/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ <h2> A Silly Game </h2>
5454
other = "btn0"
5555
}
5656

57-
let divYes = document.getElementById(other);
58-
let divNo = document.getElementById(no);
57+
const divYes = document.getElementById(other);
58+
const divNo = document.getElementById(no);
5959

6060
divYes.innerHTML = "Yes";
6161
divNo.innerHTML = "No";

0 commit comments

Comments
 (0)