mirror of
https://github.com/ssyyhhrr/stewardle.git
synced 2025-11-13 12:33:45 -05:00
Number Input Fix
This commit is contained in:
2
app.js
2
app.js
@@ -180,7 +180,7 @@ function server() {
|
|||||||
else response.push(3) // incorrect nationality
|
else response.push(3) // incorrect nationality
|
||||||
|
|
||||||
// constructors
|
// constructors
|
||||||
if (guess.constructors[guess.constructors.length - 1] == actual.constructors[guess.constructors.length - 1]) response.push(1) // correct constructor
|
if (guess.constructors[guess.constructors.length - 1] == actual.constructors[actual.constructors.length - 1]) response.push(1) // correct constructor
|
||||||
else if (actual.constructors.includes(guess.constructors[guess.constructors.length - 1])) response.push(4) // previous constructor
|
else if (actual.constructors.includes(guess.constructors[guess.constructors.length - 1])) response.push(4) // previous constructor
|
||||||
else response.push(3) // incorrect constructor
|
else response.push(3) // incorrect constructor
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ document.addEventListener("keyup", async function (event) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (potential <= 1 || document.getElementsByClassName("autocomplete-items")[0].children.length <= 1) {
|
if (potential == 1 || document.getElementsByClassName("autocomplete-items")[0].children.length == 1 && value.replace(/[0-9]/g, '') != "") {
|
||||||
document.getElementById("myInput").value = ""
|
document.getElementById("myInput").value = ""
|
||||||
var x = document.getElementsByClassName("autocomplete-items");
|
var x = document.getElementsByClassName("autocomplete-items");
|
||||||
for (var i = 0; i < x.length; i++) {
|
for (var i = 0; i < x.length; i++) {
|
||||||
@@ -215,14 +215,18 @@ document.addEventListener("keyup", async function (event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let element = document.getElementById("myInput")
|
shake()
|
||||||
element.style.removeProperty("animation")
|
|
||||||
setTimeout(() => element.style.animation = "shake .5s", 100)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function shake() {
|
||||||
|
let element = document.getElementById("myInput")
|
||||||
|
element.style.removeProperty("animation")
|
||||||
|
setTimeout(() => element.style.animation = "shake .5s", 100)
|
||||||
|
}
|
||||||
|
|
||||||
function similarity(s1, s2) {
|
function similarity(s1, s2) {
|
||||||
var longer = s1;
|
var longer = s1;
|
||||||
var shorter = s2;
|
var shorter = s2;
|
||||||
@@ -234,7 +238,7 @@ function similarity(s1, s2) {
|
|||||||
if (longerLength == 0) {
|
if (longerLength == 0) {
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
return (longer.includes(shorter)) ? (longerLength - editDistance(longer, shorter)) / parseFloat(longerLength) : 0;
|
return (longer.toLowerCase().includes(shorter.toLowerCase())) ? (longerLength - editDistance(longer, shorter)) / parseFloat(longerLength) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function editDistance(s1, s2) {
|
function editDistance(s1, s2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user