-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
174 lines (163 loc) · 8.08 KB
/
index.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
<!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>Chemcile - Chemistry Wordle</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
</head>
<body>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-WFLQJ4CXXV"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-WFLQJ4CXXV');
</script>
<style>
.block {
width: 80px;
height: 80px;
border: 2px;
border-color: grey;
border-style: solid;
/* background-color: green; */
/* display:inline; */
display: inline-block;
font-size: 70px;
}
</style>
<h1>Chemcile - Chemistry Wordle</h1>
<p>I have not made a cool UI yet and we don't have many forumal in the dataset, you can help me if you want!!!
<a hred="https://github.com/weathon/chemcile">https://github.com/weathon/chemcile</a></p>
<p> notice that the length will change and the word each time will be different</p>
<p>Part of the list is from https://byjus.com/chemical-compound-formulas/</p>
<p>How to play: enter a forumal in the text box and press guess. The grey box means there is no this char in the answer. Yellow means there is but it is in the wrong location; and green means it is in the right location. Pink box is from hint.</p>
<!-- yanjingsuanlaoshi sikaokunwanyanjingyangkeosu -->
<!-- <div class="block">a</div> -->
<!-- <span > -->
<!-- di=yahcixkouxueyaxkoutthanghuangkoukexkou -->
<div id="block_set"></div>
<input id="i"></input>
<button onclick="guess()">Guess</button>
<!-- </span> -->
<button onclick="alert(word)">Show answer</button>
<button onclick="hint()">Hint (Show one char)</button>
<script>
function hint()
{
if (document.getElementById("i").value.length != word.length) {
alert("Wrong length!")
return
}
// if(!(document.getElementById("i").value in Glist)) //()
if (!Glist.includes(document.getElementById("i").value)) //shouzang jianpanbaocuohuangyouianbushanglelongxkousuanyunkun 100 cpu suan hlong ram bugoule taiduole xkouduzi huangxkou
// if(!Glist.includes(word)) //shouzang jianpanbaocuohuangyouianbushanglelongxkousuanyunkun 100 cpu suan hlong ram bugoule taiduole xkouduzi huangxkou
{
alert("Not in the list")
return
}
if(Math.random()>0)
{
thisTimeDone = false;
document.getElementById("block_set").innerHTML += "<br/>"
for(var i=0; i <done.length; i++)
{
if(done[i]==0 && !thisTimeDone)
{
if(Number(word[i]) || word[i]=='0')
{
thishtml = "<span style='font-size:30px'>"+word[i]+"</span>"
}
else{
thishtml = word[i]
}
document.getElementById("block_set").innerHTML += "<div class='block' style='border-color:gold;background-color:lightpink'>" + thishtml + "</div>"
done[i] = 1;
thisTimeDone = true;
}
else
{
if(Number(document.getElementById("i").value[i]) || document.getElementById("i").value[i]=='0')
{
thishtml = "<span style='font-size:30px'>"+document.getElementById("i").value[i]+"</span>"
}
else{
thishtml = document.getElementById("i").value[i]
}
if (word[i] == document.getElementById("i").value[i]) {
done[i]=1
document.getElementById("block_set").innerHTML += "<div class='block' style='background-color:lightgreen'>" + thishtml + "</div>"
}
else {
document.getElementById("block_set").innerHTML += "<div class='block' style='background-color:gray'>?</div>"
// if (word.indexOf(document.getElementById("i").value[i]) != -1) {
// document.getElementById("block_set").innerHTML += "<div class='block' style='background-color:lightyellow'>" + thishtml + "</div>"
// }
// else {
// document.getElementById("block_set").innerHTML += "<div class='block' style='background-color:gray'>" + thishtml + "</div>"
// // document.getElementById("block_set").innerHTML += "<div class='block' style='background-color:gray'>" + word[i] + "</div>"
// }
}
}
}
}
}
word = "?"
Glist = []
done = []
fetch('https://chemcile.weasoft.com/list.json')
.then(response => response.json())
.then(function (list) {
// words = list.split('\n');
console.log(list)
Glist = list
word = list[parseInt(Math.random() * list.length)]
for(var _=0;_<word.length;_++){
done.push(0)
}
// console.log(word)
document.getElementById("block_set").innerHTML = "<div class='block'></div>".repeat(word.length)
});
function guess() {
if (document.getElementById("i").value.length != word.length) {
alert("Wrong length!")
return
}
// if(!(document.getElementById("i").value in Glist)) //()
if (!Glist.includes(document.getElementById("i").value)) //shouzang jianpanbaocuohuangyouianbushanglelongxkousuanyunkun 100 cpu suan hlong ram bugoule taiduole xkouduzi huangxkou
// if(!Glist.includes(word)) //shouzang jianpanbaocuohuangyouianbushanglelongxkousuanyunkun 100 cpu suan hlong ram bugoule taiduole xkouduzi huangxkou
{
alert("Not in the list")
return
}
document.getElementById("block_set").innerHTML += "<br/>"
for (var i = 0; i < word.length; i++) {
thishtml = ""
if(Number(document.getElementById("i").value[i]) || document.getElementById("i").value[i]=='0')
{
thishtml = "<span style='font-size:30px'>"+document.getElementById("i").value[i]+"</span>"
}
else{
thishtml = document.getElementById("i").value[i]
}
if (word[i] == document.getElementById("i").value[i]) {
done[i]=1
document.getElementById("block_set").innerHTML += "<div class='block' style='background-color:lightgreen'>" + thishtml + "</div>"
}
else {
if (word.indexOf(document.getElementById("i").value[i]) != -1) {
document.getElementById("block_set").innerHTML += "<div class='block' style='background-color:lightyellow'>" + thishtml + "</div>"
}
else {
document.getElementById("block_set").innerHTML += "<div class='block' style='background-color:gray'>" + thishtml + "</div>"
// document.getElementById("block_set").innerHTML += "<div class='block' style='background-color:gray'>" + word[i] + "</div>"
}
}
}
}
</script>
</body>
</html>