Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
r03ert0 committed Jun 3, 2020
1 parent 7042b68 commit 7ee7571
Show file tree
Hide file tree
Showing 19 changed files with 660 additions and 671 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = {
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"indent": "off",
"indent": ["error", 2],
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "error",
Expand Down
46 changes: 23 additions & 23 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ const app = express();
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
if (process.env.NODE_ENV !== 'production') {
app.use(require('morgan')('dev'));
app.use(require('morgan')('dev'));
}
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));


/* setup DB */
var checkAnyoneUser = function () {

/* check that the 'anyone' user exists. Insert it if it doesn't */
db.queryUser({username: 'anyone'})
/* check that the 'anyone' user exists. Insert it if it doesn't */
db.queryUser({username: 'anyone'})
.then((res) => {
console.log('"anyone" user correctly configured.', res);
console.log('"anyone" user correctly configured.', res);
})
.catch((err) => {
console.log('"anyone" user absent: adding one.', err);
const anyone = {
username: 'anyone',
nickname: 'anyone',
name: 'Any User',
joined: (new Date()).toJSON()
};
db.addUser(anyone);
console.log('"anyone" user absent: adding one.', err);
const anyone = {
username: 'anyone',
nickname: 'anyone',
name: 'Any User',
joined: (new Date()).toJSON()
};
db.addUser(anyone);
});
};

const db = require('./db/db')(null, checkAnyoneUser);
app.db = db;

Expand All @@ -49,21 +49,21 @@ require('./routes/routes')(app);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
console.log('ERROR: File not found', req.url);
var err = new Error('Not Found', req);
err.status = 404;
next(err);
console.log('ERROR: File not found', req.url);
var err = new Error('Not Found', req);
err.status = 404;
next(err);
});

// error handler
app.use(function(err, req, res) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page
res.status(err.status || 500);
res.render('error');
// render the error page
res.status(err.status || 500);
res.render('error');
});


