From b9dc4bf95fc23d332a5b938ae8fe4f3fcccf0d6c Mon Sep 17 00:00:00 2001 From: Jerome Etienne Date: Tue, 27 Mar 2012 10:39:57 +0200 Subject: [PATCH] updated with more modern target Makefile --- Makefile | 28 ++++++++++------------ jquery.qrcode.min.js | 56 +++++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index 5fd3598..0bc19fe 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,20 @@ PROJECT_NAME=jquery-qrcode all: +server: + python -m SimpleHTTPServer build: minify homepage_build minify: - echo -n > /tmp/jquery.qrcode.tmp.js + echo > /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 + curl --data-urlencode "js_code@/tmp/jquery.qrcode.tmp.js" \ + -d "output_format=text&output_info=compiled_code&compilation_level=SIMPLE_OPTIMIZATIONS" \ + http://closure-compiler.appspot.com/compile \ + > jquery.qrcode.min.js homepage_build: pandoc -A ~/.pandoc.header.html -s README.md -o index.html @@ -20,17 +25,8 @@ homepage_build: # deploy # ################################################################################# -deploy: build deployGhPage - -deployGhPage: - rm -rf /tmp/$(PROJECT_NAME)GhPages - (cd /tmp && git clone git@github.com:jeromeetienne/$(PROJECT_NAME).git $(PROJECT_NAME)GhPages) - (cd /tmp/$(PROJECT_NAME)GhPages && git checkout gh-pages || true ) - (cd /tmp/$(PROJECT_NAME)GhPages && git push origin :gh-pages || true ) - (cd /tmp/$(PROJECT_NAME)GhPages && git symbolic-ref HEAD refs/heads/gh-pages) - (cd /tmp/$(PROJECT_NAME)GhPages && rm .git/index) - (cd /tmp/$(PROJECT_NAME)GhPages && git clean -fdx) - cp -a examples src Makefile *.* /tmp/$(PROJECT_NAME)GhPages - (cd /tmp/$(PROJECT_NAME)GhPages && git add . && git commit -a -m "Another deployement" || true ) - (cd /tmp/$(PROJECT_NAME)GhPages && git add . && git push origin gh-pages) - #rm -rf /tmp/$(PROJECT_NAME)GhPages \ No newline at end of file +deploy: + # assume there is something to commit + # use "git diff --exit-code HEAD" to know if there is something to commit + # so two lines: one if no commit, one if something to commit + git commit -a -m "New deploy" && git push -f origin HEAD:gh-pages && git reset HEAD~ \ No newline at end of file diff --git a/jquery.qrcode.min.js b/jquery.qrcode.min.js index 81c1607..38d4d00 100644 --- a/jquery.qrcode.min.js +++ b/jquery.qrcode.min.js @@ -1,29 +1,27 @@ -(function(u){u.fn.qrcode=function(l){function x(a){this.mode=o.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=j.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=j.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 k=false;if(f>>e&1)==1;if(j.getMask(c,b,h-g))k=!k;this.modules[b][h- -g]=k;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 w,e=0;ea*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?k.get(r):0}}for(i=g=0;i=0;)c^=j.G15<=0;)c^=j.G18<>>=1}return c}, -getPatternPosition:function(a){return j.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 m.EXP_TABLE[a]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},n=0;n<8;n++)m.EXP_TABLE[n]=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 l==="string")l={text:l};l=u.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,correctLevel:v.H},l);return this.each(function(){var a;if(l.render=="canvas"){a=new p(l.typeNumber,l.correctLevel);a.addData(l.text);a.make();var c=document.createElement("canvas");c.width=l.width;c.height=l.height;for(var d=c.getContext("2d"),b=l.width/a.getModuleCount(),e=l.height/a.getModuleCount(),f=0;f").css("width",l.width+"px").css("height",l.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color","#ffffff");d=100/a.getModuleCount();b=100/a.getModuleCount();for(e=0;e").css("height",b+"%").appendTo(c);for(h=0;h").css("width",d+"%").css("background-color", -a.isDark(e,h)?"#000000":"#ffffff").appendTo(f)}a=c}jQuery(a).appendTo(this)})}})(jQuery); +(function(r){r.fn.qrcode=function(h){var s;function u(a){this.mode=s;this.data=a}function o(a,c){this.typeNumber=a;this.errorCorrectLevel=c;this.modules=null;this.moduleCount=0;this.dataCache=null;this.dataList=[]}function q(a,c){if(void 0==a.length)throw Error(a.length+"/"+c);for(var d=0;da||this.moduleCount<=a||0>c||this.moduleCount<=c)throw Error(a+","+c);return this.modules[a][c]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){for(var a=1,a=1;40>a;a++){for(var c=p.getRSBlocks(a,this.errorCorrectLevel),d=new t,b=0,e=0;e=d;d++)if(!(-1>=a+d||this.moduleCount<=a+d))for(var b=-1;7>=b;b++)-1>=c+b||this.moduleCount<=c+b||(this.modules[a+d][c+b]= +0<=d&&6>=d&&(0==b||6==b)||0<=b&&6>=b&&(0==d||6==d)||2<=d&&4>=d&&2<=b&&4>=b?!0:!1)},getBestMaskPattern:function(){for(var a=0,c=0,d=0;8>d;d++){this.makeImpl(!0,d);var b=j.getLostPoint(this);if(0==d||a>b)a=b,c=d}return c},createMovieClip:function(a,c,d){a=a.createEmptyMovieClip(c,d);this.make();for(c=0;c=f;f++)for(var i=-2;2>=i;i++)this.modules[b+f][e+i]=-2==f||2==f||-2==i||2==i||0==f&&0==i?!0:!1}},setupTypeNumber:function(a){for(var c= +j.getBCHTypeNumber(this.typeNumber),d=0;18>d;d++){var b=!a&&1==(c>>d&1);this.modules[Math.floor(d/3)][d%3+this.moduleCount-8-3]=b}for(d=0;18>d;d++)b=!a&&1==(c>>d&1),this.modules[d%3+this.moduleCount-8-3][Math.floor(d/3)]=b},setupTypeInfo:function(a,c){for(var d=j.getBCHTypeInfo(this.errorCorrectLevel<<3|c),b=0;15>b;b++){var e=!a&&1==(d>>b&1);6>b?this.modules[b][8]=e:8>b?this.modules[b+1][8]=e:this.modules[this.moduleCount-15+b][8]=e}for(b=0;15>b;b++)e=!a&&1==(d>>b&1),8>b?this.modules[8][this.moduleCount- +b-1]=e:9>b?this.modules[8][15-b-1+1]=e: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,i=this.moduleCount-1;0g;g++)if(null==this.modules[b][i-g]){var n=!1;f>>e&1));j.getMask(c,b,i-g)&&(n=!n);this.modules[b][i-g]=n;e--; -1==e&&(f++,e=7)}b+=d;if(0>b||this.moduleCount<=b){b-=d;d=-d;break}}}};o.PAD0=236;o.PAD1=17;o.createData=function(a,c,d){for(var c=p.getRSBlocks(a, +c),b=new t,e=0;e8*a)throw Error("code length overflow. ("+b.getLengthInBits()+">"+8*a+")");for(b.getLengthInBits()+4<=8*a&&b.put(0,4);0!=b.getLengthInBits()%8;)b.putBit(!1);for(;!(b.getLengthInBits()>=8*a);){b.put(o.PAD0,8);if(b.getLengthInBits()>=8*a)break;b.put(o.PAD1,8)}return o.createBytes(b,c)};o.createBytes=function(a,c){for(var d= +0,b=0,e=0,f=Array(c.length),i=Array(c.length),g=0;g>>=1;return c},getPatternPosition:function(a){return j.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,c,d){switch(a){case 0:return 0==(c+d)%2;case 1:return 0==c%2;case 2:return 0==d%3;case 3:return 0==(c+d)%3;case 4:return 0==(Math.floor(c/2)+Math.floor(d/3))%2;case 5:return 0==c*d%2+c*d%3;case 6:return 0==(c*d%2+c*d%3)%2;case 7:return 0==(c*d%3+(c+d)%2)%2;default:throw Error("bad maskPattern:"+ +a);}},getErrorCorrectPolynomial:function(a){for(var c=new q([1],0),d=0;dc)switch(a){case 1:return 10;case 2:return 9;case s:return 8;case 8:return 8;default:throw Error("mode:"+a);}else if(27>c)switch(a){case 1:return 12;case 2:return 11;case s:return 16;case 8:return 10;default:throw Error("mode:"+a);}else if(41>c)switch(a){case 1:return 14;case 2:return 13;case s:return 16;case 8:return 12;default:throw Error("mode:"+ +a);}else throw Error("type:"+c);},getLostPoint:function(a){for(var c=a.getModuleCount(),d=0,b=0;b=g;g++)if(!(0>b+g||c<=b+g))for(var h=-1;1>=h;h++)0>e+h||c<=e+h||0==g&&0==h||i==a.isDark(b+g,e+h)&&f++;5a)throw Error("glog("+a+")");return l.LOG_TABLE[a]},gexp:function(a){for(;0>a;)a+=255;for(;256<=a;)a-=255;return l.EXP_TABLE[a]},EXP_TABLE:Array(256), +LOG_TABLE:Array(256)},m=0;8>m;m++)l.EXP_TABLE[m]=1<m;m++)l.EXP_TABLE[m]=l.EXP_TABLE[m-4]^l.EXP_TABLE[m-5]^l.EXP_TABLE[m-6]^l.EXP_TABLE[m-8];for(m=0;255>m;m++)l.LOG_TABLE[l.EXP_TABLE[m]]=m;q.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var c=Array(this.getLength()+a.getLength()-1),d=0;d +this.getLength()-a.getLength())return this;for(var c=l.glog(this.get(0))-l.glog(a.get(0)),d=Array(this.getLength()),b=0;b>>7-a%8&1)},put:function(a,c){for(var d=0;d>>c-d-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);a&&(this.buffer[c]|=128>>>this.length%8);this.length++}};"string"===typeof h&&(h={text:h});h=r.extend({},{render:"canvas",width:256,height:256,typeNumber:-1, +correctLevel:2},h);return this.each(function(){var a;if("canvas"==h.render){a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();var c=document.createElement("canvas");c.width=h.width;c.height=h.height;for(var d=c.getContext("2d"),b=h.width/a.getModuleCount(),e=h.height/a.getModuleCount(),f=0;f").css("width",h.width+"px").css("height",h.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color","#ffffff");d=h.width/a.getModuleCount();b=h.height/a.getModuleCount();for(e=0;e").css("height",b+"px").appendTo(c);for(i=0;i").css("width",d+"px").css("background-color",a.isDark(e,i)?"#000000":"#ffffff").appendTo(f)}}a=c;jQuery(a).appendTo(this)})}})(jQuery);