Crossword Generator
by phyreman
HTML
<div id="crossword"><p>
It make take a while to create a crossword, or it may not. Please be patient.
</p>
<p id="status">Starting generator...</p>
<button id="quit">
Give up
</button>
</div>
CSS
#crossword {
text-align: center;
font-size: 28px;
}
.crossword {
border-collapse: collapse;
font-family: "Courier New", Courier, monospace;
font-size: 32px;
font-weight: bold;
text-transform: uppercase;
margin-left: auto;
margin-right: auto;
clear: both;
margin-top: 10px;
margin-bottom: 10px;
}
.crossword td {
border: 1px solid black;
padding: 0;
margin: 0;
vertical-align: middle;
padding: 0;
text-align: center;
line-height: 0px;
width: 30px;
height: 30px;
}
JavaScript
/*
Copyright (c) 2011 Matt Johnson
Copyright (c) 2017 John-Michael Glenn
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Helper function to bulid web workers from the contents of a given function
function makeWorker(func) {
return new Worker(URL.createObjectURL(new Blob([`self.addEventListener('message', ${func.toString()} ,false);`])));
}
/*
function* permute(permutation) {
const length = permutation.length;
let c = Array(length).fill(0),
i = 1,
k, p;
yield permutation;
while (i < length) {
if (c[i] < i) {
k = (i % 2) ? c[i] : 0,
p = permutation[i];
permutation[i] = permutation[k];
permutation[k] = p;
++c[i];
i = 1;
yield permutation;
} else {
c[i] = 0;
++i;
}
}
}*/
function work(e) {
// Each cell on the crossword grid is null or one of these
function CrosswordCell(letter) {
this.char = letter; // the actual letter for the cell on the crossword
// If a word hits this cell going in the "across"...