Index: web/client/scripts/draw.js =================================================================== --- web/client/scripts/draw.js (revision 5503) +++ web/client/scripts/draw.js (revision 5504) @@ -205,7 +205,7 @@ } } GraphicEngine.prototype.setMatrix = function() { - var scale = nanometerPerUnit(this.unit) / NM_PER_PIXEL * 8; + var scale = nanometerPerUnit(this.unit) / NM_PER_PIXEL * 5; this.canvas.setTransform(1, 0, 0, 1, 0, 0); this.canvas.scale(scale, scale); } @@ -245,4 +245,6 @@ case "s": return "square"; default: return undefined; } -} \ No newline at end of file +} + +exports.GraphicEngine = GraphicEngine; \ No newline at end of file Index: web/protocol/package.json =================================================================== --- web/protocol/package.json (revision 5503) +++ web/protocol/package.json (revision 5504) @@ -3,10 +3,7 @@ "version": "0.0.1", "description": "Implementation of the pcb-rnd remote HID protocol", "homepage": "http://repo.hu/projects/pcb-rnd/", - "repository": { - "type": "svn", - "url": "svn://repo.hu/pcb-rnd/work/remote/web/protocol" - }, + "private": true, "license": "MIT", "author": { "name": "Kalman Keri", @@ -13,13 +10,14 @@ "email": "kk@metamaya.org" }, "main": "protocol.js", - "dependencies": { - }, + "dependencies": {}, "devDependencies": { + "browserify": "^13.1.1", "jshint": "^2.9.3", "tape": "^4.6.0" }, "scripts": { + "build": "browserify protocol.js > bundle.js", "test": "jshint protocol.js test/test.js && node ./test/test.js" } } Index: web/protocol/protocol.js =================================================================== --- web/protocol/protocol.js (revision 5503) +++ web/protocol/protocol.js (revision 5504) @@ -20,7 +20,7 @@ /** * Constructs a HID protocol parser. */ -function Parser() { +function ProtocolParser() { this.state = MSG; } /** @@ -28,7 +28,7 @@ * * @param buffer - An array-like indexable object whose elements are octets. */ -Parser.prototype.parse = function (buffer) { +ProtocolParser.prototype.parse = function (buffer) { for (let i = 0; i < buffer.length; ++i) { let b = buffer[i]; switch (this.state) { @@ -120,7 +120,7 @@ this.list = this.list.parent; } else { // the root list has been closed - this.args = Parser.compactTree(this.list); + this.args = ProtocolParser.compactTree(this.list); this.list = null; this.state = EOL; } @@ -229,26 +229,25 @@ /** * Override this to execute a command. */ -Parser.prototype.onCommand = function (command, args) { +ProtocolParser.prototype.onCommand = function (command, args) { }; /** * Override this to respond to errors. */ -Parser.prototype.onError = function () { +ProtocolParser.prototype.onError = function () { }; /** * Converts the argument tree to array of arrays by removing object levels. */ -Parser.compactTree = function (tree) { +ProtocolParser.compactTree = function (tree) { let list = tree.elements; for (let i = 0; i < list.length; ++i) { let elem = list[i]; if (typeof elem === "object") { - list[i] = Parser.compactTree(elem); + list[i] = ProtocolParser.compactTree(elem); } } return list; }; - -exports.Parser = Parser; +exports.ProtocolParser = ProtocolParser; Index: web/protocol/test/test.js =================================================================== --- web/protocol/test/test.js (revision 5503) +++ web/protocol/test/test.js (revision 5504) @@ -2,7 +2,7 @@ const test = require("tape"); -const Parser = require("..").Parser; +const ProtocolParser = require("..").ProtocolParser; test("cmd", (t) => { @@ -231,7 +231,7 @@ var args; var err; let buffer = Buffer.from(str); - let parser = new Parser(); + let parser = new ProtocolParser(); parser.onCommand = function (_cmd, _args) { cmd = _cmd; Index: web/testclient/draw.html =================================================================== --- web/testclient/draw.html (revision 5503) +++ web/testclient/draw.html (revision 5504) @@ -3,12 +3,10 @@ Document drawing text - -

Document drawing

- + Index: web/testclient/draw.js =================================================================== --- web/testclient/draw.js (revision 5503) +++ web/testclient/draw.js (revision 5504) @@ -1,7 +1,13 @@ -//drawRemoteFile("../testdata/netlist.pcb.remote"); -drawRemoteFile("../testdata/line_normal.pcb.remote"); +"use strict" +var protocol = require("../protocol/protocol"); +var draw = require("../client/scripts/draw"); + +drawRemoteFile("../testdata/netlist.pcb.remote"); +//drawRemoteFile("../testdata/line_normal.pcb.remote"); + + function drawRemoteFile(url) { var crctx = document.getElementById("canvas").getContext("2d"); var req = new XMLHttpRequest(); @@ -18,7 +24,7 @@ function drawBuffer(buffer, crctx) { - let ge = new GraphicEngine({ + let ge = new draw.GraphicEngine({ comm: new TestComm(), canvas: crctx, colors: {