<commit_before>const SERVERS = [
	{
		name: "Mineplex",
		game: "Draw My Thing",
		wordList: "./wordlist-mineplex.txt",
		maxWordCount: 3,  // Maximum number of words
		defaultWordCount: 1,
		//              1wd  2words  3words
		minWordLength: [[2], [3, 3], [3, 2, 4]],  // Here if the user selects 3 words for example, then the minimum of the
		                                          // first word is 3 letters, 2 letters for the second and 4 for the third
		maxWordLength: [[11], [9, 6], [4, 3, 7]], // Same thing with maximum
		                                          // There doesn't have to be a guess that matches the extremums:
		                                          // ex: There might not be a guess that has 2 words with 3 letters each but there might be two
		                                          // guesses like that: big feet, round pig. In this case, 3 letters is possible for both words
		defaultWordLength: [[5], [5, 4], [3, 2, 4]],
	},
	{
		name: "Hive",
		game: "Draw It",
		wordList: "./wordlist-hive.txt",
		maxWordCount: 2,
		defaultWordCount: 1,
		minWordLength: [[3], [3, 3]],
		maxWordLength: [[12], [6, 7]],
		defaultWordLength: [[5], [5, 5]],
	},
	// You can add more servers if you want, they will appear in the list automatically
]

const DEFAULT_SERVER_INDEX = 0;
const MAXIMUM_POSSIBLE_LENGTH = 15; // Excluding spaces, no word must be bigger than this (maximum number of hint inputs)
const HINT_SPACE_WIDTH = "40px";

const MAX_WORDS_SHOWN = 20;
const SPLIT_WORDS_COLUMN_AT = 10;

var selectedServer = SERVERS[DEFAULT_SERVER_INDEX];
var wordList;
var wordCount;
var wordLength;

var rawWordLength;
var spaceIndexes;
var matchWords;
var allWordsShown;
var copiedWords;
var currentHint;

var wordCountRadio;
var wordLengthSpinner;
var hintInput;
var listLeftColumn;
var listRightColumn
var showAllBtn;
var resetCopyBtn;

/**
	Called when a server is selected
	@param server Server object
*/
function onServerSelected(server) {

	selectedServer = server;
	currentHint = 0;

	// Load word list for that server
    var rawFile = new XMLHttpRequest();
    rawFile.open("GET", server.wordList, false);
    rawFile.onreadystatechange = function() {
        if (rawFile.readyState === 4) {
            if (rawFile.status === 200 || rawFile.status === 0) {
                wordList = rawFile.responseText.split(",").sort();
            }
        }
    };
    rawFile.send(null);

	document.getElementById("title").innerHTML = server.game + " Cheat";

	document.getElementById("word-list-modal-title").innerHTML = "Complete list of known words for this server <b>- " + wordList.length + " words</b>";
	document.getElementById("word-list-modal-list").innerHTML = wordList.join("<br>");

	// Select default settings for that server
	wordCount = server.defaultWordCount
	wordCountRadio[wordCount-1].checked = true;
	onWordCountChanged(wordCount);

	if (server.maxWordCount == 1) {
		document.getElementById("word-count-div").style.display = "none";
	} else if (server.maxWordCount == 2) {
		document.getElementById("word-count-div").style.display = "block";
		document.getElementById("word-count-2").style.display = "inline";
		document.getElementById("word-count-3").style.display = "none";
	} else {
		document.getElementById("word-count-div").style.display = "block";
		document.getElementById("word-count-2").style.display = "inline";
		document.getElementById("word-count-3").style.display = "inline";
	}
}