Expand Down
2 changes: 1 addition & 1 deletion app/controller/api/api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function buildFileID({source, slice}) {
app.use((req, res, next) => {
if (authorized) {
req.user = {
username: 'bobby'
username: 'bobby'
}
}
return next()
Expand Down
5 changes: 2 additions & 3 deletions app/public/js/microdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Microdraw = (function () {
imageOrder: [], // names of sections ordered by their openseadragon page numbers
currentImage: null, // name of the current image
prevImage: null, // name of the last image
currentLabelIndex: 0, // current label to use
currentLabelIndex: 0, // current label to use
region: null, // currently selected region (one element of Regions[])
copyRegion: null, // clone of the currently selected region for copy/paste
handle: null, // currently selected control point or handle (if any)
Expand All @@ -27,7 +27,6 @@ const Microdraw = (function () {
params: null, // URL parameters
source: null, // data source
section: null, // section index in a multi-section dataset
// myIP, // user's IP
UndoStack: [],
RedoStack: [],
mouseUndo: null, // tentative undo information.
Expand Down Expand Up @@ -1879,7 +1878,7 @@ const Microdraw = (function () {
* @function initMicrodraw
* @returns {void}
*/
initMicrodraw: async function () {
initMicrodraw: async () => {

if( me.debug ) {
console.log("> initMicrodraw promise");
Expand Down
98 changes: 48 additions & 50 deletions app/public/js/tools/addPoint.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,65 @@
/*global Microdraw*/
/*global paper*/

var ToolAddPoint = { addPoint : (function(){
var tool = {
var ToolAddPoint = { addPoint : (function() {
var tool = {

/**
/**
* @function mouseDown
* @param {object} point The point where you clicked (x,y)
* @returns {void}
*/
mouseDown : function mouseDown(point) {
var hitResult = paper.project.hitTest(point, {
tolerance : Microdraw.tolerance,
stroke : true,
segments : true,
fill : true,
handles : true
})
Microdraw.newRegionFlag = false;

if( hitResult ) {
var i, re;
for( i = 0; i < Microdraw.ImageInfo[Microdraw.currentImage].Regions.length; i += 1 ) {
if( Microdraw.ImageInfo[Microdraw.currentImage].Regions[i].path === hitResult.item ) {
re = Microdraw.ImageInfo[Microdraw.currentImage].Regions[i];
break;
}
}
mouseDown : function mouseDown(point) {
var hitResult = paper.project.hitTest(point, {
tolerance : Microdraw.tolerance,
stroke : true,
segments : true,
fill : true,
handles : true
});
Microdraw.newRegionFlag = false;

// select path
if( Microdraw.region && Microdraw.region !== re ) {
Microdraw.region.path.selected = false;
prevRegion = Microdraw.region;
}
Microdraw.selectRegion(re);
if( hitResult ) {
var i, re;
for( i = 0; i < Microdraw.ImageInfo[Microdraw.currentImage].Regions.length; i += 1 ) {
if( Microdraw.ImageInfo[Microdraw.currentImage].Regions[i].path === hitResult.item ) {
re = Microdraw.ImageInfo[Microdraw.currentImage].Regions[i];
break;
}
}

// select path
if( Microdraw.region && Microdraw.region !== re ) {
Microdraw.region.path.selected = false;
prevRegion = Microdraw.region;
}
Microdraw.selectRegion(re);

if( hitResult.type === 'stroke'){
Microdraw.region.path
.curves[hitResult.location.index]
.divide(hitResult.location);
Microdraw.region.path.fullySelected = true;
Microdraw.commitMouseUndo();
};
} else {
if( Microdraw.region ){
Microdraw.region.path.selected = false
Microdraw.region = null
};
};
paper.view.draw();
},
if( hitResult.type === 'stroke') {
Microdraw.region.path
.curves[hitResult.location.index]
.divide(hitResult.location);
Microdraw.region.path.fullySelected = true;
Microdraw.commitMouseUndo();
}
} else if( Microdraw.region ) {
Microdraw.region.path.selected = false;
Microdraw.region = null;
}
paper.view.draw();
},

/**
/**
* @function click
* @desc add an additional point to the selected annotation
* @param {string} prevTool The previous tool to which the selection goes back
* @returns {void}
*/
click : function click(prevTool) {
Microdraw.navEnabled = false;
Microdraw.handle = null;
}
click : function click(prevTool) {
Microdraw.navEnabled = false;
Microdraw.handle = null;
}

return tool;
}())}
};

return tool;
}())};
96 changes: 47 additions & 49 deletions app/public/js/tools/addRegion.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,64 @@
/*global Microdraw*/
/*global paper*/

var ToolAddRegion = { addRegion : (function(){
var tool = {
var ToolAddRegion = { addRegion : (function() {
var tool = {

/**
/**
* @function mouseDown
* @param {object} point The point where you clicked (x,y)
* @returns {void}
*/
mouseDown : function mouseDown(point) {
var prevRegion = null
var hitResult = paper.project.hitTest(point, {
tolerance : Microdraw.tolerance,
stroke : true,
segments : true,
fill : true,
handles : true
})
Microdraw.newRegionFlag = false;

if( hitResult ) {
var re = Microdraw.ImageInfo[Microdraw.currentImage].Regions.find(region=>region.path === hitResult.item)
mouseDown : function mouseDown(point) {
var prevRegion = null;
var hitResult = paper.project.hitTest(point, {
tolerance : Microdraw.tolerance,
stroke : true,
segments : true,
fill : true,
handles : true
});
Microdraw.newRegionFlag = false;

// select path
if( Microdraw.region && Microdraw.region !== re ) {
Microdraw.region.path.selected = false;
prevRegion = Microdraw.region;
}
Microdraw.selectRegion(re);
if( hitResult ) {
var re = Microdraw.ImageInfo[Microdraw.currentImage].Regions.find((region) => region.path === hitResult.item);

if( prevRegion ) {
var newPath = Microdraw.region.path.unite(prevRegion.path);
Microdraw.removeRegion(prevRegion);
Microdraw.region.path.remove();
Microdraw.region.path = newPath;
// Microdraw.updateRegionList();
Microdraw.selectRegion(Microdraw.region);
paper.view.draw();
Microdraw.commitMouseUndo();
Microdraw.backToSelect();
}
} else {
if( Microdraw.region ){
Microdraw.region.path.selected = false
Microdraw.region = null
};
};
paper.view.draw();
},
// select path
if( Microdraw.region && Microdraw.region !== re ) {
Microdraw.region.path.selected = false;
prevRegion = Microdraw.region;
}
Microdraw.selectRegion(re);

if( prevRegion ) {
var newPath = Microdraw.region.path.unite(prevRegion.path);
Microdraw.removeRegion(prevRegion);
Microdraw.region.path.remove();
Microdraw.region.path = newPath;
// Microdraw.updateRegionList();
Microdraw.selectRegion(Microdraw.region);
paper.view.draw();
Microdraw.commitMouseUndo();
Microdraw.backToSelect();
}
} else if( Microdraw.region ) {
Microdraw.region.path.selected = false;
Microdraw.region = null;
}
paper.view.draw();
},

/**
/**
* @function click
* @desc add an additional point to the selected annotation
* @param {string} prevTool The previous tool to which the selection goes back
* @returns {void}
*/
click : function click(prevTool) {
Microdraw.navEnabled = false;
Microdraw.handle = null;
}
click : function click(prevTool) {
Microdraw.navEnabled = false;
Microdraw.handle = null;
}

return tool;
}())}
};

return tool;
}())};
20 changes: 10 additions & 10 deletions app/public/js/tools/closeMenu.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*global Microdraw*/
/*global paper*/

var ToolCloseMenu = { closeMenu : (function(){
var tool = {
var ToolCloseMenu = { closeMenu : (function() {
var tool = {

/**
/**
* @function click
* @desc closeMenu. close the side menu
* @param {string} prevTool The previous tool to which the selection goes back
* @returns {void}
*/
click : function click(prevTool) {
Microdraw.toggleMenu();
Microdraw.backToPreviousTool(prevTool);
}
click : function click(prevTool) {
Microdraw.toggleMenu();
Microdraw.backToPreviousTool(prevTool);
}

return tool;
}())}
};

return tool;
}())};
Loading

0 comments on commit 7ee7571

Please sign in to comment.