[Libreoffice-commits] online.git: 2 commits - loleaflet/src
Tor Lillqvist
tml at collabora.com
Thu Jan 12 10:11:45 UTC 2017
loleaflet/src/core/Socket.js | 9 ++++++++-
loleaflet/src/layer/tile/CalcTileLayer.js | 1 +
loleaflet/src/layer/tile/ImpressTileLayer.js | 1 +
3 files changed, 10 insertions(+), 1 deletion(-)
New commits:
commit 6370143a4b935d97556036f9c02c88ae0d00d7a0
Author: Tor Lillqvist <tml at collabora.com>
Date: Thu Jan 12 11:38:28 2017 +0200
Slight re-factoring: introduce getParameterValue() function
I started changing the cases for all the parameters to use similar
code as for the 'hash=' one: Check the parameter name with
startsWith() instead of fragile substring() function call where the
length parameter must match the length of a string literal that the
substring() result is compared to.
But then I got bored and gave up. It would be even better to not have
to tediously check for all defined parameter names, but instead just
parse each parameter using the same code that sets the property whose
name we found. Except that we have special cases where the parameter
name in the protocol doesn't match our coresponding property name, and
those that consist of a list of comma-separated values.
Maybe we indeed should just switch to JSON (or some binary
representation of JSON or somesuch).
Change-Id: Ibcdb26d7228b75f6f23c186f0b17cb46a12f3cec
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 4e4c935b..9ba1ec5 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -7,6 +7,13 @@
L.Socket = L.Class.extend({
ProtocolVersionNumber: '0.1',
+ getParameterValue: function (s) {
+ var i = s.indexOf('=');
+ if (i === -1)
+ return undefined;
+ return s.substring(i+1);
+ },
+
initialize: function (map) {
this._map = map;
try {
@@ -603,7 +610,7 @@ L.Socket = L.Class.extend({
command.rendercount = parseInt(tokens[i].substring(12));
}
else if (tokens[i].startsWith('hash=')) {
- command.hash = tokens[i].substring(tokens[i].indexOf('=')+1);
+ command.hash = this.getParameterValue(tokens[i]);
}
}
if (command.tileWidth && command.tileHeight && this._map._docLayer) {
commit 23db565b5b1aecff6ae6501250792e49ae35ed9a
Author: Tor Lillqvist <tml at collabora.com>
Date: Thu Jan 12 11:19:48 2017 +0200
Add Emacs mode lines
Change-Id: I208407f3017f71a4dfb2b86055a9bc639ee2f23c
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index cd4ed60..39869a6 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -1,3 +1,4 @@
+/* -*- js-indent-level: 8 -*- */
/*
* Calc tile layer is used to display a spreadsheet document
*/
diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js b/loleaflet/src/layer/tile/ImpressTileLayer.js
index 3326fa2..496fa91 100644
--- a/loleaflet/src/layer/tile/ImpressTileLayer.js
+++ b/loleaflet/src/layer/tile/ImpressTileLayer.js
@@ -1,3 +1,4 @@
+/* -*- js-indent-level: 8 -*- */
/*
* Impress tile layer is used to display a presentation document
*/
More information about the Libreoffice-commits
mailing list