-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 19ffe0b
Showing
16 changed files
with
783 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Some addtional features for website like: copying nicknames to clipboard, dropdown lists logic. | ||
// | ||
|
||
// Function to copy nickname | ||
function copyNickname() { | ||
const nicknameField = document.getElementById("nickname"); | ||
nicknameField.select(); | ||
document.execCommand("copy"); | ||
alert("Nickname copied: " + nicknameField.value); | ||
} | ||
|
||
|
||
// Dropdown lists (for language and nationality selection) | ||
function toggleDropdown(selector) { | ||
document.querySelector(selector).classList.toggle("active"); | ||
} | ||
|
||
document.addEventListener("click", function (event) { | ||
document.querySelectorAll(".dropdown").forEach(dropdown => { | ||
if (!dropdown.contains(event.target)) { | ||
dropdown.classList.remove("active"); | ||
} | ||
}); | ||
}); | ||
|
||
function changeSelection(selector, targetId, value) { | ||
document.getElementById(targetId).textContent = value; | ||
document.querySelector(selector).classList.remove("active"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// The logic for generating character nicknames is described here. | ||
// | ||
|
||
// Loading data from the file names.json | ||
let namesData = {}; | ||
|
||
fetch("names.json") | ||
.then(response => response.json()) | ||
.then(data => namesData = data) | ||
.catch(error => console.error("ERROR: Data loading error:", error)); | ||
|
||
// Main function | ||
function generateNickname() { | ||
// Getting user selection... | ||
const gender = document.querySelector("input[name='gender']:checked")?.id; | ||
const nationality = document.getElementById("selected-nationality").textContent.toLowerCase(); | ||
|
||
// Some checks so that the user cannot miss a choice | ||
if (!gender) { | ||
alert("ERROR: Please select the character's gender."); | ||
return; | ||
} | ||
if (nationality === "select option") { | ||
alert("ERROR: Please select the character's nationality."); | ||
return; | ||
} | ||
|
||
// Getting arrays of names and surnames... | ||
const firstNames = namesData[gender]?.[nationality]?.first_names; | ||
const lastNames = namesData[gender]?.[nationality]?.last_names; | ||
|
||
// Checking for availability of data for selected parameters (does the file names.json contain similar parameters and data for them) | ||
if (!firstNames || !lastNames) { | ||
alert("ERROR: No data for such parameters."); | ||
return; | ||
} | ||
|
||
// Random generation | ||
const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)]; | ||
const randomLastName = lastNames[Math.floor(Math.random() * lastNames.length)]; | ||
|
||
// Updating nickname in nicknamebox | ||
document.getElementById("nickname").value = `${randomFirstName}_${randomLastName}`; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.