/
WindowOrWorkerGlobalScope.cljs
206 lines (145 loc) · 6.85 KB
/
WindowOrWorkerGlobalScope.cljs
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
(ns web.WindowOrWorkerGlobalScope
"The WindowOrWorkerGlobalScope mixin describes several features
to the `web.Window` and `web.workers.WorkerGlobalScope` interfaces."
(:refer-clojure :exclude []))
(defn atob
"Method.
The WindowOrWorkerGlobalScope.atob() function decodes a string
data which has been encoded using base-64 encoding. You can use
`btoa()` method to encode and transmit data which may otherwise
communication problems, then transmit it and use the atob() method
decode the data again. For example, you can encode, transmit,
decode control characters such as ASCII values 0 through 31.
`var decodedData = scope.atob(encodedData);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/atob`"
[this encoded-data]
(-> this (.atob encoded-data)))
(defn btoa
"Method.
The WindowOrWorkerGlobalScope.btoa() method creates a base-64
ASCII string from a binary string (i.e., a `js.String` object
which each character in the string is treated as a byte of binary
`var encodedData = scope.btoa(stringToEncode);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/btoa`"
[this string-to-encode]
(-> this (.btoa string-to-encode)))
(defn clear-interval
"Method.
The clearInterval() method of the `web.WindowOrWorkerGlobalScope`
cancels a timed, repeating action which was previously established
a call to `setInterval()`.
`scope.clearInterval(intervalID)`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/clearInterval`"
[this interval-id]
(-> this (.clearInterval interval-id)))
(defn clear-timeout
"Method.
The clearTimeout() method of the `web.WindowOrWorkerGlobalScope`
cancels a timeout previously established by calling `setTimeout()`.
`scope.clearTimeout(timeoutID)`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/clearTimeout`"
[this timeout-id]
(-> this (.clearTimeout timeout-id)))
(defn create-image-bitmap
"Method.
The createImageBitmap() method creates a bitmap from a given
optionally cropped to contain only a portion of that source.
method exists on the global scope in both windows and workers.
accepts a variety of different image sources, and returns a `js.Promise`
resolves to an `web.canvas.ImageBitmap`.
`createImageBitmap(image[, options]).then(function(response) { ... });
createImageBitmap(image, sx, sy, sw, sh[, options]).then(function(response) { ... });`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap`"
[this & args]
(apply (-> this .-createImageBitmap) (concat [this] args)))
(defn fetch
"Method.
The fetch() method of the `web.WindowOrWorkerGlobalScope` mixin
the process of fetching a resource from the network, returning
promise which is fulfilled once the response is available.
`fetchResponsePromise = fetch(resource, init);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch`"
[this resource init]
(-> this (.fetch resource init)))
(defn queue-microtask
"Method.
The queueMicrotask() method of the `web.WindowOrWorkerGlobalScope`
queues a microtask.
`scope.queueMicrotask(function);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/queueMicrotask`"
[this function]
(-> this (.queueMicrotask function)))
(defn set-interval
"Method.
The setInterval() method, offered on the `web.Window` and `web.workers.Worker`
repeatedly calls a function or executes a code snippet, with
fixed time delay between each call.
`var intervalID = scope.setInterval(func, delay[, arg1, arg2, ...]);
var intervalID = scope.setInterval(code, delay);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval`"
[this & args]
(apply (-> this .-setInterval) (concat [this] args)))
(defn set-timeout
"Method.
The setTimeout() method of the `web.WindowOrWorkerGlobalScope`
(and successor to Window.setTimeout()) sets a timer which executes
function or specified piece of code once the timer expires.
`var timeoutID = scope.setTimeout(function[, delay, arg1, arg2, ...]);
var timeoutID = scope.setTimeout(function[, delay]);
var timeoutID = scope.setTimeout(code[, delay]);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout`"
[this & args]
(apply (-> this .-setTimeout) (concat [this] args)))
(defn caches
"Property.
The caches read-only property of the `web.WindowOrWorkerGlobalScope`
returns the `web.service-workers.CacheStorage` object associated
the current context. This object enables functionality such as
assets for offline use, and generating custom responses to requests.
`var myCacheStorage = self.caches; // or just caches`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/caches`"
[this]
(-> this (.caches)))
(defn indexed-db
"Property.
The indexedDB read-only property of the `web.WindowOrWorkerGlobalScope`
provides a mechanism for applications to asynchronously access
capabilities of indexed databases.
`var IDBFactory = self.indexedDB;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/indexedDB`"
[this]
(-> this (.indexedDB)))
(defn is-secure-context
"Property.
The isSecureContext read-only property of the `web.WindowOrWorkerGlobalScope`
returns a boolean indicating whether the current context is secure
or not (false).
`var isItSecure = self.isSecureContext; // or just isSecureContext`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/isSecureContext`"
[this]
(-> this (.isSecureContext)))
(defn set-is-secure-context!
"Property.
The isSecureContext read-only property of the `web.WindowOrWorkerGlobalScope`
returns a boolean indicating whether the current context is secure
or not (false).
`var isItSecure = self.isSecureContext; // or just isSecureContext`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/isSecureContext`"
[this val]
(aset this "isSecureContext" val))
(defn origin
"Property.
The origin read-only property of the `web.WindowOrWorkerGlobalScope`
returns the origin of the global scope, serialized as a string.
`var myOrigin = self.origin; // or just origin`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/origin`"
[this]
(-> this (.origin)))
(defn set-origin!
"Property.
The origin read-only property of the `web.WindowOrWorkerGlobalScope`
returns the origin of the global scope, serialized as a string.
`var myOrigin = self.origin; // or just origin`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/origin`"
[this val]
(aset this "origin" val))