aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-05-06 17:59:13 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-05-06 17:59:13 +0200
commit8139ff9b8f512e8003786e07bd546e1ad74ea3dd (patch)
tree1a7bd9dbb3fa0a8f15fddfd92074a5e532c546f4 /static
parentAdd marker on today in small calendar. (diff)
downloadcalp-8139ff9b8f512e8003786e07bd546e1ad74ea3dd.tar.gz
calp-8139ff9b8f512e8003786e07bd546e1ad74ea3dd.tar.xz
Add unused js for creating events.
Diffstat (limited to 'static')
-rw-r--r--static/script.js66
-rw-r--r--static/style.css4
2 files changed, 70 insertions, 0 deletions
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;