Skip to content

Commit

Permalink
chore: eslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Jan 25, 2019
1 parent e9f6191 commit d051704
Show file tree
Hide file tree
Showing 21 changed files with 1,162 additions and 699 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ parserOptions:
rules:
# Disable those for now
no-console: 1
no-eval: 0
curly: 0
eqeqeq: 0
camelcase: 0
Expand Down
122 changes: 66 additions & 56 deletions src/modules/types/bio/feature_viewer/Biojs.MyFeatureViewer.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
'use strict';

/* global Biojs canvg*/
Biojs.MyFeatureViewer = Biojs.FeatureViewer.extend(
/* @lends Biojs.DasProteinFeatureViewer */
{
/*
* Private variables
*/
* Private variables
*/
_webservice: 'http://wwwdev.ebi.ac.uk/uniprot/featureViewer/image',
_dasReference: 'http://www.ebi.ac.uk/das-srv/uniprot/das/uniprot/',
/*
* Default values for the options
* @name Biojs.DasProteinFeatureViewer-constructor
*/
* Default values for the options
* @name Biojs.DasProteinFeatureViewer-constructor
*/
constructor: function (options) {
this.base(options);
try {
Expand All @@ -20,7 +21,8 @@ Biojs.MyFeatureViewer = Biojs.FeatureViewer.extend(
}
} catch (err) {
document.getElementById(this.opt.target).innerHTML = '';
document.getElementById(this.opt.target).innerHTML = 'No image available. Did you provide a valid UniProt accession or identifier, and valid limits?';
document.getElementById(this.opt.target).innerHTML =
'No image available. Did you provide a valid UniProt accession or identifier, and valid limits?';
}
},

Expand All @@ -40,51 +42,51 @@ Biojs.MyFeatureViewer = Biojs.FeatureViewer.extend(
},

/*
* Array containing the supported event names
* @name Biojs.DasProteinFeatureViewer-eventTypes
*/
* Array containing the supported event names
* @name Biojs.DasProteinFeatureViewer-eventTypes
*/
eventTypes: [],

/*
* Opens a new window/tab in the browser with the graphical representation for all feature types.
*
* @example
* myPainter.showGeneralLegend();
*
*/
* Opens a new window/tab in the browser with the graphical representation for all feature types.
*
* @example
* myPainter.showGeneralLegend();
*
*/
showGeneralLegend: function () {
var config = this.opt.json.configuration;
var dataURL = `${this._webservice}?`;
window.open(dataURL); // open generated image in new tab/window
},

/*
* Opens a new window/tab in the browser with the graphical representation as a plain image.
* Note: For IE it does not reflect the drags/drops on sites
*
* @example
* myPainter.exportFeaturesToImage();
*
*/
* Opens a new window/tab in the browser with the graphical representation as a plain image.
* Note: For IE it does not reflect the drags/drops on sites
*
* @example
* myPainter.exportFeaturesToImage();
*
*/
exportFeaturesToImage: function () {
// if (typeof FlashCanvas != 'undefined') {
// FlashCanvas.initElement(canvas);
// }
var config = this.opt.json.configuration;
var dataURL = '';
if (jQuery.browser.msie) { // canvas does not work (not even with IE 9)
if (jQuery.browser.msie) {
// canvas does not work (not even with IE 9)
var args = `segment=${this.opt.json.segment}`;
if ((config.requestedStart != 0) && (config.requestedStop != 0)) {
if (config.requestedStart != 0 && config.requestedStop != 0) {
args = `${args}:${config.requestedStart},${config.requestedStop}`;
}
args = `${args
}&dasReference=${config.dasReference
}&dasSources=${config.dasSources
}&width=${config.sizeX
}&option=image` +
`&hgrid=${config.horizontalGrid
}&vgrid=${config.verticalGrid
}&style=${config.style}`;
args =
`${args}&dasReference=${config.dasReference}&dasSources=${
config.dasSources
}&width=${config.sizeX}&option=image` +
`&hgrid=${config.horizontalGrid}&vgrid=${config.verticalGrid}&style=${
config.style
}`;
dataURL = `${this._webservice}?${args}`;
window.open(dataURL); // open generated image in new tab/window
} else {
Expand All @@ -94,14 +96,19 @@ Biojs.MyFeatureViewer = Biojs.FeatureViewer.extend(
var oldH = $svg.attr('height');
$svg.attr('width', `${$svg.width()}px`);
$svg.attr('height', `${$svg.height()}px`);
var svg = document.getElementById('uniprotFeaturePainter-holder').innerHTML;
var svg = document.getElementById('uniprotFeaturePainter-holder')
.innerHTML;
var canvas = document.createElement('canvas');
canvg(canvas, svg);
dataURL = canvas.toDataURL();
$svg.attr('width', `${$svg.width()}px`);
$svg.attr('height', oldH).attr('width', oldW);
this.$imageExported = jQuery('<div id="uniprotFeaturePainter-imageExportedDiv"></div>')
.html(`<img id="uniprotFeaturePainter-imageExported" alt="exported image" src="${dataURL}"/>`)
this.$imageExported = jQuery(
'<div id="uniprotFeaturePainter-imageExportedDiv"></div>'
)
.html(
`<img id="uniprotFeaturePainter-imageExported" alt="exported image" src="${dataURL}"/>`
)
.dialog({
autoOpen: true,
title: 'Exported image',
Expand All @@ -112,42 +119,45 @@ Biojs.MyFeatureViewer = Biojs.FeatureViewer.extend(
},

/*
* Applies a style, either "centered", "nonOverlapping", or "rows".
* @param show
*
* @example
* myPainter.applyStyle("centered");
*/
* Applies a style, either "centered", "nonOverlapping", or "rows".
* @param show
*
* @example
* myPainter.applyStyle("centered");
*/
applyStyle: function (style) {
if ((style != undefined) && ((style == 'centered') || (style == 'nonOverlapping') || (style = 'rows'))) {
if (
style != undefined &&
(style == 'centered' || style == 'nonOverlapping' || (style = 'rows'))
) {
var config = this.opt.json.configuration;
this.customize(style, config.horizontalGrid, config.verticalGrid);
}
},

/*
* Shows/hide the horizontal guide lines.
* @param show
*
* @example
* myPainter.showHideHorizontalGrid(true);
*/
* Shows/hide the horizontal guide lines.
* @param show
*
* @example
* myPainter.showHideHorizontalGrid(true);
*/
showHideHorizontalGrid: function (show) {
if ((show != undefined) && ((show == true) || (show == false))) {
if (show != undefined && (show == true || show == false)) {
var config = this.opt.json.configuration;
this.customize(config.style, show, config.verticalGrid);
}
},

/*
* Shows/hide the horizontal guide lines.
* @param show
*
* @example
* myPainter.showHideVerticalGrid(true);
*/
* Shows/hide the horizontal guide lines.
* @param show
*
* @example
* myPainter.showHideVerticalGrid(true);
*/
showHideVerticalGrid: function (show) {
if ((show != undefined) && ((show == true) || (show == false))) {
if (show != undefined && (show == true || show == false)) {
var config = this.opt.json.configuration;
this.customize(config.style, config.horizontalGrid, show);
}
Expand Down
24 changes: 10 additions & 14 deletions src/modules/types/chart/advanced/canvas_matrix/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,30 @@ function getColorFromValue(value) {
}

function getColorBetween(value, color1, color2, color1Val, color2Val) {
/* var color1 = getRGB(color1);
var color2 = getRGB(color2);
*/
// Between 0 and 1
var ratio = (value - color1Val) / (color2Val - color1Val);

return [
parseInt(ratio * (color2[0] - color1[0]) + color1[0]),
parseInt(ratio * (color2[1] - color1[1]) + color1[1]),
parseInt(ratio * (color2[2] - color1[2]) + color1[2]),
parseInt(ratio * (color2[3] - color1[3]) + color1[3])
parseInt(ratio * (color2[0] - color1[0]) + color1[0], 10),
parseInt(ratio * (color2[1] - color1[1]) + color1[1], 10),
parseInt(ratio * (color2[2] - color1[2]) + color1[2], 10),
parseInt(ratio * (color2[3] - color1[3]) + color1[3], 10)
];
// return [parseInt(ratio * Math.abs(color2[0] - color1[0]) + Math.min(color2[0], color1[0])), parseInt(ratio * Math.abs(color2[1] - color1[1]) + Math.min(color2[1], color1[1])), parseInt(ratio * Math.abs(color2[2] - color1[2]) + Math.min(color2[2], color1[2]))];
}

function getRGB(color) {
if (!color) return false;
if (color.length == 7) {
return [
parseInt(`0x${color.substring(1, 3)}`),
parseInt(`0x${color.substring(3, 5)}`),
parseInt(`0x${color.substring(5, 7)}`)
parseInt(`0x${color.substring(1, 3)}`, 16),
parseInt(`0x${color.substring(3, 5)}`, 16),
parseInt(`0x${color.substring(5, 7)}`, 16)
];
} else if (color.length == 4) {
return [
parseInt(`0x${color.substring(1, 2)}`),
parseInt(`0x${color.substring(2, 3)}`),
parseInt(`0x${color.substring(3, 4)}`)
parseInt(`0x${color.substring(1, 2)}`, 16),
parseInt(`0x${color.substring(2, 3)}`, 16),
parseInt(`0x${color.substring(3, 4)}`, 16)
];
}
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/types/chart/advanced/plot_function/view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';

define([
'require',
'modules/default/defaultview',
Expand Down
5 changes: 2 additions & 3 deletions src/modules/types/chart/basic/radar_chart/view.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict';

/* global dhtmlXChart*/
define([
'modules/default/defaultview',
'src/util/datatraversing',
'src/util/api',
'src/util/util',
'lib/dhtmlxchart/dhtmlxchart'
], function (Default, Traversing, API, Util) {
], function (Default, Util) {
function View() {}

$.extend(true, View.prototype, Default, {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/types/chart/basic/scatter3D/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1152,9 +1152,9 @@ define([
var result = '';
for (var i = 0; i < num.length; i++) {
if (num[i] === '2' || num[i] === '3') {
result += String.fromCharCode(176 + parseInt(num[i]));
result += String.fromCharCode(176 + parseInt(num[i], 10));
} else if (num[i] >= '0' && num[i] < '9') {
result += String.fromCharCode(8304 + parseInt(num[i]));
result += String.fromCharCode(8304 + parseInt(num[i], 10));
} else if (num[i] === '-') {
result += String.fromCharCode(8315);
}
Expand Down
Loading

0 comments on commit d051704

Please sign in to comment.