From 8139ff9b8f512e8003786e07bd546e1ad74ea3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 6 May 2019 17:59:13 +0200 Subject: Add unused js for creating events. --- static/script.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ static/style.css | 4 ++++ 2 files changed, 70 insertions(+) create mode 100644 static/script.js (limited to 'static') diff --git a/static/script.js b/static/script.js new file mode 100644 index 00000000..a299701b --- /dev/null +++ b/static/script.js @@ -0,0 +1,66 @@ + +function part_to_hour (f) { + return Math.floor(10 * 24 * f) / 10; +} + +var start_time = 0 +var start_fraq = 0 + +var parent +var createdEvents = false + +function onmousedownhandler (e) { + last = this + event = e + var comp = this + console.log(comp.clientHeight) + while (! comp.classList.contains("events")) { + comp = comp.parentElement + } + console.log(e); + parent = comp + console.log(comp.clientHeight) + fraq = e.offsetY / comp.clientHeight + start_fraq = fraq + start_time = part_to_hour(fraq); + createdEvent = document.createElement("div"); + createdEvent.className = "event generated"; + createdEvent.style.pointerEvents = "none"; + createdEvent.style.width = "100%"; + createdEvent.style.top = fraq * 100 + "%"; + createdEvent.innerText = "New Event"; +} + +function onmousemovehandler (e) { + if (createdEvent) { + fraq = e.offsetY / this.clientHeight + var diff = fraq - start_fraq; + if (! createdEvent.parentElement) { + for (let e of this.children) { + e.style.pointerEvents = "none"; + } + this.appendChild(createdEvent); + } + createdEvent.style.height = diff * 100 + "%"; + } + +} + +function onmouseuphandler (e) { + var end_time = part_to_hour(e.offsetY / this.clientHeight); + console.log("Creating event " + start_time + " - " + end_time); + createdEvent = false; + + for (let e of parent.children) { + e.style.pointerEvents = "initial"; + } + +} + +window.onload = function () { + for (let c of document.getElementsByClassName("events")) { + c.onmousedown = onmousedownhandler; + c.onmouseup = onmouseuphandler; + c.onmousemove = onmousemovehandler; + } +} diff --git a/static/style.css b/static/style.css index 2d8e24ed..5017e5ef 100644 --- a/static/style.css +++ b/static/style.css @@ -225,6 +225,10 @@ #FFF0 90%, #0007 100%); } +.event.generated { + background-color: #55FF5550; +} + .selected { width: 100% !important; left: 0 !important; -- cgit v1.2.3