[Libreoffice-commits] online.git: 2 commits - loleaflet/html loleaflet/js
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Mar 6 11:38:29 UTC 2019
loleaflet/html/loleaflet.html.m4 | 44 ++++++++++++++++++---------------------
loleaflet/js/global.js | 42 ++++++++++++++++++++++++++++++++-----
2 files changed, 58 insertions(+), 28 deletions(-)
New commits:
commit 97970bc081f733532d55ba6e27b219f2776ff99d
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Mar 6 13:36:25 2019 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Mar 6 13:36:25 2019 +0200
Define window.ThisIsAMobileApp etc before they are used in global.js
Change-Id: I7ae2687019575fc27e4c5dff128c8a97595676ea
diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index f87a180b4..5c4a03dc4 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -142,28 +142,6 @@ ifelse(MOBILEAPP,[true],
<div id="lokit-version"></div>
</div>
- <script defer>
-ifelse(MOBILEAPP,[true],
- [window.host = '';
- window.serviceRoot = '';
- window.accessToken = '';
- window.accessTokenTTL = '';
- window.accessHeader = '';
- window.loleafletLogging = 'true';
- window.outOfFocusTimeoutSecs = 1000000;
- window.idleTimeoutSecs = 1000000;
- window.tileSize = 256;],
- [window.host = '<%HOST%>';
- window.serviceRoot = '<%SERVICE_ROOT%>';
- window.accessToken = '<%ACCESS_TOKEN%>';
- window.accessTokenTTL = '<%ACCESS_TOKEN_TTL%>';
- window.accessHeader = '<%ACCESS_HEADER%>';
- window.loleafletLogging = '<%LOLEAFLET_LOGGING%>';
- window.outOfFocusTimeoutSecs = <%OUT_OF_FOCUS_TIMEOUT_SECS%>;
- window.idleTimeoutSecs = <%IDLE_TIMEOUT_SECS%>;
- window.tileSize = 256;])
-syscmd([cat ]GLOBAL_JS)dnl
- </script>
<script defer>
dnl# For use in conditionals in JS: window.ThisIsAMobileApp, window.ThisIsTheiOSApp,
@@ -194,7 +172,27 @@ ifelse(ANDROIDAPP,[true],
window.postMobileDebug = function(msg) { window.LOOLMessageHandler.postMobileDebug(msg); };],
[ window.ThisIsTheAndroidApp = false;]
)
- </script>
+ifelse(MOBILEAPP,[true],
+ [window.host = '';
+ window.serviceRoot = '';
+ window.accessToken = '';
+ window.accessTokenTTL = '';
+ window.accessHeader = '';
+ window.loleafletLogging = 'true';
+ window.outOfFocusTimeoutSecs = 1000000;
+ window.idleTimeoutSecs = 1000000;
+ window.tileSize = 256;],
+ [window.host = '<%HOST%>';
+ window.serviceRoot = '<%SERVICE_ROOT%>';
+ window.accessToken = '<%ACCESS_TOKEN%>';
+ window.accessTokenTTL = '<%ACCESS_TOKEN_TTL%>';
+ window.accessHeader = '<%ACCESS_HEADER%>';
+ window.loleafletLogging = '<%LOLEAFLET_LOGGING%>';
+ window.outOfFocusTimeoutSecs = <%OUT_OF_FOCUS_TIMEOUT_SECS%>;
+ window.idleTimeoutSecs = <%IDLE_TIMEOUT_SECS%>;
+ window.tileSize = 256;])
+syscmd([cat ]GLOBAL_JS)dnl
+ </script>
ifelse(MOBILEAPP,[true],
ifelse(DEBUG,[true],foreachq([fileJS],[LOLEAFLET_JS],
commit 039913499be7d0adabb17b4c4b2b379a608979ac
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Mar 6 13:32:59 2019 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Mar 6 13:32:59 2019 +0200
We need the FakeWebSocket code for the mobile apps here, too
We don't use (real) WebSockets for anything at all in the mobile apps.
Is the WebSocket (and FakeWebSocket) code in Socket.js still relevant?
Has it been superseded by what is now in global.js? Good question.
Next question please.
Change-Id: Ief4209b738ba1f0c1a8c496ae53bedcb1f7e14f9
diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js
index ea2933d73..d7cbc3413 100644
--- a/loleaflet/js/global.js
+++ b/loleaflet/js/global.js
@@ -1,6 +1,33 @@
/* -*- js-indent-level: 8 -*- */
(function (global) {
+ global.fakeWebSocketCounter = 0;
+ global.FakeWebSocket = function () {
+ this.binaryType = 'arraybuffer';
+ this.bufferedAmount = 0;
+ this.extensions = '';
+ this.protocol = '';
+ this.readyState = 1;
+ this.id = window.fakeWebSocketCounter++;
+ this.sendCounter = 0;
+ this.onclose = function() {
+ };
+ this.onerror = function() {
+ };
+ this.onmessage = function() {
+ };
+ this.onopen = function() {
+ };
+ }
+
+ global.FakeWebSocket.prototype.close = function() {
+ }
+
+ global.FakeWebSocket.prototype.send = function(data) {
+ this.sendCounter++;
+ window.postMobileMessage(data);
+ }
+
// If not debug, don't print anything on the console
// except in tile debug mode (Ctrl-Shift-Alt-d)
console.log2 = console.log;
@@ -68,12 +95,17 @@
global.docURL = filePath;
}
- var websocketURI = global.host + global.serviceRoot + '/lool/' + encodeURIComponent(global.docURL + (docParams ? '?' + docParams : '')) + '/ws' + wopiSrc;
+ if (window.ThisIsAMobileApp) {
+ global.socket = new global.FakeWebSocket();
+ window.TheFakeWebSocket = global.socket;
+ } else {
+ var websocketURI = global.host + global.serviceRoot + '/lool/' + encodeURIComponent(global.docURL + (docParams ? '?' + docParams : '')) + '/ws' + wopiSrc;
- try {
- global.socket = new WebSocket(websocketURI);
- } catch (err) {
- console.log(err);
+ try {
+ global.socket = new WebSocket(websocketURI);
+ } catch (err) {
+ console.log(err);
+ }
}
if (global.socket && global.socket.readyState !== 3) {
More information about the Libreoffice-commits
mailing list