2024-03-26 23:49:45 +01:00
|
|
|
<!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">
|
2024-03-27 18:16:06 +01:00
|
|
|
<script src="/static/js/FileSaver.js"></script>
|
2024-09-10 00:36:05 +02:00
|
|
|
<link rel="stylesheet" type="text/css" href="/static/css/basics.css" />
|
2024-09-19 11:13:50 +02:00
|
|
|
<link rel="stylesheet" type="text/css" href="/static/css/svg.css" />
|
2024-03-26 23:49:45 +01:00
|
|
|
</head>
|
2024-03-27 18:16:06 +01:00
|
|
|
|
|
|
|
<body>
|
|
|
|
|
2024-03-26 23:49:45 +01:00
|
|
|
{{ svg|safe }}
|
2024-03-27 18:16:06 +01:00
|
|
|
|
2024-06-07 11:22:07 +02:00
|
|
|
<div id="save-buttons">
|
2024-09-10 00:36:05 +02:00
|
|
|
<label for="text-checkbox"
|
2024-09-19 11:13:50 +02:00
|
|
|
title="display the remaining text and markers in the svg output in red">
|
|
|
|
preview</label>
|
|
|
|
<input id="text-checkbox" type="checkbox" class="body-class-check" value="check-text" data-name="c" data-frame="svg-iframe"/>
|
2024-06-09 15:35:30 +02:00
|
|
|
<button id="save-svg">get SVG</button>
|
|
|
|
<button id="save-hpgl">get HPGL</button>
|
2024-06-07 11:22:07 +02:00
|
|
|
</div>
|
2024-03-28 10:42:47 +01:00
|
|
|
|
|
|
|
<script>
|
2024-09-10 00:36:05 +02:00
|
|
|
function toggle_class(classname, val){
|
|
|
|
if(val){
|
|
|
|
document.body.classList.add(classname);
|
2024-03-28 10:42:47 +01:00
|
|
|
}
|
|
|
|
else{
|
2024-09-10 00:36:05 +02:00
|
|
|
document.body.classList.remove(classname);
|
2024-03-28 10:42:47 +01:00
|
|
|
}
|
|
|
|
}
|
2024-09-10 00:36:05 +02:00
|
|
|
let body_class_checkboxes = document.getElementsByClassName("body-class-check");
|
|
|
|
for(let checkbox of body_class_checkboxes){
|
|
|
|
let classname = checkbox.value;
|
|
|
|
checkbox.addEventListener('input', function(){
|
|
|
|
toggle_class(classname, checkbox.checked);
|
|
|
|
});
|
|
|
|
toggle_class(classname, checkbox.checked);
|
|
|
|
}
|
2024-03-28 10:42:47 +01:00
|
|
|
</script>
|
2024-03-27 18:16:06 +01:00
|
|
|
|
|
|
|
<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');
|
|
|
|
});
|
2024-06-07 11:22:07 +02:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|
2024-03-27 18:16:06 +01:00
|
|
|
</script>
|
|
|
|
|
2024-03-26 23:49:45 +01:00
|
|
|
</body>
|
|
|
|
</html>
|