annotate libervia/web/pages/_browser/tmp_aio.py @ 1602:6feac4a25e60

browser: Remote Control implementation: - Add `cbor-x` JS dependency. - In "Call" page, a Remote Control session can now be started. This is done by clicking on a search item 3 dots menu. Libervia Web will act as a controlling device. The call box is then adapted, and mouse/wheel and keyboard events are sent to remote, touch events are converted to mouse one. - Some Brython 3.12* related changes. rel 436
author Goffi <goffi@goffi.org>
date Sat, 11 May 2024 14:02:22 +0200
parents eb00d593801d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1347
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
1 from browser import window
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
2
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
3 """Q&D module to do ajax requests with data types currently unsupported by Brython"""
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # FIXME: remove this module when official aio module allows to work with blobs
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
5
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
6 window.eval("""
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
7 var _tmp_ajax = function(method, url, format, data){
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
8 return new Promise(function(resolve, reject){
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
9 var xhr = new XMLHttpRequest()
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
10 xhr.open(method, url, true)
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
11 xhr.responseType = format
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
12 xhr.onreadystatechange = function(){
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
13 if(this.readyState == 4){
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
14 resolve(this)
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
15 }
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
16 }
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
17 if(data){
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
18 xhr.send(data)
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
19 }else{
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
20 xhr.send()
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
21 }
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
22 })
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
23 }
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
24 """)
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
25
48e2a8b07c0b browser: async version of bridge
Goffi <goffi@goffi.org>
parents:
diff changeset
26 ajax = window._tmp_ajax