|
|
|
@ -14,7 +14,7 @@ svgElement.addEventListener("mousedown", function (e) {
|
|
|
|
|
bufferSize = document.getElementById("cmbBufferSize").value;
|
|
|
|
|
path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
|
|
|
path.setAttribute("fill", "none");
|
|
|
|
|
path.setAttribute("stroke", "#000");
|
|
|
|
|
path.setAttribute("stroke", "currentColor");
|
|
|
|
|
path.setAttribute("stroke-width", strokeWidth);
|
|
|
|
|
buffer = [];
|
|
|
|
|
var pt = getMousePosition(e);
|
|
|
|
@ -37,6 +37,12 @@ svgElement.addEventListener("mouseup", function () {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
svgElement.addEventListener("mouseleave", function () {
|
|
|
|
|
if (path) {
|
|
|
|
|
path = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var getMousePosition = function (e) {
|
|
|
|
|
return {
|
|
|
|
|
x: e.pageX - rect.left,
|
|
|
|
@ -101,16 +107,20 @@ var updateSvgPath = function () {
|
|
|
|
|
const send = document.getElementById("send");
|
|
|
|
|
send.addEventListener("click", (e) => saveSVG(e));
|
|
|
|
|
|
|
|
|
|
function saveSVG(e) {
|
|
|
|
|
async function saveSVG(e) {
|
|
|
|
|
let wrapper = document.createElement("div");
|
|
|
|
|
wrapper.appendChild(svgElement);
|
|
|
|
|
|
|
|
|
|
fetch(`${svgElement.dataset.parent}`, {
|
|
|
|
|
await fetch(`${svgElement.dataset.parent}`, {
|
|
|
|
|
method: "POST",
|
|
|
|
|
redirect: "follow",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
content: wrapper.innerHTML,
|
|
|
|
|
parent: svgElement.dataset.parent,
|
|
|
|
|
branch: svgElement.dataset.branch,
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
}).then((res) => (window.location = res.url));
|
|
|
|
|
}
|
|
|
|
|