Skip to content

Commit

Permalink
Add lint command
Browse files Browse the repository at this point in the history
  • Loading branch information
Izzatbek committed Mar 17, 2016
1 parent f6c32cf commit e46c4a0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Makefile
*.iobj
*.ipdb
*.tlog
*.log
*.vs

*node_modules*
Expand Down
2 changes: 1 addition & 1 deletion bindings/Node/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fs.readFile('./server/server.js', 'utf8', function (err, data) {
}
originalFile = data;
var result = originalFile.replace(/require\("libpointing"\)/g, 'require("./pointing.node")');
var result = result.replace(/#!\/usr\/bin\/env node/g, '');
result = result.replace(/#!\/usr\/bin\/env node/g, '');

fs.writeFile('./nw/server.js', result, 'utf8', function (err) {
if (err) return console.log(err);
Expand Down
42 changes: 21 additions & 21 deletions bindings/Node/client/pointing.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
*/

var pointing = new function() {
var pointing = function() {

var socket = io.connect('http://localhost:3423');
this.pointingIsAvailable = true;
Expand All @@ -30,7 +30,7 @@ var pointing = new function() {

var DeviceManager = function() {
this.deviceList = [];
}
};
DeviceManager.prototype = {
addDeviceUpdateCallback: function(updateCallback) {
this.callback = updateCallback;
Expand Down Expand Up @@ -59,7 +59,7 @@ var pointing = new function() {
that.callCallback(desc, true);
});
}
}
};



Expand All @@ -75,7 +75,7 @@ var pointing = new function() {
socket.on('pointingDeviceList', function(ls) {
that.changeDeviceList(ls);
});
}
};
PointingDeviceManager.prototype = Object.create(DeviceManager.prototype);
PointingDeviceManager.prototype.constructor = PointingDeviceManager;

Expand All @@ -93,13 +93,13 @@ var pointing = new function() {
socket.on('displayDeviceList', function(ls) {
that.changeDeviceList(ls);
});
}
};
DisplayDeviceManager.prototype = Object.create(DeviceManager.prototype);
DisplayDeviceManager.prototype.constructor = DisplayDeviceManager;



var dispatcher = new function() {
var dispatcher = function() {

this.objects = {};
var that = this;
Expand Down Expand Up @@ -129,7 +129,7 @@ var pointing = new function() {
var PointingObject = function() {
this.id = idCount++;
dispatcher.objects[this.id] = this;
}
};
PointingObject.prototype = {

dispose: function() {
Expand All @@ -145,15 +145,15 @@ var pointing = new function() {
}
}

}
};



var DisplayDevice = function(uri) {
this.uri = uri;
PointingObject.call(this);
socket.emit('displayDeviceCreate', uri, this.id);
}
};
DisplayDevice.prototype = Object.create(PointingObject.prototype);
DisplayDevice.prototype.constructor = DisplayDevice;

Expand All @@ -163,62 +163,62 @@ var pointing = new function() {
this.uri = uri;
PointingObject.call(this);
socket.emit('pointingDeviceCreate', uri, this.id);
}
};
PointingDevice.prototype = Object.create(PointingObject.prototype);
PointingDevice.prototype.constructor = PointingDevice;
PointingDevice.prototype.setPointingCallback = function(pointingCallback) {
this.callback = pointingCallback;
socket.emit('setPointingCallback', this.id, this.funcId, this.floating);
return this;
}
};
PointingDevice.prototype.applyTransferFunction = function(transferFunction, floating) {
this.funcId = transferFunction.id;
this.floating = floating;
if (this.callback)
socket.emit('setPointingCallback', this.id, this.funcId, this.floating);
}
};



var TransferFunction = function(uri, inputDevice, displayDevice) {
this.uri = uri;
PointingObject.call(this);
socket.emit('transferFunctionCreate', uri, this.id, inputDevice.id, displayDevice.id);
}
};
TransferFunction.prototype = Object.create(PointingObject.prototype);
TransferFunction.prototype.constructor = TransferFunction;
TransferFunction.prototype.clearState = function() {
socket.emit('transferFunctionClearState', this.id);
return this;
}
};
TransferFunction.prototype.setSubPixeling = function(subPixeling) {
socket.emit('transferFunctionSetSubPixeling', this.id, subPixeling);
return this;
}
};
TransferFunction.prototype.setHumanResolution = function(humanResolution) {
socket.emit('transferFunctionHumanResolution', this.id, humanResolution);
return this;
}
};
TransferFunction.prototype.setCardinalitySize = function(cardinality, widgetSize) {
socket.emit('transferFunctionCardinalitySize', this.id, cardinality, widgetSize);
return this;
}
};



