Commit 0a4967cc authored by Piotr Gawron's avatar Piotr Gawron
Browse files

lint fixes

parent 6d01c077
/dist/
/coverage/
/node_modules/
/npm-debug.log
......@@ -24,6 +24,9 @@
"smarttabs": true,
"globals" : {
"alert" : false,
/* MOCHA */
"describe" : false,
"it" : false,
......@@ -37,9 +40,54 @@
"ServerConnector" : false,
"google" : false,
/* JSF commands */
"_actualizeParams" : false,
"_clearChemicalOverlayCollection" : false,
"_clearCommentOverlayCollection" : false,
"_clearDrugOverlayCollection" : false,
"_clearMiRnaOverlayCollection" : false,
"_clearMissingConnectionOverlayCollection" : false,
"_clearSearchOverlayCollection" : false,
"_createSubmodelDialog" : false,
"_refreshChemicalOverlayCollection" : false,
"_refreshCommentOverlayCollection" : false,
"_refreshDrugOverlayCollection" : false,
"_refreshMiRnaOverlayCollection" : false,
"_refreshMissingConnectionOverlayCollection" : false,
"_refreshSearchOverlayCollection" : false,
"_requestChemicalDetailDataFunction": false,
"_requestCommentDetailDataFunction" : false,
"_requestDrugDetailDataFunction" : false,
"_requestMiRnaDetailDataFunction" : false,
"_registerChemicalOverlayCollection": false,
"_registerCommentOverlayCollection" : false,
"_registerDrugOverlayCollection" : false,
"_registerMiRnaOverlayCollection" : false,
"_registerMissingConnectionOverlayCollection" : false,
"_registerSearchOverlayCollection" : false,
"_retreiveActiveAliasesForLayout" : false,
"_retreiveActiveReactionsForLayout" : false,
"_retreiveFullAliases" : false,
"_retreiveFullAliasesForLayout" : false,
"_retreiveLightAliases" : false,
"_retreiveLightReactions" : false,
"_searchByCoord" : false,
"_sendReferenceGenomeDetailRequest" : false,
"_setShowComments" : false,
"_setModelZoomLevel" : false,
"_searchMissingConnections" : false,
"_updateCommentList" : false,
/* jQuery */
"$" : false,
"jQuery" : false
"jQuery" : false,
/* Primefaces */
"PrimeFaces" : false,
"PF" : false
}
}
......@@ -27,10 +27,10 @@ function Configuration(data) {
this.registerListenerType("onreload");
if (data != null) {
if (data !== undefined) {
this.loadFromModelView(data);
}
};
}
// this class inherits from ObjectWithListeners class where generic methods for
// listeners are set
......@@ -48,7 +48,7 @@ Configuration.prototype.loadFromModelView = function(modelView) {
// replace is due to some strange problem with serialization
modelView = JSON.parse(modelView.replace(/\n/g, " "));
}
this.ID_MODEL = modelView.idObject;
this.ID_MODEL = parseInt(modelView.idObject);
this.TILE_SIZE = modelView.tileSize;
this.PICTURE_SIZE = modelView.pictureSize;
this.MAX_ZOOM = modelView.maxZoom;
......@@ -61,7 +61,7 @@ Configuration.prototype.loadFromModelView = function(modelView) {
this.MAPS = this.MAPS.concat(modelView.customLayouts);
this.SUBMODELS = [];
if (modelView.submodels != null) {
if (modelView.submodels !== undefined) {
for (var i = 0; i < modelView.submodels.length; i++) {
var conf = new Configuration();
conf.loadFromModelView(modelView.submodels[i]);
......
......@@ -8,12 +8,12 @@ var Functions = {};
* Bounds value between opt_min and opt_max (result will be not smaller than
* opt_min and not bigger than opt_max).
*/
Functions.bound = function(value, opt_min, opt_max) {
if (opt_min != null) {
value = Math.max(value, opt_min);
Functions.bound = function(value, minVal, maxVal) {
if (minVal !== null && minVal !== undefined) {
value = Math.max(value, minVal);
}
if (opt_max != null) {
value = Math.min(value, opt_max);
if (maxVal !== null && maxVal !== undefined) {
value = Math.min(value, maxVal);
}
return value;
};
......@@ -27,6 +27,7 @@ Functions.radiansToDegrees = function(rad) {
};
Functions.intToColorString = function(value) {
/* jslint bitwise: true */
var timmedValue = (value & 0xFFFFFF);
var colorStr = timmedValue.toString(16);
while (colorStr.length < 6) {
......@@ -89,7 +90,7 @@ Functions.pointInsidePolygon = function(point, polygon) {
for (var i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
var xi = polygon[i].x, yi = polygon[i].y;
var xj = polygon[j].x, yj = polygon[j].y;
var intersect = ((yi > y) != (yj > y))
var intersect = ((yi > y) !== (yj > y))
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
if (intersect) {
inside = !inside;
......@@ -112,20 +113,21 @@ Functions.browser = {
// Get the user agent string
var ua = navigator.userAgent;
this.compatibilityMode = false;
if (navigator.appName == 'Microsoft Internet Explorer') {
var re;
if (navigator.appName === 'Microsoft Internet Explorer') {
this.name = "IE";
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null) {
re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) !== undefined && re.exec(ua) !== null) {
this.version = parseFloat(RegExp.$1);
}
if (ua.indexOf("MSIE 7.0") > -1) {
this.compatibilityMode = true;
}
} else if (navigator.appName == 'Netscape') {
} else if (navigator.appName === 'Netscape') {
this.name = "IE";
var ua = navigator.userAgent;
var re = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null) {
ua = navigator.userAgent;
re = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) !== undefined && re.exec(ua) !== null) {
this.version = parseFloat(RegExp.$1);
}
if (ua.indexOf("MSIE 7.0") > -1) {
......@@ -164,12 +166,15 @@ Functions.isDomElement = function(o) {
};
Functions.overlayToColor = function(elementOverlay) {
if (elementOverlay == null) {
/* jslint bitwise: true */
if (elementOverlay === null || elementOverlay === undefined) {
logger.error("elementOverlay cannot be null!");
return null;
} else if (elementOverlay.color != null) {
} else if (elementOverlay.color !== undefined
&& elementOverlay.color !== null) {
return this.intToColorString(elementOverlay.color.value);
} else if (elementOverlay.value != null) {
} else if (elementOverlay.value !== undefined
&& elementOverlay.value !== null) {
var ratio = 0;
var color;
if (elementOverlay.value < 0) {
......@@ -194,7 +199,7 @@ Functions.overlayToColor = function(elementOverlay) {
blue = parseInt(blue);
blue = blue & 0x0000FF;
var color = red | green | blue;
color = red | green | blue;
return this.intToColorString(color);
} else {
logger.error("elementOverlay doesn't have neither color nor value set!");
......
"use strict";
var logger = require('./logger');
var SearchPanel = require('./SearchPanel');
var TabNavi = require('./TabNavi');
......@@ -43,6 +45,17 @@ document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() {
GuiConnector.getParams[decode(arguments[1])] = decode(arguments[2]);
});
GuiConnector.setCustomMap = function(customMap) {
if (customMap === undefined) {
logger.error("CustomMap cannot be undefiend");
}
this._customMap = customMap;
};
GuiConnector.getCustomMap = function() {
return this._customMap;
};
GuiConnector.init = function() {
GuiConnector.leftPanelTabNavi = new TabNavi("tabView", {
top : "17px"
......@@ -57,7 +70,8 @@ GuiConnector.init = function() {
tabSize : 1,
top : "5px"
});
if (document.getElementById("tabView:chemicalForm:chemicalResults") != null) {
if (document.getElementById("tabView:chemicalForm:chemicalResults") !== null
&& document.getElementById("tabView:chemicalForm:chemicalResults") !== undefined) {
GuiConnector.chemicalTabNavi = new TabNavi(
"tabView:chemicalForm:chemicalResults", {
hideRemaining : false,
......@@ -74,7 +88,7 @@ GuiConnector.init = function() {
GuiConnector.searchPanel = new SearchPanel(document
.getElementById('tabView:mainForm:searchText_input'), document
.getElementById('tabView:mainForm:searchButton'), function() {
tabViewVar.select(0);
_tabViewVar.select(0);
});
};
......@@ -269,23 +283,24 @@ GuiConnector.getJsPopupForSubmodelId = function(id) {
*/
GuiConnector.openDialog = function(id) {
var jsVar = GuiConnector.getJsPopupForSubmodelId(id);
if (jsVar != null) {
if (jsVar !== null) {
var htmlTag = GuiConnector.getHtmlTagForSubmodelId(id);
customMap.openSubmodel(id, htmlTag, jsVar);
this.getCustomMap().openSubmodel(id, htmlTag, jsVar);
}
return false;
};
GuiConnector.referenceToHtml = function(reference) {
if (reference.summary != null && reference.summary != "") {
var result = '<div title="' + reference.summary + '">';
var result;
if (reference.summary !== undefined && reference.summary !== "") {
result = '<div title="' + reference.summary + '">';
result += '<a href="' + reference.link + '" target="_blank">'
+ reference.name + "</a>";
// + reference.name + "(" + reference.type + ")</a>";
result += "</div>";
return result;
} else {
var result = '<div><a href="' + reference.link + '" target="_blank">'
result = '<div><a href="' + reference.link + '" target="_blank">'
+ reference.name + "</a></div>";
// + reference.name + "(" + reference.type + ")</a></div>";
return result;
......@@ -314,4 +329,8 @@ GuiConnector.getObjectByPrimefaceId = function(id) {
return $(PrimeFaces.escapeClientId(id));
};
GuiConnector.getOverviewDialog = function() {
return _overviewDialog;
};
module.exports = GuiConnector;
......@@ -9,7 +9,7 @@ var logger = require('./logger');
function ObjectWithListeners() {
this._validListeners = [];
this._validPropertyListeners = [];
};
}
/**
* Adds a listener function to the object.
......@@ -20,11 +20,11 @@ function ObjectWithListeners() {
* function that should be thrown when type event occures
*/
ObjectWithListeners.prototype.addListener = function(type, fun) {
if (this._validListeners[type] == null) {
if (this._validListeners[type] === undefined) {
throw "Unknown listener type: " + type;
}
if (typeof (fun) != "function") {
if (typeof fun !== "function") {
throw "Second parameter must be a function but \"" + typeof (fun)
+ "\" found.";
}
......@@ -42,11 +42,11 @@ ObjectWithListeners.prototype.addListener = function(type, fun) {
* called
*/
ObjectWithListeners.prototype.addPropertyChangeListener = function(name, fun) {
if (this._validPropertyListeners[name] == null) {
if (this._validPropertyListeners[name] === undefined) {
throw "Unknown property type: " + name;
}
if (typeof (fun) != "function") {
if (typeof fun !== "function") {
throw "Second parameter must be a function but \"" + typeof (fun)
+ "\" found.";
}
......@@ -61,7 +61,7 @@ ObjectWithListeners.prototype.addPropertyChangeListener = function(name, fun) {
* string identifing new type of listener
*/
ObjectWithListeners.prototype.registerListenerType = function(type) {
if (this._validListeners[type] != null) {
if (this._validListeners[type] !== undefined) {
throw "Listener type already registered: " + type;
}
this._validListeners[type] = [];
......@@ -74,7 +74,7 @@ ObjectWithListeners.prototype.registerListenerType = function(type) {
* string identifing proeprty
*/
ObjectWithListeners.prototype.registerPropertyType = function(name) {
if (this._validPropertyListeners[name] != null) {
if (this._validPropertyListeners[name] !== undefined) {
throw "Property already registered: " + name;
}
this._validPropertyListeners[name] = [];
......@@ -89,11 +89,11 @@ ObjectWithListeners.prototype.registerPropertyType = function(name) {
* function that was call when event occred that should be removed
*/
ObjectWithListeners.prototype.removeListener = function(type, fun) {
if (this._validListeners[type] == null) {
if (this._validListeners[type] === undefined) {
throw "Unknown listener type: " + type;
}
if (typeof (fun) != "function") {
if (typeof (fun) !== "function") {
throw "Second parameter must be a function but \"" + typeof (fun)
+ "\" found.";
}
......@@ -117,11 +117,11 @@ ObjectWithListeners.prototype.removeListener = function(type, fun) {
* function that was call when event occred that should be removed
*/
ObjectWithListeners.prototype.removePropertyListener = function(name, fun) {
if (this._validPropertyListeners[name] == null) {
if (this._validPropertyListeners[name] === undefined) {
throw "Unknown property: " + name;
}
if (typeof (fun) != "function") {
if (typeof (fun) !== "function") {
throw "Second parameter must be a function but \"" + typeof (fun)
+ "\" found.";
}
......@@ -143,7 +143,7 @@ ObjectWithListeners.prototype.removePropertyListener = function(name, fun) {
* type of the listener (string)
*/
ObjectWithListeners.prototype.callListeners = function(type) {
if (this._validListeners[type] == null) {
if (this._validListeners[type] === undefined) {
throw "Unknown listener type: " + type;
}
var listenerList = this._validListeners[type];
......@@ -171,7 +171,7 @@ ObjectWithListeners.prototype.callListeners = function(type) {
ObjectWithListeners.prototype.firePropertyChangeListener = function(
propertyName, oldval, newval) {
var self = this;
if (this._validPropertyListeners[propertyName] == null) {
if (this._validPropertyListeners[propertyName] === undefined) {
throw "Unknown property type: " + propertyName;
}
var listenerList = this._validPropertyListeners[propertyName];
......
......@@ -145,8 +145,12 @@ ServerConnector.setVisibleLayouts = function(value) {
* Get layout of the {@link CustomMap} which was last browsed.
*/
ServerConnector.getSelectedLayout = function() {
return document.getElementById(ServerConnector.formIdentifier
var result = document.getElementById(ServerConnector.formIdentifier
+ ':selectedLayout').value;
if (result === undefined) {
result = null;
}
return result;
};
/**
......@@ -171,7 +175,7 @@ ServerConnector.actualizeSessionData = function() {
* @see ServerConnector.actualizeSessionData
*/
ServerConnector.actualizeParams = function() {
actualizeParams();
_actualizeParams();
};
/**
......@@ -243,7 +247,7 @@ ServerConnector.setShowComments = function(value) {
ServerConnector.showSimilarDataMining = function(param) {
document.getElementById(ServerConnector.formIdentifier + ':geneName').value = ""
+ param;
searchMissingConnections();
_searchMissingConnections();
};
/**
......@@ -345,9 +349,9 @@ ServerConnector.retreiveLightReactions = function(ids) {
*/
ServerConnector.sendRefreshRequest = function(overlayName) {
var functions = ServerConnector._overlayMethods[overlayName];
if (functions != null) {
if (functions !== undefined) {
var refreshFunction = functions.refreshFunction;
if (refreshFunction != null) {
if (refreshFunction !== undefined) {
refreshFunction();
} else {
logger.warn("Refresh function for " + overlayName + " doesn't exist");
......@@ -361,13 +365,13 @@ ServerConnector.sendRefreshRequest = function(overlayName) {
* Adds {@link OverlayCollection} to ServerConnector.
*/
ServerConnector.addOverlayCollection = function(overlay) {
if (ServerConnector._overlayMethods[overlay.name] != null) {
if (ServerConnector._overlays[overlay.name] != null) {
if (ServerConnector._overlayMethods[overlay.name] !== undefined) {
if (ServerConnector._overlays[overlay.name] !== undefined) {
logger.warn("Overlay with name " + overlay.name + " already added");
return;
}
ServerConnector._overlays[overlay.name] = overlay;
if (ServerConnector._overlayMethods[overlay.name].initFunction != null) {
if (ServerConnector._overlayMethods[overlay.name].initFunction !== undefined) {
ServerConnector._overlayMethods[overlay.name].initFunction();
} else {
logger.warn("Cannot initialize overlay: " + overlay);
......@@ -390,7 +394,7 @@ ServerConnector.addOverlayCollection = function(overlay) {
ServerConnector.updateOverlayCollection = function(overlayName, data, fitBounds) {
logger.debug("Updating: " + overlayName);
var overlay = ServerConnector._overlays[overlayName];
if (overlay != null) {
if (overlay !== undefined) {
overlay.updateOverlays(data, fitBounds);
} else {
logger.warn("Overlay " + overlayName
......@@ -699,9 +703,9 @@ ServerConnector._overlayMethods[ServerConnector.MI_RNA_OVERLAY_NAME] = {
ServerConnector.sendClearRequest = function(overlayName) {
var functions = ServerConnector._overlayMethods[overlayName];
if (functions != null) {
if (functions !== undefined) {
var clearFunction = functions.clearFunction;
if (clearFunction != null) {
if (clearFunction !== undefined) {
clearFunction();
} else {
logger.warn("Clear function for " + overlayName + " doesn't exist");
......@@ -713,7 +717,7 @@ ServerConnector.sendClearRequest = function(overlayName) {
ServerConnector.setOverlayResultIds = function(overlayName, ids) {
var overlay = this._overlays[overlayName];
if (overlay != null) {
if (overlay !== undefined) {
overlay.setResultsIds(ids);
} else {
logger.warn("Overlay '" + overlayName + "' doesn't exist");
......@@ -723,17 +727,17 @@ ServerConnector.setOverlayResultIds = function(overlayName, ids) {
ServerConnector.sendOverlayDetailDataRequest = function(overlayName,
identifiedElement, general) {
var overlay = ServerConnector._overlays[overlayName];
if (overlay == null) {
if (overlay === undefined) {
logger.warn("Unknown overlay: " + overlayName);
return;
}
var functions = ServerConnector._overlayMethods[overlayName];
if (functions != null) {
if (functions !== undefined) {
var requestDetailDataFunction = functions.requestDetailDataFunction;
if (requestDetailDataFunction != null) {
if (requestDetailDataFunction !== undefined) {
var missingData = overlay.getMissingDetailDataIds(identifiedElement,
general);
if (missingData.length == 0) {
if (missingData.length === 0) {
logger
.warn(
"request of missing data called for empty data set... overlay name = ",
......@@ -755,7 +759,7 @@ ServerConnector.sendOverlayDetailDataRequest = function(overlayName,
ServerConnector.updateOverviewElementDetailData = function(overlayName,
searchResultIdentifier, identifiedElement, data) {
var overlay = this._overlays[overlayName];
if (overlay != null) {
if (overlay !== undefined) {
overlay.updateOverviewElementDetailData(identifiedElement,
searchResultIdentifier, data);
} else {
......@@ -771,10 +775,10 @@ ServerConnector.updateOverviewElementDetailData = function(overlayName,
* data from server, <code>false</code> otherwise.
*/
ServerConnector.isWaitingForData = function() {
var result = (this._waitingForAliasLayoutData != 0) || //
(this._waitingForAliasData != 0) || //
(this._waitingForReactionLayoutData != 0) || //
(this._waitingForReactionData != 0);
var result = (this._waitingForAliasLayoutData !== 0) || //
(this._waitingForAliasData !== 0) || //
(this._waitingForReactionLayoutData !== 0) || //
(this._waitingForReactionData !== 0);
return result;
};
......@@ -808,7 +812,7 @@ ServerConnector.setWaitingForAliasLayoutData = function(layoutId, value) {
"WaitingForAliasLayoutData layoutId must be integer, but found: ",
layoutId);
}
}
};
ServerConnector.setWaitingForFullAliasLayoutData = function(layoutId, aliasId,
value) {
......@@ -840,7 +844,7 @@ ServerConnector.setWaitingForFullAliasLayoutData = function(layoutId, aliasId,
"setWaitingForFullAliasLayoutData value must be boolean, but found: ",
value);
}
}
};
ServerConnector.isWaitingForFullAliasLayoutData = function(layoutId, aliasId) {
if (!functions.isInt(layoutId)) {
......@@ -856,11 +860,11 @@ ServerConnector.isWaitingForFullAliasLayoutData = function(layoutId, aliasId) {
}
var val = this._waitingFullAliasLayoutDataById[layoutId + "-" + aliasId];
if (val == null) {
if (val === undefined) {
return false;
}
return val;
}
};
/**
* Sets waitingForAliasData flag that monitors if we are waiting for the data
......@@ -1036,22 +1040,41 @@ ServerConnector.updateReferenceGenomeData = function(organismId, type, version,
ServerConnector.getMinOverlayColorInt = function() {
var color = document.getElementById("overlayConfigForm:userMinColor").value;
if (color == "") {
if (color === "") {
color = document.getElementById("overlayConfigForm:systemMinColor").value;
}
color = parseInt(color, 16);
var color = (color & 0xFFFFFF);
/* jslint bitwise: true */
color = (color & 0xFFFFFF);
return color;
};
ServerConnector.getMaxOverlayColorInt = function() {
var color = document.getElementById("overlayConfigForm:userMaxColor").value;
if (color == "") {
if (color === "") {
color = document.getElementById("overlayConfigForm:systemMaxColor").value;
}
color = parseInt(color, 16);
var color = (color & 0xFFFFFF);
/* jslint bitwise: true */
color = (color & 0xFFFFFF);
return color;
};
ServerConnector.createSubmodelDialog = function(submodelId) {
_createSubmodelDialog([ {
name : 'submodelId',
value : submodelId
} ]);
};
ServerConnector.setModelZoomLevel = function(id, zoom) {
_setModelZoomLevel([ {
name : 'mapId',
value : id
}, {
name : 'zoomLevel',
value : zoom
} ]);
};
module.exports = ServerConnector;
"use strict";
var logger = require('./logger');
/**
* Class that adds tab navigation to defavult primefaces tabView component.
*/
function TabNavi(elementId, params) {
var self = this;
if (params == null) {
if (params === undefined) {
params = {};
}