Bläddra i källkod

Adds load and error callback to the script util.

dev1
damencho 9 år sedan
förälder
incheckning
68b78bb730
1 ändrade filer med 9 tillägg och 1 borttagningar
  1. 9
    1
      modules/util/ScriptUtil.js

+ 9
- 1
modules/util/ScriptUtil.js Visa fil

18
      * @param relativeURL whether we need load the library from url relative
18
      * @param relativeURL whether we need load the library from url relative
19
      * to the url that lib-jitsi-meet was loaded. Useful when sourcing the
19
      * to the url that lib-jitsi-meet was loaded. Useful when sourcing the
20
      * library from different location than the app that is using it
20
      * library from different location than the app that is using it
21
+     * @param loadCallback on load callback function
22
+     * @param errorCallback callback to be called on error loading the script
21
      */
23
      */
22
-    loadScript: function (src, async, prepend, relativeURL) {
24
+    loadScript: function (src, async, prepend, relativeURL,
25
+                          loadCallback, errorCallback) {
23
         var d = document;
26
         var d = document;
24
         var tagName = 'script';
27
         var tagName = 'script';
25
         var script = d.createElement(tagName);
28
         var script = d.createElement(tagName);
40
             }
43
             }
41
         }
44
         }
42
 
45
 
46
+        if (loadCallback)
47
+            script.onload = loadCallback;
48
+        if (errorCallback)
49
+            script.onerror = errorCallback;
50
+
43
         script.src = src;
51
         script.src = src;
44
         if (prepend) {
52
         if (prepend) {
45
             referenceNode.parentNode.insertBefore(script, referenceNode);
53
             referenceNode.parentNode.insertBefore(script, referenceNode);

Laddar…
Avbryt
Spara