├── .gitignore ├── README.md ├── index.html ├── package.json ├── styles └── index.css ├── scripts └── index.js └── LICENSE.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## jsqrcode-ui 2 | 3 | node-webkit drag and drop ui for jsqrcode 4 | 5 | ![qrcode_scanner](https://cloud.githubusercontent.com/assets/419703/3220166/3c3170cc-effd-11e3-9100-bd90f139b700.gif) 6 | 7 | ### Running 8 | 9 | Install `node-webkit` and execute in this folder: 10 | 11 | ```sh 12 | nw . 13 | ``` 14 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Drop your file here! 5 | 6 | 7 | 8 |
Drag your image here
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsqrcode-ui", 3 | "description": "node-webkit drag and drop UI for jsqrcode", 4 | "version": "0.0.1", 5 | "dependencies": { 6 | "jsqrcode": "https://github.com/pose/jsqrcode-1/tarball/master" 7 | }, 8 | "main": "index.html", 9 | "window": { 10 | "toolbar": false, 11 | "width": 612, 12 | "height": 310 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /styles/index.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | padding: 0; 3 | margin: 0; 4 | width: 100%; 5 | height: 100%; 6 | } 7 | 8 | #holder { 9 | border: 10px dashed #ccc; 10 | width: 100%; 11 | height: 100%; 12 | margin: 0; 13 | -webkit-box-sizing:border-box; 14 | text-align: center; 15 | font-size: 28pt; 16 | font-family: Helvetica; 17 | padding: 30px; 18 | color: black; 19 | } 20 | 21 | #holder.hover { 22 | border: 10px dashed #333; 23 | } 24 | -------------------------------------------------------------------------------- /scripts/index.js: -------------------------------------------------------------------------------- 1 | HTMLCanvasElement = window.HTMLCanvasElement; 2 | var qrcode = require('jsqrcode')(); 3 | 4 | // prevent default behavior from changing page on dropped file 5 | window.ondragover = function(e) { 6 | e.preventDefault(); 7 | return false; 8 | }; 9 | window.ondrop = function(e) { 10 | e.preventDefault(); 11 | return false; 12 | }; 13 | 14 | var holder = document.getElementById('holder'); 15 | holder.ondragover = function () { this.className = 'hover'; return false; }; 16 | holder.ondragend = function () { this.className = ''; return false; }; 17 | holder.ondrop = function (e) { 18 | e.preventDefault(); 19 | var fileName = e.dataTransfer.files[0].path; 20 | 21 | var image = new Image(); 22 | holder.innerText = 'Loading...'; 23 | 24 | image.onload = function () { 25 | var result; 26 | try{ 27 | result = qrcode.decode(image); 28 | holder.innerText = 'Result of scanning QR code: ' + result; 29 | } catch(e) { 30 | holder.innerText = 'Unable to read QR code.'; 31 | } 32 | }; 33 | 34 | image.src = fileName; 35 | 36 | return false; 37 | }; 38 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) {{{year}}} {{{fullname}}} 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------