forked from rabbibotton/clog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
19-tutorial.lisp
32 lines (28 loc) · 1.34 KB
/
19-tutorial.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(defpackage #:clog-tut-19
(:use #:cl #:clog)
(:export start-tutorial))
(in-package :clog-tut-19)
;;; In this tutorial we will see how to easily use a JavaScript
;;; component. In the static-files directory there is a simple
;;; JavaScript component (clog/static-files/tutorial/jslists) to create
;;; collapsible trees that we will use for this tutorial.
(defun on-new-window (body)
;; First we need to load jslists' JavaScript file and css
(load-css (html-document body) "/tutorial/jslists/jsLists.css")
(load-script (html-document body) "/tutorial/jslists/jsLists.js")
;; Second we need to build an example list. jsLists uses an ordered
;; or unordered list for its data.
(let* ((list-top (create-unordered-list body))
(item (create-list-item list-top :content "Top of tree"))
(list-b (create-unordered-list item))
(item (create-list-item list-b :content "Item 1"))
(item (create-list-item list-b :content "Item 2"))
(item (create-list-item list-b :content "Item 3"))
(item (create-list-item list-b :content "Item 4")))
(declare (ignore item))
(js-execute body (format nil "JSLists.applyToList('~A', 'ALL');"
(html-id list-top)))))
(defun start-tutorial ()
"Start tutorial."
(initialize 'on-new-window)
(open-browser))