Skip to content
This repository was archived by the owner on Dec 25, 2023. It is now read-only.
/ noi-tu Public archive

Commit ebd26fd

Browse files
committed
modified: index.html
modified: main.js modified: style.css modified: words/words.js modified: words/words_gen.rb new file: words/words_start.js
1 parent 3639420 commit ebd26fd

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
</div>
2323

2424
<script type="text/javascript" src="words/words.js"></script>
25+
<script type="text/javascript" src="words/words_start.js"></script>
2526
<script type="text/javascript" src="main.js"></script>
2627
</body>
2728
</html>

main.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const scoreDisplay = document.getElementById("score");
22
const pieces = document.getElementById("pieces");
33
const warningBar = document.getElementById("warningBar");
4+
45
const buttonEnd = document.getElementById("buttonEnd");
56
const buttonInfo = document.getElementById("buttonInfo");
67
const buttonStartIcon = document.getElementById("buttonStartIcon");
@@ -39,7 +40,7 @@ function startGame() {
3940
score = 0;
4041
scoreDisplay.innerHTML = 0;
4142

42-
currentWord = words[Math.floor(Math.random() * words.length)].split(" ")[0];
43+
currentWord = words_start[Math.floor(Math.random() * 100)];
4344
pieces.innerHTML = `
4445
<div class="piece">
4546
<input class="shadow" disabled value="${currentWord}" />
@@ -99,8 +100,8 @@ function checkWord(event) {
99100

100101
const fullWord = `${currentWord} ${joinWordFormated}`;
101102

102-
if (! words.includes(fullWord)) { warning("Từ này không có trong từ điển"); return }
103-
if (history.includes(fullWord)) { warning("Từ này đã được sử dụng"); return }
103+
if (! words[currentWord].includes(joinWordFormated)) { warning("Từ này không có trong từ điển"); return }
104+
if (history.includes(fullWord) ) { warning("Từ này đã được sử dụng"); return }
104105

105106
history.push(fullWord);
106107
currentWord = joinWordFormated;
@@ -177,6 +178,8 @@ function scoreBoard() {
177178
<iframe class="shadow" src="https://docs.google.com/spreadsheets/d/e/2PACX-1vTgPJqsipjuAGyCwu-OpUJdbnlvqgPFHiXxBKESWwp50RbO0KaLBaJBhYwtLzHIIsUp2ll4-yZh2WGI/pubhtml?gid=1462957762&amp;single=true&amp;widget=true&amp;headers=false"></iframe>
178179
`;
179180

181+
warning();
182+
180183
buttonEnd.classList.add("disabled");
181184
buttonInfo.classList.remove("disabled");
182185
buttonStartIcon.classList.remove("la-redo-alt");

style.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@import url('https://fonts.googleapis.com/css?family=Comfortaa&display=swap');
33
@import url('https://fonts.googleapis.com/css?family=Lobster&display=swap');
44

5-
@font-face{
5+
@font-face {
66
font-family: "Bmono";
77
src: url("https://raw.githubusercontent.com/NNBnh/bmono/main/dist/bmono/woff2/bmono-regular.woff2") format("woff2");
88
}
@@ -220,7 +220,7 @@ body {
220220
}
221221

222222
iframe {
223-
height: 80vh;
223+
height: 70vh;
224224
width: 80vw;
225225
min-width: 20em;
226226
border-radius: 0.2em;

words/words.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

words/words_gen.rb

100644100755
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1+
#!/usr/bin/env ruby
12

3+
require "json"
4+
5+
words = {}
6+
File.readlines("words.txt").each do |word|
7+
first, last = word.split
8+
words[first] = Array(words[first]) + [last]
9+
end
10+
11+
words_start = words.sort_by { -_2.size } .first(100).to_h.keys
12+
13+
File.write("words.js", "const words = #{words.to_json};")
14+
File.write("words_start.js", "const words_start = #{words_start};")

words/words_start.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)