/**
	Called when number of words radio is checked
	@param count Between 0 and 2 depending on the server (1-3)
*/
function onWordCountChanged(count) {

	wordLength = selectedServer.defaultWordLength[count-1];
	for (var i = 0; i < (count == 1 ? 1 : count+1); i++) {
		var word = (i <= 1 ? 0 : i-1);
		wordLengthSpinner[i].min = selectedServer.minWordLength[count-1][word];
		wordLengthSpinner[i].max = selectedServer.maxWordLength[count-1][word];
		wordLengthSpinner[i].value = wordLength[word];
	}
	onWordLengthChanged();

	if (count == 1) {
		document.getElementById("single-word-length-div").style.display = "block";
		document.getElementById("multiple-word-length-div").style.display = "none";
	} else if (count == 2) {
		document.getElementById("single-word-length-div").style.display = "none";
		document.getElementById("multiple-word-length-div").style.display = "block";
		document.getElementById("word-length-label-3").style.display = "none";
	} else {
		document.getElementById("single-word-length-div").style.display = "none";
		document.getElementById("multiple-word-length-div").style.display = "block";
		document.getElementById("word-length-label-3").style.display = "inline";
	}
}

/**
	Called when word length spinner value is changed
	@param length New length of the word
*/
function onWordLengthChanged() {
	// Adjust hint inputs to match words lengths
	rawWordLength = 0;
	spaceIndexes = [];
	for (var i = 0; i < wordCount; i++) {
		rawWordLength += wordLength[i];
		if (wordCount != 1 && i < wordCount-1) spaceIndexes.push(rawWordLength);
	}
	var spaces = spaceIndexes.slice(0);
	for (var i = 0; i < MAXIMUM_POSSIBLE_LENGTH; i++) {
		hintInput[i].style.display = (i < rawWordLength ? "inline" : "none");
		hintInput[i].value = "";
		if (spaces.length > 0 && i == spaces[0]) {
			// Add left margin to add space between words
			hintInput[i].style.marginLeft = HINT_SPACE_WIDTH;
			spaces.shift();
		} else {
			hintInput[i].style.marginLeft = "5px";  // Reset margin
		}
	}

	findWords();  // Find words matching new length
}<commit_msg>Fixed Reset Input popping up everywhere<commit_after>const SERVERS = [
	{
		name: "Mineplex",
		game: "Draw My Thing",
		wordList: "./wordlist-mineplex.txt",
		maxWordCount: 3,  // Maximum number of words
		defaultWordCount: 1,
		//              1wd  2words  3words
		minWordLength: [[2], [3, 3], [3, 2, 4]],  // Here if the user selects 3 words for example, then the minimum of the
		                                          // first word is 3 letters, 2 letters for the second and 4 for the third
		maxWordLength: [[11], [9, 6], [4, 3, 7]], // Same thing with maximum
		                                          // There doesn't have to be a guess that matches the extremums:
		                                          // ex: There might not be a guess that has 2 words with 3 letters each but there might be two
		                                          // guesses like that: big feet, round pig. In this case, 3 letters is possible for both words
		defaultWordLength: [[5], [5, 4], [3, 2, 4]],
	},
	{
		name: "Hive",
		game: "Draw It",
		wordList: "./wordlist-hive.txt",
		maxWordCount: 2,
		defaultWordCount: 1,
		minWordLength: [[3], [3, 3]],
		maxWordLength: [[12], [6, 7]],
		defaultWordLength: [[5], [5, 5]],
	},
	// You can add more servers if you want, they will appear in the list automatically
]

const DEFAULT_SERVER_INDEX = 0;
const MAXIMUM_POSSIBLE_LENGTH = 15; // Excluding spaces, no word must be bigger than this (maximum number of hint inputs)
const HINT_SPACE_WIDTH = "40px";

const MAX_WORDS_SHOWN = 20;
const SPLIT_WORDS_COLUMN_AT = 10;

var selectedServer = SERVERS[DEFAULT_SERVER_INDEX];
var wordList;
var wordCount;
var wordLength;

var rawWordLength;
var spaceIndexes;
var matchWords;
var allWordsShown;
var copiedWords;
var currentHint;

var wordCountRadio;
var wordLengthSpinner;
var hintInput;
var listLeftColumn;
var listRightColumn
var showAllBtn;
var resetCopyBtn;

