Commit 442528e8 authored by Tobias Liese's avatar Tobias Liese

frontend is getting better and better

parent 64f720fa
Pipeline #93433 failed with stages
in 29 seconds
......@@ -27,10 +27,10 @@
<a id="removeState">Remove</a>
</li>
<li>
<a>Edit</a>
<a id="editState">Edit</a>
</li>
<li>
<a>Add Transaction</a>
<a id="addTransition">Add Transition</a>
</li>
</ul>
</div>
......@@ -51,6 +51,5 @@
<canvas id="canvas" width="1" height="1"></canvas>
</div>
<script src="main.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -15,6 +15,13 @@ class Field {
document.getElementById("createState").addEventListener("mousedown", () => {
this.addState(100, 300, "q1")
});
document.getElementById("editState").addEventListener("mousedown", () => {
// @todo
});
document.getElementById("addTransition").addEventListener("mousedown", () => {
transitionMode = true
document.body.style.cursor = "crosshair"
});
}
addState(x: number, y: number, name: string) {
......@@ -107,9 +114,11 @@ class State {
onmousemove = (event: MouseEvent) => {
if (dragMode) {
field.updateState(selected, event.x - field.xOrigin, event.y - field.yOrigin, null)
} else if (contextMenu == null) {
} else if (menuVisible) {
selected = field.getStateIndex(event.clientX - field.xOrigin, event.clientY - field.yOrigin)
if (selected != null) {
if (transitionMode) {
document.body.style.cursor = "crosshair"
} else if (selected != null) {
document.body.style.cursor = "grab"
} else {
document.body.style.cursor = "default"
......@@ -122,21 +131,30 @@ onmousedown = (event: MouseEvent) => {
if (contextMenu != null) {
contextMenu.className = "hide";
contextMenu = null
}
if (selected != null) {
} else if (transitionMode) {
if (selected != null) {
console.log("connect")
} else {
console.log("cancel")
}
transitionMode = false
} else if (selected != null) {
dragMode = true
document.body.style.cursor = "grabbing"
} else if (transitionMode && selected != null) {
transitionMode = false
}
}
onmouseup = () => {
dragMode = false
if (selected != null) {
document.body.style.cursor = "grab"
} else {
document.body.style.cursor = "default"
if (!transitionMode) {
if (selected != null) {
document.body.style.cursor = "grab"
} else {
document.body.style.cursor = "default"
}
}
}
onresize = () => {
......@@ -164,7 +182,7 @@ let menuVisible: boolean = false
const field: Field = new Field();
let selected: number
let dragMode: boolean = false
let transitionMode: boolean = false
// let webSocket = new WebSocket(
// 'ws://' + window.location.host + "/websocket");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment