From 77e365d590caf09e8c60ce5e1e533090bfb13835 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Thu, 5 Jan 2017 14:19:02 +0100 Subject: [PATCH] lint issues --- frontend-js/src/main/js/ServerConnector.js | 5 +-- frontend-js/src/main/js/gui/CommentDialog.js | 45 +++++++++---------- .../src/main/js/map/AbstractCustomMap.js | 2 +- frontend-js/src/main/js/map/CustomMap.js | 2 +- frontend-js/src/main/js/map/data/MapModel.js | 2 +- .../main/js/map/overlay/CommentDbOverlay.js | 3 +- .../main/js/map/overlay/OverlayCollection.js | 2 +- .../main/js/map/window/AbstractInfoWindow.js | 2 +- .../src/main/js/map/window/AliasInfoWindow.js | 12 ++--- .../src/main/js/map/window/PointInfoWindow.js | 2 - .../src/test/js/ServerConnector-test.js | 2 +- .../src/test/js/gui/CommentDialog-test.js | 9 ++-- .../js/map/overlay/OverlayCollection-test.js | 3 +- .../js/map/window/AliasInfoWindow-test.js | 18 ++++---- 14 files changed, 52 insertions(+), 57 deletions(-) diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index 81f7438b05..d0a2df4e78 100644 --- a/frontend-js/src/main/js/ServerConnector.js +++ b/frontend-js/src/main/js/ServerConnector.js @@ -836,10 +836,10 @@ ServerConnector.getOverlayElementsUrl = function(overlayId, projectId, token) { ServerConnector.idsToString = function (ids) { var result = ""; if (ids!==undefined) { - ids.sort(function(a, b){return a-b}); + ids.sort(function(a, b){return a-b;}); for (var i = 0; i < ids.length; i++) { if (result !== "") { - if (ids[i-1]!=ids[i]) { + if (ids[i-1]!==ids[i]) { result = result + "," + ids[i]; } // we ignore duplicates } else { @@ -1159,7 +1159,6 @@ ServerConnector.getClosestElementsByCoordinates = function(params) { ServerConnector.addComment = function(params) { var self = this; - var projectId; return new Promise(function(resolve, reject) { return self.getProjectId(params.projectId).then(function(result) { params.projectId = result; diff --git a/frontend-js/src/main/js/gui/CommentDialog.js b/frontend-js/src/main/js/gui/CommentDialog.js index cdb2f59e89..bf03298de0 100644 --- a/frontend-js/src/main/js/gui/CommentDialog.js +++ b/frontend-js/src/main/js/gui/CommentDialog.js @@ -7,6 +7,16 @@ var Reaction = require('../map/data/Reaction'); var logger = require('../logger'); var Functions = require('../Functions'); +function createRow(elements) { + var row = document.createElement('tr'); + for (var i = 0; i < elements.length; i++) { + var container = document.createElement('td'); + container.appendChild(elements[i]); + row.appendChild(container); + } + return row; +} + function CommentDialog(element, customMap) { var self = this; @@ -40,9 +50,6 @@ function CommentDialog(element, customMap) { table.appendChild(createRow([ nameLabel, nameInput ])); this.setNameInput(nameInput); - nameInput.onchange = function(el) { - logger.debug(nameInput.value); - } var emailLabel = document.createElement('label'); emailLabel.innerHTML = "Email:<br/>(Visible to moderators only)"; @@ -71,7 +78,7 @@ function CommentDialog(element, customMap) { logger.warn("Cannot close dialog"); } }); - } + }; table.appendChild(createRow([ sendButton ])); @@ -87,19 +94,20 @@ function CommentDialog(element, customMap) { } else if (option instanceof Reaction) { text = "Reactants: "; var reactants = option.getReactants(); - for (var i = 0; i < reactants.length; i++) { + var i; + for (i = 0; i < reactants.length; i++) { text += reactants[i].getName() + ","; } text += "<br/>"; text += "Modifiers: "; var modifiers = option.getModifiers(); - for (var i = 0; i < modifiers.length; i++) { + for (i = 0; i < modifiers.length; i++) { text += modifiers[i].getName() + ","; } text += "<br/>"; text += "Products: "; var products = option.getProducts(); - for (var i = 0; i < products.length; i++) { + for (i = 0; i < products.length; i++) { text += products[i].getName() + ","; } text += "<br/>"; @@ -111,31 +119,22 @@ function CommentDialog(element, customMap) { CommentDialog.GENERAL = "<General>"; -function createRow(elements) { - var row = document.createElement('tr'); - for (var i = 0; i < elements.length; i++) { - var container = document.createElement('td'); - container.appendChild(elements[i]); - row.appendChild(container); - } - return row; -}; CommentDialog.prototype.setMap = function(map) { this._map = map; -} +}; CommentDialog.prototype.getMap = function() { return this._map; -} +}; CommentDialog.prototype.setElement = function(element) { this._element = element; -} +}; CommentDialog.prototype.getElement = function() { return this._element; -} +}; CommentDialog.prototype.open = function(types) { var self = this; @@ -178,7 +177,7 @@ CommentDialog.prototype.setTypes = function(types) { typeOptions.value = 0; this._types = types; -} +}; CommentDialog.prototype.getTypes = function() { return this._types; @@ -193,7 +192,7 @@ CommentDialog.prototype.setSelectedType = function(value) { this.getTypeOptions().value = value; this.getTypeOptions().onchange(); } else { - throw new Error("Unknown value type: " + value) + throw new Error("Unknown value type: " + value); } }; @@ -229,7 +228,7 @@ CommentDialog.prototype.getPinnedCheckbox = function() { return this._pinnedCheckbox; }; -CommentDialog.prototype.getTypes = function(types) { +CommentDialog.prototype.getTypes = function() { return this._types; }; diff --git a/frontend-js/src/main/js/map/AbstractCustomMap.js b/frontend-js/src/main/js/map/AbstractCustomMap.js index 34ed259182..5263499926 100644 --- a/frontend-js/src/main/js/map/AbstractCustomMap.js +++ b/frontend-js/src/main/js/map/AbstractCustomMap.js @@ -357,7 +357,7 @@ AbstractCustomMap.prototype.registerMapClickEvents = function() { }); // context menu event - google.maps.event.addListener(this.getGoogleMap(), 'rightclick', function(mouseEvent) { + google.maps.event.addListener(this.getGoogleMap(), 'rightclick', function() { GuiConnector.showRightClickMenu(GuiConnector.xPos, GuiConnector.yPos); }); }; diff --git a/frontend-js/src/main/js/map/CustomMap.js b/frontend-js/src/main/js/map/CustomMap.js index b61ad58958..2837a1ad7b 100644 --- a/frontend-js/src/main/js/map/CustomMap.js +++ b/frontend-js/src/main/js/map/CustomMap.js @@ -1771,7 +1771,7 @@ CustomMap.prototype.setCommentDialog = function(commentDialog) { this._commentDialog = commentDialog; commentDialog.close = function(){ jsfCommentDialog.hide(); - } + }; }; CustomMap.prototype.getCommentDialog = function() { diff --git a/frontend-js/src/main/js/map/data/MapModel.js b/frontend-js/src/main/js/map/data/MapModel.js index c2fcb21d92..6201f0a402 100644 --- a/frontend-js/src/main/js/map/data/MapModel.js +++ b/frontend-js/src/main/js/map/data/MapModel.js @@ -176,7 +176,7 @@ MapModel.prototype.getReactionById = function(id, complete) { MapModel.prototype.getCompleteReactionById = function(id) { var self = this; - return new Promise(function(resolve, reject) { + return new Promise(function(resolve) { if (self._reactions[id]!==undefined && self._reactions[id].isComplete()) { resolve(self._reactions[id]); } else { diff --git a/frontend-js/src/main/js/map/overlay/CommentDbOverlay.js b/frontend-js/src/main/js/map/overlay/CommentDbOverlay.js index d6fbdb1b68..41df64f1cc 100644 --- a/frontend-js/src/main/js/map/overlay/CommentDbOverlay.js +++ b/frontend-js/src/main/js/map/overlay/CommentDbOverlay.js @@ -3,7 +3,6 @@ var Promise = require("bluebird"); var OverlayCollection = require('./OverlayCollection'); -var IdentifiedElement = require('../data/IdentifiedElement'); function CommentDbOverlay(params) { // call super constructor @@ -52,7 +51,7 @@ CommentDbOverlay.prototype.getIdentifiedElements = function(){ } } return result; -} +}; module.exports = CommentDbOverlay; diff --git a/frontend-js/src/main/js/map/overlay/OverlayCollection.js b/frontend-js/src/main/js/map/overlay/OverlayCollection.js index 53bb95392b..c1fff1bcb6 100644 --- a/frontend-js/src/main/js/map/overlay/OverlayCollection.js +++ b/frontend-js/src/main/js/map/overlay/OverlayCollection.js @@ -238,6 +238,6 @@ OverlayCollection.prototype.setAllowGeneralSearch = function(allowGeneralSearch) OverlayCollection.prototype.getIdentifiedElements = function(){ return this.elements; -} +}; module.exports = OverlayCollection; diff --git a/frontend-js/src/main/js/map/window/AbstractInfoWindow.js b/frontend-js/src/main/js/map/window/AbstractInfoWindow.js index 6ce121a8fc..8a20080eb0 100644 --- a/frontend-js/src/main/js/map/window/AbstractInfoWindow.js +++ b/frontend-js/src/main/js/map/window/AbstractInfoWindow.js @@ -195,7 +195,7 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function(overlay, data) { return this._createDefaultInfoDiv(overlay, data); } } else { - logger.debug(alias) + logger.debug(alias); throw new Error("Cannot customize info window. Alias type is unknown "); } } else { diff --git a/frontend-js/src/main/js/map/window/AliasInfoWindow.js b/frontend-js/src/main/js/map/window/AliasInfoWindow.js index 000ff0740f..a2f59a8764 100644 --- a/frontend-js/src/main/js/map/window/AliasInfoWindow.js +++ b/frontend-js/src/main/js/map/window/AliasInfoWindow.js @@ -12,15 +12,15 @@ var pileup = require('pileup'); /** * Class representing info window that should be opened when clicking on alias. */ -function AliasInfoWindow(alias, map, onloadFun) { +function AliasInfoWindow(aliasParam, map, onloadFun) { // call super constructor - AbstractInfoWindow.call(this, alias, map); + AbstractInfoWindow.call(this, aliasParam, map); - if (alias instanceof AliasMarker) { - this.setAlias(alias.getAliasData()); - map = alias.getCustomMap(); + if (aliasParam instanceof AliasMarker) { + this.setAlias(aliasParam.getAliasData()); + map = aliasParam.getCustomMap(); } else { - this.setAlias(alias); + this.setAlias(aliasParam); } var self = this; diff --git a/frontend-js/src/main/js/map/window/PointInfoWindow.js b/frontend-js/src/main/js/map/window/PointInfoWindow.js index 0b9261f84a..bc1edd44dc 100644 --- a/frontend-js/src/main/js/map/window/PointInfoWindow.js +++ b/frontend-js/src/main/js/map/window/PointInfoWindow.js @@ -1,7 +1,5 @@ "use strict"; -var logger = require('../../logger'); - var AbstractInfoWindow = require('./AbstractInfoWindow'); var PointMarker = require('../marker/PointMarker'); diff --git a/frontend-js/src/test/js/ServerConnector-test.js b/frontend-js/src/test/js/ServerConnector-test.js index c2c9f5a3e7..e22cceac7b 100644 --- a/frontend-js/src/test/js/ServerConnector-test.js +++ b/frontend-js/src/test/js/ServerConnector-test.js @@ -65,7 +65,7 @@ describe('ServerConnector', function() { it('idsToString', function() { var ids = [ 3, 2, 9, 1, 6, 8, 3, 2, 9, 1, 7, 3 ]; var str = ServerConnector.idsToString(ids); - assert.equal(str, "1,2,3,6,7,8,9") + assert.equal(str, "1,2,3,6,7,8,9"); }); }); diff --git a/frontend-js/src/test/js/gui/CommentDialog-test.js b/frontend-js/src/test/js/gui/CommentDialog-test.js index 19adaedd03..1771c51076 100644 --- a/frontend-js/src/test/js/gui/CommentDialog-test.js +++ b/frontend-js/src/test/js/gui/CommentDialog-test.js @@ -19,13 +19,14 @@ describe('CommentDialog', function() { it('contructor', function() { var map = helper.createCustomMap(); - - var dialog = new CommentDialog(testDiv, map); + + new CommentDialog(testDiv, map); assert.ok(testDiv.innerHTML); + assert.equal(logger.getWarnings().length, 0); }); - + it('getName', function() { var dialog = new CommentDialog(testDiv); - assert.ok(dialog.getName()!==undefined); + assert.ok(dialog.getName() !== undefined); }); }); diff --git a/frontend-js/src/test/js/map/overlay/OverlayCollection-test.js b/frontend-js/src/test/js/map/overlay/OverlayCollection-test.js index 31fc519b43..bf88db4244 100644 --- a/frontend-js/src/test/js/map/overlay/OverlayCollection-test.js +++ b/frontend-js/src/test/js/map/overlay/OverlayCollection-test.js @@ -30,6 +30,7 @@ describe('OverlayCollection', function() { }); assert.ok(oc); assert.equal(oc.getName(), 'test name'); + assert.equal(logger.getWarnings().length, 0); }); it("constructor 2", function() { @@ -55,7 +56,7 @@ describe('OverlayCollection', function() { it("updateOverviewElementDetailData", function() { var map = helper.createCustomMap(); - + var searchId = 'some_id'; var oc = helper.createDrugDbOverlay(map); diff --git a/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js b/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js index 3eb32d845c..09a73f8003 100644 --- a/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js +++ b/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js @@ -34,6 +34,7 @@ describe('AliasInfoWindow', function() { assert.equal(alias, aliasWindow.getAlias()); assert.equal(map, aliasWindow.getCustomMap()); assert.ok(aliasWindow.getContent().innerHTML.indexOf("loading") >= 0); + assert.equal(logger.getWarnings().length, 0); }); it("AliasInfoWindow Constructor 2", function() { @@ -118,13 +119,12 @@ describe('AliasInfoWindow', function() { var alias = new Alias(javaObject); map.getModel().addAlias(alias); - var onload = function(){ + var aliasWindow = new AliasInfoWindow(alias, map, function() { assert.equal(alias, aliasWindow.alias); assert.equal(map, aliasWindow.customMap); assert.ok(aliasWindow.getContent().innerHTML.indexOf("loading") === -1); done(); - } - var aliasWindow = new AliasInfoWindow(alias, map, onload); + }); }); @@ -241,17 +241,16 @@ describe('AliasInfoWindow', function() { alias.setIsComplete(true); alias.setModelId(map.getId()); map.getModel().addAlias(alias); - var aliasWindow = new AliasInfoWindow(alias, map); - return oc.getDetailDataByIdentifiedElement(new IdentifiedElement(alias), true).then(function(data){ + return oc.getDetailDataByIdentifiedElement(new IdentifiedElement(alias), true).then(function(data) { var comment = helper.createComment(alias); - comment.setContent("test comment Content"); - - data[0] = comment; + comment.setContent("test comment Content"); + + data[0] = comment; data['__FULL__'] = null; - + var overlayDiv = aliasWindow.createOverlayInfoDiv(oc, data); assert.ok(functions.isDomElement(overlayDiv)); @@ -259,7 +258,6 @@ describe('AliasInfoWindow', function() { assert.ok(overlayDiv.innerHTML.indexOf(comment.getId()) >= 0); }); - }); it("AliasInfoWindow createWaitingContentDiv", function() { -- GitLab