mirror of https://github.com/YosysHQ/yosys.git
YosysJS fixes for firefox
This commit is contained in:
parent
3e5e9a3889
commit
4c22195c38
|
@ -4,8 +4,8 @@
|
|||
</head><body onload="document.getElementById('command').focus()">
|
||||
<h1>YosysJS Example Application #01</h1>
|
||||
<table width="100%"><tr><td><div id="tabs"></div></td><td align="right"><tt>[ <span onclick="load_example()">load example</span> ]</tt></td></tr></table>
|
||||
<svg id="svg" style="display: none; position: absolute; padding: 10px; width: calc(100% - 40px);"></svg>
|
||||
<div><textarea id="output" style="width: 100%" rows="30" cols="100"></textarea></div>
|
||||
<svg id="svg" style="display: none; position: absolute; padding: 10px; width: calc(100% - 40px); height: 480px;"></svg>
|
||||
<div><textarea id="output" style="width: 100%; height: 500px"></textarea></div>
|
||||
<div id="wait" style="display: block"><br/><b><span id="waitmsg">Loading...</span></b></div>
|
||||
<div id="input" style="display: none"><form onsubmit="window.setTimeout(run_command); return false"><br/><tt><span id="prompt">
|
||||
</span></tt><input id="command" type="text" onkeydown="history(event)" style="font-family: monospace; font-weight: bold;" size="100"></form></div>
|
||||
|
|
|
@ -22,7 +22,7 @@ var YosysJS = new function() {
|
|||
}
|
||||
|
||||
this.dot_into_svg = function(dot_text, svg_element) {
|
||||
if (typeof(svg_element) == 'string')
|
||||
if (typeof(svg_element) == 'string' && svg_element != "")
|
||||
svg_element = document.getElementById(svg_element);
|
||||
svg_element.innerHTML = this.dot_to_svg(dot_text);
|
||||
c = svg_element.firstChild;
|
||||
|
@ -43,9 +43,10 @@ var YosysJS = new function() {
|
|||
ys.init_script = "";
|
||||
ys.ready = false;
|
||||
ys.verbose = false;
|
||||
ys.logprint = false;
|
||||
ys.echo = false;
|
||||
|
||||
if (typeof(reference_element) == 'string')
|
||||
if (typeof(reference_element) == 'string' && reference_element != "")
|
||||
reference_element = document.getElementById(reference_element);
|
||||
|
||||
if (reference_element) {
|
||||
|
@ -80,33 +81,51 @@ var YosysJS = new function() {
|
|||
return;
|
||||
ys.print_buffer += text + "\n";
|
||||
ys.got_normal_log_message = true;
|
||||
if (ys.logprint)
|
||||
console.log(text);
|
||||
if (ys.verbose) {
|
||||
ys.last_line_empty = text == "";
|
||||
span = doc.createElement('span');
|
||||
span.textContent = text + "\n";
|
||||
span.style.fontFamily = 'monospace';
|
||||
span.style.whiteSpace = 'pre';
|
||||
doc.body.appendChild(span);
|
||||
ys.window.scrollTo(0, doc.body.scrollHeight)
|
||||
if (text == "") {
|
||||
span = doc.createElement('br');
|
||||
} else {
|
||||
span = doc.createElement('span');
|
||||
span.textContent = text + "\n";
|
||||
span.style.fontFamily = 'monospace';
|
||||
span.style.whiteSpace = 'pre';
|
||||
}
|
||||
doc.firstChild.appendChild(span);
|
||||
if (doc.body)
|
||||
ys.window.scrollTo(0, doc.body.scrollHeight);
|
||||
else
|
||||
ys.window.scrollBy(0, 100);
|
||||
}
|
||||
ys.ready = true;
|
||||
},
|
||||
printErr: function(text) {
|
||||
if (typeof(text) == 'number')
|
||||
return;
|
||||
if (ys.logprint)
|
||||
console.log(text);
|
||||
if (ys.got_normal_log_message) {
|
||||
ys.print_buffer += text + "\n";
|
||||
ys.last_line_empty = text == "";
|
||||
span = doc.createElement('span');
|
||||
span.textContent = text + "\n";
|
||||
span.style.fontFamily = 'monospace';
|
||||
span.style.whiteSpace = 'pre';
|
||||
span.style.color = 'red';
|
||||
doc.body.appendChild(span);
|
||||
ys.window.scrollTo(0, doc.body.scrollHeight)
|
||||
} else {
|
||||
if (text == "") {
|
||||
span = doc.createElement('br');
|
||||
} else {
|
||||
span = doc.createElement('span');
|
||||
span.textContent = text + "\n";
|
||||
span.style.fontFamily = 'monospace';
|
||||
span.style.whiteSpace = 'pre';
|
||||
span.style.color = 'red';
|
||||
}
|
||||
doc.firstChild.appendChild(span);
|
||||
if (doc.body)
|
||||
ys.window.scrollTo(0, doc.body.scrollHeight);
|
||||
else
|
||||
ys.window.scrollBy(0, 100);
|
||||
} else
|
||||
if (!ys.logprint)
|
||||
console.log(text);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -148,10 +167,9 @@ var YosysJS = new function() {
|
|||
return ys.window.FS.readdir(dirname);
|
||||
}
|
||||
|
||||
el = doc.createElement('script');
|
||||
el.type = 'text/javascript';
|
||||
el.src = this.url_prefix + 'yosys.js';
|
||||
doc.head.appendChild(el);
|
||||
doc.open()
|
||||
doc.write('<script type="text/javascript" src="' + this.url_prefix + 'yosys.js"></' + 'script>');
|
||||
doc.close()
|
||||
|
||||
if (on_ready || ys.init_script) {
|
||||
function check_ready() {
|
||||
|
|
Loading…
Reference in New Issue