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