From e79201608aea44dda68fb1219ba93dfa21f2d190 Mon Sep 17 00:00:00 2001 From: Jerome Etienne Date: Thu, 7 Apr 2011 09:22:32 +0200 Subject: [PATCH] more work --- MIT-LICENSE.txt | 20 ++++++ Makefile | 6 +- README.md | 33 +++++++-- examples/demo.html | 23 +++++++ examples/index.html | 5 +- index.html | 156 +++++++++++++++++++++++++++++++++++++++++++ jquery.qrcode.min.js | 22 ++++++ 7 files changed, 258 insertions(+), 7 deletions(-) create mode 100644 MIT-LICENSE.txt create mode 100644 examples/demo.html create mode 100644 index.html create mode 100644 jquery.qrcode.min.js diff --git a/MIT-LICENSE.txt b/MIT-LICENSE.txt new file mode 100644 index 0000000..6d32551 --- /dev/null +++ b/MIT-LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2011 Jerome Etienne, http://jetienne.com + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Makefile b/Makefile index bf5ea35..8d22f9d 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,11 @@ all: build: minify homepage_build minify: - closurec --js src/jquery.qrcode.js --js_output_file jquery.qrcode.min.js + echo -n > /tmp/jquery.qrcode.tmp.js + head -2 src/jquery.qrcode.js >> /tmp/jquery.qrcode.tmp.js + cat src/qrcode.js >> /tmp/jquery.qrcode.tmp.js + tail -n +3 src/jquery.qrcode.js >> /tmp/jquery.qrcode.tmp.js + closurec --js /tmp/jquery.qrcode.tmp.js --js_output_file jquery.qrcode.min.js homepage_build: pandoc -A ~/.pandoc.header.html -s README.md -o index.html diff --git a/README.md b/README.md index 45f87c0..c5f97d4 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,31 @@ # jQuery.qrcode.js -with jQuery.qrcode.js you can easily add qrcode to your webpages. - - jQuery("#container").qrcode("this plugin is great") - +With jQuery.qrcode.js you can easily add qrcode to your webpages. It is standalone, no external services which go on and off, or add latency -while loading. \ No newline at end of file +while loading. + +Show, dont tell, here is a demo + +## How to Use It + +First include it in your webpage with the usual script tag + + + +Then create a DOM element which gonna contains the generated qrcode image. Lets say +a div + +
+ +Then you add the *qrcode* in this container by + + jQuery('#qrcode').qrcode("this plugin is great"); + +This is it. + +## Conclusion + +MicroEvent.js is available on github here +under MIT license. +If you hit bugs, fill issues on github. +Feel free to fork, modify and have fun with it :) \ No newline at end of file diff --git a/examples/demo.html b/examples/demo.html new file mode 100644 index 0000000..92945ad --- /dev/null +++ b/examples/demo.html @@ -0,0 +1,23 @@ + + +Demo page + + + +

+ TODO make a nice looking pure client qrcode generator + even allow download of the image +

+ +
+ + + + + + + diff --git a/examples/index.html b/examples/index.html index 3a488ca..8fb9b5e 100644 --- a/examples/index.html +++ b/examples/index.html @@ -9,8 +9,11 @@ even allow download of the image

