aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-04-26 18:50:41 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-04-26 18:50:41 +0200
commit72792b048e6bbdd06ba3c775c8b870d64dcd856d (patch)
tree0e1e4254f72e71c29b742c999431817981c0b0e1
parentTable cells date now in <time> tag. (diff)
downloadcalp-72792b048e6bbdd06ba3c775c8b870d64dcd856d.tar.gz
calp-72792b048e6bbdd06ba3c775c8b870d64dcd856d.tar.xz
Sidebar event code now reusable for popups.
-rw-r--r--module/output/html.scm51
-rw-r--r--static/script.js11
2 files changed, 39 insertions, 23 deletions
diff --git a/module/output/html.scm b/module/output/html.scm
index bc8eefae..3cf110da 100644
--- a/module/output/html.scm
+++ b/module/output/html.scm
@@ -128,6 +128,9 @@
(define (event-debug-html event)
+ `(div (@ (class "eventlist"))
+ ,(fmt-single-event event))
+ #;
`(table
(tbody
,@(hash-map->list
@@ -364,18 +367,20 @@
;; For sidebar, just text
-(define (fmt-single-event ev)
+(define* (fmt-single-event ev
+ optional: (attributes '())
+ key: (fmt-header list))
;; (format (current-error-port) "fmt-single-event: ~a~%" (attr ev 'X-HNH-FILENAME))
- `(article (@ (id ,(UID ev))
- (class "eventtext CAL_bg_"
- ,(html-attr (or (attr (parent ev) 'NAME) "unknown"))
- ,(when (and (attr ev 'PARTSTAT) (string= "TENTATIVE" (attr ev 'PARTSTAT)))
- " tentative")))
- (h3 (a (@ (href "#" ,(date-link (as-date (attr ev 'DTSTART))))
- (class "hidelink"))
- ,(when (attr ev 'RRULE)
- `(span (@ (class "repeating")) "↺"))
- ,(attr ev 'SUMMARY)))
+ `(article (@ ,@(assq-merge
+ attributes
+ `((class "eventtext CAL_bg_"
+ ,(html-attr (or (attr (parent ev) 'NAME) "unknown"))
+ ,(when (and (attr ev 'PARTSTAT) (string= "TENTATIVE" (attr ev 'PARTSTAT)))
+ " tentative")))))
+ (h3 ,(fmt-header
+ (when (attr ev 'RRULE)
+ `(span (@ (class "repeating")) "↺"))
+ (attr ev 'SUMMARY)))
(div
,(call-with-values (lambda () (fmt-time-span ev))
(match-lambda* [(start end) `(div ,start " — " ,end)]
@@ -401,15 +406,21 @@
`(a (@ (href "#" ,s)
(class "hidelink")) ,s))))
,@(stream->list
- (stream-map fmt-single-event
- (stream-filter
- (lambda (ev)
- ;; If start was an earlier day
- ;; This removes all descriptions from
- ;; events for previous days,
- ;; solving duplicates.
- (date/-time<=? date (attr ev 'DTSTART)))
- events))))))
+ (stream-map
+ (lambda (ev) (fmt-single-event
+ ev `((id ,(UID ev)))
+ fmt-header: (lambda body
+ `(a (@ (href "#" ,(date-link (as-date (attr ev 'DTSTART))))
+ (class "hidelink"))
+ ,@body))))
+ (stream-filter
+ (lambda (ev)
+ ;; If start was an earlier day
+ ;; This removes all descriptions from
+ ;; events for previous days,
+ ;; solving duplicates.
+ (date/-time<=? date (attr ev 'DTSTART)))
+ events))))))
;;; Table output
diff --git a/static/script.js b/static/script.js
index a5a5093d..274bcb86 100644
--- a/static/script.js
+++ b/static/script.js
@@ -128,9 +128,14 @@ function max(a, b) {
/*
https://stackoverflow.com/questions/21064101/understanding-offsetwidth-clientwidth-scrollwidth-and-height-respectively
*/
-function new_popup () {
+function new_popup (event) {
- popup = this.children[0].children[0]
+ console.log(event.target);
+ console.log(this);
+ // if (event.target !== this) return;
+
+ /* popup = this.children[0].children[0] */
+ popup = this.parentElement.getElementsByClassName("popup")[0];
popup.classList.toggle("show")
/* x-axis fix */
@@ -197,7 +202,7 @@ window.onload = function () {
// }
days = document.getElementsByClassName("days")[0]
- for (let e of days.getElementsByClassName("event")) {
+ for (let e of days.getElementsByClassName("body")) {
e.onclick = new_popup;
}