diff --git a/example/file_input_require.html b/example/file_input_require.html deleted file mode 100644 index 5c7b9cd0..00000000 --- a/example/file_input_require.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - index - - - - - - - - -
-
-

QuaggaJS

- -

An advanced barcode-scanner written in JavaScript

-
-
-
-

Working with file-input

- -

This example let's you select an image from your local filesystem. - QuaggaJS then tries to decode the barcode using - the preferred method (Code128 or EAN). - There is no server interaction needed as the - file is simply accessed through the File API.

- -

This also works great on a wide range of mobile-phones where the camera - access through getUserMedia is still very limited.

- -
-
- - -
-
- - - - - -
-
-
- -
-
-
-
- - - - - \ No newline at end of file diff --git a/example/file_input_require.js b/example/file_input_require.js deleted file mode 100644 index baf9498b..00000000 --- a/example/file_input_require.js +++ /dev/null @@ -1,161 +0,0 @@ -requirejs.config({ - "baseUrl" : "../src", - "shim" : { - "typedefs" : { - "deps" : [], - "exports" : "typedefs" - } - }, - - "paths" : { - "typedefs" : "typedefs", - "gl-matrix": "../node_modules/gl-matrix/dist/gl-matrix-min" - } -}); - -requirejs(['quagga'], function(Quagga) { - var App = { - init: function() { - App.attachListeners(); - }, - attachListeners: function() { - var self = this; - - $(".controls input[type=file]").on("change", function(e) { - if (e.target.files && e.target.files.length) { - App.decode(URL.createObjectURL(e.target.files[0])); - } - }); - - $(".controls button").on("click", function(e) { - var input = document.querySelector(".controls input[type=file]"); - if (input.files && input.files.length) { - App.decode(URL.createObjectURL(input.files[0])); - } - }); - - $(".controls .reader-config-group").on("change", "input, select", function(e) { - e.preventDefault(); - var $target = $(e.target), - value = $target.attr("type") === "checkbox" ? $target.prop("checked") : $target.val(), - name = $target.attr("name"), - state = self._convertNameToState(name); - - console.log("Value of "+ state + " changed to " + value); - self.setState(state, value); - }); - }, - _accessByPath: function(obj, path, val) { - var parts = path.split('.'), - depth = parts.length, - setter = (typeof val !== "undefined") ? true : false; - - return parts.reduce(function(o, key, i) { - if (setter && (i + 1) === depth) { - o[key] = val; - } - return key in o ? o[key] : {}; - }, obj); - }, - _convertNameToState: function(name) { - return name.replace("_", ".").split("-").reduce(function(result, value) { - return result + value.charAt(0).toUpperCase() + value.substring(1); - }); - }, - detachListeners: function() { - $(".controls input[type=file]").off("change"); - $(".controls .reader-config-group").off("change", "input, select"); - $(".controls button").off("click"); - }, - decode: function(src) { - var self = this, - config = $.extend({}, self.state, {src: src}); - - Quagga.decodeSingle(config, function(result) {}); - }, - setState: function(path, value) { - var self = this; - - if (typeof self._accessByPath(self.inputMapper, path) === "function") { - value = self._accessByPath(self.inputMapper, path)(value); - } - - self._accessByPath(self.state, path, value); - - console.log(JSON.stringify(self.state)); - App.detachListeners(); - App.init(); - }, - inputMapper: { - inputStream: { - size: function(value){ - return parseInt(value); - } - }, - numOfWorkers: function(value) { - return parseInt(value); - }, - decoder: { - readers: function(value) { - return [value + "_reader"]; - } - } - }, - state: { - inputStream: { - size: 640, - singleChannel: false - }, - locator: { - patchSize: "medium", - halfSample: true, - showCanvas: true - }, - numOfWorkers: 0, - decoder: { - readers: ["code_128_reader"], - showFrequency: true, - showPattern: true - }, - locate: true, - src: null - } - }; - - App.init(); - - Quagga.onProcessed(function(result) { - var drawingCtx = Quagga.canvas.ctx.overlay, - drawingCanvas = Quagga.canvas.dom.overlay; - - if (result) { - if (result.boxes) { - drawingCtx.clearRect(0, 0, parseInt(drawingCanvas.getAttribute("width")), parseInt(drawingCanvas.getAttribute("height"))); - result.boxes.filter(function (box) { - return box !== result.box; - }).forEach(function (box) { - Quagga.ImageDebug.drawPath(box, {x: 0, y: 1}, drawingCtx, {color: "green", lineWidth: 2}); - }); - } - - if (result.box) { - Quagga.ImageDebug.drawPath(result.box, {x: 0, y: 1}, drawingCtx, {color: "#00F", lineWidth: 2}); - } - - if (result.codeResult && result.codeResult.code) { - Quagga.ImageDebug.drawPath(result.line, {x: 'x', y: 'y'}, drawingCtx, {color: 'red', lineWidth: 3}); - } - } - }); - - Quagga.onDetected(function(result) { - var code = result.codeResult.code, - $node, - canvas = Quagga.canvas.dom.image; - - $node = $('
  • '); - $node.find("img").attr("src", canvas.toDataURL()); - $node.find("h4.code").html(code + " (" + result.codeResult.format + ")"); - $("#result_strip ul.thumbnails").prepend($node); - }); -}); \ No newline at end of file diff --git a/package.json b/package.json index 7c6ea57a..4f0eb058 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,7 @@ "karma-webpack": "^1.7.0", "mocha": "^2.3.2", "sinon": "^1.16.1", - "webpack": "^1.12.2", - "webpack-core": "^0.6.7" + "webpack": "^1.12.2" }, "directories": { "doc": "doc" @@ -41,7 +40,7 @@ "test": "grunt test", "integrationtest": "grunt integrationtest", "build": "webpack && webpack --config webpack.config.min.js && grunt uglyasm && webpack --config webpack.node.config.js", - "dev-server": "webpack-dev-server" + "watch": "webpack --watch" }, "repository": { "type": "git",