[Libreoffice-commits] online.git: loleaflet/main.js loleaflet/src

Jan Holesovsky kendy at collabora.com
Fri Sep 8 15:10:28 UTC 2017


 loleaflet/main.js                             |    3 ++-
 loleaflet/src/core/Socket.js                  |    6 +++++-
 loleaflet/src/layer/tile/TileLayer.js         |    7 ++++++-
 loleaflet/src/map/Map.js                      |    3 ++-
 loleaflet/src/map/handler/Map.FileInserter.js |    6 +++++-
 5 files changed, 20 insertions(+), 5 deletions(-)

New commits:
commit c5fc1594e1295b2bfb7484aaebe025774e2117ce
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Sep 8 16:42:28 2017 +0200

    HA: Pass WOPISrc= param in all the requests that need to...
    
    ...end up in the same loolwsd instance.
    
    Change-Id: I69c4f5be0c0a6f4ffdec6dd571a5d62f2df4b1fb

diff --git a/loleaflet/main.js b/loleaflet/main.js
index 42660a13..ece21653 100644
--- a/loleaflet/main.js
+++ b/loleaflet/main.js
@@ -100,7 +100,7 @@ if (wopiSrc != '') {
 	docParams = wopiParams;
 	isWopi = true;
 } else {
-    docURL = filePath;
+	docURL = filePath;
 	docParams = {};
 }
 
@@ -114,6 +114,7 @@ var map = L.map('map', {
 	documentContainer: 'document-container',
 	debug: debugMode,
 	wopi: isWopi,
+	wopiSrc: wopiSrc,
 	alwaysActive: alwaysActive,
 	idleTimeoutSecs: idleTimeoutSecs,  // Dim when user is idle.
 	outOfFocusTimeoutSecs: outOfFocusTimeoutSecs // Dim after switching tabs.
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index fbdfd340..4614a00d 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -22,7 +22,11 @@ L.Socket = L.Class.extend({
 			if (map.options.permission) {
 				map.options.docParams['permission'] = map.options.permission;
 			}
-			this.socket = new WebSocket(map.options.server + '/lool/' + encodeURIComponent(map.options.doc + '?' + $.param(map.options.docParams)) + '/ws');
+			var wopiSrc = '';
+			if (map.options.wopiSrc != '') {
+				wopiSrc = '?WOPISrc=' + map.options.wopiSrc;
+			}
+			this.socket = new WebSocket(map.options.server + '/lool/' + encodeURIComponent(map.options.doc + '?' + $.param(map.options.docParams)) + '/ws' + wopiSrc);
 			this.socket.onerror = L.bind(this._onSocketError, this);
 			this.socket.onclose = L.bind(this._onSocketClose, this);
 			this.socket.onopen = L.bind(this._onSocketOpen, this);
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index aed686f4..d5ffef57 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -537,8 +537,13 @@ L.TileLayer = L.GridLayer.extend({
 		var command = this._map._socket.parseServerCmd(textMsg);
 		var parser = document.createElement('a');
 		parser.href = this._map.options.server;
+
+		var wopiSrc = '';
+		if (map.options.wopiSrc != '') {
+			wopiSrc = '?WOPISrc=' + map.options.wopiSrc;
+		}
 		var url = this._map.options.webserver + '/' + this._map.options.urlPrefix + '/' +
-		    encodeURIComponent(this._map.options.doc) + '/' + command.jail + '/' + command.dir + '/' + command.name;
+		    encodeURIComponent(this._map.options.doc) + '/' + command.jail + '/' + command.dir + '/' + command.name + wopiSrc;
 
 		this._map.hideBusy();
 		if (command.id === 'print') {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index fca9e8c6..d66d75f4 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -18,7 +18,8 @@ L.Map = L.Evented.extend({
 		defaultZoom: 10,
 		tileWidthTwips: 3840,
 		tileHeightTwips: 3840,
-		urlPrefix: 'lool'
+		urlPrefix: 'lool',
+		wopiSrc: ''
 	},
 
 	lastActiveTime: Date.now(),
diff --git a/loleaflet/src/map/handler/Map.FileInserter.js b/loleaflet/src/map/handler/Map.FileInserter.js
index f6388dbb..7b6811b0 100644
--- a/loleaflet/src/map/handler/Map.FileInserter.js
+++ b/loleaflet/src/map/handler/Map.FileInserter.js
@@ -14,8 +14,12 @@ L.Map.FileInserter = L.Handler.extend({
 		this._toInsert = {};
 		var parser = document.createElement('a');
 		parser.href = map.options.server;
+		var wopiSrc = '';
+		if (map.options.wopiSrc != '') {
+			wopiSrc = '?WOPISrc=' + map.options.wopiSrc;
+		}
 		this._url = map.options.webserver + '/' + map.options.urlPrefix +
-			'/' + encodeURIComponent(map.options.doc) + '/insertfile';
+			'/' + encodeURIComponent(map.options.doc) + '/insertfile' + wopiSrc;
 	},
 
 	addHooks: function () {


More information about the Libreoffice-commits mailing list