- + + +
+ + + + diff --git a/jquery.qrcode.min.js b/jquery.qrcode.min.js new file mode 100644 index 0000000..aa6e8a8 --- /dev/null +++ b/jquery.qrcode.min.js @@ -0,0 +1,22 @@ +(function(v){v.fn.qrcode=function(o){function w(a){this.mode=n.MODE_8BIT_BYTE;this.data=a}function p(a,c){this.typeNumber=a;this.errorCorrectLevel=c;this.modules=null;this.moduleCount=0;this.dataCache=null;this.dataList=[]}function t(a,c){if(a.length==undefined)throw Error(a.length+"/"+c);for(var d=0;d=7&&this.setupTypeNumber(a);if(this.dataCache==null)this.dataCache=p.createData(this.typeNumber, +this.errorCorrectLevel,this.dataList);this.mapData(this.dataCache,c)},setupPositionProbePattern:function(a,c){for(var d=-1;d<=7;d++)if(!(a+d<=-1||this.moduleCount<=a+d))for(var b=-1;b<=7;b++)c+b<=-1||this.moduleCount<=c+b||(this.modules[a+d][c+b]=0<=d&&d<=6&&(b==0||b==6)||0<=b&&b<=6&&(d==0||d==6)||2<=d&&d<=4&&2<=b&&b<=4?true:false)},getBestMaskPattern:function(){for(var a=0,c=0,d=0;d<8;d++){this.makeImpl(true,d);var b=k.getLostPoint(this);if(d==0||a>b){a=b;c=d}}return c},createMovieClip:function(a, +c,d){a=a.createEmptyMovieClip(c,d);this.make();for(c=0;c>d&1)==1;this.modules[Math.floor(d/3)][d%3+this.moduleCount-8-3]=b}for(d=0;d<18;d++){b=!a&&(c>>d&1)==1;this.modules[d%3+this.moduleCount-8-3][Math.floor(d/ +3)]=b}},setupTypeInfo:function(a,c){for(var d=k.getBCHTypeInfo(this.errorCorrectLevel<<3|c),b=0;b<15;b++){var e=!a&&(d>>b&1)==1;if(b<6)this.modules[b][8]=e;else if(b<8)this.modules[b+1][8]=e;else this.modules[this.moduleCount-15+b][8]=e}for(b=0;b<15;b++){e=!a&&(d>>b&1)==1;if(b<8)this.modules[8][this.moduleCount-b-1]=e;else if(b<9)this.modules[8][15-b-1+1]=e;else this.modules[8][15-b-1]=e}this.modules[this.moduleCount-8][8]=!a},mapData:function(a,c){for(var d=-1,b=this.moduleCount-1,e=7,f=0,h=this.moduleCount- +1;h>0;h-=2)for(h==6&&h--;;){for(var g=0;g<2;g++)if(this.modules[b][h-g]==null){var j=false;if(f>>e&1)==1;if(k.getMask(c,b,h-g))j=!j;this.modules[b][h-g]=j;e--;if(e==-1){f++;e=7}}b+=d;if(b<0||this.moduleCount<=b){b-=d;d=-d;break}}}};p.PAD0=236;p.PAD1=17;p.createData=function(a,c,d){c=q.getRSBlocks(a,c);for(var b=new x,e=0;e +a*8)throw Error("code length overflow. ("+b.getLengthInBits()+">"+a*8+")");for(b.getLengthInBits()+4<=a*8&&b.put(0,4);b.getLengthInBits()%8!=0;)b.putBit(false);for(;;){if(b.getLengthInBits()>=a*8)break;b.put(p.PAD0,8);if(b.getLengthInBits()>=a*8)break;b.put(p.PAD1,8)}return p.createBytes(b,c)};p.createBytes=function(a,c){for(var d=0,b=0,e=0,f=Array(c.length),h=Array(c.length),g=0;g=0?j.get(r):0}}for(i=g=0;i=0;)c^=k.G15<=0;)c^=k.G18<>>=1}return c},getPatternPosition:function(a){return k.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,c,d){switch(a){case s.PATTERN000:return(c+d)%2==0;case s.PATTERN001:return c%2==0;case s.PATTERN010:return d%3==0;case s.PATTERN011:return(c+d)%3==0;case s.PATTERN100:return(Math.floor(c/2)+Math.floor(d/3))%2==0;case s.PATTERN101:return c*d%2+c*d%3==0;case s.PATTERN110:return(c* +d%2+c*d%3)%2==0;case s.PATTERN111:return(c*d%3+(c+d)%2)%2==0;default:throw Error("bad maskPattern:"+a);}},getErrorCorrectPolynomial:function(a){for(var c=new t([1],0),d=0;d5)d+=3+f-5}for(b=0;b=256;)a-=255;return l.EXP_TABLE[a]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},m=0;m<8;m++)l.EXP_TABLE[m]=1<>>7-a%8&1)==1},put:function(a,c){for(var d=0;d>>c-d-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(a){var c=Math.floor(this.length/8);this.buffer.length<=c&&this.buffer.push(0);if(a)this.buffer[c]|=128>>>this.length%8;this.length++}};if(typeof o==="string")o={text:o};o=v.extend({},{width:256,height:256,typeNumber:4,correctLevel:u.H},o);return this.each(function(){var a= +new p(o.typeNumber,o.correctLevel);a.addData(o.text);a.make();var c=document.createElement("canvas");c.width=o.width;c.height=o.height;for(var d=c.getContext("2d"),b=o.width/a.getModuleCount(),e=o.height/a.getModuleCount(),f=0;f