-
Notifications
You must be signed in to change notification settings - Fork 0
/
collider-client.lisp
45 lines (29 loc) · 1 KB
/
collider-client.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
(require 'drakma)
(use-package 'drakma)
(defparameter *browser* "http://localhost:8204")
(defun browser-request (location parameters)
(let ((results
(multiple-value-list (http-request (concatenate 'string *browser* location)
:method :post
:content-length t
:parameters parameters))))
(if (eql (second results) 200)
(first results)
results)
) )
(defun nav (url)
(browser-request "/loadurl" `(("url" . ,url))))
(defun reload ()
(browser-request "/reload-browser" ()))
(defun run-javascript (code)
(browser-request "/run-javascript" `(("code" . ,code))))
(defun run-parenscript (code)
(browser-request "/run-parenscript" `(("code" . ,(format nil "~S" code)))))
(defun load-javascript-file (url)
(browser-request "/load-javascript-file" `(("url" . ,url))))
(defun load-js-uri (uri)
(load-javascript-file uri))
(defun js-exe (code)
(run-javascript code))
(defun goto-uri (uri)
(nav uri))