Skip to content

Commit

Permalink
frontend: handle UTF-8 characters in GraphViz graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
xddxdd committed Jun 30, 2024
1 parent 6575658 commit f0f072c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion frontend/assets/templates/bgpmap.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@
<script src="/static/jsdelivr/npm/[email protected]/viz.min.js" crossorigin="anonymous"></script>
<script src="/static/jsdelivr/npm/[email protected]/lite.render.js" crossorigin="anonymous"></script>
<script>
function decodeBase64(base64) {
const text = atob(base64);
const length = text.length;
const bytes = new Uint8Array(length);
for (let i = 0; i < length; i++) {
bytes[i] = text.charCodeAt(i);
}
const decoder = new TextDecoder();
return decoder.decode(bytes);
}
var viz = new Viz();
viz.renderSVGElement(atob({{ .Result }}))
viz.renderSVGElement(decodeBase64({{ .Result }}))
.then(element => {
document.getElementById("bgpmap").appendChild(element);
})
Expand Down

0 comments on commit f0f072c

Please sign in to comment.