loleaflet/.eslintrc | 4 loleaflet/dist/toolbar/toolbar.js | 28 +++--- loleaflet/src/admin/AdminSocketAnalytics.js | 15 +-- loleaflet/src/admin/AdminSocketBase.js | 5 - loleaflet/src/admin/AdminSocketHistory.js | 4 loleaflet/src/admin/AdminSocketOverview.js | 86 +++++++++------------ loleaflet/src/admin/AdminSocketSettings.js | 7 - loleaflet/src/admin/Util.js | 2 loleaflet/src/control/Control.Attribution.js | 2 loleaflet/src/control/Control.ColumnHeader.js | 14 +-- loleaflet/src/control/Control.DocumentRepair.js | 10 +- loleaflet/src/control/Control.Header.js | 4 loleaflet/src/control/Control.LokDialog.js | 6 - loleaflet/src/control/Control.Menubar.js | 18 ++-- loleaflet/src/control/Control.MetricInput.js | 12 +- loleaflet/src/control/Control.PartsPreview.js | 2 loleaflet/src/control/Control.RowHeader.js | 14 +-- loleaflet/src/control/Control.Scroll.Annotation.js | 9 -- loleaflet/src/control/Parts.js | 10 +- loleaflet/src/control/Ruler.js | 6 - loleaflet/src/control/Styles.js | 2 loleaflet/src/control/Toolbar.js | 2 loleaflet/src/core/Socket.js | 21 ++--- loleaflet/src/geometry/LineUtil.js | 2 loleaflet/src/layer/AnnotationManager.js | 9 -- loleaflet/src/layer/marker/Annotation.js | 2 loleaflet/src/layer/tile/CalcTileLayer.js | 5 - loleaflet/src/layer/tile/GridLayer.js | 2 loleaflet/src/layer/tile/ImpressTileLayer.js | 16 +-- loleaflet/src/layer/tile/TileLayer.js | 24 ++--- loleaflet/src/layer/vector/Path.Popup.js | 2 loleaflet/src/map/Map.js | 4 loleaflet/src/map/handler/Map.FileInserter.js | 2 loleaflet/src/map/handler/Map.Keyboard.js | 8 + loleaflet/src/map/handler/Map.WOPI.js | 14 +-- 35 files changed, 179 insertions(+), 194 deletions(-)
New commits: commit b4038eb442bd7d22386287841479c06727746197 Author: Pranav Kant <[email protected]> Date: Tue Dec 19 18:11:45 2017 +0530 Make eslint more strict, and fix all the problems reported The new checks should help keep the codebase a bit cleaner from now. Change-Id: Ib1d77af00e234b8eeb34b09beffc24b95c2eeafc diff --git a/loleaflet/.eslintrc b/loleaflet/.eslintrc index d073b55f..48a6d2ad 100644 --- a/loleaflet/.eslintrc +++ b/loleaflet/.eslintrc @@ -1,4 +1,5 @@ { + "extends": "eslint:recommended", "rules": { "camelcase": 2, "quotes": [2, "single"], @@ -14,7 +15,8 @@ "no-multi-spaces": 0, "strict": 0, "key-spacing": 0, - "no-shadow": 0 + "no-shadow": 0, + "no-console": 0 }, "globals": { "L": true, diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js index a5c7868b..5baaf22d 100644 --- a/loleaflet/dist/toolbar/toolbar.js +++ b/loleaflet/dist/toolbar/toolbar.js @@ -3,7 +3,7 @@ */ /* global $ map closebutton w2ui w2utils vex _ */ - +/* exported onUseritemClicked editorUpdate */ var mobileWidth = 768; function onDelete(e) { @@ -169,7 +169,7 @@ function _cancelSearch() { function onClick(id, item, subItem) { if (w2ui['toolbar-up'].get(id) !== null) { var toolbar = w2ui['toolbar-up']; - var item = toolbar.get(id); + item = toolbar.get(id); } else if (w2ui.formulabar.get(id) !== null) { toolbar = w2ui.formulabar; @@ -621,7 +621,7 @@ $(function () { onClick: function (e) { onClick(e.target); }, - onRefresh: function(e) { + onRefresh: function() { $('#addressInput').off('keyup', onAddressInput).on('keyup', onAddressInput); $('#formulaInput').off('keyup', onFormulaInput).on('keyup', onFormulaInput); $('#formulaInput').off('blur', onFormulaBarBlur).on('blur', onFormulaBarBlur); @@ -711,7 +711,7 @@ $(function () { } onClick(e.target, e.item, e.subItem); }, - onRefresh: function(e) { + onRefresh: function() { $('#tb_toolbar-down_item_userlist .w2ui-tb-caption').addClass('loleaflet-font'); $('#search-input').off('input', onSearch).on('input', onSearch); $('#search-input').off('keypress', onSearchKeyPress).on('keypress', onSearchKeyPress); @@ -774,7 +774,7 @@ function selectItem(item, func) } } -function onSearch(e) { +function onSearch() { var toolbar = w2ui['toolbar-down']; // conditionally disabling until, we find a solution for tdf#108577 if (L.DomUtil.get('search-input').value === '') { @@ -1065,8 +1065,8 @@ map.on('doclayerinit', function () { html: '<div id="StatusSelectionMode" class="loleaflet-font" title="'+_('Selection Mode')+ '" style="padding: 5px 5px;">  </div>' }, {type: 'break', id:'break8'}, {type: 'html', id: 'StateTableCell', - html: '<div id="StateTableCell" class="loleaflet-font" title="'+_('Choice of functions')+ '" style="padding: 5px 5px;">  </div>' }, - {type: 'menu', id: 'StateTableCellMenu', caption: '', current: 5, items: [ + html: '<div id="StateTableCell" class="loleaflet-font" title="'+_('Choice of functions')+ '" style="padding: 5px 5px;">  </div>' }, + {type: 'menu', id: 'StateTableCellMenu', caption: '', current: 5, items: [ { func: '2', text: _('Average'), icon: ''}, { func: '8', text: _('CountA'), icon: ''}, { func: '4', text: _('Count'), icon: ''}, @@ -1074,8 +1074,8 @@ map.on('doclayerinit', function () { { func: '32', text: _('Minimum'), icon: ''}, { func: '512', text: _('Sum'), icon: 'selected'}, { func: '8192', text: _('Selection count'), icon: ''}, - { func: '1', text: _('None'), icon: ''}, - ]}, + { func: '1', text: _('None'), icon: ''} + ]} ]); // Remove irrelevant toolbars @@ -1156,7 +1156,6 @@ map.on('commandstatechanged', function (e) { var state = e.state; var found = false; var value, color, div; - var matches; if (commandName === '.uno:AssignLayout') { $('.styles-select').val(state).trigger('change'); @@ -1464,7 +1463,7 @@ function updateCommandValues() { } } -map.on('updatetoolbarcommandvalues', function(e) { +map.on('updatetoolbarcommandvalues', function() { w2ui['toolbar-up'].refresh(); }); @@ -1830,11 +1829,11 @@ map.on('removeview', function(e) { }); map.on('updateEditorName', function(e) { - $('#currently-msg').show() + $('#currently-msg').show(); $('#current-editor').text(e.username); }); -map.on('setFollowOff', function(e) { +map.on('setFollowOff', function() { var docLayer = map._docLayer; var viewId = docLayer._followThis; if (viewId !== -1 && map._viewInfo[viewId]) { @@ -1850,11 +1849,10 @@ $(window).resize(function() { }); $(document).ready(function() { - var toolbar = w2ui['toolbar-up']; if (!closebutton) { $('#closebuttonwrapper').hide(); } else { - $('#closebutton').click(function(e) { + $('#closebutton').click(function() { map.fire('postMessage', {msgId: 'close', args: {EverModified: map._everModified, Deprecated: true}}); map.fire('postMessage', {msgId: 'UI_Close', args: {EverModified: map._everModified}}); map.remove(); diff --git a/loleaflet/src/admin/AdminSocketAnalytics.js b/loleaflet/src/admin/AdminSocketAnalytics.js index 7652d4b6..d6a80f17 100644 --- a/loleaflet/src/admin/AdminSocketAnalytics.js +++ b/loleaflet/src/admin/AdminSocketAnalytics.js @@ -3,8 +3,7 @@ containing various graphs to show to the user on specified interval */ -/* global d3 Util AdminSocketBase */ -/* eslint no-unused-vars:0 */ +/* global d3 Util AdminSocketBase $ Admin */ var AdminSocketAnalytics = AdminSocketBase.extend({ constructor: function(host) { this.base(host); @@ -120,9 +119,11 @@ var AdminSocketAnalytics = AdminSocketBase.extend({ d3XAxis = d3.svg.axis() .scale(xScale) .tickFormat(function(d) { - var d = Math.abs(d / 1000), sUnit; + d = Math.abs(d / 1000); + var sUnit = 0; + var i = 0; var units = ['s', 'min', 'hr']; - for (var i = 0; i < units.length && Math.abs(d) >= 60; i++) { + for (i = 0; i < units.length && Math.abs(d) >= 60; i++) { sUnit = parseInt(d % 60); d = parseInt(d / 60); } @@ -393,9 +394,9 @@ var AdminSocketAnalytics = AdminSocketBase.extend({ } if (reset) { - for (i = 0; i <= this._netStatsSize - this._netAvgSize; i++) { + for (var i = 0; i <= this._netStatsSize - this._netAvgSize; i++) { tempSum = 0; - for (j = 0; j < this._netAvgSize; j++) { + for (var j = 0; j < this._netAvgSize; j++) { tempSum += data[i + j].value; } tempSum /= this._netAvgSize; @@ -580,4 +581,4 @@ var AdminSocketAnalytics = AdminSocketBase.extend({ Admin.Analytics = function(host) { return new AdminSocketAnalytics(host); -}; \ No newline at end of file +}; diff --git a/loleaflet/src/admin/AdminSocketBase.js b/loleaflet/src/admin/AdminSocketBase.js index 145755cf..1d518245 100644 --- a/loleaflet/src/admin/AdminSocketBase.js +++ b/loleaflet/src/admin/AdminSocketBase.js @@ -2,8 +2,7 @@ Abstract class */ -/* global Util vex Base */ -/* eslint no-unused-vars:0 */ +/* global _ Util vex Base */ var AdminSocketBase = Base.extend({ socket: null, @@ -27,7 +26,7 @@ var AdminSocketBase = Base.extend({ onSocketOpen: function() { // Authenticate - cookie = Util.getCookie('jwt'); + var cookie = Util.getCookie('jwt'); this.socket.send('auth ' + cookie); }, diff --git a/loleaflet/src/admin/AdminSocketHistory.js b/loleaflet/src/admin/AdminSocketHistory.js index 05f9b063..f3fca24c 100644 --- a/loleaflet/src/admin/AdminSocketHistory.js +++ b/loleaflet/src/admin/AdminSocketHistory.js @@ -1,8 +1,7 @@ /* Socket to be intialized on opening the history page in Admin console */ -/* global $ nodejson2html Util AdminSocketBase */ -/* eslint no-unused-vars:0 */ +/* global Admin $ AdminSocketBase */ var AdminSocketHistory = AdminSocketBase.extend({ constructor: function(host) { this.base(host); @@ -48,4 +47,3 @@ var AdminSocketHistory = AdminSocketBase.extend({ Admin.History = function(host) { return new AdminSocketHistory(host); }; - diff --git a/loleaflet/src/admin/AdminSocketOverview.js b/loleaflet/src/admin/AdminSocketOverview.js index 664b0143..01cf754f 100644 --- a/loleaflet/src/admin/AdminSocketOverview.js +++ b/loleaflet/src/admin/AdminSocketOverview.js @@ -1,8 +1,7 @@ /* Socket to be intialized on opening the overview page in Admin console */ -/* global vex $ Util AdminSocketBase */ -/* eslint no-unused-vars:0 */ +/* global _ vex $ Util AdminSocketBase Admin */ function appendDocRow(document, $rowContainer, $userContainer, sPid, sName, sViews, sMem, sDocTime, sDocIdle, modified) { @@ -128,11 +127,11 @@ var AdminSocketOverview = AdminSocketBase.extend({ var $doc, $a, $rowContainer; var nViews, nTotalViews; - var docProps, sPid, sName, sViews, sMem, sDocTime; + var docProps, sPid, sName, sViews, sMem, sDocTime, sDocIdle, modified, userListJson; if (textMsg.startsWith('documents')) { - jsonStart = textMsg.indexOf('{'); - jsonMsg = JSON.parse(textMsg.substr(jsonStart).trim()); - docList = jsonMsg['documents']; + var jsonStart = textMsg.indexOf('{'); + var jsonMsg = JSON.parse(textMsg.substr(jsonStart).trim()); + var docList = jsonMsg['documents']; for (var i = 0; i < docList.length; i++) { docProps = docList[i]; @@ -147,44 +146,43 @@ var AdminSocketOverview = AdminSocketBase.extend({ $doc = $('#doc' + sPid); $rowContainer = $(document.createElement('tr')).attr('id', 'doc' + sPid); - $userContainer = $(document.createElement('div')).attr('id', 'ucontainer' + sPid) + var $userContainer = $(document.createElement('div')).attr('id', 'ucontainer' + sPid) .addClass('userContainer dropdown'); - $listContainer = $(document.createElement('ul')).addClass('dropdown-menu'); - $listLabel = $(document.createElement('li')).addClass('dropdown-header') + var $listContainer = $(document.createElement('ul')).addClass('dropdown-menu'); + var $listLabel = $(document.createElement('li')).addClass('dropdown-header') .text('Users'); $listContainer.append($listLabel); for (var j = 0; j < userListJson.length; j++) { - $user = $(document.createElement('li')).attr('id', 'user' + userListJson[j]['sessionid']); - $userA = $(document.createElement('a')).text(userListJson[j]['userName']); + var $user = $(document.createElement('li')).attr('id', 'user' + userListJson[j]['sessionid']); + var $userA = $(document.createElement('a')).text(userListJson[j]['userName']); $user.append($userA); $listContainer.append($user); - sessionid = userListJson[j]['sessionid']; - UName = userListJson[j]['userName']; - encodedUId = encodeURI(userListJson[j]['userId']); + var sessionid = userListJson[j]['sessionid']; + var encodedUId = encodeURI(userListJson[j]['userId']); - $userListRow = $(document.getElementById('usr' + encodedUId)); + var $userListRow = $(document.getElementById('usr' + encodedUId)); if ($userListRow.length == 0) { $userListRow = $(document.createElement('tr')).attr('id', 'usr' + encodedUId); - $uName = $(document.createElement('td')).text(userListJson[j]['userName']); + var $uName = $(document.createElement('td')).text(userListJson[j]['userName']); $userListRow.append($uName); $number = $(document.createElement('div')).addClass('doc_number').attr('id', 'num' + encodedUId).text(1); - $noOfDocuments = $(document.createElement('td')).append($number); + var $noOfDocuments = $(document.createElement('td')).append($number); // Document List - $docListContainer = $(document.createElement('div')).addClass('dropdown docContainer'); - $docDropDown = $(document.createElement('ul')).addClass('dropdown-menu') - .attr('id', 'docListContainer_' + encodedUId); - $docListHeader = $(document.createElement('li')).addClass('dropdown-header') - .text(_('Documents')); - $name = $(document.createElement('a')).text(sName); - $docentry = $(document.createElement('li')).addClass('docentry') - .attr('id', sessionid + '_' + sPid) - .append($name); + var $docListContainer = $(document.createElement('div')).addClass('dropdown docContainer'); + var $docDropDown = $(document.createElement('ul')).addClass('dropdown-menu') + .attr('id', 'docListContainer_' + encodedUId); + var $docListHeader = $(document.createElement('li')).addClass('dropdown-header') + .text(_('Documents')); + var $name = $(document.createElement('a')).text(sName); + var $docentry = $(document.createElement('li')).addClass('docentry') + .attr('id', sessionid + '_' + sPid) + .append($name); $docDropDown.append($docListHeader); $docDropDown.append($docentry); $docListContainer.append($docDropDown); @@ -195,14 +193,9 @@ var AdminSocketOverview = AdminSocketBase.extend({ $('#userlist').append($userListRow); } else { - userListChildren = $userListRow[0].childNodes; - var $number = $(document.getElementById('num' + encodedUId)); - docCount = parseInt($number.text()) + var docCount = parseInt($number.text()); $number.text(docCount + 1); - - $docParent = $(userListChildren[1]); - $name = $(document.createElement('a')).text(sName); $docentry = $(document.createElement('li')).addClass('docentry') .attr('id', sessionid + '_' + sPid) @@ -231,7 +224,7 @@ var AdminSocketOverview = AdminSocketBase.extend({ sPid = docProps[0]; sName = decodeURI(docProps[1]); sessionid = docProps[2]; - uName = decodeURI(docProps[3]); + var uName = decodeURI(docProps[3]); encodedUId = encodeURI(docProps[4]); sMem = docProps[5]; @@ -255,12 +248,12 @@ var AdminSocketOverview = AdminSocketBase.extend({ $a.text(parseInt($a.text()) + 1); } - $views = $(document.getElementById('docview' + sPid)); + var $views = $(document.getElementById('docview' + sPid)); nViews = parseInt($views.text()); $views.text(nViews + 1); $userContainer = $(document.getElementById('ucontainer' + sPid)); - $list = $('ul', $userContainer) + var $list = $('ul', $userContainer); $user = $(document.createElement('li')).attr('id', 'user' + sessionid); $userA = $(document.createElement('a')).text(uName); $user.append($userA); @@ -302,14 +295,9 @@ var AdminSocketOverview = AdminSocketBase.extend({ $('#userlist').append($userListRow); } else { - userListChildren = $userListRow[0].childNodes; - - var $number = $(document.getElementById('num' + encodedUId)); - docCount = parseInt($number.text()) + $number = $(document.getElementById('num' + encodedUId)); + docCount = parseInt($number.text()); $number.text(docCount + 1); - - $docParent = $(userListChildren[1]); - $name = $(document.createElement('a')).text(sName); $docentry = $(document.createElement('li')).addClass('docentry') .attr('id', sessionid + '_' + sPid) @@ -356,9 +344,9 @@ var AdminSocketOverview = AdminSocketBase.extend({ $a.text(nTotalViews - 1); } - $docEntry = $('#' + sessionid + '_' + sPid); + var $docEntry = $('#' + sessionid + '_' + sPid); $user = $docEntry.parent().parent().parent(); - $nDocs = $('.doc_number', $user.parent()); + var $nDocs = $('.doc_number', $user.parent()); docCount = parseInt($nDocs.text()); if (docCount == 1) { $user.parent().remove(); @@ -372,13 +360,13 @@ var AdminSocketOverview = AdminSocketBase.extend({ textMsg = textMsg.substring('propchange'.length); docProps = textMsg.trim().split(' '); sPid = docProps[0]; - sProp = docProps[1]; - sValue = docProps[2]; + var sProp = docProps[1]; + var sValue = docProps[2]; $doc = $('#doc' + sPid); if ($doc.length !== 0) { if (sProp == 'mem') { - $mem = $('#docmem' + sPid); + var $mem = $('#docmem' + sPid); $mem.text(Util.humanizeMem(parseInt(sValue))); } } @@ -387,9 +375,9 @@ var AdminSocketOverview = AdminSocketBase.extend({ textMsg = textMsg.substring('modifications'.length); docProps = textMsg.trim().split(' '); sPid = docProps[0]; - value = docProps[1]; + var value = docProps[1]; - $mod = $(document.getElementById('mod' + sPid)); + var $mod = $(document.getElementById('mod' + sPid)); $mod.text(value); } }, diff --git a/loleaflet/src/admin/AdminSocketSettings.js b/loleaflet/src/admin/AdminSocketSettings.js index e44fe289..71e6bf9d 100644 --- a/loleaflet/src/admin/AdminSocketSettings.js +++ b/loleaflet/src/admin/AdminSocketSettings.js @@ -1,8 +1,7 @@ /* Socket to be intialized on opening the settings page in Admin console */ -/* global $ AdminSocketBase */ -/* eslint no-unused-vars:0 */ +/* global vex $ AdminSocketBase Admin _ */ var AdminSocketSettings = AdminSocketBase.extend({ constructor: function(host) { this.base(host); @@ -32,7 +31,7 @@ var AdminSocketSettings = AdminSocketBase.extend({ $('#btnShutdown').click(function() { vex.dialog.confirm({ message: _('Are you sure you want to shut down the server?'), - callback: function(value) { + callback: function() { // TODO: Prompt for reason. socketSettings.send('shutdown maintenance'); } @@ -82,7 +81,7 @@ var AdminSocketSettings = AdminSocketBase.extend({ } else if (textMsg.startsWith('lokitversion ')) { var lokitVersionObj = JSON.parse(textMsg.substring(textMsg.indexOf('{'))); - var h = lokitVersionObj.BuildId.substring(0, 7); + h = lokitVersionObj.BuildId.substring(0, 7); if (parseInt(h,16).toString(16) === h.toLowerCase().replace(/^0+/, '')) { h = '<a target="_blank" href="https://hub.libreoffice.org/git-core/' + h + '">' + h + '</a>'; } diff --git a/loleaflet/src/admin/Util.js b/loleaflet/src/admin/Util.js index 35f6c81f..467bac97 100644 --- a/loleaflet/src/admin/Util.js +++ b/loleaflet/src/admin/Util.js @@ -1,7 +1,7 @@ /* Utility class */ -/* global Base */ +/* global Base _ */ /* eslint no-unused-vars:0 */ var Util = Base.extend({ constructor: null diff --git a/loleaflet/src/control/Control.Attribution.js b/loleaflet/src/control/Control.Attribution.js index 17cc79e5..8d4f5ccc 100644 --- a/loleaflet/src/control/Control.Attribution.js +++ b/loleaflet/src/control/Control.Attribution.js @@ -12,7 +12,7 @@ L.Control.Attribution = L.Control.extend({ L.setOptions(this, options); }, - onAdd: function (map) { + onAdd: function () { if (!this._container) { this._container = L.DomUtil.create('div', 'leaflet-control-attribution'); L.DomEvent.disableClickPropagation(this._container); diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js index 741ef825..d3f86b0f 100644 --- a/loleaflet/src/control/Control.ColumnHeader.js +++ b/loleaflet/src/control/Control.ColumnHeader.js @@ -60,7 +60,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ items: { 'insertcolbefore': { name: _('Insert column before'), - callback: function(key, options) { + callback: function() { var index = colHeaderObj._lastMouseOverIndex; if (index) { colHeaderObj.insertColumn.call(colHeaderObj, index); @@ -69,7 +69,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ }, 'deleteselectedcol': { name: _('Delete column'), - callback: function(key, options) { + callback: function() { var index = colHeaderObj._lastMouseOverIndex; if (index) { colHeaderObj.deleteColumn.call(colHeaderObj, index); @@ -78,7 +78,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ }, 'optimalwidth': { name: _('Optimal Width') + '...', - callback: function(key, options) { + callback: function() { var index = colHeaderObj._lastMouseOverIndex; if (index) { colHeaderObj.optimalWidth.call(colHeaderObj, index); @@ -87,7 +87,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ }, 'hideColumn': { name: _('Hide Columns'), - callback: function(key, options) { + callback: function() { var index = colHeaderObj._lastMouseOverIndex; if (index) { colHeaderObj.hideColumn.call(colHeaderObj, index); @@ -96,7 +96,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ }, 'showColumn': { name: _('Show Columns'), - callback: function(key, options) { + callback: function() { var index = colHeaderObj._lastMouseOverIndex; if (index) { colHeaderObj.showColumn.call(colHeaderObj, index); @@ -167,7 +167,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ this._position = Math.min(0, this._position- offset); }, - _onClearSelection: function (e) { + _onClearSelection: function () { this.clearSelection(this._data); }, @@ -594,7 +594,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ this._map.removeLayer(this._vertLine); }, - onDragClick: function (item, clicks, e) { + onDragClick: function (item, clicks/*, e*/) { this._map.removeLayer(this._vertLine); if (!this._mouseOverEntry) diff --git a/loleaflet/src/control/Control.DocumentRepair.js b/loleaflet/src/control/Control.DocumentRepair.js index f425db7f..3718ba52 100644 --- a/loleaflet/src/control/Control.DocumentRepair.js +++ b/loleaflet/src/control/Control.DocumentRepair.js @@ -1,7 +1,7 @@ /* * L.Control.DocumentRepair. */ - +/* global $ _ */ L.Control.DocumentRepair = L.Control.extend({ options: { position: 'topright' @@ -11,7 +11,7 @@ L.Control.DocumentRepair = L.Control.extend({ L.setOptions(this, options); }, - onAdd: function (map) { + onAdd: function () { this._initLayout(); return this._container; @@ -69,7 +69,7 @@ L.Control.DocumentRepair = L.Control.extend({ // Show relative date by default, absolute one as tooltip. td = L.DomUtil.create('td', '', row); - var relativeDateTime = jQuery.timeago(dateTime.replace(/,.*/, 'Z')); + var relativeDateTime = $.timeago(dateTime.replace(/,.*/, 'Z')); var span = document.createElement('span'); span.title = dateTime; span.appendChild(document.createTextNode(relativeDateTime)); @@ -110,7 +110,7 @@ L.Control.DocumentRepair = L.Control.extend({ L.DomUtil.addClass(this._selected, 'leaflet-popup-selected'); }, - _onCloseClick: function (e) { + _onCloseClick: function () { this._map.enable(true); this._refocusOnMap(); this.remove(); @@ -122,7 +122,7 @@ L.Control.DocumentRepair = L.Control.extend({ } }, - _onJumpClick: function (e) { + _onJumpClick: function () { if (this._selected) { var action = this._selected.childNodes[0].innerHTML; var index = parseInt(this._selected.childNodes[1].innerHTML); diff --git a/loleaflet/src/control/Control.Header.js b/loleaflet/src/control/Control.Header.js index ad8edec3..844e340e 100644 --- a/loleaflet/src/control/Control.Header.js +++ b/loleaflet/src/control/Control.Header.js @@ -255,7 +255,7 @@ L.Control.Header = L.Control.extend({ this._onHeaderMouseOut(e); }, - _onHeaderMouseOut: function (e) { + _onHeaderMouseOut: function () { if (!this._overHeaderArea) return; this._overHeaderArea = false; @@ -785,4 +785,4 @@ L.Control.Header = L.Control.extend({ }); -})(); \ No newline at end of file +})(); diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js index 772e7328..b710950d 100644 --- a/loleaflet/src/control/Control.LokDialog.js +++ b/loleaflet/src/control/Control.LokDialog.js @@ -2,7 +2,7 @@ * L.Control.LokDialog used for displaying LOK dialogs */ -/* global vex $ map */ +/* global $ map */ L.Control.LokDialog = L.Control.extend({ dialogIdPrefix: 'lokdialog-', @@ -132,10 +132,10 @@ L.Control.LokDialog = L.Control.extend({ this._sendPaintWindow(e.id, this._createRectStr()); } else if (e.action === 'cursor_invalidate') { if (this._isOpen(e.id) && !!e.rectangle) { - var rectangle = e.rectangle.split(','); + rectangle = e.rectangle.split(','); var x = parseInt(rectangle[0]); var y = parseInt(rectangle[1]); - var height = parseInt(rectangle[3]); + height = parseInt(rectangle[3]); $('#' + strDlgId + '-cursor').css({height: height}); // set the position of the lokdialog-cursor diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js index a9fb86f2..c4238091 100644 --- a/loleaflet/src/control/Control.Menubar.js +++ b/loleaflet/src/control/Control.Menubar.js @@ -11,7 +11,7 @@ L.Control.Menubar = L.Control.extend({ {name: _('Edit'), disabled: true}, {name: _('View'), disabled: true}, {name: _('Insert'), disabled: true}, - {name: _('Tools'), disabled: true}, + {name: _('Tools'), disabled: true} ], text: [ {name: _('File'), id: 'file', type: 'menu', menu: [ @@ -47,7 +47,7 @@ L.Control.Menubar = L.Control.extend({ {name: _('Previous'), type: 'unocommand', uno: '.uno:PreviousTrackedChange'}, {name: _('Next'), type: 'unocommand', uno: '.uno:NextTrackedChange'} ]}, - {name: _('Edit Style...'), uno: '.uno:EditStyle', type: 'unocommand'}, + {name: _('Edit Style...'), uno: '.uno:EditStyle', type: 'unocommand'} ]}, {name: _('View'), id: 'view', type: 'menu', menu: [ {name: _('Full screen'), id: 'fullscreen', type: 'action'}, @@ -56,7 +56,7 @@ L.Control.Menubar = L.Control.extend({ {name: _('Zoom out'), id: 'zoomout', type: 'action'}, {name: _('Reset zoom'), id: 'zoomreset', type: 'action'}, {type: 'separator'}, - {name: _('Formatting Marks'), type: 'unocommand', uno: '.uno:ControlCodes'}, + {name: _('Formatting Marks'), type: 'unocommand', uno: '.uno:ControlCodes'} ] }, {name: _('Insert'), type: 'menu', menu: [ @@ -409,9 +409,9 @@ L.Control.Menubar = L.Control.extend({ return a.translated < b.translated ? -1 : a.translated > b.translated ? 1 : 0; }); - $menuSelection = $('#menu-noneselection').parent(); - $menuParagraph = $('#menu-noneparagraph').parent(); - $menuDefault = $('#menu-nonelanguage').parent(); + var $menuSelection = $('#menu-noneselection').parent(); + var $menuParagraph = $('#menu-noneparagraph').parent(); + var $menuDefault = $('#menu-nonelanguage').parent(); for (var lang in languages) { translated = languages[lang].translated; neutral = languages[lang].neutral; @@ -467,7 +467,7 @@ L.Control.Menubar = L.Control.extend({ var $mainMenuState = $('#main-menu-state'); if ($mainMenuState.length) { // animate mobile menu - $mainMenuState.change(function(e) { + $mainMenuState.change(function() { var $menu = $('#main-menu'); if (this.checked) { $menu.hide().slideDown(250, function() { $menu.css('display', ''); }); @@ -773,8 +773,8 @@ L.Control.Menubar = L.Control.extend({ if (!subitemList.length) { continue; } - for (var j in subitemList) { - ulItem.appendChild(subitemList[j]); + for (var idx in subitemList) { + ulItem.appendChild(subitemList[idx]); } } else if (menu[i].type === 'unocommand') { $(aItem).data('type', 'unocommand'); diff --git a/loleaflet/src/control/Control.MetricInput.js b/loleaflet/src/control/Control.MetricInput.js index df616d51..c174bcef 100644 --- a/loleaflet/src/control/Control.MetricInput.js +++ b/loleaflet/src/control/Control.MetricInput.js @@ -1,7 +1,7 @@ /* * L.Control.MetricInput. */ - +/* global _ */ L.Control.MetricInput = L.Control.extend({ options: { position: 'topmiddle', @@ -16,7 +16,7 @@ L.Control.MetricInput = L.Control.extend({ this._default = value; }, - onAdd: function (map) { + onAdd: function () { this._initLayout(); return this._container; @@ -71,7 +71,7 @@ L.Control.MetricInput = L.Control.extend({ content.appendChild(inputButton); }, - onRemove: function (map) { + onRemove: function () { this._input = null; }, @@ -81,17 +81,17 @@ L.Control.MetricInput = L.Control.extend({ this._input.focus(); }, - _onDefaultClick: function (e) { + _onDefaultClick: function () { this._input.value = this._default; }, - _onOKButtonClick: function (e) { + _onOKButtonClick: function () { var data = parseFloat(this._input.value); this.remove(); this._callback.call(this._context, {type: 'submit', value: data}); }, - _onCloseButtonClick: function (e) { + _onCloseButtonClick: function () { this.remove(); this._callback.call(this._context, {type : 'close'}); } diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js index f466be8c..055f1053 100644 --- a/loleaflet/src/control/Control.PartsPreview.js +++ b/loleaflet/src/control/Control.PartsPreview.js @@ -2,7 +2,7 @@ * L.Control.PartsPreview */ -/* global $ map */ +/* global $ */ L.Control.PartsPreview = L.Control.extend({ options: { autoUpdate: true diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js index 48e982ab..30fdf98b 100644 --- a/loleaflet/src/control/Control.RowHeader.js +++ b/loleaflet/src/control/Control.RowHeader.js @@ -57,7 +57,7 @@ L.Control.RowHeader = L.Control.Header.extend({ items: { 'insertrowabove': { name: _('Insert row above'), - callback: function(key, options) { + callback: function() { var index = rowHeaderObj._lastMouseOverIndex; if (index) { rowHeaderObj.insertRow.call(rowHeaderObj, index); @@ -66,7 +66,7 @@ L.Control.RowHeader = L.Control.Header.extend({ }, 'deleteselectedrow': { name: _('Delete row'), - callback: function(key, options) { + callback: function() { var index = rowHeaderObj._lastMouseOverIndex; if (index) { rowHeaderObj.deleteRow.call(rowHeaderObj, index); @@ -75,7 +75,7 @@ L.Control.RowHeader = L.Control.Header.extend({ }, 'optimalheight': { name: _('Optimal Height') + '...', - callback: function(key, options) { + callback: function() { var index = rowHeaderObj._lastMouseOverIndex; if (index) { rowHeaderObj.optimalHeight.call(rowHeaderObj, index); @@ -84,7 +84,7 @@ L.Control.RowHeader = L.Control.Header.extend({ }, 'hideRow': { name: _('Hide Rows'), - callback: function(key, options) { + callback: function() { var index = rowHeaderObj._lastMouseOverIndex; if (index) { rowHeaderObj.hideRow.call(rowHeaderObj, index); @@ -93,7 +93,7 @@ L.Control.RowHeader = L.Control.Header.extend({ }, 'showRow': { name: _('Show Rows'), - callback: function(key, options) { + callback: function() { var index = rowHeaderObj._lastMouseOverIndex; if (index) { rowHeaderObj.showRow.call(rowHeaderObj, index); @@ -158,7 +158,7 @@ L.Control.RowHeader = L.Control.Header.extend({ this._position = Math.min(0, this._position - offset); }, - _onClearSelection: function (e) { + _onClearSelection: function () { this.clearSelection(this._data); }, @@ -552,7 +552,7 @@ L.Control.RowHeader = L.Control.Header.extend({ this._map.removeLayer(this._horzLine); }, - onDragClick: function (item, clicks, e) { + onDragClick: function (item, clicks/*, e*/) { this._map.removeLayer(this._horzLine); if (!this._mouseOverEntry) diff --git a/loleaflet/src/control/Control.Scroll.Annotation.js b/loleaflet/src/control/Control.Scroll.Annotation.js index 0eb3b2ce..64003f04 100644 --- a/loleaflet/src/control/Control.Scroll.Annotation.js +++ b/loleaflet/src/control/Control.Scroll.Annotation.js @@ -1,7 +1,7 @@ /* * L.Control.Scroll.Annotation */ - +/* global _ */ L.Control.Scroll.Annotation = L.Control.extend({ options: { position: 'topright', @@ -27,14 +27,11 @@ L.Control.Scroll.Annotation = L.Control.extend({ return container; }, - onRemove: function (map) { - }, - - _onScrollUp: function (e) { + _onScrollUp: function () { this._map.fire('AnnotationScrollUp'); }, - _onScrollDown: function (e) { + _onScrollDown: function () { this._map.fire('AnnotationScrollDown'); }, diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js index 1071db03..d8f89944 100644 --- a/loleaflet/src/control/Parts.js +++ b/loleaflet/src/control/Parts.js @@ -66,11 +66,11 @@ L.Map.include({ return; } else { - part = index; - tilePosX = 0; - tilePosY = 0; - tileWidth = docLayer._docWidthTwips; - tileHeight = docLayer._docHeightTwips; + var part = index; + var tilePosX = 0; + var tilePosY = 0; + var tileWidth = docLayer._docWidthTwips; + var tileHeight = docLayer._docHeightTwips; } var docRatio = tileWidth / tileHeight; var imgRatio = maxWidth / maxHeight; diff --git a/loleaflet/src/control/Ruler.js b/loleaflet/src/control/Ruler.js index d13e3cbd..c301580f 100644 --- a/loleaflet/src/control/Ruler.js +++ b/loleaflet/src/control/Ruler.js @@ -2,7 +2,7 @@ * Ruler Handler */ -/* global $ L */ +/* global $ L _ */ L.Control.Ruler = L.Control.extend({ options: { interactive: true, @@ -191,7 +191,7 @@ L.Control.Ruler = L.Control.extend({ this._rMarginDrag.style.width = newPos + 'px'; } else { - var newPos = this.options.DraggableConvertRatio*this.options.nullOffset + posChange; + newPos = this.options.DraggableConvertRatio*this.options.nullOffset + posChange; this._lToolTip.style.display = 'block'; this._lToolTip.style.left = newPos - 25 + 'px'; this._lToolTip.innerText = (Math.round(newPos / (this.options.DraggableConvertRatio * 100)) / 10).toString() + unit; @@ -234,4 +234,4 @@ L.Control.Ruler = L.Control.extend({ L.control.ruler = function (options) { return new L.Control.Ruler(options); -}; \ No newline at end of file +}; diff --git a/loleaflet/src/control/Styles.js b/loleaflet/src/control/Styles.js index 7cd3febd..a53c5685 100644 --- a/loleaflet/src/control/Styles.js +++ b/loleaflet/src/control/Styles.js @@ -328,5 +328,5 @@ L.Styles = { 'Extending selection', 'Adding selection', 'Block selection' - ], + ] }; diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js index 337188a0..0c8e7fd6 100644 --- a/loleaflet/src/control/Toolbar.js +++ b/loleaflet/src/control/Toolbar.js @@ -2,7 +2,7 @@ * Toolbar handler */ -/* global $ window vex brandProductName */ +/* global $ window vex brandProductName _ map */ L.Map.include({ // a mapping of uno commands to more readable toolbar items diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js index fb814ef2..9129b9c5 100644 --- a/loleaflet/src/core/Socket.js +++ b/loleaflet/src/core/Socket.js @@ -3,7 +3,7 @@ * L.Socket contains methods for the communication with the server */ -/* global _ vex $ errorMessages */ +/* global _ vex $ errorMessages Uint8Array brandProductName brandProductFAQURL */ L.Socket = L.Class.extend({ ProtocolVersionNumber: '0.1', ReconnectCount: 0, @@ -215,7 +215,7 @@ L.Socket = L.Class.extend({ } else if (textMsg.startsWith('lokitversion ')) { var lokitVersionObj = JSON.parse(textMsg.substring(textMsg.indexOf('{'))); - var h = lokitVersionObj.BuildId.substring(0, 7); + h = lokitVersionObj.BuildId.substring(0, 7); if (parseInt(h,16).toString(16) === h.toLowerCase().replace(/^0+/, '')) { h = '<a target="_blank" href="https://hub.libreoffice.org/git-core/' + h + '">' + h + '</a>'; } @@ -288,7 +288,7 @@ L.Socket = L.Class.extend({ var max = 10000; var timeoutMs = Math.floor(Math.random() * (max - min) + min); - socket = this; + var socket = this; map = this._map; vex.timer = setInterval(function() { if (socket.connected()) { @@ -305,6 +305,7 @@ L.Socket = L.Class.extend({ try { map.loadDocument(map); } catch (error) { + console.warn('Cannot load document.'); } }, timeoutMs); } @@ -326,13 +327,14 @@ L.Socket = L.Class.extend({ // Activate and cancel timer and dialogs. map._activate(); } catch (error) { + console.warn('Cannot activate map'); } }, 3000); } // Close any open dialogs first. if (vex.dialogID > 0) { - var id = vex.dialogID; + id = vex.dialogID; vex.dialogID = -1; vex.close(id); } @@ -368,7 +370,7 @@ L.Socket = L.Class.extend({ if (textMsg === 'idle' || textMsg === 'oom') { var map = this._map; - options.$vex.bind('click.vex', function(e) { + options.$vex.bind('click.vex', function() { console.debug('idleness: reactivating'); map._documentIdle = false; return map._activate(); @@ -415,7 +417,7 @@ L.Socket = L.Class.extend({ // TODO: We really really need to factor this out duplicate dialog code logic everywhere // Close any open dialogs first. if (vex.dialogID > 0) { - var id = vex.dialogID; + id = vex.dialogID; vex.dialogID = -1; vex.close(id); } @@ -509,6 +511,7 @@ L.Socket = L.Class.extend({ // Activate and cancel timer and dialogs. map._activate(); } catch (error) { + console.warn('Cannot activate map'); } }, 1000); } @@ -602,7 +605,7 @@ L.Socket = L.Class.extend({ this.ReconnectCount = 0; clearTimeout(vex.timer); if (vex.dialogID > 0) { - var id = vex.dialogID; + id = vex.dialogID; vex.dialogID = -1; vex.close(id); } @@ -642,7 +645,7 @@ L.Socket = L.Class.extend({ for (var i = 0; i < data.length; i++) { strBytes += String.fromCharCode(data[i]); } - var img = 'data:image/png;base64,' + window.btoa(strBytes); + img = 'data:image/png;base64,' + window.btoa(strBytes); } } @@ -733,7 +736,7 @@ L.Socket = L.Class.extend({ // Let onclose (_onSocketClose) report errors. }, - _onSocketClose: function (e) { + _onSocketClose: function () { console.debug('_onSocketClose:'); var isActive = this._map._active; this._map.hideBusy(); diff --git a/loleaflet/src/geometry/LineUtil.js b/loleaflet/src/geometry/LineUtil.js index c93209df..7d37961e 100644 --- a/loleaflet/src/geometry/LineUtil.js +++ b/loleaflet/src/geometry/LineUtil.js @@ -2,7 +2,7 @@ * L.LineUtil contains different utility functions for line segments * and polylines (clipping, simplification, distances, etc.) */ - +/* global Uint8Array */ L.LineUtil = { // Simplify polyline with vertex reduction and Douglas-Peucker simplification. diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js index c3e9b9a2..c9a6a09b 100644 --- a/loleaflet/src/layer/AnnotationManager.js +++ b/loleaflet/src/layer/AnnotationManager.js @@ -91,16 +91,13 @@ L.AnnotationManager = L.Class.extend({ return false; } - var rectangles, color, viewId; // transform change tracking index into an id redline.id = 'change-' + redline.index; redline.anchorPos = L.LOUtil.stringToBounds(redline.textRange); redline.anchorPix = this._map._docLayer._twipsToPixels(redline.anchorPos.min); redline.trackchange = true; redline.text = redline.comment; - rectangles = L.PolyUtil.rectanglesToPolygons(L.LOUtil.stringToRectangles(redline.textRange), this._map._docLayer); - viewId = this._map.getViewId(redline.author); - color = viewId >= 0 ? L.LOUtil.rgbToHex(this._map.getViewColor(viewId)) : '#43ACE8'; + var rectangles = L.PolyUtil.rectanglesToPolygons(L.LOUtil.stringToRectangles(redline.textRange), this._map._docLayer); if (rectangles.length > 0) { redline.textSelected = L.polygon(rectangles, { pointerEvents: 'all', @@ -257,7 +254,7 @@ L.AnnotationManager = L.Class.extend({ var point; var docRight = this._map.project(this._map.options.docBounds.getNorthEast()); point = this._map._docLayer._twipsToPixels(this._selected._data.anchorPos.min); - this._arrow.setLatLngs([this._map.unproject(point), map.unproject(L.point(docRight.x, point.y))]); + this._arrow.setLatLngs([this._map.unproject(point), this._map.unproject(L.point(docRight.x, point.y))]); this._map.addLayer(this._arrow); } else { this._map.removeLayer(this._arrow); @@ -665,7 +662,7 @@ L.AnnotationManager = L.Class.extend({ this._map.focus(); }, - _onAnnotationZoom: function (e) { + _onAnnotationZoom: function () { this._map.fire('updatemaxbounds', {sizeChanged: true}); this.layout(true); } diff --git a/loleaflet/src/layer/marker/Annotation.js b/loleaflet/src/layer/marker/Annotation.js index 9682034d..e357811c 100644 --- a/loleaflet/src/layer/marker/Annotation.js +++ b/loleaflet/src/layer/marker/Annotation.js @@ -2,7 +2,7 @@ * L.Annotation */ -/* global $ Autolinker L */ +/* global $ Autolinker L _ */ L.Annotation = L.Layer.extend({ options: { diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js index d0296b15..2cbeb06c 100644 --- a/loleaflet/src/layer/tile/CalcTileLayer.js +++ b/loleaflet/src/layer/tile/CalcTileLayer.js @@ -434,6 +434,7 @@ L.CalcTileLayer = L.TileLayer.extend({ return; } + var comment; if (values.commandName === '.uno:ViewRowColumnHeaders') { this._map.fire('viewrowcolumnheaders', { data: values, @@ -443,7 +444,6 @@ L.CalcTileLayer = L.TileLayer.extend({ this._onUpdateCurrentHeader(); this._onUpdateSelectionHeader(); } else if (values.comments) { - var comment; this.clearAnnotations(); for (var index in values.comments) { comment = values.comments[index]; @@ -458,9 +458,8 @@ L.CalcTileLayer = L.TileLayer.extend({ } this.showAnnotations(); } else if (values.commentsPos) { - var comment; this.hideAnnotations(); - for (var index in values.commentsPos) { + for (index in values.commentsPos) { comment = values.commentsPos[index]; comment.tab = parseInt(comment.tab); comment.cellPos = L.LOUtil.stringToBounds(comment.cellPos); diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js index d080cdfe..3994b847 100644 --- a/loleaflet/src/layer/tile/GridLayer.js +++ b/loleaflet/src/layer/tile/GridLayer.js @@ -368,7 +368,7 @@ L.GridLayer = L.Layer.extend({ return; } if (!zoom) { - var zoom = this._map.getZoom(); + zoom = this._map.getZoom(); } var docPixelLimits = new L.Point(this._docWidthTwips / this.options.tileWidthTwips, this._docHeightTwips / this.options.tileHeightTwips); diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js b/loleaflet/src/layer/tile/ImpressTileLayer.js index e20ff78a..fdbcc9fc 100644 --- a/loleaflet/src/layer/tile/ImpressTileLayer.js +++ b/loleaflet/src/layer/tile/ImpressTileLayer.js @@ -70,7 +70,7 @@ L.ImpressTileLayer = L.TileLayer.extend({ this._draft = null; }, - onAnnotationCancel: function (e) { + onAnnotationCancel: function () { if (this._draft) { this._map.removeLayer(this._draft); this._draft = null; @@ -137,7 +137,7 @@ L.ImpressTileLayer = L.TileLayer.extend({ this._map.focus(); }, - _onAnnotationZoom: function (e) { + _onAnnotationZoom: function () { this.onAnnotationCancel(); }, @@ -157,12 +157,12 @@ L.ImpressTileLayer = L.TileLayer.extend({ this._map.focus(); }, - onAnnotationScrollDown: function (e) { + onAnnotationScrollDown: function () { this._topAnnotation[this._selectedPart] = Math.min(++this._topAnnotation[this._selectedPart], this._annotations[this._partHashes[this._selectedPart]].length - 1); this.onAnnotationCancel(); }, - onAnnotationScrollUp: function (e) { + onAnnotationScrollUp: function () { if (this._topAnnotation[this._selectedPart] === 0) { this._map.fire('scrollby', {x: 0, y: -100}); } @@ -170,7 +170,7 @@ L.ImpressTileLayer = L.TileLayer.extend({ this.onAnnotationCancel(); }, - onUpdateParts: function (e) { + onUpdateParts: function () { if (typeof this._prevSelectedPart === 'number') { this.hideAnnotations(this._prevSelectedPart); if (this.hasAnnotations(this._selectedPart)) { @@ -235,13 +235,13 @@ L.ImpressTileLayer = L.TileLayer.extend({ bounds.extend(L.point(bounds.max.x, bounds.max.y + 2 * this.options.marginY)); } var offsetX = L.point(2 * this.options.marginX, 0); - var topLeft = (bounds ? bounds.getBottomLeft() : topRight).subtract(offsetX); + topLeft = (bounds ? bounds.getBottomLeft() : topRight).subtract(offsetX); annotation.setLatLng(this._map.layerPointToLatLng(topLeft)); bounds = annotation.getBounds(); bounds = L.bounds(bounds.getBottomLeft().add(offsetX), bounds.getTopRight().add(offsetX)); bounds.extend(L.point(bounds.max.x, bounds.max.y + 3 * this.options.marginY)); } else { - var topLeft = bounds ? bounds.getBottomLeft() : topRight; + topLeft = bounds ? bounds.getBottomLeft() : topRight; annotation.setLatLng(this._map.layerPointToLatLng(topLeft)); annotation.show(); bounds = annotation.getBounds(); @@ -277,7 +277,7 @@ L.ImpressTileLayer = L.TileLayer.extend({ if (values.comments) { this._annotations = {}; for (var index in values.comments) { - comment = values.comments[index]; + var comment = values.comments[index]; if (!this._annotations[comment.parthash]) { this._annotations[comment.parthash] = []; } diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index eedc1c51..26d12f8a 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -2,7 +2,7 @@ /* * L.TileLayer is used for standard xyz-numbered tile layers. */ - +/* global $ _ map Uint8ClampedArray Uint8Array */ // Implement String::startsWith which is non-portable (Firefox only, it seems) // See http://stackoverflow.com/questions/646628/how-to-check-if-a-string-startswith-another-string#4579228 @@ -15,11 +15,11 @@ if (typeof String.prototype.startsWith !== 'function') { function hex2string(inData) { - hexified = []; - data = new Uint8Array(inData); + var hexified = []; + var data = new Uint8Array(inData); for (var i = 0; i < data.length; i++) { - hex = data[i].toString(16); - paddedHex = ('00' + hex).slice(-2); + var hex = data[i].toString(16); + var paddedHex = ('00' + hex).slice(-2); hexified.push(paddedHex); } return hexified.join(''); @@ -1283,7 +1283,7 @@ L.TileLayer = L.GridLayer.extend({ canvas.height = 256; var ctx = canvas.getContext('2d'); - oldImg = new Image(); + var oldImg = new Image(); oldImg.src = tile.el.src; ctx.drawImage(oldImg, 0, 0); @@ -1331,10 +1331,10 @@ L.TileLayer = L.GridLayer.extend({ } break; case 100: // 'd': // new run - var destRow = delta[i+1]; + destRow = delta[i+1]; var destCol = delta[i+2]; var span = delta[i+3]; - var offset = destRow * canvas.width * 4 + destCol * 4; + offset = destRow * canvas.width * 4 + destCol * 4; i += 4; console.log('apply new span of size ' + span + ' at pos ' + destCol + ', ' + destRow + ' into delta at byte: ' + offset); span *= 4; @@ -1526,7 +1526,7 @@ L.TileLayer = L.GridLayer.extend({ // enable or disable blinking cursor and the cursor overlay depending on // the state of the document (if the falgs are set) - _updateCursorAndOverlay: function (update) { + _updateCursorAndOverlay: function (/*update*/) { if (this._map._permission === 'edit' && this._isCursorVisible && this._isCursorOverlayVisible @@ -2301,10 +2301,10 @@ L.TileLayer = L.GridLayer.extend({ rect.setStyle({fillOpacity: opac - 0.04}); } } - for (var key in this._debugTiles) { - var rect = this._debugTiles[key]; + for (key in this._debugTiles) { + rect = this._debugTiles[key]; var col = rect.options.fillColor; - var opac = rect.options.fillOpacity; + opac = rect.options.fillOpacity; if (col === 'blue' && opac >= 0.04 && rect.date + 1000 < +new Date()) { rect.setStyle({fillOpacity: opac - 0.04}); } diff --git a/loleaflet/src/layer/vector/Path.Popup.js b/loleaflet/src/layer/vector/Path.Popup.js index 247d8062..32079f4e 100644 --- a/loleaflet/src/layer/vector/Path.Popup.js +++ b/loleaflet/src/layer/vector/Path.Popup.js @@ -44,7 +44,7 @@ L.Path.include({ return this; }, - firstPopup: function (e) { + firstPopup: function () { if (this._popup) { this._openPopup({latlng: this._bounds.getCenter()}); } diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js index 6c5d8f71..9020f160 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -3,7 +3,7 @@ * L.Map is the central class of the API - it is used to create a map. */ -/* global vex $ */ +/* global vex $ _ */ L.Map = L.Evented.extend({ options: { @@ -906,7 +906,7 @@ L.Map = L.Evented.extend({ vex: options }); - options.$vex.bind('click.vex', function(e) { + options.$vex.bind('click.vex', function() { console.debug('_dim: click.vex function'); return map._activate(); }); diff --git a/loleaflet/src/map/handler/Map.FileInserter.js b/loleaflet/src/map/handler/Map.FileInserter.js index 7b6811b0..fe0f4b31 100644 --- a/loleaflet/src/map/handler/Map.FileInserter.js +++ b/loleaflet/src/map/handler/Map.FileInserter.js @@ -2,6 +2,8 @@ * L.Map.FileInserter is handling the fileInserter action */ +/* global _ */ + L.Map.mergeOptions({ fileInserter: true }); diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js index 1109b35f..134b37ff 100644 --- a/loleaflet/src/map/handler/Map.Keyboard.js +++ b/loleaflet/src/map/handler/Map.Keyboard.js @@ -2,6 +2,8 @@ * L.Map.Keyboard is handling keyboard interaction with the map, enabled by default. */ +/* global map */ + L.Map.mergeOptions({ keyboard: true, keyboardPanOffset: 20, @@ -373,9 +375,9 @@ L.Map.Keyboard = L.Handler.extend({ if (!this._keyHandled && this._bufferedTextInputEvent) { var textInputData = this._bufferedTextInputEvent.originalEvent.data; charCode = e.originalEvent.keyCode; - var compCharCodes = []; - for (var i = 0; i < textInputData.length; i++) { - compCharCodes.push(textInputData[i].charCodeAt()); + compCharCodes = []; + for (var idx = 0; i < textInputData.length; i++) { + compCharCodes.push(textInputData[idx].charCodeAt()); } docLayer._postKeyboardEvents('input', compCharCodes, Array.apply(null, Array(compCharCodes.length)).map(Number.prototype.valueOf, 0)); } diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js index 54278376..67495fb7 100644 --- a/loleaflet/src/map/handler/Map.WOPI.js +++ b/loleaflet/src/map/handler/Map.WOPI.js @@ -2,7 +2,7 @@ * L.WOPI contains WOPI related logic */ -/* global w2ui toolbarUpMobileItems resizeToolbar */ +/* global $ w2ui toolbarUpMobileItems resizeToolbar _ */ L.Map.WOPI = L.Handler.extend({ // If the CheckFileInfo call fails on server side, we won't have any PostMessageOrigin. // So use '*' because we still needs to send 'close' message to the parent frame which @@ -58,7 +58,7 @@ L.Map.WOPI = L.Handler.extend({ _setWopiProps: function(wopiInfo) { // Store postmessageorigin property, if it exists - if (!!wopiInfo['PostMessageOrigin']) { + if (wopiInfo['PostMessageOrigin']) { this.PostMessageOrigin = wopiInfo['PostMessageOrigin']; } @@ -201,7 +201,7 @@ L.Map.WOPI = L.Handler.extend({ var fileName = this._map['wopi'].BaseFileName; fileName = fileName.substr(0, fileName.lastIndexOf('.')); fileName = fileName === '' ? 'document' : fileName; - this._map.downloadAs(filename + '.' + format, format); + this._map.downloadAs(fileName + '.' + format, format); } } else if (msg.MessageId === 'Action_ShowBusy') { @@ -214,10 +214,10 @@ L.Map.WOPI = L.Handler.extend({ } else if (msg.MessageId === 'Get_Export_Formats') { var exportFormatsResp = []; - for (var idx in this._map._docLayer._exportFormats) { + for (var index in this._map._docLayer._exportFormats) { exportFormatsResp.push({ - Label: this._map._docLayer._exportFormats[idx].label, - Format: this._map._docLayer._exportFormats[idx].format + Label: this._map._docLayer._exportFormats[index].label, + Format: this._map._docLayer._exportFormats[index].format }); } @@ -227,7 +227,7 @@ L.Map.WOPI = L.Handler.extend({ if (msg.Values) { if (msg.Values.Filename !== null && msg.Values.Filename !== undefined) { this._map.showBusy(_('Creating copy...'), false); - map.saveAs(msg.Values.Filename); + this._map.saveAs(msg.Values.Filename); } } } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
