Fix ANSI code formatting
This commit is contained in:
parent
178f2d472a
commit
c683472895
|
@ -13,16 +13,29 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<br><br>
|
<br><br>
|
||||||
<iframe type="text/html" src="{{url_for('static', filename='logs/1.txt')}}" width="100%" height="85%" id="embed">
|
<iframe type="text/html" src="{{url_for('static', filename='logs/1.txt')}}" width="100%" height="85%" id="embed"></iframe>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script defer>
|
||||||
const subdoc = document.getElementsByTagName("iframe")[0].contentWindow.document;
|
const iframe = document.getElementsByTagName("iframe")[0];
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
|
|
||||||
|
// Wait until ansi_up load
|
||||||
script.onload = function () {
|
script.onload = function () {
|
||||||
const ansiOutput = subdoc.getElementsByTagName("body")[0].getElementsByTagName("pre")[0]
|
// Wait until iframe load
|
||||||
const ansi_up = new AnsiUp();
|
iframe.onload = function() {
|
||||||
ansiOutput.innerHTML = ansi_up.ansi_to_html(ansiOutput.innerText)
|
const subdoc = iframe.contentWindow.document;
|
||||||
|
const subBody = subdoc.getElementsByTagName("body")[0]
|
||||||
|
let ansiOutput = subBody;
|
||||||
|
// Depending on the content encoding (and maybe on the browser)
|
||||||
|
// a <pre> is added around the content of the file
|
||||||
|
if (subBody.getElementsByTagName("pre").length > 0) {
|
||||||
|
ansiOutput = subBody.getElementsByTagName("pre")[0];
|
||||||
|
}
|
||||||
|
const ansi_up = new AnsiUp();
|
||||||
|
ansiOutput.innerHTML = ansi_up.ansi_to_html(ansiOutput.innerText);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
script.src = "https://cdn.jsdelivr.net/npm/ansi_up@4.0.4/ansi_up.js";
|
script.src = "https://cdn.jsdelivr.net/npm/ansi_up@4.0.4/ansi_up.js";
|
||||||
document.head.appendChild(script);
|
document.head.appendChild(script);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue