-
This commit is contained in:
@@ -43,12 +43,29 @@
|
||||
webview-value/bool
|
||||
webview-value/symbol
|
||||
webview-value/number
|
||||
;webview-value/date
|
||||
;webview-value/time
|
||||
;webview-value/datetime
|
||||
|
||||
webview-add-class!
|
||||
webview-remove-class!
|
||||
webview-set-style!
|
||||
webview-unset-style!
|
||||
|
||||
webview-set-attr!
|
||||
webview-attr
|
||||
;webview-attr/bool
|
||||
;webview-attr/symbol
|
||||
;webview-attr/number
|
||||
;webview-attr/date
|
||||
;webview-attr/time
|
||||
;webview-attr/datetime
|
||||
|
||||
;webview-del-attr!
|
||||
|
||||
webview-standard-file-getter
|
||||
|
||||
test
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -242,10 +259,10 @@
|
||||
|
||||
(define/contract (webview-close wv)
|
||||
(-> wv? symbol?)
|
||||
(let ((r (rkt-webview-close (wv-handle wv))))
|
||||
(begin
|
||||
(rkt-webview-close (wv-handle wv))
|
||||
(kill-thread (wv-webserver-thread wv))
|
||||
r)
|
||||
)
|
||||
'oke))
|
||||
|
||||
(define/contract (webview-bind! wv selector event)
|
||||
(-> wv? (or/c symbol? string?) symbol? list?)
|
||||
@@ -283,9 +300,12 @@
|
||||
(if (webview-call-js-result? result)
|
||||
(if (eq? (car result) 'oke)
|
||||
(hash-ref (fromJson (cadr result)) 'result #f)
|
||||
(error "Error calling javascript. Message: ~a" (hash-ref (fromJson (cadr result)) 'exn result))
|
||||
(error
|
||||
(format "Error calling javascript. Message: ~a"
|
||||
(hash-ref (fromJson (cadr result)) 'exn result)))
|
||||
)
|
||||
(error "Wrong result from webview-call-js: ~a" result)
|
||||
(error
|
||||
(format "Wrong result from webview-call-js: ~a" result))
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -331,12 +351,9 @@
|
||||
" }\n"
|
||||
"};\n"))
|
||||
-> "f()"))))
|
||||
(if (eq? (car v) 'oke)
|
||||
(let ((h (fromJson (cadr v))))
|
||||
(hash-ref h 'result #f))
|
||||
#f)
|
||||
)
|
||||
)
|
||||
(if (eq? v #f)
|
||||
#f
|
||||
v)))
|
||||
|
||||
(define/contract (webview-value/number wv id)
|
||||
(-> wv? symbol? (or/c number? boolean?))
|
||||
@@ -403,8 +420,96 @@
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(define/contract (webview-set-style! wv selector style-entries)
|
||||
(-> wv? (or/c symbol? string?) (or/c kv? list-of-kv?) hash?)
|
||||
(let ((sel (if (symbol? selector)
|
||||
(format "#~a" selector)
|
||||
selector))
|
||||
(cl (mk-js-array (if (kv? style-entries)
|
||||
(list style-entries)
|
||||
style-entries)))
|
||||
)
|
||||
(webview-call-js wv
|
||||
(with-selector sel
|
||||
(format
|
||||
(js-code
|
||||
"function(id, el) {"
|
||||
" let cl = ~a;"
|
||||
" cl.forEach(function(st) {"
|
||||
" el.style[st[0]] = st[1];"
|
||||
" });"
|
||||
" return id;"
|
||||
"}") cl))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(define/contract (webview-unset-style! wv selector style-entries)
|
||||
(-> wv? (or/c symbol? string?) (or/c symbol? list-of-symbol?) hash?)
|
||||
(let ((sel (if (symbol? selector)
|
||||
(format "#~a" selector)
|
||||
selector))
|
||||
(cl (mk-js-array (if (symbol? style-entries)
|
||||
(list style-entries)
|
||||
style-entries)))
|
||||
)
|
||||
(webview-call-js wv
|
||||
(with-selector sel
|
||||
(format
|
||||
(js-code
|
||||
"function(id, el) {"
|
||||
" let cl = ~a;"
|
||||
" cl.forEach(function(st) {"
|
||||
" el.style[st] = '';"
|
||||
" });"
|
||||
" return id;"
|
||||
"}") cl)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(define/contract (webview-set-attr! wv selector attr-entries)
|
||||
(-> wv? (or/c symbol? string?) (or/c kv? list-of-kv?) hash?)
|
||||
(let ((sel (if (symbol? selector)
|
||||
(format "#~a" selector)
|
||||
selector))
|
||||
(cl (mk-js-array (if (kv? attr-entries)
|
||||
(list attr-entries)
|
||||
attr-entries)))
|
||||
)
|
||||
(webview-call-js wv
|
||||
(with-selector sel
|
||||
(format
|
||||
(js-code
|
||||
"function(id, el) {"
|
||||
" let cl = ~a;"
|
||||
" cl.forEach(function(av) {"
|
||||
" el.setAttribute(av[0], av[1]);"
|
||||
" });"
|
||||
" return id;"
|
||||
"}") cl))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(define/contract (webview-attr wv id attr)
|
||||
(-> wv? symbol? (or/c symbol? string?) (or/c string? boolean?))
|
||||
(let ((v (webview-call-js wv
|
||||
(with-id id el
|
||||
-> (format "el.getAttribute('~a');" attr))
|
||||
)))
|
||||
(if (eq? v 'null)
|
||||
#f
|
||||
v)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#|(define/contract (webview-set-style! wv selector style-entries)
|
||||
(-> wv? (or/c symbol? string?) (or/c list? list-of-kv?) hash?)
|
||||
|
||||
(define (webview-set-style!* wv selector h)
|
||||
@@ -435,7 +540,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|#
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; testing
|
||||
|
||||
Reference in New Issue
Block a user