Commit 77e365d5 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

lint issues

parent 8590c87f
......@@ -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;
......
......@@ -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;
};
......
......@@ -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);
});
};
......
......@@ -1771,7 +1771,7 @@ CustomMap.prototype.setCommentDialog = function(commentDialog) {
this._commentDialog = commentDialog;
commentDialog.close = function(){
jsfCommentDialog.hide();
}
};
};
CustomMap.prototype.getCommentDialog = function() {
......
......@@ -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 {
......
......@@ -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;
......@@ -238,6 +238,6 @@ OverlayCollection.prototype.setAllowGeneralSearch = function(allowGeneralSearch)
OverlayCollection.prototype.getIdentifiedElements = function(){
return this.elements;
}
};
module.exports = OverlayCollection;
......@@ -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 {
......
......@@ -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;
......
"use strict";
var logger = require('../../logger');
var AbstractInfoWindow = require('./AbstractInfoWindow');
var PointMarker = require('../marker/PointMarker');
......
......@@ -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");
});
});
......@@ -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);
});
});
......@@ -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);
......
......@@ -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() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment