mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Improved yosys.js example
This commit is contained in:
parent
4d34d031f9
commit
c2cc342e1a
132
misc/yosys.html
132
misc/yosys.html
|
@ -1,60 +1,72 @@
|
||||||
<html>
|
<html><head>
|
||||||
<head>
|
<title>yosys.js example application</title>
|
||||||
<title>yosys.js example application</title>
|
</head><body onload="document.getElementById('command').focus()">
|
||||||
</head>
|
<h1>yosys.js example application</h1>
|
||||||
<body onload="document.getElementById('command').focus()">
|
<div><textarea id="output" style="width: 100%" rows="30" cols="100"></textarea></div>
|
||||||
<h1>yosys.js example application</h1>
|
<div id="wait" style="display: block"><br/><b><span id="waitmsg">Loading...</span></b></div>
|
||||||
<div><textarea id="output" style="width: 100%" rows="30" cols="100">Loading...</textarea></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>
|
||||||
<div><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 = {
|
print: (function() {
|
||||||
print: (function() {
|
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) {
|
||||||
got_log_messages = true;
|
document.getElementById('wait').style.display = 'none';
|
||||||
if (element && typeof(text) != "number") {
|
document.getElementById('input').style.display = 'block';
|
||||||
element.value += text + "\n";
|
document.getElementById('waitmsg').innerText = 'Waiting for yosys.js...';
|
||||||
element.scrollTop = element.scrollHeight; // focus on bottom
|
got_log_messages = true;
|
||||||
}
|
}
|
||||||
};
|
if (element && typeof(text) != "number") {
|
||||||
})(),
|
element.value += text + "\n";
|
||||||
printErr: (function() {
|
element.scrollTop = element.scrollHeight; // focus on bottom
|
||||||
var element = document.getElementById('output');
|
}
|
||||||
if (element) element.value = ''; // clear browser cache
|
};
|
||||||
return function(text) {
|
})(),
|
||||||
if (element && typeof(text) != "number") {
|
printErr: (function() {
|
||||||
console.log(text);
|
var element = document.getElementById('output');
|
||||||
if (got_log_messages) {
|
if (element) element.value = ''; // clear browser cache
|
||||||
element.value += text + "\n";
|
return function(text) {
|
||||||
element.scrollTop = element.scrollHeight; // focus on bottom
|
if (element && typeof(text) != "number") {
|
||||||
}
|
console.log(text);
|
||||||
}
|
if (got_log_messages) {
|
||||||
};
|
element.value += text + "\n";
|
||||||
})(),
|
element.scrollTop = element.scrollHeight; // focus on bottom
|
||||||
command: (function(cmd) {
|
}
|
||||||
Module.ccall('run', '', ['string'], [cmd])
|
}
|
||||||
}),
|
};
|
||||||
prompt: (function(cmd) {
|
})(),
|
||||||
return Module.ccall('prompt', 'string', [], [])
|
command: (function(cmd) {
|
||||||
})
|
Module.ccall('run', '', ['string'], [cmd])
|
||||||
};
|
}),
|
||||||
function run_command() {
|
prompt: (function(cmd) {
|
||||||
var cmd = document.getElementById('command').value;
|
return Module.ccall('prompt', 'string', [], [])
|
||||||
document.getElementById('command').value = '';
|
})
|
||||||
Module.print(Module.prompt() + cmd);
|
};
|
||||||
try {
|
function run_command() {
|
||||||
Module.command(cmd);
|
var cmd = document.getElementById('command').value;
|
||||||
} catch (e) {
|
document.getElementById('command').value = '';
|
||||||
Module.print('Caught JavaScript exception. (see JavaScript console for details.)');
|
Module.print(Module.prompt() + cmd);
|
||||||
console.log(e);
|
document.getElementById('wait').style.display = 'block';
|
||||||
}
|
document.getElementById('input').style.display = 'none';
|
||||||
document.getElementById('command').focus();
|
|
||||||
document.getElementById('prompt').innerText = Module.prompt();
|
function run_command_bh() {
|
||||||
return false;
|
try {
|
||||||
}
|
Module.command(cmd);
|
||||||
</script>
|
} catch (e) {
|
||||||
<script async type="text/javascript" src="yosys.js"></script>
|
Module.print('Caught JavaScript exception. (see JavaScript console for details.)');
|
||||||
</body>
|
console.log(e);
|
||||||
</html>
|
}
|
||||||
|
document.getElementById('wait').style.display = 'none';
|
||||||
|
document.getElementById('input').style.display = 'block';
|
||||||
|
document.getElementById('prompt').innerText = Module.prompt();
|
||||||
|
document.getElementById('command').focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
window.setTimeout(run_command_bh, 50);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script async type="text/javascript" src="yosys.js"></script>
|
||||||
|
</body></html>
|
||||||
|
|
Loading…
Reference in a new issue