mirror of
				https://github.com/fooflington/wordsearch.git
				synced 2025-10-31 04:38:33 +00:00 
			
		
		
		
	working web
This commit is contained in:
		
							
								
								
									
										22
									
								
								war/about.html
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										22
									
								
								war/about.html
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| <html> | ||||
| <head> | ||||
| 	<title>About</title> | ||||
| </head> | ||||
|  | ||||
| <body> | ||||
| 	<h1>Wordsearch Builder: About</h1> | ||||
| 	Wordsearch Builder takes a list of words and places them on a grid in any direction allowing the to cross-over where possible then fills in the remaining empty spaces with semi-random letters. | ||||
| 	<h2>Basic algorithm</h2> | ||||
| 	<ol> | ||||
| 		<li>Foreach word | ||||
| 			<ol> | ||||
| 				<li>Pick a direction at random</li> | ||||
| 				<li>Compute possible start points based on word length, direction and grid size</li> | ||||
| 				<li>Begin placing word. If an occupied cell is encountered which contains a different character than would go in for this word, then abort and start this word again.</li> | ||||
| 			</ol> | ||||
| 		</li> | ||||
| 		<li>When all words are placed, infill the remaining cells with random characters weighted by <a href="https://www.math.cornell.edu/~mec/2003-2004/cryptography/subs/frequencies.html">standard English letter frequencies</a></li> | ||||
| 	</ol> | ||||
| 	The abort-and-retry word placement to try 500 times before giving up. | ||||
| </body> | ||||
| </html> | ||||
| @@ -7,10 +7,28 @@ | ||||
| 		border-collapse: collapse; | ||||
| 		padding: 2px 4px; | ||||
| 	} | ||||
|  | ||||
| 	#grid { | ||||
| 		font-family: monospace; font-size: 16; | ||||
| 	} | ||||
|  | ||||
| 	#wrapper { | ||||
| 		width: 80%; | ||||
| 		margin: 0 auto; | ||||
| 	} | ||||
| 	#wordsearch { | ||||
| 		float: left; | ||||
| 	} | ||||
|  | ||||
| 	#words { | ||||
| 		float: right; | ||||
| 		width: 200px; | ||||
| 	} | ||||
| 	</style> | ||||
| </head> | ||||
| <%@ page import="uk.org.mafoo.wordsearch.*" %> | ||||
| <%@ page import="java.util.*" %> | ||||
| <%@ page import="org.apache.commons.lang.StringUtils" %> | ||||
| <%@ page errorPage="error.jsp" %> | ||||
| <% | ||||
|  | ||||
| @@ -24,31 +42,52 @@ | ||||
| 	for ( String line : request.getParameter("words").split("\r\n")) { | ||||
| 		words.add(line.trim()); | ||||
| 	} | ||||
|   	 | ||||
|   	Collections.sort(words); | ||||
|  | ||||
|  | ||||
|   	char[][] grid = GridFactory.makeGrid(words, height, width); | ||||
|  | ||||
|   	String csv = ""; | ||||
| %> | ||||
| <body> | ||||
| <h1>Wordsearch builder</h1> | ||||
| <h2>Words</h2> | ||||
|  | ||||
| <div style="float: right; padding: 15px;"> | ||||
| 	<ul> | ||||
| 	<% for (String word : words) { %> | ||||
| 	   <li><%= word.trim() %></li> | ||||
| 	<% } %> | ||||
| 	</ul> | ||||
| <a id='csvdownload'>Download CSV</a> | ||||
| <script> | ||||
|     var csv = '<%= csv %>'; | ||||
|     var csvdownload = document.getElementById('csvdownload'); | ||||
|     csvdownload.href='data:text/csv;base64,' + btoa(csv); | ||||
| </script> | ||||
| </div> | ||||
|  | ||||
| <h2>Grid</h2> | ||||
| <table style="font-family: monospace; font-size: 16;"> | ||||
| <% for(char[] row : grid) { %> | ||||
| 	<tr> | ||||
| 		<% for(char c : row) { %> | ||||
| 		<td><%= c %></td> | ||||
| 		<% } %> | ||||
| 	</tr> | ||||
| <% } %> | ||||
| </table> | ||||
| <div id="wrapper"> | ||||
| <div id="wordsearch"> | ||||
| 	<h2>Grid</h2> | ||||
| 	<table id="grid"> | ||||
| 	<% for(char[] row : grid) { %> | ||||
| 		<tr> | ||||
| 			<% for(char c : row) {  | ||||
| 				csv += "" + c + ','; | ||||
| 			%> | ||||
| 			<td><%= c %></td> | ||||
| 			<% 	} %> | ||||
| 		</tr> | ||||
| 	<%  | ||||
| 		csv += "\\n"; | ||||
| 		} | ||||
| 	%> | ||||
| 	</table> | ||||
| </div> <!-- end wordsearch -->  | ||||
|  | ||||
| <div id="words"> | ||||
| 	<h2>Words</h2> | ||||
| 		<ul> | ||||
| 		<% for (String word : words) { %> | ||||
| 		   <li><%= word.trim() %></li> | ||||
| 		<% } %> | ||||
| 		</ul> | ||||
| </div> <!-- end words --> | ||||
| </div> <!-- end wrapper -->  | ||||
| <br /> | ||||
| <div> | ||||
| </body> | ||||
| </html> | ||||
|   | ||||
| @@ -2,8 +2,10 @@ | ||||
| <head><title>Wordsearch builder</title></head> | ||||
| <body> | ||||
| <h1>Wordsearch builder</h1> | ||||
| <a href="about.html">About</a> | ||||
|  | ||||
| <h2>Words</h2> | ||||
| <form action="build.jsp"> | ||||
| <form action="build.jsp" method="post"> | ||||
| <textarea name="words" rows="10"> | ||||
| Kitchen | ||||
| Lounge | ||||
|   | ||||
		Reference in New Issue
	
	Block a user