From 3cac7be0466acd9d81126d4c12e05bdb6e0ce257 Mon Sep 17 00:00:00 2001 From: Jim Ulle Date: Wed, 18 Oct 2017 00:37:55 -0400 Subject: [PATCH] fixed some linting errors --- controller/mri/index.js | 23 +++++++++++----------- controller/project/index.js | 12 ++++++------ controller/user/index.js | 19 +++++++++---------- js/mri-loader.js | 24 +++++++++++------------ package.json | 1 + public/js/brainbox-intro.js | 38 ++++++++++++++++++------------------- test/client.js | 20 +++++++++---------- test/test.js | 15 ++++++++------- 8 files changed, 77 insertions(+), 75 deletions(-) diff --git a/controller/mri/index.js b/controller/mri/index.js index f388e59..f609187 100644 --- a/controller/mri/index.js +++ b/controller/mri/index.js @@ -1,22 +1,23 @@ -var express = require('express'); -var controller = require('./mri.controller'); -var upload_controller = require('./upload.controller'); +const express = require('express'); +const multer = require('multer'); -var multer = require('multer'); -var router = express.Router(); +const router = express.Router(); + +const controller = require('./mri.controller'); +const uploadController = require('./upload.controller'); router.get('', controller.validator, controller.mri); router.get('/json', controller.validator, tokenAuthentication, controller.api_mri_get); router.post('/json', controller.validator_post, tokenAuthentication, controller.api_mri_post); -router.get('/upload', upload_controller.token); +router.get('/upload', uploadController.token); router.post('/upload', - multer({ dest: './tmp/'}).array('atlas'), - upload_controller.validator, - upload_controller.other_validations, - upload_controller.upload); + multer({dest: './tmp/'}).array('atlas'), + uploadController.validator, + uploadController.other_validations, + uploadController.upload); router.get('/reset', controller.reset); -module.exports = router; \ No newline at end of file +module.exports = router; diff --git a/controller/project/index.js b/controller/project/index.js index 82491eb..047f1aa 100644 --- a/controller/project/index.js +++ b/controller/project/index.js @@ -1,18 +1,18 @@ -var express = require('express'); -var controller = require('./project.controller'); +const express = require('express'); +const controller = require('./project.controller'); -var router = express.Router(); +const router = express.Router(); // router.get('/new', controller.newProject); router.get('/json', tokenAuthentication, controller.api_projectAll); -router.get('/json/:projectName', controller.validator , tokenAuthentication, controller.api_project); -router.get('/json/:projectName/files', controller.validator , tokenAuthentication, controller.api_projectFiles); +router.get('/json/:projectName', controller.validator, tokenAuthentication, controller.api_project); +router.get('/json/:projectName/files', controller.validator, tokenAuthentication, controller.api_projectFiles); router.post('/json/:projectName', controller.validator, tokenAuthentication, controller.post_project); router.delete('/json/:projectName', controller.validator, tokenAuthentication, controller.delete_project); router.get('/:projectName', controller.validator, controller.project); router.get('/:projectName/settings', controller.validator, controller.settings); -module.exports = router; \ No newline at end of file +module.exports = router; diff --git a/controller/user/index.js b/controller/user/index.js index 32364d6..205946c 100644 --- a/controller/user/index.js +++ b/controller/user/index.js @@ -1,14 +1,13 @@ -var express = require('express'); -var controller = require('./user.controller'); +const express = require('express'); +const controller = require('./user.controller'); -var router = express.Router(); +const router = express.Router(); router.get('/json', controller.api_userAll); -router.get('/json/:userName', controller.validator , controller.api_user); -router.get('/json/:userName/files', controller.validator , controller.api_userFiles); -router.get('/json/:userName/atlas', controller.validator , controller.api_userAtlas); -router.get('/json/:userName/projects', controller.validator , controller.api_userProjects); -router.get('/:userName', controller.validator , controller.user); +router.get('/json/:userName', controller.validator, controller.api_user); +router.get('/json/:userName/files', controller.validator, controller.api_userFiles); +router.get('/json/:userName/atlas', controller.validator, controller.api_userAtlas); +router.get('/json/:userName/projects', controller.validator, controller.api_userProjects); +router.get('/:userName', controller.validator, controller.user); - -module.exports = router; \ No newline at end of file +module.exports = router; diff --git a/js/mri-loader.js b/js/mri-loader.js index f437426..e354467 100644 --- a/js/mri-loader.js +++ b/js/mri-loader.js @@ -1,15 +1,15 @@ -var fs = require('fs'); -var zlib = require('zlib'); -var fileType=require("file-type"); +// const fs = require('fs'); +// const zlib = require('zlib'); +// const fileType = require('file-type'); -var MRILoader = function() { +const MRILoader = function () { /* var loadNifti = function(nii) { var vox_offset=352; var sizeof_hdr=nii.readUInt32LE(0); var dimensions=nii.readUInt16LE(40); - + var mri={}; mri.hdr=nii.slice(0,vox_offset); mri.dim=[]; @@ -49,20 +49,20 @@ var loadNifti = function(nii) { default: console.log("ERROR: Unknown dataType: "+mri.datatype); } - + return mri; } var loadBrainNifti = function(nii,callback) { var brain=loadNifti(nii); - + var i,sum=0,min,max; min=brain.data[0]; max=min; for(i=0;imax) max=brain.data[i]; } @@ -77,7 +77,7 @@ var loadBrainMGZ = function(data,callback) { var hdr_sz=284; var brain={}; var datatype; - + brain.dim=[]; brain.dim[0]=data.readInt32BE(4); brain.dim[1]=data.readInt32BE(8); @@ -87,7 +87,7 @@ var loadBrainMGZ = function(data,callback) { brain.pixdim[0]=data.readFloatBE(30); brain.pixdim[1]=data.readFloatBE(34); brain.pixdim[2]=data.readFloatBE(38); - + var tmp switch(datatype) { case 0: // MGHUCHAR @@ -119,7 +119,7 @@ var loadBrainMGZ = function(data,callback) { max=min; for(i=0;imax) max=brain.data[i]; } @@ -139,7 +139,7 @@ this.loadBrain = function(path,callback) { datagz=fs.readFileSync(path); var ft=fileType(datagz); var ext=path.split('.').pop(); - + switch(ft.ext) { case 'gz': { switch(ext) { diff --git a/package.json b/package.json index 42b825d..048b3bb 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "struct": "0.0.11", "url": "^0.11.0", "validator": "^6.0.0", + "webpage": "^0.3.0", "ws": "^1.1.1" }, "devDependencies": { diff --git a/public/js/brainbox-intro.js b/public/js/brainbox-intro.js index 1bdcd67..68f41a8 100644 --- a/public/js/brainbox-intro.js +++ b/public/js/brainbox-intro.js @@ -1,31 +1,31 @@ -function startIntro(){ - var intro = introJs(); +function startIntro() { + const intro = introJs(); intro.setOptions({ steps: [ { - intro: "Welcome to BrainBox." - + "BrainBox allows you to visualise and segment collaboratively " - + "any brain MRI dataset available online. Follow this tutorial " - + "to learn how to enter data into BrainBox, view it, edit it, " - + "and create collaborative segmentation projects. BrainBox is an " - + "open project – you will learn how to help us improving it by " - + "reporting bugs and suggestions to our GitHub repository" + intro: 'Welcome to BrainBox.' + + 'BrainBox allows you to visualise and segment collaboratively ' + + 'any brain MRI dataset available online. Follow this tutorial ' + + 'to learn how to enter data into BrainBox, view it, edit it, ' + + 'and create collaborative segmentation projects. BrainBox is an ' + + 'open project – you will learn how to help us improving it by ' + + 'reporting bugs and suggestions to our GitHub repository' }, { - element: "#url", - intro: "This is BrainBox's URL field. You can paste here a link " - + "to any MRI on the web. Currently, BrainBox supports Nifti " - + "format (.nii.gz files) and MGH format (.mgz files). Any link " - + "on the Web should work, from Zenodo, FigShare, DropBox, Amazon, " - + "etc. If you want to try BrainBox but you don't have any link to " - + "an MRI, you can select a brain from the \"Take me to a brain\" " - + "list, or browse among the community created projects.", + element: '#url', + intro: 'This is BrainBox\'s URL field. You can paste here a link ' + + 'to any MRI on the web. Currently, BrainBox supports Nifti ' + + 'format (.nii.gz files) and MGH format (.mgz files). Any link ' + + 'on the Web should work, from Zenodo, FigShare, DropBox, Amazon, ' + + 'etc. If you want to try BrainBox but you don\'t have any link to ' + + 'an MRI, you can select a brain from the "Take me to a brain" ' + + 'list, or browse among the community created projects.', position: 'top' }, { element: '#go', - intro: "Once you have entered the link to an MRI in the URL field " - + "click the Go button to go to BrainBox's viewer" + intro: 'Once you have entered the link to an MRI in the URL field ' + + 'click the Go button to go to BrainBox\'s viewer' } ] }); diff --git a/test/client.js b/test/client.js index 45408c1..b2088f8 100644 --- a/test/client.js +++ b/test/client.js @@ -1,24 +1,24 @@ -var page = require('webpage').create(); +const page = require('webpage').create(); -//viewportSize being the actual size of the headless browser -page.viewportSize = { width: 1024, height: 768 }; +// viewportSize being the actual size of the headless browser +page.viewportSize = {width: 1024, height: 768}; -//the clipRect is the portion of the page you are taking a screenshot of -page.clipRect = { top: 0, left: 0, width: 1024, height: 768 }; +// the clipRect is the portion of the page you are taking a screenshot of +page.clipRect = {top: 0, left: 0, width: 1024, height: 768}; -page.open('http://brainbox.dev', function(status) { - if (status !== 'success') { +page.open('http://brainbox.dev', function (status) { + if (!(status === 'success')) { console.log('Unable to access network'); } else { // a screenshot of the home page page.render('index.jpg'); - + // log the title - var title = page.evaluate(function() { + const title = page.evaluate(function () { return document.title; }); console.log(title); } phantom.exit(); -}); \ No newline at end of file +}); diff --git a/test/test.js b/test/test.js index eeff236..008368d 100644 --- a/test/test.js +++ b/test/test.js @@ -1,8 +1,9 @@ -var assert = require("assert"); -describe('Array', function(){ - describe('#indexOf()', function(){ - it('should return -1 when the value is not present', function(){ - assert.equal(-1, [1,2,3].indexOf(4)); // 4 is not present in this array so indexOf returns -1 - }) - }) +const assert = require('assert'); + +describe('Array', function () { + describe('#indexOf()', function () { + it('should return -1 when the value is not present', function () { + assert.equal(-1, [1, 2, 3].indexOf(4)); // 4 is not present in this array so indexOf returns -1 + }); + }); }); -- GitLab