1$(document).ready(function() { 2 getPreferences(); 3 createPage(); 4 5 $("#bot-type").change(function() { 6 let val = $(this).val(); 7 localStorage.setItem('bot_type', val); 8 setBotMode(val); 9 resetPage(); 10 // createPage(); 11 }); 12 13 $(document).on('input', '.warmle-selector', function() { 14 let val = $(this).val(); 15 localStorage.setItem('warmle_dist', val); 16 update(); 17 }); 18 19 $("#word-length").on('input', function() { 20 localStorage.setItem('word_length' + bot.type, $(this).val()); 21 createPage(); 22 }); 23 24 $("#max-guesses").on('input', function() { 25 localStorage.setItem('guesses' + bot.type, $(this).val()); 26 createPage(); 27 }); 28 29 $(".wordbank").on('input', function() { 30 if (!$(this).is(':checked')) { 31 $(this).prop('checked', true); 32 return; 33 } 34 35 localStorage.setItem('wordbank', $(this).attr('id')); 36 $("#" + otherWordbank($(this).attr('id'))).prop('checked', false); 37 setWordbank(); 38 update(); 39 }); 40 41 42 $("#word-entered").on('input', function(e) { 43 let val = $("#word-entered").val(); 44 if (val.length == word_length) { 45 if (!words.includes(val) && guessesMadeSoFar() > 0) { 46 return; 47 } 48 49 $("#word-entered").blur(); 50 51 makeTables(val); 52 53 if (word_length == 11) { 54 $(".tile").css('font-size', '1rem'); 55 } 56 } 57 }); 58 59 $(document).on('click', '.click', function() { 60 makeTables($(this).html()); 61 }) 62 63 $(document).on('click', '.showlist', function() { 64 if ($(this).children().hasClass("visible")) { 65 ($(this).children().removeClass("visible")); 66 } else { 67 $(this).children().addClass("visible"); 68 } 69 }); 70}); 71 72function createPage() { 73 drawPage(); 74 setLength(); 75 setWordbank(); 76 update(); 77} 78 79function resetPage() { 80 spotle = false; 81 82 clearGrids(); 83 clearHTML(document.getElementById('next-previous-buttons')); 84 drawPage(); 85 update(); 86} 87 88function clearGrids() { 89 let grids = document.getElementsByClassName('grid'); 90 91 for (let i = 0; i < grids.length; i++) { 92 clearHTML(grids[i]); 93 } 94 95 let full_grid = document.getElementById('hints'); 96 full_grid.classList.add('empty'); 97 98 drawPage(); 99 update(); 100} 101 102function getPreferences() { 103 if (localStorage.getItem('bot_type')) { 104 let bot_type = localStorage.getItem('bot_type'); 105 setBotMode(bot_type); 106 document.getElementById('bot-type').value = bot_type; 107 } else { 108 setBotMode(WORDLE); 109 } 110 111 if (localStorage.getItem('wordbank')) { 112 let bank = localStorage.getItem('wordbank'); 113 document.getElementById(bank).checked = true; 114 document.getElementById(otherWordbank(bank)).checked = false; 115 setWordbank() 116 } 117 118 // if (bot.isFor(WARMLE) && localStorage.getItem('warmle_dist')) { 119 // let dist = localStorage.getItem('warmle_dist'); 120 // document.getElementsByClassName('warmle-selector')[0].value = dist; 121 // } 122} 123 124function otherWordbank(bank) { 125 if (bank == 'restricted') return 'complete'; 126 return 'restricted'; 127} 128 129function drawPage() {
130 let container = document.getElementById('container'); 131 let header = document.getElementById('top-of-screen'); 132 let hints = document.getElementById('hints'); 133 134 addGrid(hints); 135 136 createMainHeader(header); 137 createWordLengthSelector(); 138 139 createGuessInput(container); 140 createAnswerSuggestions(container); 141 142 updateSettings(); 143} 144 145function updateSettings() { 146 let extra = document.getElementsByClassName('extra-settings')[0]; 147 148 if (bot.isFor(WARMLE)) { 149 let selector = createElement('select', '', 'warmle-selector'); 150 151 for (let i = 3; i >= 1; i--) { 152 let option = createElement('option', i); 153 option.value = i; 154 selector.append(option); 155 } 156 157 setHTML(extra, 158 "Yellows are " + selector.outerHTML + " letters away from the correct letter."); 159 160 if (localStorage.getItem('warmle_dist')) { 161 document.getElementsByClassName('warmle-selector')[0].value = localStorage.getItem('warmle_dist'); 162 } 163 } else { 164 clearHTML(extra); 165 } 166} 167 168function addGrid(hints) { 169 clearHTML(hints); 170 171 for (let i = 0; i < bot.getCount(); i++) { 172 let grid = createElement('div', '', 'grid'); 173 hints.append(grid); 174 } 175 176 if (bot.isFor(SPOTLE)) { 177 setUpBlankGrid(); 178 } 179} 180 181function setUpBlankGrid() { 182 let grid_size = 6; 183 184 for (let i = 0; i < grid_size; i++) { 185 makeTables(" ".repeat(word_length)); 186 } 187 188 addFinalizeGridButton(); 189} 190 191function addFinalizeGridButton() { 192 clearHTML(document.getElementById('next-previous-buttons')); 193 194 let finalize = createElement('button', 'finalize grid', 'finalize'); 195 let button_container = document.getElementById('next-previous-buttons'); 196 197 finalize.addEventListener('click', function () { 198 update(); 199 }); 200 201 button_container.append(finalize); 202} 203 204function createMainHeader(div) { 205 let main_header = document.getElementById('top-of-screen'); 206 let title = main_header.getElementsByTagName('h1')[0]; 207 208 title.innerHTML = bot.type + ' Calcle'; 209 main_header.append(title); 210} 211 212function createWordLengthSelector() { 213 let select_length = document.getElementById('word-length'); 214 215 let options = ""; 216 for (let i = SMALLEST_WORD; i <= LARGEST_WORD; i++) { 217 let selected = ""; 218 if (i == 5) selected = "selected = 'selected'"; 219 options += "<option value='" + i + "' " + selected +">" + i + "</option>"; 220 } 221 222 if (bot.isFor(THIRDLE)) { 223 localStorage.setItem('word_length' + bot.type, 3); 224 options = "<option value ='3' selected = 'selected'>3</option>"; 225 } 226 227 if (bot.isFor(SPOTLE)) { 228 localStorage.setItem('word_length' + bot.type, 5); 229 options = "<option value ='5' selected = 'selected'>5</option>"; 230 } 231 232 select_length.innerHTML = options; 233 234 if (localStorage.getItem('word_length'+ bot.type) && (localStorage.getItem('word_length'+ bot.type) >= SMALLEST_WORD || bot.isFor(THIRDLE))) { 235 select_length.value = localStorage.getItem('word_length'+ bot.type); 236 } 237} 238 239function createMaxGuesses(div) { 240 let max_input = document.getElementById('max-guesses'); 241 242 let options = ""; 243 for (let i = 3; i <= 21; i++) { 244 let selected = ""; 245 if (i == 6) selected = "selected = 'selected'"; 246 options += "<option value='" + i + "' " + selected +">" + i + "</option>"; 247 } 248 249 if (bot.isFor(THIRDLE)) { 250 localStorage.setItem('guesses' + bot.type, 3); 251 options = "<option value ='3' selected = 'selected'>3</option>"; 252 } 253 254 if (bot.isFor(SPOTLE)) { 255 localStorage.setItem('guesses' + bot.type, 6); 256 options = "<option value ='6' selected = 'selected'>6</option>"; 257 } 258 259 max_input.innerHTML = options; 260 261 if (localStorage.getItem('guesses' + bot.type)) { 262 max_input.value = localStorage.getItem('guesses' + bot.type); 263 } 264} 265 266const EXAMPLE_LIST = 267 [ 268 {word: 'BLOKE', score: '2.188 guesses left', wrong: '96.77% solve rate'}, 269 {word: 'YOLKS', score: '2.250 guesses left'}, 270 {word: 'KOELS', score: '2.250 guesses left'}, 271 {word: 'KYLOE', score: '2.250 guesses left'} 272 ]; 273 274function createExample() { 275 let example_row = createRow('TRAIN', 'dummy'); 276 bot.setRowColor('GBYBB', example_row); 277 278 let example_list = createElement('ul', '', 'word-list dummy'); 279 280 for (let i = 0; i < EXAMPLE_LIST.length; i++) { 281 // example_list.innerHTML += createListItem(EXAMPLE_LIST[i].word, EXAMPLE_LIST[i].score, i+1); 282 example_list.append(createListItem(EXAMPLE_LIST[i].word, EXAMPLE_LIST[i].score, i+1)); 283 } 284 285 return {row: example_row, list: example_list}; 286} 287 288function createWrongExample() { 289 let example_wrong = createElement('ul', '', 'word-list dummy'); 290 // example_wrong.innerHTML = createListItem(EXAMPLE_LIST[0].word, EXAMPLE_LIST[0].wrong, 1); 291 example_wrong.append(createListItem(EXAMPLE_LIST[0].word, EXAMPLE_LIST[0].wrong, 1)); 292 293 return example_wrong; 294} 295 296function makeCloseButton(type) {
297 let close_button = createElement('button', '', type + ' close'); 298 return close_button; 299} 300 301function createInfoParagraphs() { 302 let p1 = createElement('p', `Simply enter in your last guess, click on the tiles until the colors match, hit calculate, 303 and the WordleBot will give you the best possible guesses from that point.`); 304 305 let p2 = createElement('p', `This means the best guess from this point would be ` + EXAMPLE_LIST[0].word + `, 306 and that you have an average of ` + EXAMPLE_LIST[0].score + `. If you see:`); 307 308 let p3 = createElement('p', `That means ` + EXAMPLE_LIST[0].word + ` will only solve 96.77% of the remaining possible answers within ` + bot.guessesAllowed() + ` guesses. 309 Generally speaking, you should only see this if you're playing on hard mode.`); 310 311 let p4 = createElement('p', `Want to see how good your starting word is? Click the 312 <button class = 'test dummy' disabled><i class="gg-bot"></i></button> on the top right to get a good idea.`); 313 314 return [p1, p2, p3, p4] 315} 316 317function explainExample() { 318 let explanation = createElement('div', '', 'description'); 319 320 if (bot.isFor(WORDLE)) { 321 explanation.innerHTML = 'T is in the correct position, A is in the word but not in the correct position, and R, I, and N are not in the word.' 322 } 323 324 if (bot.isFor(WOODLE)) { 325 explanation.innerHTML = 'TRAIN has one letter in the correct position, and one letter in the word, but not in the correct position'; 326 } 327 328 if (bot.isFor(PEAKS)) { 329 explanation.innerHTML = 'The 1st letter of the word is T, the second 2nd letter comes before R in the alphabet, the 3rd comes after A, the 4th before I, and the 5th before N.'; 330 } 331 332 return explanation; 333} 334 335function createInfoPage() { 336 let info = document.getElementsByClassName('info screen')[0]; 337 if (info.classList.contains('display')) return; 338 339 let close_button = makeCloseButton('info'); 340 let example = createExample(); 341 let explanation = explainExample(); 342 let example_wrong = createWrongExample(); 343 let paragraphs = createInfoParagraphs(); 344 345 let main_header = createElement('h3', 'How does this Work?', 'top-header'); 346 let sub_header = createElement('h3', 'After each guess you should see something like this:', 'mini'); 347 348 info.append(close_button); // button to close screen 349 info.append(main_header); // 'how does this work' 350 info.append(paragraphs[0]); // intro paragraph 351 info.append(sub_header); // header to examples 352 info.append(example.row); // example row w/ colors 353 info.append(explanation) // explanation of tiles 354 info.append(example.list); // example answer list 355 info.append(paragraphs[1]); // explanation of answer list 356 info.append(example_wrong); // example answer list with wrong % 357 info.append(paragraphs[2]); // explanation of wrong % 358 info.append(paragraphs[3]); // bot paragraph 359 360 info.classList.remove('back'); 361 info.classList.add('display'); 362 363 close_button.addEventListener('click', function() { 364 info.classList.remove("display"); 365 info.classList.add("back"); 366 clearHTML(info); 367 }); 368} 369 370function createSettingsPage() { 371 let settings = document.getElementsByClassName('settings screen')[0]; 372 373 settings.classList.remove('hide'); 374 settings.classList.add('display'); 375 376 let close = settings.getElementsByClassName('close')[0]; 377 close.addEventListener('click', function() { 378 settings.classList.remove("display"); 379 settings.classList.add("hide"); 380 }); 381} 382 383function createGuessInput(div) { 384 let input = document.getElementById('word-entered'); 385 setInputAttributes(input); 386} 387 388function setInputAttributes(input) { 389 input.setAttribute('autocomplete', 'off'); 390 input.setAttribute('placeholder', 'enter your guess here'); 391 input.setAttribute('onkeypress', 'return /[a-z]/i.test(event.key)'); 392 input.setAttribute('oninput', 'this.value = this.value.toUpperCase()'); 393} 394 395function createAnswerSuggestions() { 396 let suggestions = document.getElementById('suggestions'); 397 398 if (bot.hasHardMode() && !document.getElementById('mode')) { 399 createHardModeSwitch(suggestions); 400 } else if (!bot.hasHardMode() && document.getElementById('mode')) { 401 removeHardModeSwitch(suggestions); 402 } 403 404 if (bot.hasMax()) { 405 createMaxGuesses(suggestions); 406 } else { 407 let max = document.getElementById('max-guesses'); 408 localStorage.setItem('guesses' + bot.type, 'infinity'); 409 max.innerHTML = "<option value ='infinity' selected = 'selected'> ∞ </option>"; 410 } 411 412 createAnswerLists(suggestions); 413} 414 415function createAnswerLists(div) { 416 if (document.getElementById('answers')) { 417 document.getElementById('answers').remove(); 418 } 419 420 let answer_lists = createElement('div', '', '', 'answers'); 421 422 createOptions(answer_lists); 423 div.append(answer_lists); 424} 425 426function createOptions(div) { 427 let best_guesses = createElement('div', '', 'best-guesses'); 428 let word_list = createElement('ul', '', 'word-list'); 429 430 best_guesses.append(word_list); 431 div.append(best_guesses); 432} 433 434function createHardModeSwitch(div) { 435 let switch_label = createElement('div', "Show me the best guesses for 'Hard Mode':", 'hard label'); 436 let switch_container = createElement('label', '', 'hard switch'); 437 let switch_slider = createElement('span', '', 'slider round'); 438 let switch_checkbox = createElement('input', '', '', 'mode'); 439 switch_checkbox.setAttribute('type', 'checkbox'); 440 441 switch_container.append(switch_checkbox); 442 switch_container.append(switch_slider); 443 444 let header = document.getElementsByClassName('mini-title')[0]; 445 div.insertBefore(switch_label, header); 446 div.insertBefore(switch_container, header); 447 448 switch_checkbox.addEventListener('change', function() { 449 update(); 450 }); 451} 452 453function removeHardModeSwitch() { 454 let label = document.getElementsByClassName('hard label')[0];
455 let container = document.getElementsByClassName('hard switch')[0]; 456 457 if (label) label.remove(); 458 if (container) container.remove(); 459}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.