diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fd1294f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +charset = utf-8 +trim_trailing_whitespace = true + +end_of_line = lf +insert_final_newline = true + +indent_style = space +indent_size = 4 diff --git a/README.md b/README.md new file mode 100644 index 0000000..ad814f9 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Codsworth name generator +Choose a fitting name for your _Fallout 4_ character that Codsworth can pronounce. +This tool gives you a list of names that look like yours so that you can pretend he's saying the right name. diff --git a/index.html b/index.html index c691aac..b2ff4ee 100644 --- a/index.html +++ b/index.html @@ -11,230 +11,238 @@ Codsworth name generator - - - - + -
- -
-
-

Codsworth name generator

-
-

These generators use the - - list of names that can be pronounced by Codsworth to help you find an appropriate name - for your character. -

-
-
-
- - - +
+ +
- -
-
-

Similar names

-
-
-

Random names

-
-
- -
-
- - -
-
-
- -
-
- - - - -
-
- - - - -
-
+

Codsworth name generator

+ +
+

+ These generators use the + + list of names that can be pronounced by Codsworth + + to help you find an appropriate name for your character. +

+
+
- - -
+ +
+ +
+
+

Similar names

+
+
+

Random names

+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + + + +
+
+ + + + +
+
+
- - - - + + + // Returns `amount` best matches + getSimilar(amount) { + const similar = []; + + for (let i = 0; i < amount; i++) + similar[i] = this.hits_[i][0]; + + return similar; + }; + } + + + /// Event handling + const generateSimilar = () => { + const name = $("#similarInput").value; + if (name === undefined || name === "") + return; + + const names = (new JaroWinkler(name)).getSimilar(similarCount); + $("#similarNames").value = names.join("\n"); + }; + + $("#generateSimilar").onclick = generateSimilar; + $("#similarInput").addEventListener("keypress", e => { + if (e.key === "Enter") { + generateSimilar(); + e.preventDefault(); + } + }); + + + const randNamer = new Name(randomCount); + const generateRandom = () => { + randNamer.addRandom(); + + const randOutput = $("#randomNames"); + randOutput.value = randNamer.getHistory("\n"); + randOutput.scrollTop = randOutput.scrollHeight; + }; + + $("#generateRandom").onclick = generateRandom; +