annotate libervia/pages/_browser/tmp_aio.py @ 1438:433c02214e6d

Added translation using Weblate (Slovak)
author Weblate <noreply@weblate.org>
date Wed, 16 Jun 2021 17:18:59 +0000
parents 48e2a8b07c0b
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