mirror of
https://gitlab.constantvzw.org/osp/tools.cobbled-paths.git
synced 2024-12-23 04:51:25 +01:00
116 lines
2.9 KiB
HTML
116 lines
2.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<script src="/static/js/FileSaver.js"></script>
|
|
<style>
|
|
#save-svg{
|
|
position: fixed;
|
|
top: 0.5em;
|
|
right: 0.5em;
|
|
}
|
|
.svgbob text {
|
|
font-family: monospace !important;
|
|
font-weight: bold !important;
|
|
fill: red !important;
|
|
}
|
|
.svgbob text{
|
|
visibility: hidden;
|
|
}
|
|
body.check-text .svgbob text{
|
|
visibility: visible;
|
|
}
|
|
.double-font{
|
|
height: 100vh;
|
|
display: grid;
|
|
grid-template-rows: 1fr 1fr;
|
|
gap: 1rem;
|
|
margin: 0;
|
|
}
|
|
.double-font div{
|
|
background-color: white;
|
|
border: 1px solid black;
|
|
overflow: auto;
|
|
padding: 1rem;
|
|
font-family: monospace;
|
|
font-size: 1rem;
|
|
}
|
|
.f-ascii{
|
|
font-family: monospace;
|
|
font-size: 1rem;
|
|
|
|
}
|
|
.f-svg svg{
|
|
overflow: visible;
|
|
}
|
|
input, button{
|
|
font-family: monospace;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="double-font">
|
|
|
|
<div class="f-svg">
|
|
{{ svg|safe }}
|
|
</div>
|
|
|
|
<div class="f-ascii"><pre>{{ ascii|safe }}</pre></div>
|
|
|
|
<div id="save-buttons">
|
|
<button id="save-svg">get SVG</button>
|
|
<button id="save-hpgl">get HPGL</button>
|
|
</div>
|
|
|
|
<script>
|
|
function get2bodyclass(){
|
|
const url = new URL(window.location.href);
|
|
let checked = url.searchParams.get("c");
|
|
if(checked == "false"){
|
|
document.body.classList.remove("check-text");
|
|
}
|
|
else{
|
|
document.body.classList.add("check-text");
|
|
}
|
|
}
|
|
get2bodyclass();
|
|
</script>
|
|
|
|
<script>
|
|
let save_button = document.getElementById('save-svg');
|
|
|
|
save_button.addEventListener('click', function(){
|
|
//get svg element.
|
|
let svg = document.getElementsByTagName("svg")[0];
|
|
|
|
//get svg source.
|
|
let serializer = new XMLSerializer();
|
|
let source = serializer.serializeToString(svg);
|
|
|
|
let blob = new Blob([source], {type: "text/plain;charset=utf-8"});
|
|
saveAs(blob, 'cobbled-paths.svg');
|
|
});
|
|
|
|
let save_button_hpgl = document.getElementById('save-hpgl');
|
|
save_button_hpgl.addEventListener('click', function () {
|
|
let url = document.URL,
|
|
parts = url.split('/'),
|
|
name = parts[parts.length-1],
|
|
hpgl_url = '/hpgl/' + name,
|
|
a = document.createElement('a');
|
|
a.href = hpgl_url;
|
|
a.setAttribute('download', 'download');
|
|
if (document.createEvent) {
|
|
const event = document.createEvent('MouseEvents');
|
|
event.initEvent('click', true, true);
|
|
a.dispatchEvent(event);
|
|
}
|
|
else {
|
|
a.click();
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html> |