tools.cobbled-paths/templates/draw.html

87 lines
2.7 KiB
HTML
Raw Normal View History

2024-03-09 13:22:52 +01:00
{% extends "base.html" %}
{% block body_class %}draw{% endblock %}
{% block body %}
<header class="controls">
<label>etherpad</label>
<input id="pad-name" type="text" value="{{params['pad']}}" data-name="p"/>
<button id="button-pad" data-use="pad-name">go</button>
2024-03-09 13:22:52 +01:00
<hr>
<button id="button-svg">generate</button>
2024-03-09 13:22:52 +01:00
<!-- <label>weight</label>
<input class="get-input" type="range" min="1" max="8" value="{{params['weight']}}" data-name="w"/> -->
2024-03-09 13:22:52 +01:00
<!-- <label class="text-label" for="text-checkbox"
2024-03-09 13:22:52 +01:00
title="display the remaining text in the svg output in red">
output text</label>
<input id="text-checkbox" type="checkbox"
class="body-class-check" value="check-text" checked/> -->
2024-03-09 13:22:52 +01:00
<script>
function updateGET(frame, param, value){
// object from GET parameters
let [base_src, params_src] = frame.src.split("?");
let params = new URLSearchParams(params_src);
// update param
params.set(param, value);
// reconstituate URL
let new_src = base_src + "?" + params.toString();
// set and refresh
frame.src = new_src;
2024-03-09 13:22:52 +01:00
}
let button_pad = document.getElementById('button-pad');
let button_svg = document.getElementById('button-svg');
// --- pad go button
button_pad.addEventListener('click', function(){
let svg_iframe = document.getElementById('svg-iframe');
let pad_iframe = document.getElementById('pad-iframe');
let input = document.getElementById(button_pad.dataset.use);
let value = input.value;
let param = input.dataset.name;
let pad_src = pad_iframe.src;
pad_src = pad_src.split('-');
pad_src[pad_src.length-1] = value;
pad_src = pad_src.join('-');
pad_iframe.src = pad_src;
let svg_src = svg_iframe.src;
svg_src = svg_src.split('/');
svg_src[svg_src.length-1] = value;
svg_src = svg_src.join('/');
svg_iframe.src = svg_src;
});
// --- svg generation button
button_svg.addEventListener('click', function(){
let svg_iframe = document.getElementById('svg-iframe');
svg_iframe.contentWindow.location.reload();
});
2024-03-09 13:22:52 +01:00
</script>
</header>
<div class="font">
<iframe class="f-ascii" id="pad-iframe" src="{{params['pad-full']}}">
2024-03-09 13:22:52 +01:00
</iframe>
<div class="f-svg">
<iframe id="svg-iframe" src="/drawing/{{params['pad']}}">
</iframe>
</div>
2024-03-09 13:22:52 +01:00
<aside class="right">
<button>> SVG</button>
<button>> HPGL</button>
</aside>
</div>
{% endblock %}