var SystemPointerAcceleration = function() {
PointingObject.call(this);
socket.emit('systemPointerAcceleration', this.id);
}
};
SystemPointerAcceleration.prototype = Object.create(PointingObject.prototype);
SystemPointerAcceleration.prototype.constructor = SystemPointerAcceleration;

SystemPointerAcceleration.prototype.set = function(argsObj) {
socket.emit('setSystemPointerAcceleration', this.id, argsObj);
}
};
SystemPointerAcceleration.prototype.get = function(argsObj) {
socket.emit('systemPointerAcceleration', this.id, argsObj);
}
};



Expand All @@ -233,7 +233,7 @@ var pointing = new function() {
callback(position.x, position.y);
});
}
}
};



Expand Down
9 changes: 4 additions & 5 deletions bindings/Node/consoleExample.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
var pointing = require('libpointing');

if (process.argv.length < 5)
console.log("Usage: node", process.argv[1], "[inputdeviceURI [outputdeviceURI [transferfunctionURI]]]")
console.log("Usage: node", process.argv[1], "[inputdeviceURI [outputdeviceURI [transferfunctionURI]]]");

global.input = new pointing.PointingDevice((process.argv[2]) ? process.argv[2] : "any:")
global.input = new pointing.PointingDevice((process.argv[2]) ? process.argv[2] : "any:");
var output = new pointing.DisplayDevice((process.argv[3]) ? process.argv[3] : "any:");
var tFunc = new pointing.TransferFunction((process.argv[4]) ? process.argv[4] : "system:", input, output);
var tFunc = new pointing.TransferFunction((process.argv[4]) ? process.argv[4] : "sigmoid:", input, output);

input.setPointingCallback(function(timestamp, dx, dy, buttons) {
var pixels = tFunc.applyi(dx, dy, timestamp);
console.log(timestamp, dx, dy, buttons, " -> ", pixels.dx, pixels.dy);
});

var manager = new pointing.PointingDeviceManager().addDeviceUpdateCallback(
function(deviceDescriptor, wasAdded)
{
function(deviceDescriptor, wasAdded) {
console.log(deviceDescriptor, wasAdded);
}
);
Expand Down
7 changes: 5 additions & 2 deletions bindings/Node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
"version": "1.0.0",
"description": "This folder is dedicated for libpointing Node.js bindings",
"main": "builder.js",
"devDependencies": {},
"devDependencies": {
"jshint": "latest"
},
"scripts": {
"install": "cd libpointing && npm install",
"build": "cd libpointing && node-gyp configure build"
"build": "cd libpointing && node-gyp configure build",
"lint": "jshint *.js server/*.js client/*.js"
},
"author": "Izzat Mukhanov",
"license": "GPL-2.0",
Expand Down
4 changes: 2 additions & 2 deletions bindings/Node/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if (process.argv.length < 3)
console.log("Usage: pointingserver [start | stop]");

var arg = (process.argv.length > 2) ? process.argv[2] : 'start'
var arg = (process.argv.length > 2) ? process.argv[2] : 'start';
var pidPath = __dirname + '/pointing.pid';
const fs = require('fs');

Expand Down Expand Up @@ -37,7 +37,7 @@ if (arg == 'stop') {
if (ex.code == 'ESRCH') {
console.log('PointingServer is not running');
}
};
}
}
});
}
2 changes: 1 addition & 1 deletion bindings/Node/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ app.get('/', function(req, res) {
*/

function uriIsOK(deviceDescriptor) {
var ls = ['Keyboard', 'osxhid://0/AppleMikeyHIDDriver', 'osxhid:/USB/1d182000/AppleUSBMultitouchDriver', 'BNBTrackpadDevice', 'AppleUSBTCButtons']
var ls = ['Keyboard', 'osxhid://0/AppleMikeyHIDDriver', 'osxhid:/USB/1d182000/AppleUSBMultitouchDriver', 'BNBTrackpadDevice', 'AppleUSBTCButtons'];
for (var i = 0; i < ls.length; i++) {
if (deviceDescriptor.devURI.indexOf(ls[i]) != -1) {
return false;
Expand Down

0 comments on commit e46c4a0

Please sign in to comment.