/**
	Called when a server is selected
	@param server Server object
*/
function onServerSelected(server) {

	selectedServer = server;
	currentHint = 0;

	// Load word list for that server
    var rawFile = new XMLHttpRequest();
    rawFile.open("GET", server.wordList, false);
    rawFile.onreadystatechange = function() {
        if (rawFile.readyState === 4) {
            if (rawFile.status === 200 || rawFile.status === 0) {
                wordList = rawFile.responseText.split(",").sort();
            }
        }
    };
    rawFile.send(null);

	document.getElementById("title").innerHTML = server.game + " Cheat";

	document.getElementById("word-list-modal-title").innerHTML = "Complete list of known words for this server <b>- " + wordList.length + " words</b>";
	document.getElementById("word-list-modal-list").innerHTML = wordList.join("<br>");

	// Select default settings for that server
	wordCount = server.defaultWordCount
	wordCountRadio[wordCount-1].checked = true;
	onWordCountChanged(wordCount);

	if (server.maxWordCount == 1) {
		document.getElementById("word-count-div").style.display = "none";
	} else if (server.maxWordCount == 2) {
		document.getElementById("word-count-div").style.display = "block";
		document.getElementById("word-count-2").style.display = "inline";
		document.getElementById("word-count-3").style.display = "none";
	} else {
		document.getElementById("word-count-div").style.display = "block";
		document.getElementById("word-count-2").style.display = "inline";
		document.getElementById("word-count-3").style.display = "inline";
	}
}

/**
	Called when number of words radio is checked
	@param count Between 0 and 2 depending on the server (1-3)
*/
function onWordCountChanged(count) {

	wordLength = selectedServer.defaultWordLength[count-1];
	for (var i = 0; i < (count == 1 ? 1 : count+1); i++) {
		var word = (i <= 1 ? 0 : i-1);
		wordLengthSpinner[i].min = selectedServer.minWordLength[count-1][word];
		wordLengthSpinner[i].max = selectedServer.maxWordLength[count-1][word];
		wordLengthSpinner[i].value = wordLength[word];
	}
	onWordLengthChanged();

	if (count == 1) {
		document.getElementById("single-word-length-div").style.display = "block";
		document.getElementById("multiple-word-length-div").style.display = "none";
	} else if (count == 2) {
		document.getElementById("single-word-length-div").style.display = "none";
		document.getElementById("multiple-word-length-div").style.display = "block";
		document.getElementById("word-length-label-3").style.display = "none";
	} else {
		document.getElementById("single-word-length-div").style.display = "none";
		document.getElementById("multiple-word-length-div").style.display = "block";
		document.getElementById("word-length-label-3").style.display = "inline";
	}
}

/**
	Called when word length spinner value is changed
	@param length New length of the word
*/
function onWordLengthChanged() {
	// Adjust hint inputs to match words lengths
	rawWordLength = 0;
	spaceIndexes = [];
	for (var i = 0; i < wordCount; i++) {
		rawWordLength += wordLength[i];
		if (wordCount != 1 && i < wordCount-1) spaceIndexes.push(rawWordLength);
	}
	var spaces = spaceIndexes.slice(0);
	for (var i = 0; i < MAXIMUM_POSSIBLE_LENGTH; i++) {
		hintInput[i].style.display = (i < rawWordLength ? "inline" : "none");
		hintInput[i].value = "";
		if (spaces.length > 0 && i == spaces[0]) {
			// Add left margin to add space between words
			hintInput[i].style.marginLeft = HINT_SPACE_WIDTH;
			spaces.shift();
		} else {
			hintInput[i].style.marginLeft = "5px";  // Reset margin
		}
	}

	findWords();  // Find words matching new length
	var x = document.getElementById("resetletters");
	x.style.display = 'none';
}
{'fraction_non_alphanumeric': 0.13894642053129222, 'fraction_numerical': 0.016569113012156685, 'mean_word_length': 3.489086499595796, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2911564', 'n_tokens_mistral': 3663, 'n_tokens_neox': 3385, 'n_words': 954}