Skip to content

Commit

Permalink
Improve js logger
Browse files Browse the repository at this point in the history
  • Loading branch information
ayjayt committed Oct 28, 2024
1 parent cb72d4f commit 341a0bc
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/py/kaleido/scopes/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,12 @@ def make_page_string(self):
<title>Kaleido-fier</title>
<script>
window.KaleidoReport = ["no error"];
window.addEventListener('error', function (e) {
if (typeof window.KaleidoReport == 'undefined') {
window.KaleidoReport = new Array();
}
if (navigator.onLine) {
window.KaleidoReport.push(e);
} else {
function logError(e) {
window.KaleidoReport.push(e);
if (!navigator.onLine) {
window.KaleidoReport.push("offline");
}
});
}
</script>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
Expand All @@ -110,12 +106,12 @@ def make_page_string(self):
pjs = "https://cdn.plot.ly/plotly-2.35.2.min.js"
elif not pjs.startswith("http") and not pjs.startswith("file"):
pjs = Path(pjs).absolute().as_uri()
page += f" <script src=\"{pjs}\" charset=\"utf-8\"></script>\n"
page += f" <script src=\"{pjs}\" charset=\"utf-8\" onerror=\"logError('plotly')\"></script>\n"

if self._mathjax:
page += f" <script type=\"text/javascript\" id=\"MathJax-script\" src=\"{self._mathjax}?config=TeX-AMS-MML_SVG\"></script>\n"
page += f" <script type=\"text/javascript\" id=\"MathJax-script\" src=\"{self._mathjax}?config=TeX-AMS-MML_SVG\" onerror=\"logError('mathjax')\"></script>\n"
page+= \
f""" <script src="{Path(self._plotlyfier).absolute().as_uri()}"></script>"""+\
f""" <script src="{Path(self._plotlyfier).absolute().as_uri()}" onerror=\"logError('scoper')\"></script>"""+\
""" </head>
<body style=\"{margin: 0; padding: 0;}\"><img id=\"kaleido-image\"><img></body>
</html>"""
Expand Down

0 comments on commit 341a0bc

Please sign in to comment.