aboutsummaryrefslogtreecommitdiff
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
parentAdd marker on today in small calendar. (diff)
downloadcalp-8139ff9b8f512e8003786e07bd546e1ad74ea3dd.tar.gz
calp-8139ff9b8f512e8003786e07bd546e1ad74ea3dd.tar.xz
Add unused js for creating events.
-rw-r--r--module/output/html.scm5
-rw-r--r--static/script.js66
-rw-r--r--static/style.css4
3 files changed, 73 insertions, 2 deletions
diff --git a/module/output/html.scm b/module/output/html.scm
index 1614bc31..0c8c3eb3 100644
--- a/module/output/html.scm
+++ b/module/output/html.scm
@@ -230,9 +230,10 @@
(meta (@ (name viewport)
(content "width=device-width, initial-scale=0.5")))
(meta (@ (name description)
- (content "Calendar for the dates between " (date->string start)
- " and " (date->string end))))
+ (content "Calendar for the dates between " ,(date->string start)
+ " and " ,(date->string end))))
,(include-css "static/style.css")
+ ;; (script (@ (src "static/script.js")) "")
(style ,(format #f "~:{.CAL_~a { background-color: ~a; color: ~a }~%.CAL_bg_~a { border-color: ~a }~%~}"
(map (lambda (c)
(let* ((name (html-attr (attr c 'NAME)))
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;