-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add and example and update the README
- Loading branch information
Showing
3 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
;; 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 | ||
(modal-dialog "The header" | ||
"The modal dialog test" | ||
:lines (list :line1 (list "Upcase on backend:" #'up2) | ||
:line2 (list "Upcase on frontend:" #'up1) | ||
:line3 "Enter something:" | ||
:buttons (list (list "OK" #'dialog-ok) | ||
(list "Cancel" #'close-current-dialog)))))) | ||
|
||
(play-yt "vla6vpa1-Bk") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
jsmax | ||
jsmin | ||
jsrandom | ||
js-string-split | ||
load-js-script | ||
make-dialog | ||
make-js-function | ||
|