mirror of
https://github.com/sigmasternchen/axowall
synced 2025-03-15 08:38:55 +00:00
migrating element structure to javascript
This commit is contained in:
parent
44f96fffe9
commit
52fb006041
2 changed files with 30 additions and 22 deletions
24
index.html
24
index.html
|
@ -6,7 +6,7 @@
|
||||||
.captcha {
|
.captcha {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
padding: 20px;
|
padding: 19px;
|
||||||
border: 1px solid grey;
|
border: 1px solid grey;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
@ -78,29 +78,9 @@
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener("load", () => {
|
|
||||||
[...document.querySelectorAll(".captcha .checkbox")].forEach(c => c.addEventListener("click", async function() {
|
|
||||||
const result = document.getElementById("result");
|
|
||||||
result.innerText = "Calculating...";
|
|
||||||
|
|
||||||
this.classList.add("loading");
|
|
||||||
|
|
||||||
const challenge = makeSuffix(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)) + ":" + makeSuffix(new Date().valueOf()) + ":";
|
|
||||||
|
|
||||||
const response = await findHashWithPrefix(15, challenge);
|
|
||||||
result.innerText = "Challenge Response: " + response;
|
|
||||||
|
|
||||||
this.classList.remove("loading");
|
|
||||||
this.classList.add("checked");
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="captcha">
|
<div class="captcha"></div>
|
||||||
<div class="checkbox"></div>
|
|
||||||
<span>I am not a robot.</span>
|
|
||||||
</div>
|
|
||||||
<div id="result"></div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
28
main.js
28
main.js
|
@ -51,3 +51,31 @@ async function findHashWithPrefix(hashPrefixBits, inputPrefix) {
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener("load", () => {
|
||||||
|
console.log("load");
|
||||||
|
[...document.getElementsByClassName("captcha")].forEach(captcha => {
|
||||||
|
console.dir(captcha);
|
||||||
|
const checkbox = document.createElement("div");
|
||||||
|
checkbox.classList.add("checkbox");
|
||||||
|
captcha.append(checkbox);
|
||||||
|
|
||||||
|
const text = document.createElement("span");
|
||||||
|
text.innerText = "I am not a robot";
|
||||||
|
captcha.append(text);
|
||||||
|
|
||||||
|
checkbox.addEventListener("click", async function() {
|
||||||
|
console.log("Calculating...");
|
||||||
|
|
||||||
|
this.classList.add("loading");
|
||||||
|
|
||||||
|
const challenge = makeSuffix(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)) + ":" + makeSuffix(new Date().valueOf()) + ":";
|
||||||
|
|
||||||
|
const response = await findHashWithPrefix(15, challenge);
|
||||||
|
console.log("Challenge Response: " + response);
|
||||||
|
|
||||||
|
this.classList.remove("loading");
|
||||||
|
this.classList.add("checked");
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue