Browse Source

auto commit

factor1
jfinn 3 weeks ago
parent
commit
71fc6cf1c8
1 changed files with 169 additions and 0 deletions
  1. 169
    0
      virtual_inline_script.call_demo.html

+ 169
- 0
virtual_inline_script.call_demo.html View File

@@ -0,0 +1,169 @@
1
+    <script>
2
+        // Dynamically generate the manifest location URL. It must be served from the document origin, and we may have
3
+        // the base pointing to the CDN. This way we can generate a full URL which will bypass the base.
4
+        document.querySelector('#manifest-placeholder').setAttribute('href', window.location.origin + '/manifest.json');
5
+
6
+        document.addEventListener('DOMContentLoaded', () => {
7
+            if (!JitsiMeetJS.app) {
8
+                return;
9
+            }
10
+
11
+            JitsiMeetJS.app.renderEntryPoint({
12
+                Component: JitsiMeetJS.app.entryPoints.APP
13
+            })
14
+
15
+            const inIframe = () => {
16
+                try {
17
+                    return window.self !== window.top;
18
+                } catch (e) {
19
+                    return true;
20
+                }
21
+            };
22
+
23
+            const isElectron = navigator.userAgent.includes('Electron');
24
+            const shouldRegisterWorker = !isElectron && !inIframe() && 'serviceWorker' in navigator;
25
+
26
+            if (shouldRegisterWorker) {
27
+                navigator.serviceWorker
28
+                    .register(window.location.origin + '/pwa-worker.js')
29
+                    .then(reg => {
30
+                        console.log('Service worker registered.', reg);
31
+                    })
32
+                    .catch(err => {
33
+                        console.log(err);
34
+                    });
35
+            }
36
+        });
37
+    </script>
38
+    <script>
39
+        // IE11 and earlier can be identified via their user agent and be
40
+        // redirected to a page that is known to have no newer js syntax.
41
+        if (window.navigator.userAgent.match(/(MSIE|Trident)/)) {
42
+            var roomName = encodeURIComponent(window.location.pathname);
43
+            window.location.pathname = 'static/recommendedBrowsers.html';
44
+        }
45
+
46
+        window.indexLoadedTime = window.performance.now();
47
+        console.log("(TIME) index.html loaded:\t", indexLoadedTime);
48
+        // XXX the code below listeners for errors and displays an error message
49
+        // in the document body when any of the required files fails to load.
50
+        // The intention is to prevent from displaying broken page.
51
+        var criticalFiles = [
52
+            "config.js",
53
+            "utils.js",
54
+            "do_external_connect.js",
55
+            "interface_config.js",
56
+            "logging_config.js",
57
+            "lib-jitsi-meet.min.js",
58
+            "app.bundle.min.js",
59
+            "all.css"
60
+        ];
61
+        var loadErrHandler = function(e) {
62
+            var target = e.target;
63
+            // Error on <script> and <link>(CSS)
64
+            // <script> will have .src and <link> .href
65
+            var fileRef = (target.src ? target.src : target.href);
66
+            if (("SCRIPT" === target.tagName || "LINK" === target.tagName)
67
+                && criticalFiles.some(
68
+                    function(file) { return fileRef.indexOf(file) !== -1 })) {
69
+                window.onload = function() {
70
+                    // The whole complex part below implements page reloads with
71
+                    // "exponential backoff". The retry attempt is passes as
72
+                    // "rCounter" query parameter
73
+                    var href = window.location.href;
74
+
75
+                    var retryMatch = href.match(/.+(\?|&)rCounter=(\d+)/);
76
+                    var retryCountStr = retryMatch ? retryMatch[2] : "0";
77
+                    var retryCount = Number.parseInt(retryCountStr);
78
+
79
+                    if (retryMatch == null) {
80
+                        var separator = href.indexOf("?") === -1 ? "?" : "&";
81
+                        var hashIdx = href.indexOf("#");
82
+
83
+                        if (hashIdx === -1) {
84
+                            href += separator + "rCounter=1";
85
+                        } else {
86
+                            var hashPart = href.substr(hashIdx);
87
+
88
+                            href = href.substr(0, hashIdx)
89
+                                + separator + "rCounter=1" + hashPart;
90
+                        }
91
+                    } else {
92
+                        var separator = retryMatch[1];
93
+
94
+                        href = href.replace(
95
+                            /(\?|&)rCounter=(\d+)/,
96
+                            separator + "rCounter=" + (retryCount + 1));
97
+                    }
98
+
99
+                    var delay = Math.pow(2, retryCount) * 2000;
100
+                    if (isNaN(delay) || delay < 2000 || delay > 60000)
101
+                        delay = 10000;
102
+
103
+                    var showMoreText = "show more";
104
+                    var showLessText = "show less";
105
+
106
+                    document.body.innerHTML
107
+                        = "<div style='"
108
+                        + "position: absolute;top: 50%;left: 50%;"
109
+                        + "text-align: center;"
110
+                        + "font-size: medium;"
111
+                        + "font-weight: 400;"
112
+                        + "transform: translate(-50%, -50%)'>"
113
+                        + "Uh oh! We couldn't fully download everything we needed :("
114
+                        + "<br/> "
115
+                        + "We will try again shortly. In the mean time, check for problems with your Internet connection!"
116
+                        + "<br/><br/> "
117
+                        + "<div id='moreInfo' style='"
118
+                        + "display: none;'>" + "Missing " + fileRef
119
+                        + "<br/><br/></div>"
120
+                        + "<a id='showMore' style='"
121
+                        + "text-decoration: underline;"
122
+                        + "font-size:small;"
123
+                        + "cursor: pointer'>" + showMoreText + "</a>"
124
+                        + "&nbsp;&nbsp;&nbsp;"
125
+                        + "<a id ='reloadLink' style='"
126
+                        + "text-decoration: underline;"
127
+                        + "font-size:small;"
128
+                        + "'>reload now</a>"
129
+                        + "</div>";
130
+
131
+                    var reloadLink = document.getElementById('reloadLink');
132
+                    reloadLink.setAttribute('href', href);
133
+
134
+                    var showMoreElem = document.getElementById("showMore");
135
+                    showMoreElem.addEventListener('click', function () {
136
+                            var moreInfoElem
137
+                                    = document.getElementById("moreInfo");
138
+
139
+                            if (showMoreElem.innerHTML === showMoreText) {
140
+                                moreInfoElem.setAttribute(
141
+                                    "style",
142
+                                    "display: block;"
143
+                                    + "color:#FF991F;"
144
+                                    + "font-size:small;"
145
+                                    + "user-select:text;");
146
+                                showMoreElem.innerHTML = showLessText;
147
+                            }
148
+                            else {
149
+                                moreInfoElem.setAttribute(
150
+                                    "style", "display: none;");
151
+                                showMoreElem.innerHTML = showMoreText;
152
+                            }
153
+                        });
154
+
155
+                    window.setTimeout(
156
+                        function () { window.location.replace(href); }, delay);
157
+
158
+                    // Call extra handler if defined.
159
+                    if (typeof postLoadErrorHandler === "function") {
160
+                        postLoadErrorHandler(fileRef);
161
+                    }
162
+                };
163
+                window.removeEventListener(
164
+                    'error', loadErrHandler, true /* capture phase */);
165
+            }
166
+        };
167
+        window.addEventListener(
168
+            'error', loadErrHandler, true /* capture phase type of listener */);
169
+    </script>

Loading…
Cancel
Save