diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-20 11:46:25 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-08-20 14:23:57 +0200 |
commit | f95628636b6ccdf3eae2449ca718e075b072f678 (patch) | |
tree | 35d51980c87b7d6747bdff6e37bdfe37e3c989dc /client/src/app/helpers | |
parent | a9f6802e7dac4f21599076bc1119bb6ff16961dc (diff) | |
download | PeerTube-f95628636b6ccdf3eae2449ca718e075b072f678.tar.gz PeerTube-f95628636b6ccdf3eae2449ca718e075b072f678.tar.zst PeerTube-f95628636b6ccdf3eae2449ca718e075b072f678.zip |
Support plugin hooks in embed
Diffstat (limited to 'client/src/app/helpers')
-rw-r--r-- | client/src/app/helpers/utils.ts | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/client/src/app/helpers/utils.ts b/client/src/app/helpers/utils.ts index d05541ca9..d9007dd77 100644 --- a/client/src/app/helpers/utils.ts +++ b/client/src/app/helpers/utils.ts | |||
@@ -148,41 +148,6 @@ function scrollToTop () { | |||
148 | window.scroll(0, 0) | 148 | window.scroll(0, 0) |
149 | } | 149 | } |
150 | 150 | ||
151 | // Thanks: https://github.com/uupaa/dynamic-import-polyfill | ||
152 | function importModule (path: string) { | ||
153 | return new Promise((resolve, reject) => { | ||
154 | const vector = '$importModule$' + Math.random().toString(32).slice(2) | ||
155 | const script = document.createElement('script') | ||
156 | |||
157 | const destructor = () => { | ||
158 | delete window[ vector ] | ||
159 | script.onerror = null | ||
160 | script.onload = null | ||
161 | script.remove() | ||
162 | URL.revokeObjectURL(script.src) | ||
163 | script.src = '' | ||
164 | } | ||
165 | |||
166 | script.defer = true | ||
167 | script.type = 'module' | ||
168 | |||
169 | script.onerror = () => { | ||
170 | reject(new Error(`Failed to import: ${path}`)) | ||
171 | destructor() | ||
172 | } | ||
173 | script.onload = () => { | ||
174 | resolve(window[ vector ]) | ||
175 | destructor() | ||
176 | } | ||
177 | const absURL = (environment.apiUrl || window.location.origin) + path | ||
178 | const loader = `import * as m from "${absURL}"; window.${vector} = m;` // export Module | ||
179 | const blob = new Blob([ loader ], { type: 'text/javascript' }) | ||
180 | script.src = URL.createObjectURL(blob) | ||
181 | |||
182 | document.head.appendChild(script) | ||
183 | }) | ||
184 | } | ||
185 | |||
186 | function isInViewport (el: HTMLElement) { | 151 | function isInViewport (el: HTMLElement) { |
187 | const bounding = el.getBoundingClientRect() | 152 | const bounding = el.getBoundingClientRect() |
188 | return ( | 153 | return ( |
@@ -216,7 +181,6 @@ export { | |||
216 | getAbsoluteEmbedUrl, | 181 | getAbsoluteEmbedUrl, |
217 | objectLineFeedToHtml, | 182 | objectLineFeedToHtml, |
218 | removeElementFromArray, | 183 | removeElementFromArray, |
219 | importModule, | ||
220 | scrollToTop, | 184 | scrollToTop, |
221 | isInViewport, | 185 | isInViewport, |
222 | isXPercentInViewport | 186 | isXPercentInViewport |