-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.lisp
58 lines (45 loc) · 2.23 KB
/
example.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
;; Load this file via (load "example.lisp") in the REPL and open http://localhost:7500 in the browser
(require :omg)
(defpackage :my-test
(:use cl omg omgui jscl))
(in-package :my-test)
;; (setf omg::*ssl-cert* "sslcert.pem")
;; (setf omg::*ssl-key* "sslkey.pem")
;; (setf omg::*port* 7500)
(defun-f play-yt (video-id)
(add-youtube-player (append-element (create-element "div"))
:video-id video-id
:width 800
:onready (lambda (ev)
((jscl::oget ev "target" "mute")) ;; respect autoplay restrictions
((jscl::oget ev "target" "playVideo"))
(jslog "Starting playback"))
:onstatechange (lambda (ev)
(if (equal (jscl::oget ev "data")
(jscl::oget (jscl::%js-vref "YT") "PlayerState" "PLAYING"))
(progn
(jslog "Playback started!")
(execute-after 10.0 ;; Pause video after 10 sec. playback
(lambda ()
((jscl::oget ev "target" "pauseVideo")))))))))
(defun-f up1 (s)
(string-upcase s))
(defun-r up2 (s)
(string-upcase s))
(defun-r my-boot ()
(print "BOOT!")
(set-debug-session (current-session-id)))
(add-to-boot '(my-boot)) ;; call my-boot just after connection
(restart-server) ;; (re)start a server on default port 7500
;; execute this via SLIME after browser connection:
(in-debug-session
(print
(modal-dialog "The header"
"The modal dialog test"
:lines (list :line1 (list "Upcase on backend:" :filter #'up2)
:line2 (list "Upcase on frontend:" :filter #'up1)
:pass (list "Upcase on frontend:" :type "password")
:line3 "Enter something:"
:buttons (list (list "OK" #'dialog-ok)
(list "Cancel" #'close-current-dialog))))))
(play-yt "vla6vpa1-Bk")