mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	Improved yosys.js example
This commit is contained in:
		
							parent
							
								
									4d34d031f9
								
							
						
					
					
						commit
						c2cc342e1a
					
				
					 1 changed files with 72 additions and 60 deletions
				
			
		|  | @ -1,11 +1,10 @@ | ||||||
| <html> | <html><head> | ||||||
|   <head> |  | ||||||
| 	<title>yosys.js example application</title> | 	<title>yosys.js example application</title> | ||||||
|   </head> | </head><body onload="document.getElementById('command').focus()"> | ||||||
|   <body onload="document.getElementById('command').focus()"> |  | ||||||
| 	<h1>yosys.js example application</h1> | 	<h1>yosys.js example application</h1> | ||||||
|     <div><textarea id="output" style="width: 100%" rows="30" cols="100">Loading...</textarea></div> | 	<div><textarea id="output" style="width: 100%" rows="30" cols="100"></textarea></div> | ||||||
|     <div><form onsubmit="return run_command()"><tt><span id="prompt"><br/>yosys> </span></tt><input id="command" type="text" size="100"></form></div> | 	<div id="wait" style="display: block"><br/><b><span id="waitmsg">Loading...</span></b></div> | ||||||
|  | 	<div id="input" style="display: none"><form onsubmit="return run_command()"><tt><span id="prompt"><br/>yosys> </span></tt><input id="command" type="text" size="100"></form></div> | ||||||
| 	<script type='text/javascript'> | 	<script type='text/javascript'> | ||||||
| 		var got_log_messages = false; | 		var got_log_messages = false; | ||||||
| 		var Module = { | 		var Module = { | ||||||
|  | @ -13,7 +12,12 @@ | ||||||
| 				var element = document.getElementById('output'); | 				var element = document.getElementById('output'); | ||||||
| 				if (element) element.value = ''; // clear browser cache | 				if (element) element.value = ''; // clear browser cache | ||||||
| 				return function(text) { | 				return function(text) { | ||||||
|  | 					if (!got_log_messages) { | ||||||
|  | 						document.getElementById('wait').style.display = 'none'; | ||||||
|  | 						document.getElementById('input').style.display = 'block'; | ||||||
|  | 						document.getElementById('waitmsg').innerText = 'Waiting for yosys.js...'; | ||||||
| 						got_log_messages = true; | 						got_log_messages = true; | ||||||
|  | 					} | ||||||
| 					if (element && typeof(text) != "number") { | 					if (element && typeof(text) != "number") { | ||||||
| 						element.value += text + "\n"; | 						element.value += text + "\n"; | ||||||
| 						element.scrollTop = element.scrollHeight; // focus on bottom | 						element.scrollTop = element.scrollHeight; // focus on bottom | ||||||
|  | @ -44,17 +48,25 @@ | ||||||
| 			var cmd = document.getElementById('command').value; | 			var cmd = document.getElementById('command').value; | ||||||
| 			document.getElementById('command').value = ''; | 			document.getElementById('command').value = ''; | ||||||
| 			Module.print(Module.prompt() + cmd); | 			Module.print(Module.prompt() + cmd); | ||||||
|  | 			document.getElementById('wait').style.display = 'block'; | ||||||
|  | 			document.getElementById('input').style.display = 'none'; | ||||||
|  | 
 | ||||||
|  | 			function run_command_bh() { | ||||||
| 				try { | 				try { | ||||||
| 					Module.command(cmd); | 					Module.command(cmd); | ||||||
| 				} catch (e) { | 				} catch (e) { | ||||||
| 					Module.print('Caught JavaScript exception. (see JavaScript console for details.)'); | 					Module.print('Caught JavaScript exception. (see JavaScript console for details.)'); | ||||||
| 					console.log(e); | 					console.log(e); | ||||||
| 				} | 				} | ||||||
| 	document.getElementById('command').focus(); | 				document.getElementById('wait').style.display = 'none'; | ||||||
|  | 				document.getElementById('input').style.display = 'block'; | ||||||
| 				document.getElementById('prompt').innerText = Module.prompt(); | 				document.getElementById('prompt').innerText = Module.prompt(); | ||||||
|  | 				document.getElementById('command').focus(); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			window.setTimeout(run_command_bh, 50); | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| 	</script> | 	</script> | ||||||
| 	<script async type="text/javascript" src="yosys.js"></script> | 	<script async type="text/javascript" src="yosys.js"></script> | ||||||
|   </body> | </body></html> | ||||||
| </html> |  | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue