1653 lines
78 KiB
JavaScript
1653 lines
78 KiB
JavaScript
// Source: public/lib/momentjs/min/moment.min.js
|
|
//! moment.js
|
|
//! version : 2.5.1
|
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
|
//! license : MIT
|
|
//! momentjs.com
|
|
(function(a){function b(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function c(a,b){return function(c){return k(a.call(this,c),b)}}function d(a,b){return function(c){return this.lang().ordinal(a.call(this,c),b)}}function e(){}function f(a){w(a),h(this,a)}function g(a){var b=q(a),c=b.year||0,d=b.month||0,e=b.week||0,f=b.day||0,g=b.hour||0,h=b.minute||0,i=b.second||0,j=b.millisecond||0;this._milliseconds=+j+1e3*i+6e4*h+36e5*g,this._days=+f+7*e,this._months=+d+12*c,this._data={},this._bubble()}function h(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return b.hasOwnProperty("toString")&&(a.toString=b.toString),b.hasOwnProperty("valueOf")&&(a.valueOf=b.valueOf),a}function i(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&qb.hasOwnProperty(b)&&(c[b]=a[b]);return c}function j(a){return 0>a?Math.ceil(a):Math.floor(a)}function k(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.length<b;)d="0"+d;return(e?c?"+":"":"-")+d}function l(a,b,c,d){var e,f,g=b._milliseconds,h=b._days,i=b._months;g&&a._d.setTime(+a._d+g*c),(h||i)&&(e=a.minute(),f=a.hour()),h&&a.date(a.date()+h*c),i&&a.month(a.month()+i*c),g&&!d&&db.updateOffset(a),(h||i)&&(a.minute(e),a.hour(f))}function m(a){return"[object Array]"===Object.prototype.toString.call(a)}function n(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function o(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&s(a[d])!==s(b[d]))&&g++;return g+f}function p(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=Tb[a]||Ub[b]||b}return a}function q(a){var b,c,d={};for(c in a)a.hasOwnProperty(c)&&(b=p(c),b&&(d[b]=a[c]));return d}function r(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}db[b]=function(e,f){var g,h,i=db.fn._lang[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=db().utc().set(d,a);return i.call(db.fn._lang,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function s(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function t(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function u(a){return v(a)?366:365}function v(a){return a%4===0&&a%100!==0||a%400===0}function w(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[jb]<0||a._a[jb]>11?jb:a._a[kb]<1||a._a[kb]>t(a._a[ib],a._a[jb])?kb:a._a[lb]<0||a._a[lb]>23?lb:a._a[mb]<0||a._a[mb]>59?mb:a._a[nb]<0||a._a[nb]>59?nb:a._a[ob]<0||a._a[ob]>999?ob:-1,a._pf._overflowDayOfYear&&(ib>b||b>kb)&&(b=kb),a._pf.overflow=b)}function x(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!a._pf.empty&&!a._pf.invalidMonth&&!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length)),a._isValid}function y(a){return a?a.toLowerCase().replace("_","-"):a}function z(a,b){return b._isUTC?db(a).zone(b._offset||0):db(a).local()}function A(a,b){return b.abbr=a,pb[a]||(pb[a]=new e),pb[a].set(b),pb[a]}function B(a){delete pb[a]}function C(a){var b,c,d,e,f=0,g=function(a){if(!pb[a]&&rb)try{require("./lang/"+a)}catch(b){}return pb[a]};if(!a)return db.fn._lang;if(!m(a)){if(c=g(a))return c;a=[a]}for(;f<a.length;){for(e=y(a[f]).split("-"),b=e.length,d=y(a[f+1]),d=d?d.split("-"):null;b>0;){if(c=g(e.slice(0,b).join("-")))return c;if(d&&d.length>=b&&o(e,d,!0)>=b-1)break;b--}f++}return db.fn._lang}function D(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function E(a){var b,c,d=a.match(vb);for(b=0,c=d.length;c>b;b++)d[b]=Yb[d[b]]?Yb[d[b]]:D(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function F(a,b){return a.isValid()?(b=G(b,a.lang()),Vb[b]||(Vb[b]=E(b)),Vb[b](a)):a.lang().invalidDate()}function G(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(wb.lastIndex=0;d>=0&&wb.test(a);)a=a.replace(wb,c),wb.lastIndex=0,d-=1;return a}function H(a,b){var c,d=b._strict;switch(a){case"DDDD":return Ib;case"YYYY":case"GGGG":case"gggg":return d?Jb:zb;case"Y":case"G":case"g":return Lb;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return d?Kb:Ab;case"S":if(d)return Gb;case"SS":if(d)return Hb;case"SSS":if(d)return Ib;case"DDD":return yb;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Cb;case"a":case"A":return C(b._l)._meridiemParse;case"X":return Fb;case"Z":case"ZZ":return Db;case"T":return Eb;case"SSSS":return Bb;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return d?Hb:xb;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return xb;default:return c=new RegExp(P(O(a.replace("\\","")),"i"))}}function I(a){a=a||"";var b=a.match(Db)||[],c=b[b.length-1]||[],d=(c+"").match(Qb)||["-",0,0],e=+(60*d[1])+s(d[2]);return"+"===d[0]?-e:e}function J(a,b,c){var d,e=c._a;switch(a){case"M":case"MM":null!=b&&(e[jb]=s(b)-1);break;case"MMM":case"MMMM":d=C(c._l).monthsParse(b),null!=d?e[jb]=d:c._pf.invalidMonth=b;break;case"D":case"DD":null!=b&&(e[kb]=s(b));break;case"DDD":case"DDDD":null!=b&&(c._dayOfYear=s(b));break;case"YY":e[ib]=s(b)+(s(b)>68?1900:2e3);break;case"YYYY":case"YYYYY":case"YYYYYY":e[ib]=s(b);break;case"a":case"A":c._isPm=C(c._l).isPM(b);break;case"H":case"HH":case"h":case"hh":e[lb]=s(b);break;case"m":case"mm":e[mb]=s(b);break;case"s":case"ss":e[nb]=s(b);break;case"S":case"SS":case"SSS":case"SSSS":e[ob]=s(1e3*("0."+b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,c._tzm=I(b);break;case"w":case"ww":case"W":case"WW":case"d":case"dd":case"ddd":case"dddd":case"e":case"E":a=a.substr(0,1);case"gg":case"gggg":case"GG":case"GGGG":case"GGGGG":a=a.substr(0,2),b&&(c._w=c._w||{},c._w[a]=b)}}function K(a){var b,c,d,e,f,g,h,i,j,k,l=[];if(!a._d){for(d=M(a),a._w&&null==a._a[kb]&&null==a._a[jb]&&(f=function(b){var c=parseInt(b,10);return b?b.length<3?c>68?1900+c:2e3+c:c:null==a._a[ib]?db().weekYear():a._a[ib]},g=a._w,null!=g.GG||null!=g.W||null!=g.E?h=Z(f(g.GG),g.W||1,g.E,4,1):(i=C(a._l),j=null!=g.d?V(g.d,i):null!=g.e?parseInt(g.e,10)+i._week.dow:0,k=parseInt(g.w,10)||1,null!=g.d&&j<i._week.dow&&k++,h=Z(f(g.gg),k,j,i._week.doy,i._week.dow)),a._a[ib]=h.year,a._dayOfYear=h.dayOfYear),a._dayOfYear&&(e=null==a._a[ib]?d[ib]:a._a[ib],a._dayOfYear>u(e)&&(a._pf._overflowDayOfYear=!0),c=U(e,0,a._dayOfYear),a._a[jb]=c.getUTCMonth(),a._a[kb]=c.getUTCDate()),b=0;3>b&&null==a._a[b];++b)a._a[b]=l[b]=d[b];for(;7>b;b++)a._a[b]=l[b]=null==a._a[b]?2===b?1:0:a._a[b];l[lb]+=s((a._tzm||0)/60),l[mb]+=s((a._tzm||0)%60),a._d=(a._useUTC?U:T).apply(null,l)}}function L(a){var b;a._d||(b=q(a._i),a._a=[b.year,b.month,b.day,b.hour,b.minute,b.second,b.millisecond],K(a))}function M(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function N(a){a._a=[],a._pf.empty=!0;var b,c,d,e,f,g=C(a._l),h=""+a._i,i=h.length,j=0;for(d=G(a._f,g).match(vb)||[],b=0;b<d.length;b++)e=d[b],c=(h.match(H(e,a))||[])[0],c&&(f=h.substr(0,h.indexOf(c)),f.length>0&&a._pf.unusedInput.push(f),h=h.slice(h.indexOf(c)+c.length),j+=c.length),Yb[e]?(c?a._pf.empty=!1:a._pf.unusedTokens.push(e),J(e,c,a)):a._strict&&!c&&a._pf.unusedTokens.push(e);a._pf.charsLeftOver=i-j,h.length>0&&a._pf.unusedInput.push(h),a._isPm&&a._a[lb]<12&&(a._a[lb]+=12),a._isPm===!1&&12===a._a[lb]&&(a._a[lb]=0),K(a),w(a)}function O(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e})}function P(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Q(a){var c,d,e,f,g;if(0===a._f.length)return a._pf.invalidFormat=!0,a._d=new Date(0/0),void 0;for(f=0;f<a._f.length;f++)g=0,c=h({},a),c._pf=b(),c._f=a._f[f],N(c),x(c)&&(g+=c._pf.charsLeftOver,g+=10*c._pf.unusedTokens.length,c._pf.score=g,(null==e||e>g)&&(e=g,d=c));h(a,d||c)}function R(a){var b,c,d=a._i,e=Mb.exec(d);if(e){for(a._pf.iso=!0,b=0,c=Ob.length;c>b;b++)if(Ob[b][1].exec(d)){a._f=Ob[b][0]+(e[6]||" ");break}for(b=0,c=Pb.length;c>b;b++)if(Pb[b][1].exec(d)){a._f+=Pb[b][0];break}d.match(Db)&&(a._f+="Z"),N(a)}else a._d=new Date(d)}function S(b){var c=b._i,d=sb.exec(c);c===a?b._d=new Date:d?b._d=new Date(+d[1]):"string"==typeof c?R(b):m(c)?(b._a=c.slice(0),K(b)):n(c)?b._d=new Date(+c):"object"==typeof c?L(b):b._d=new Date(c)}function T(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function U(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function V(a,b){if("string"==typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!=typeof a)return null}else a=parseInt(a,10);return a}function W(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function X(a,b,c){var d=hb(Math.abs(a)/1e3),e=hb(d/60),f=hb(e/60),g=hb(f/24),h=hb(g/365),i=45>d&&["s",d]||1===e&&["m"]||45>e&&["mm",e]||1===f&&["h"]||22>f&&["hh",f]||1===g&&["d"]||25>=g&&["dd",g]||45>=g&&["M"]||345>g&&["MM",hb(g/30)]||1===h&&["y"]||["yy",h];return i[2]=b,i[3]=a>0,i[4]=c,W.apply({},i)}function Y(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=db(a).add("d",f),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function Z(a,b,c,d,e){var f,g,h=U(a,0,1).getUTCDay();return c=null!=c?c:e,f=e-h+(h>d?7:0)-(e>h?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:u(a-1)+g}}function $(a){var b=a._i,c=a._f;return null===b?db.invalid({nullInput:!0}):("string"==typeof b&&(a._i=b=C().preparse(b)),db.isMoment(b)?(a=i(b),a._d=new Date(+b._d)):c?m(c)?Q(a):N(a):S(a),new f(a))}function _(a,b){db.fn[a]=db.fn[a+"s"]=function(a){var c=this._isUTC?"UTC":"";return null!=a?(this._d["set"+c+b](a),db.updateOffset(this),this):this._d["get"+c+b]()}}function ab(a){db.duration.fn[a]=function(){return this._data[a]}}function bb(a,b){db.duration.fn["as"+a]=function(){return+this/b}}function cb(a){var b=!1,c=db;"undefined"==typeof ender&&(a?(gb.moment=function(){return!b&&console&&console.warn&&(b=!0,console.warn("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.")),c.apply(null,arguments)},h(gb.moment,c)):gb.moment=db)}for(var db,eb,fb="2.5.1",gb=this,hb=Math.round,ib=0,jb=1,kb=2,lb=3,mb=4,nb=5,ob=6,pb={},qb={_isAMomentObject:null,_i:null,_f:null,_l:null,_strict:null,_isUTC:null,_offset:null,_pf:null,_lang:null},rb="undefined"!=typeof module&&module.exports&&"undefined"!=typeof require,sb=/^\/?Date\((\-?\d+)/i,tb=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,ub=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,vb=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,wb=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,xb=/\d\d?/,yb=/\d{1,3}/,zb=/\d{1,4}/,Ab=/[+\-]?\d{1,6}/,Bb=/\d+/,Cb=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Db=/Z|[\+\-]\d\d:?\d\d/gi,Eb=/T/i,Fb=/[\+\-]?\d+(\.\d{1,3})?/,Gb=/\d/,Hb=/\d\d/,Ib=/\d{3}/,Jb=/\d{4}/,Kb=/[+-]?\d{6}/,Lb=/[+-]?\d+/,Mb=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Nb="YYYY-MM-DDTHH:mm:ssZ",Ob=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],Pb=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],Qb=/([\+\-]|\d\d)/gi,Rb="Date|Hours|Minutes|Seconds|Milliseconds".split("|"),Sb={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},Tb={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},Ub={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},Vb={},Wb="DDD w W M D d".split(" "),Xb="M D H h m s w W".split(" "),Yb={M:function(){return this.month()+1},MMM:function(a){return this.lang().monthsShort(this,a)},MMMM:function(a){return this.lang().months(this,a)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(a){return this.lang().weekdaysMin(this,a)},ddd:function(a){return this.lang().weekdaysShort(this,a)},dddd:function(a){return this.lang().weekdays(this,a)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return k(this.year()%100,2)},YYYY:function(){return k(this.year(),4)},YYYYY:function(){return k(this.year(),5)},YYYYYY:function(){var a=this.year(),b=a>=0?"+":"-";return b+k(Math.abs(a),6)},gg:function(){return k(this.weekYear()%100,2)},gggg:function(){return k(this.weekYear(),4)},ggggg:function(){return k(this.weekYear(),5)},GG:function(){return k(this.isoWeekYear()%100,2)},GGGG:function(){return k(this.isoWeekYear(),4)},GGGGG:function(){return k(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return s(this.milliseconds()/100)},SS:function(){return k(s(this.milliseconds()/10),2)},SSS:function(){return k(this.milliseconds(),3)},SSSS:function(){return k(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+k(s(a/60),2)+":"+k(s(a)%60,2)},ZZ:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+k(s(a/60),2)+k(s(a)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},Zb=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];Wb.length;)eb=Wb.pop(),Yb[eb+"o"]=d(Yb[eb],eb);for(;Xb.length;)eb=Xb.pop(),Yb[eb+eb]=c(Yb[eb],2);for(Yb.DDDD=c(Yb.DDD,3),h(e.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(a){return this._months[a.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a){var b,c,d;for(this._monthsParse||(this._monthsParse=[]),b=0;12>b;b++)if(this._monthsParse[b]||(c=db.utc([2e3,b]),d="^"+this.months(c,"")+"|^"+this.monthsShort(c,""),this._monthsParse[b]=new RegExp(d.replace(".",""),"i")),this._monthsParse[b].test(a))return b},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c,d;for(this._weekdaysParse||(this._weekdaysParse=[]),b=0;7>b;b++)if(this._weekdaysParse[b]||(c=db([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(a,b){var c=this._calendar[a];return"function"==typeof c?c.apply(b):c},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",preparse:function(a){return a},postformat:function(a){return a},week:function(a){return Y(a,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),db=function(c,d,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._i=c,g._f=d,g._l=e,g._strict=f,g._isUTC=!1,g._pf=b(),$(g)},db.utc=function(c,d,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._useUTC=!0,g._isUTC=!0,g._l=e,g._i=c,g._f=d,g._strict=f,g._pf=b(),$(g).utc()},db.unix=function(a){return db(1e3*a)},db.duration=function(a,b){var c,d,e,f=a,h=null;return db.isDuration(a)?f={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(f={},b?f[b]=a:f.milliseconds=a):(h=tb.exec(a))?(c="-"===h[1]?-1:1,f={y:0,d:s(h[kb])*c,h:s(h[lb])*c,m:s(h[mb])*c,s:s(h[nb])*c,ms:s(h[ob])*c}):(h=ub.exec(a))&&(c="-"===h[1]?-1:1,e=function(a){var b=a&&parseFloat(a.replace(",","."));return(isNaN(b)?0:b)*c},f={y:e(h[2]),M:e(h[3]),d:e(h[4]),h:e(h[5]),m:e(h[6]),s:e(h[7]),w:e(h[8])}),d=new g(f),db.isDuration(a)&&a.hasOwnProperty("_lang")&&(d._lang=a._lang),d},db.version=fb,db.defaultFormat=Nb,db.updateOffset=function(){},db.lang=function(a,b){var c;return a?(b?A(y(a),b):null===b?(B(a),a="en"):pb[a]||C(a),c=db.duration.fn._lang=db.fn._lang=C(a),c._abbr):db.fn._lang._abbr},db.langData=function(a){return a&&a._lang&&a._lang._abbr&&(a=a._lang._abbr),C(a)},db.isMoment=function(a){return a instanceof f||null!=a&&a.hasOwnProperty("_isAMomentObject")},db.isDuration=function(a){return a instanceof g},eb=Zb.length-1;eb>=0;--eb)r(Zb[eb]);for(db.normalizeUnits=function(a){return p(a)},db.invalid=function(a){var b=db.utc(0/0);return null!=a?h(b._pf,a):b._pf.userInvalidated=!0,b},db.parseZone=function(a){return db(a).parseZone()},h(db.fn=f.prototype,{clone:function(){return db(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().lang("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var a=db(this).utc();return 0<a.year()&&a.year()<=9999?F(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):F(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds()]},isValid:function(){return x(this)},isDSTShifted:function(){return this._a?this.isValid()&&o(this._a,(this._isUTC?db.utc(this._a):db(this._a)).toArray())>0:!1},parsingFlags:function(){return h({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(a){var b=F(this,a||db.defaultFormat);return this.lang().postformat(b)},add:function(a,b){var c;return c="string"==typeof a?db.duration(+b,a):db.duration(a,b),l(this,c,1),this},subtract:function(a,b){var c;return c="string"==typeof a?db.duration(+b,a):db.duration(a,b),l(this,c,-1),this},diff:function(a,b,c){var d,e,f=z(a,this),g=6e4*(this.zone()-f.zone());return b=p(b),"year"===b||"month"===b?(d=432e5*(this.daysInMonth()+f.daysInMonth()),e=12*(this.year()-f.year())+(this.month()-f.month()),e+=(this-db(this).startOf("month")-(f-db(f).startOf("month")))/d,e-=6e4*(this.zone()-db(this).startOf("month").zone()-(f.zone()-db(f).startOf("month").zone()))/d,"year"===b&&(e/=12)):(d=this-f,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-g)/864e5:"week"===b?(d-g)/6048e5:d),c?e:j(e)},from:function(a,b){return db.duration(this.diff(a)).lang(this.lang()._abbr).humanize(!b)},fromNow:function(a){return this.from(db(),a)},calendar:function(){var a=z(db(),this).startOf("day"),b=this.diff(a,"days",!0),c=-6>b?"sameElse":-1>b?"lastWeek":0>b?"lastDay":1>b?"sameDay":2>b?"nextDay":7>b?"nextWeek":"sameElse";return this.format(this.lang().calendar(c,this))},isLeapYear:function(){return v(this.year())},isDST:function(){return this.zone()<this.clone().month(0).zone()||this.zone()<this.clone().month(5).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=V(a,this.lang()),this.add({d:a-b})):b},month:function(a){var b,c=this._isUTC?"UTC":"";return null!=a?"string"==typeof a&&(a=this.lang().monthsParse(a),"number"!=typeof a)?this:(b=this.date(),this.date(1),this._d["set"+c+"Month"](a),this.date(Math.min(b,this.daysInMonth())),db.updateOffset(this),this):this._d["get"+c+"Month"]()},startOf:function(a){switch(a=p(a)){case"year":this.month(0);case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===a?this.weekday(0):"isoWeek"===a&&this.isoWeekday(1),this},endOf:function(a){return a=p(a),this.startOf(a).add("isoWeek"===a?"week":a,1).subtract("ms",1)},isAfter:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)>+db(a).startOf(b)},isBefore:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)<+db(a).startOf(b)},isSame:function(a,b){return b=b||"ms",+this.clone().startOf(b)===+z(a,this).startOf(b)},min:function(a){return a=db.apply(null,arguments),this>a?this:a},max:function(a){return a=db.apply(null,arguments),a>this?this:a},zone:function(a){var b=this._offset||0;return null==a?this._isUTC?b:this._d.getTimezoneOffset():("string"==typeof a&&(a=I(a)),Math.abs(a)<16&&(a=60*a),this._offset=a,this._isUTC=!0,b!==a&&l(this,db.duration(b-a,"m"),1,!0),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(a){return a=a?db(a).zone():0,(this.zone()-a)%60===0},daysInMonth:function(){return t(this.year(),this.month())},dayOfYear:function(a){var b=hb((db(this).startOf("day")-db(this).startOf("year"))/864e5)+1;return null==a?b:this.add("d",a-b)},quarter:function(){return Math.ceil((this.month()+1)/3)},weekYear:function(a){var b=Y(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==a?b:this.add("y",a-b)},isoWeekYear:function(a){var b=Y(this,1,4).year;return null==a?b:this.add("y",a-b)},week:function(a){var b=this.lang().week(this);return null==a?b:this.add("d",7*(a-b))},isoWeek:function(a){var b=Y(this,1,4).week;return null==a?b:this.add("d",7*(a-b))},weekday:function(a){var b=(this.day()+7-this.lang()._week.dow)%7;return null==a?b:this.add("d",a-b)},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},get:function(a){return a=p(a),this[a]()},set:function(a,b){return a=p(a),"function"==typeof this[a]&&this[a](b),this},lang:function(b){return b===a?this._lang:(this._lang=C(b),this)}}),eb=0;eb<Rb.length;eb++)_(Rb[eb].toLowerCase().replace(/s$/,""),Rb[eb]);_("year","FullYear"),db.fn.days=db.fn.day,db.fn.months=db.fn.month,db.fn.weeks=db.fn.week,db.fn.isoWeeks=db.fn.isoWeek,db.fn.toJSON=db.fn.toISOString,h(db.duration.fn=g.prototype,{_bubble:function(){var a,b,c,d,e=this._milliseconds,f=this._days,g=this._months,h=this._data;h.milliseconds=e%1e3,a=j(e/1e3),h.seconds=a%60,b=j(a/60),h.minutes=b%60,c=j(b/60),h.hours=c%24,f+=j(c/24),h.days=f%30,g+=j(f/30),h.months=g%12,d=j(g/12),h.years=d},weeks:function(){return j(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*s(this._months/12)},humanize:function(a){var b=+this,c=X(b,!a,this.lang());return a&&(c=this.lang().pastFuture(b,c)),this.lang().postformat(c)},add:function(a,b){var c=db.duration(a,b);return this._milliseconds+=c._milliseconds,this._days+=c._days,this._months+=c._months,this._bubble(),this},subtract:function(a,b){var c=db.duration(a,b);return this._milliseconds-=c._milliseconds,this._days-=c._days,this._months-=c._months,this._bubble(),this},get:function(a){return a=p(a),this[a.toLowerCase()+"s"]()},as:function(a){return a=p(a),this["as"+a.charAt(0).toUpperCase()+a.slice(1)+"s"]()},lang:db.fn.lang,toIsoString:function(){var a=Math.abs(this.years()),b=Math.abs(this.months()),c=Math.abs(this.days()),d=Math.abs(this.hours()),e=Math.abs(this.minutes()),f=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||f?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(f?f+"S":""):"P0D"}});for(eb in Sb)Sb.hasOwnProperty(eb)&&(bb(eb,Sb[eb]),ab(eb.toLowerCase()));bb("Weeks",6048e5),db.duration.fn.asMonths=function(){return(+this-31536e6*this.years())/2592e6+12*this.years()},db.lang("en",{ordinal:function(a){var b=a%10,c=1===s(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),rb?(module.exports=db,cb(!0)):"function"==typeof define&&define.amd?define("moment",function(b,c,d){return d.config&&d.config()&&d.config().noGlobal!==!0&&cb(d.config().noGlobal===a),db}):cb()}).call(this);
|
|
// Source: public/lib/qrcode-generator/js/qrcode.js
|
|
//---------------------------------------------------------------------
|
|
//
|
|
// QR Code Generator for JavaScript
|
|
//
|
|
// Copyright (c) 2009 Kazuhiko Arase
|
|
//
|
|
// URL: http://www.d-project.com/
|
|
//
|
|
// Licensed under the MIT license:
|
|
// http://www.opensource.org/licenses/mit-license.php
|
|
//
|
|
// The word 'QR Code' is registered trademark of
|
|
// DENSO WAVE INCORPORATED
|
|
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
|
//
|
|
//---------------------------------------------------------------------
|
|
|
|
var qrcode = function() {
|
|
|
|
//---------------------------------------------------------------------
|
|
// qrcode
|
|
//---------------------------------------------------------------------
|
|
|
|
/**
|
|
* qrcode
|
|
* @param typeNumber 1 to 10
|
|
* @param errorCorrectLevel 'L','M','Q','H'
|
|
*/
|
|
var qrcode = function(typeNumber, errorCorrectLevel) {
|
|
|
|
var PAD0 = 0xEC;
|
|
var PAD1 = 0x11;
|
|
|
|
var _typeNumber = typeNumber;
|
|
var _errorCorrectLevel = QRErrorCorrectLevel[errorCorrectLevel];
|
|
var _modules = null;
|
|
var _moduleCount = 0;
|
|
var _dataCache = null;
|
|
var _dataList = new Array();
|
|
|
|
var _this = {};
|
|
|
|
var makeImpl = function(test, maskPattern) {
|
|
|
|
_moduleCount = _typeNumber * 4 + 17;
|
|
_modules = function(moduleCount) {
|
|
var modules = new Array(moduleCount);
|
|
for (var row = 0; row < moduleCount; row += 1) {
|
|
modules[row] = new Array(moduleCount);
|
|
for (var col = 0; col < moduleCount; col += 1) {
|
|
modules[row][col] = null;
|
|
}
|
|
}
|
|
return modules;
|
|
}(_moduleCount);
|
|
|
|
setupPositionProbePattern(0, 0);
|
|
setupPositionProbePattern(_moduleCount - 7, 0);
|
|
setupPositionProbePattern(0, _moduleCount - 7);
|
|
setupPositionAdjustPattern();
|
|
setupTimingPattern();
|
|
setupTypeInfo(test, maskPattern);
|
|
|
|
if (_typeNumber >= 7) {
|
|
setupTypeNumber(test);
|
|
}
|
|
|
|
if (_dataCache == null) {
|
|
_dataCache = createData(_typeNumber, _errorCorrectLevel, _dataList);
|
|
}
|
|
|
|
mapData(_dataCache, maskPattern);
|
|
};
|
|
|
|
var setupPositionProbePattern = function(row, col) {
|
|
|
|
for (var r = -1; r <= 7; r += 1) {
|
|
|
|
if (row + r <= -1 || _moduleCount <= row + r) continue;
|
|
|
|
for (var c = -1; c <= 7; c += 1) {
|
|
|
|
if (col + c <= -1 || _moduleCount <= col + c) continue;
|
|
|
|
if ( (0 <= r && r <= 6 && (c == 0 || c == 6) )
|
|
|| (0 <= c && c <= 6 && (r == 0 || r == 6) )
|
|
|| (2 <= r && r <= 4 && 2 <= c && c <= 4) ) {
|
|
_modules[row + r][col + c] = true;
|
|
} else {
|
|
_modules[row + r][col + c] = false;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var getBestMaskPattern = function() {
|
|
|
|
var minLostPoint = 0;
|
|
var pattern = 0;
|
|
|
|
for (var i = 0; i < 8; i += 1) {
|
|
|
|
makeImpl(true, i);
|
|
|
|
var lostPoint = QRUtil.getLostPoint(_this);
|
|
|
|
if (i == 0 || minLostPoint > lostPoint) {
|
|
minLostPoint = lostPoint;
|
|
pattern = i;
|
|
}
|
|
}
|
|
|
|
return pattern;
|
|
};
|
|
|
|
var setupTimingPattern = function() {
|
|
|
|
for (var r = 8; r < _moduleCount - 8; r += 1) {
|
|
if (_modules[r][6] != null) {
|
|
continue;
|
|
}
|
|
_modules[r][6] = (r % 2 == 0);
|
|
}
|
|
|
|
for (var c = 8; c < _moduleCount - 8; c += 1) {
|
|
if (_modules[6][c] != null) {
|
|
continue;
|
|
}
|
|
_modules[6][c] = (c % 2 == 0);
|
|
}
|
|
};
|
|
|
|
var setupPositionAdjustPattern = function() {
|
|
|
|
var pos = QRUtil.getPatternPosition(_typeNumber);
|
|
|
|
for (var i = 0; i < pos.length; i += 1) {
|
|
|
|
for (var j = 0; j < pos.length; j += 1) {
|
|
|
|
var row = pos[i];
|
|
var col = pos[j];
|
|
|
|
if (_modules[row][col] != null) {
|
|
continue;
|
|
}
|
|
|
|
for (var r = -2; r <= 2; r += 1) {
|
|
|
|
for (var c = -2; c <= 2; c += 1) {
|
|
|
|
if (r == -2 || r == 2 || c == -2 || c == 2
|
|
|| (r == 0 && c == 0) ) {
|
|
_modules[row + r][col + c] = true;
|
|
} else {
|
|
_modules[row + r][col + c] = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var setupTypeNumber = function(test) {
|
|
|
|
var bits = QRUtil.getBCHTypeNumber(_typeNumber);
|
|
|
|
for (var i = 0; i < 18; i += 1) {
|
|
var mod = (!test && ( (bits >> i) & 1) == 1);
|
|
_modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;
|
|
}
|
|
|
|
for (var i = 0; i < 18; i += 1) {
|
|
var mod = (!test && ( (bits >> i) & 1) == 1);
|
|
_modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
|
|
}
|
|
};
|
|
|
|
var setupTypeInfo = function(test, maskPattern) {
|
|
|
|
var data = (_errorCorrectLevel << 3) | maskPattern;
|
|
var bits = QRUtil.getBCHTypeInfo(data);
|
|
|
|
// vertical
|
|
for (var i = 0; i < 15; i += 1) {
|
|
|
|
var mod = (!test && ( (bits >> i) & 1) == 1);
|
|
|
|
if (i < 6) {
|
|
_modules[i][8] = mod;
|
|
} else if (i < 8) {
|
|
_modules[i + 1][8] = mod;
|
|
} else {
|
|
_modules[_moduleCount - 15 + i][8] = mod;
|
|
}
|
|
}
|
|
|
|
// horizontal
|
|
for (var i = 0; i < 15; i += 1) {
|
|
|
|
var mod = (!test && ( (bits >> i) & 1) == 1);
|
|
|
|
if (i < 8) {
|
|
_modules[8][_moduleCount - i - 1] = mod;
|
|
} else if (i < 9) {
|
|
_modules[8][15 - i - 1 + 1] = mod;
|
|
} else {
|
|
_modules[8][15 - i - 1] = mod;
|
|
}
|
|
}
|
|
|
|
// fixed module
|
|
_modules[_moduleCount - 8][8] = (!test);
|
|
};
|
|
|
|
var mapData = function(data, maskPattern) {
|
|
|
|
var inc = -1;
|
|
var row = _moduleCount - 1;
|
|
var bitIndex = 7;
|
|
var byteIndex = 0;
|
|
var maskFunc = QRUtil.getMaskFunction(maskPattern);
|
|
|
|
for (var col = _moduleCount - 1; col > 0; col -= 2) {
|
|
|
|
if (col == 6) col -= 1;
|
|
|
|
while (true) {
|
|
|
|
for (var c = 0; c < 2; c += 1) {
|
|
|
|
if (_modules[row][col - c] == null) {
|
|
|
|
var dark = false;
|
|
|
|
if (byteIndex < data.length) {
|
|
dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1);
|
|
}
|
|
|
|
var mask = maskFunc(row, col - c);
|
|
|
|
if (mask) {
|
|
dark = !dark;
|
|
}
|
|
|
|
_modules[row][col - c] = dark;
|
|
bitIndex -= 1;
|
|
|
|
if (bitIndex == -1) {
|
|
byteIndex += 1;
|
|
bitIndex = 7;
|
|
}
|
|
}
|
|
}
|
|
|
|
row += inc;
|
|
|
|
if (row < 0 || _moduleCount <= row) {
|
|
row -= inc;
|
|
inc = -inc;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var createBytes = function(buffer, rsBlocks) {
|
|
|
|
var offset = 0;
|
|
|
|
var maxDcCount = 0;
|
|
var maxEcCount = 0;
|
|
|
|
var dcdata = new Array(rsBlocks.length);
|
|
var ecdata = new Array(rsBlocks.length);
|
|
|
|
for (var r = 0; r < rsBlocks.length; r += 1) {
|
|
|
|
var dcCount = rsBlocks[r].dataCount;
|
|
var ecCount = rsBlocks[r].totalCount - dcCount;
|
|
|
|
maxDcCount = Math.max(maxDcCount, dcCount);
|
|
maxEcCount = Math.max(maxEcCount, ecCount);
|
|
|
|
dcdata[r] = new Array(dcCount);
|
|
|
|
for (var i = 0; i < dcdata[r].length; i += 1) {
|
|
dcdata[r][i] = 0xff & buffer.getBuffer()[i + offset];
|
|
}
|
|
offset += dcCount;
|
|
|
|
var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
|
|
var rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1);
|
|
|
|
var modPoly = rawPoly.mod(rsPoly);
|
|
ecdata[r] = new Array(rsPoly.getLength() - 1);
|
|
for (var i = 0; i < ecdata[r].length; i += 1) {
|
|
var modIndex = i + modPoly.getLength() - ecdata[r].length;
|
|
ecdata[r][i] = (modIndex >= 0)? modPoly.getAt(modIndex) : 0;
|
|
}
|
|
}
|
|
|
|
var totalCodeCount = 0;
|
|
for (var i = 0; i < rsBlocks.length; i += 1) {
|
|
totalCodeCount += rsBlocks[i].totalCount;
|
|
}
|
|
|
|
var data = new Array(totalCodeCount);
|
|
var index = 0;
|
|
|
|
for (var i = 0; i < maxDcCount; i += 1) {
|
|
for (var r = 0; r < rsBlocks.length; r += 1) {
|
|
if (i < dcdata[r].length) {
|
|
data[index] = dcdata[r][i];
|
|
index += 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
for (var i = 0; i < maxEcCount; i += 1) {
|
|
for (var r = 0; r < rsBlocks.length; r += 1) {
|
|
if (i < ecdata[r].length) {
|
|
data[index] = ecdata[r][i];
|
|
index += 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
return data;
|
|
};
|
|
|
|
var createData = function(typeNumber, errorCorrectLevel, dataList) {
|
|
|
|
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
|
|
|
|
var buffer = qrBitBuffer();
|
|
|
|
for (var i = 0; i < dataList.length; i += 1) {
|
|
var data = dataList[i];
|
|
buffer.put(data.getMode(), 4);
|
|
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber) );
|
|
data.write(buffer);
|
|
}
|
|
|
|
// calc num max data.
|
|
var totalDataCount = 0;
|
|
for (var i = 0; i < rsBlocks.length; i += 1) {
|
|
totalDataCount += rsBlocks[i].dataCount;
|
|
}
|
|
|
|
if (buffer.getLengthInBits() > totalDataCount * 8) {
|
|
throw new Error('code length overflow. ('
|
|
+ buffer.getLengthInBits()
|
|
+ '>'
|
|
+ totalDataCount * 8
|
|
+ ')');
|
|
}
|
|
|
|
// end code
|
|
if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
|
|
buffer.put(0, 4);
|
|
}
|
|
|
|
// padding
|
|
while (buffer.getLengthInBits() % 8 != 0) {
|
|
buffer.putBit(false);
|
|
}
|
|
|
|
// padding
|
|
while (true) {
|
|
|
|
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
break;
|
|
}
|
|
buffer.put(PAD0, 8);
|
|
|
|
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
break;
|
|
}
|
|
buffer.put(PAD1, 8);
|
|
}
|
|
|
|
return createBytes(buffer, rsBlocks);
|
|
};
|
|
|
|
_this.addData = function(data) {
|
|
var newData = qr8BitByte(data);
|
|
_dataList.push(newData);
|
|
_dataCache = null;
|
|
};
|
|
|
|
_this.isDark = function(row, col) {
|
|
if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {
|
|
throw new Error(row + ',' + col);
|
|
}
|
|
return _modules[row][col];
|
|
};
|
|
|
|
_this.getModuleCount = function() {
|
|
return _moduleCount;
|
|
};
|
|
|
|
_this.make = function() {
|
|
makeImpl(false, getBestMaskPattern() );
|
|
};
|
|
|
|
_this.createTableTag = function(cellSize, margin) {
|
|
|
|
cellSize = cellSize || 2;
|
|
margin = (typeof margin == 'undefined')? cellSize * 4 : margin;
|
|
|
|
var qrHtml = '';
|
|
|
|
qrHtml += '<table style="';
|
|
qrHtml += ' border-width: 0px; border-style: none;';
|
|
qrHtml += ' border-collapse: collapse;';
|
|
qrHtml += ' padding: 0px; margin: ' + margin + 'px;';
|
|
qrHtml += '">';
|
|
qrHtml += '<tbody>';
|
|
|
|
for (var r = 0; r < _this.getModuleCount(); r += 1) {
|
|
|
|
qrHtml += '<tr>';
|
|
|
|
for (var c = 0; c < _this.getModuleCount(); c += 1) {
|
|
qrHtml += '<td style="';
|
|
qrHtml += ' border-width: 0px; border-style: none;';
|
|
qrHtml += ' border-collapse: collapse;';
|
|
qrHtml += ' padding: 0px; margin: 0px;';
|
|
qrHtml += ' width: ' + cellSize + 'px;';
|
|
qrHtml += ' height: ' + cellSize + 'px;';
|
|
qrHtml += ' background-color: ';
|
|
qrHtml += _this.isDark(r, c)? '#000000' : '#ffffff';
|
|
qrHtml += ';';
|
|
qrHtml += '"/>';
|
|
}
|
|
|
|
qrHtml += '</tr>';
|
|
}
|
|
|
|
qrHtml += '</tbody>';
|
|
qrHtml += '</table>';
|
|
|
|
return qrHtml;
|
|
};
|
|
|
|
_this.createImgTag = function(cellSize, margin) {
|
|
|
|
cellSize = cellSize || 2;
|
|
margin = (typeof margin == 'undefined')? cellSize * 4 : margin;
|
|
|
|
var size = _this.getModuleCount() * cellSize + margin * 2;
|
|
var min = margin;
|
|
var max = size - margin;
|
|
|
|
return createImgTag(size, size, function(x, y) {
|
|
if (min <= x && x < max && min <= y && y < max) {
|
|
var c = Math.floor( (x - min) / cellSize);
|
|
var r = Math.floor( (y - min) / cellSize);
|
|
return _this.isDark(r, c)? 0 : 1;
|
|
} else {
|
|
return 1;
|
|
}
|
|
} );
|
|
};
|
|
|
|
return _this;
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// qrcode.stringToBytes
|
|
//---------------------------------------------------------------------
|
|
|
|
qrcode.stringToBytes = function(s) {
|
|
var bytes = new Array();
|
|
for (var i = 0; i < s.length; i += 1) {
|
|
var c = s.charCodeAt(i);
|
|
bytes.push(c & 0xff);
|
|
}
|
|
return bytes;
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// qrcode.createStringToBytes
|
|
//---------------------------------------------------------------------
|
|
|
|
/**
|
|
* @param unicodeData base64 string of byte array.
|
|
* [16bit Unicode],[16bit Bytes], ...
|
|
* @param numChars
|
|
*/
|
|
qrcode.createStringToBytes = function(unicodeData, numChars) {
|
|
|
|
// create conversion map.
|
|
|
|
var unicodeMap = function() {
|
|
|
|
var bin = base64DecodeInputStream(unicodeData);
|
|
var read = function() {
|
|
var b = bin.read();
|
|
if (b == -1) throw new Error();
|
|
return b;
|
|
};
|
|
|
|
var count = 0;
|
|
var unicodeMap = {};
|
|
while (true) {
|
|
var b0 = bin.read();
|
|
if (b0 == -1) break;
|
|
var b1 = read();
|
|
var b2 = read();
|
|
var b3 = read();
|
|
var k = String.fromCharCode( (b0 << 8) | b1);
|
|
var v = (b2 << 8) | b3;
|
|
unicodeMap[k] = v;
|
|
count += 1;
|
|
}
|
|
if (count != numChars) {
|
|
throw new Error(count + ' != ' + numChars);
|
|
}
|
|
|
|
return unicodeMap;
|
|
}();
|
|
|
|
var unknownChar = '?'.charCodeAt(0);
|
|
|
|
return function(s) {
|
|
var bytes = new Array();
|
|
for (var i = 0; i < s.length; i += 1) {
|
|
var c = s.charCodeAt(i);
|
|
if (c < 128) {
|
|
bytes.push(c);
|
|
} else {
|
|
var b = unicodeMap[s.charAt(i)];
|
|
if (typeof b == 'number') {
|
|
if ( (b & 0xff) == b) {
|
|
// 1byte
|
|
bytes.push(b);
|
|
} else {
|
|
// 2bytes
|
|
bytes.push(b >>> 8);
|
|
bytes.push(b & 0xff);
|
|
}
|
|
} else {
|
|
bytes.push(unknownChar);
|
|
}
|
|
}
|
|
}
|
|
return bytes;
|
|
};
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// QRMode
|
|
//---------------------------------------------------------------------
|
|
|
|
var QRMode = {
|
|
MODE_NUMBER : 1 << 0,
|
|
MODE_ALPHA_NUM : 1 << 1,
|
|
MODE_8BIT_BYTE : 1 << 2,
|
|
MODE_KANJI : 1 << 3
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// QRErrorCorrectLevel
|
|
//---------------------------------------------------------------------
|
|
|
|
var QRErrorCorrectLevel = {
|
|
L : 1,
|
|
M : 0,
|
|
Q : 3,
|
|
H : 2
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// QRMaskPattern
|
|
//---------------------------------------------------------------------
|
|
|
|
var QRMaskPattern = {
|
|
PATTERN000 : 0,
|
|
PATTERN001 : 1,
|
|
PATTERN010 : 2,
|
|
PATTERN011 : 3,
|
|
PATTERN100 : 4,
|
|
PATTERN101 : 5,
|
|
PATTERN110 : 6,
|
|
PATTERN111 : 7
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// QRUtil
|
|
//---------------------------------------------------------------------
|
|
|
|
var QRUtil = function() {
|
|
|
|
var PATTERN_POSITION_TABLE = [
|
|
[],
|
|
[6, 18],
|
|
[6, 22],
|
|
[6, 26],
|
|
[6, 30],
|
|
[6, 34],
|
|
[6, 22, 38],
|
|
[6, 24, 42],
|
|
[6, 26, 46],
|
|
[6, 28, 50],
|
|
[6, 30, 54],
|
|
[6, 32, 58],
|
|
[6, 34, 62],
|
|
[6, 26, 46, 66],
|
|
[6, 26, 48, 70],
|
|
[6, 26, 50, 74],
|
|
[6, 30, 54, 78],
|
|
[6, 30, 56, 82],
|
|
[6, 30, 58, 86],
|
|
[6, 34, 62, 90],
|
|
[6, 28, 50, 72, 94],
|
|
[6, 26, 50, 74, 98],
|
|
[6, 30, 54, 78, 102],
|
|
[6, 28, 54, 80, 106],
|
|
[6, 32, 58, 84, 110],
|
|
[6, 30, 58, 86, 114],
|
|
[6, 34, 62, 90, 118],
|
|
[6, 26, 50, 74, 98, 122],
|
|
[6, 30, 54, 78, 102, 126],
|
|
[6, 26, 52, 78, 104, 130],
|
|
[6, 30, 56, 82, 108, 134],
|
|
[6, 34, 60, 86, 112, 138],
|
|
[6, 30, 58, 86, 114, 142],
|
|
[6, 34, 62, 90, 118, 146],
|
|
[6, 30, 54, 78, 102, 126, 150],
|
|
[6, 24, 50, 76, 102, 128, 154],
|
|
[6, 28, 54, 80, 106, 132, 158],
|
|
[6, 32, 58, 84, 110, 136, 162],
|
|
[6, 26, 54, 82, 110, 138, 166],
|
|
[6, 30, 58, 86, 114, 142, 170]
|
|
];
|
|
var G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0);
|
|
var G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0);
|
|
var G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1);
|
|
|
|
var _this = {};
|
|
|
|
var getBCHDigit = function(data) {
|
|
var digit = 0;
|
|
while (data != 0) {
|
|
digit += 1;
|
|
data >>>= 1;
|
|
}
|
|
return digit;
|
|
};
|
|
|
|
_this.getBCHTypeInfo = function(data) {
|
|
var d = data << 10;
|
|
while (getBCHDigit(d) - getBCHDigit(G15) >= 0) {
|
|
d ^= (G15 << (getBCHDigit(d) - getBCHDigit(G15) ) );
|
|
}
|
|
return ( (data << 10) | d) ^ G15_MASK;
|
|
};
|
|
|
|
_this.getBCHTypeNumber = function(data) {
|
|
var d = data << 12;
|
|
while (getBCHDigit(d) - getBCHDigit(G18) >= 0) {
|
|
d ^= (G18 << (getBCHDigit(d) - getBCHDigit(G18) ) );
|
|
}
|
|
return (data << 12) | d;
|
|
};
|
|
|
|
_this.getPatternPosition = function(typeNumber) {
|
|
return PATTERN_POSITION_TABLE[typeNumber - 1];
|
|
};
|
|
|
|
_this.getMaskFunction = function(maskPattern) {
|
|
|
|
switch (maskPattern) {
|
|
|
|
case QRMaskPattern.PATTERN000 :
|
|
return function(i, j) { return (i + j) % 2 == 0; };
|
|
case QRMaskPattern.PATTERN001 :
|
|
return function(i, j) { return i % 2 == 0; };
|
|
case QRMaskPattern.PATTERN010 :
|
|
return function(i, j) { return j % 3 == 0; };
|
|
case QRMaskPattern.PATTERN011 :
|
|
return function(i, j) { return (i + j) % 3 == 0; };
|
|
case QRMaskPattern.PATTERN100 :
|
|
return function(i, j) { return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0; };
|
|
case QRMaskPattern.PATTERN101 :
|
|
return function(i, j) { return (i * j) % 2 + (i * j) % 3 == 0; };
|
|
case QRMaskPattern.PATTERN110 :
|
|
return function(i, j) { return ( (i * j) % 2 + (i * j) % 3) % 2 == 0; };
|
|
case QRMaskPattern.PATTERN111 :
|
|
return function(i, j) { return ( (i * j) % 3 + (i + j) % 2) % 2 == 0; };
|
|
|
|
default :
|
|
throw new Error('bad maskPattern:' + maskPattern);
|
|
}
|
|
};
|
|
|
|
_this.getErrorCorrectPolynomial = function(errorCorrectLength) {
|
|
var a = qrPolynomial([1], 0);
|
|
for (var i = 0; i < errorCorrectLength; i += 1) {
|
|
a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0) );
|
|
}
|
|
return a;
|
|
};
|
|
|
|
_this.getLengthInBits = function(mode, type) {
|
|
|
|
if (1 <= type && type < 10) {
|
|
|
|
// 1 - 9
|
|
|
|
switch(mode) {
|
|
case QRMode.MODE_NUMBER : return 10;
|
|
case QRMode.MODE_ALPHA_NUM : return 9;
|
|
case QRMode.MODE_8BIT_BYTE : return 8;
|
|
case QRMode.MODE_KANJI : return 8;
|
|
default :
|
|
throw new Error('mode:' + mode);
|
|
}
|
|
|
|
} else if (type < 27) {
|
|
|
|
// 10 - 26
|
|
|
|
switch(mode) {
|
|
case QRMode.MODE_NUMBER : return 12;
|
|
case QRMode.MODE_ALPHA_NUM : return 11;
|
|
case QRMode.MODE_8BIT_BYTE : return 16;
|
|
case QRMode.MODE_KANJI : return 10;
|
|
default :
|
|
throw new Error('mode:' + mode);
|
|
}
|
|
|
|
} else if (type < 41) {
|
|
|
|
// 27 - 40
|
|
|
|
switch(mode) {
|
|
case QRMode.MODE_NUMBER : return 14;
|
|
case QRMode.MODE_ALPHA_NUM : return 13;
|
|
case QRMode.MODE_8BIT_BYTE : return 16;
|
|
case QRMode.MODE_KANJI : return 12;
|
|
default :
|
|
throw new Error('mode:' + mode);
|
|
}
|
|
|
|
} else {
|
|
throw new Error('type:' + type);
|
|
}
|
|
};
|
|
|
|
_this.getLostPoint = function(qrcode) {
|
|
|
|
var moduleCount = qrcode.getModuleCount();
|
|
|
|
var lostPoint = 0;
|
|
|
|
// LEVEL1
|
|
|
|
for (var row = 0; row < moduleCount; row += 1) {
|
|
for (var col = 0; col < moduleCount; col += 1) {
|
|
|
|
var sameCount = 0;
|
|
var dark = qrcode.isDark(row, col);
|
|
|
|
for (var r = -1; r <= 1; r += 1) {
|
|
|
|
if (row + r < 0 || moduleCount <= row + r) {
|
|
continue;
|
|
}
|
|
|
|
for (var c = -1; c <= 1; c += 1) {
|
|
|
|
if (col + c < 0 || moduleCount <= col + c) {
|
|
continue;
|
|
}
|
|
|
|
if (r == 0 && c == 0) {
|
|
continue;
|
|
}
|
|
|
|
if (dark == qrcode.isDark(row + r, col + c) ) {
|
|
sameCount += 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (sameCount > 5) {
|
|
lostPoint += (3 + sameCount - 5);
|
|
}
|
|
}
|
|
};
|
|
|
|
// LEVEL2
|
|
|
|
for (var row = 0; row < moduleCount - 1; row += 1) {
|
|
for (var col = 0; col < moduleCount - 1; col += 1) {
|
|
var count = 0;
|
|
if (qrcode.isDark(row, col) ) count += 1;
|
|
if (qrcode.isDark(row + 1, col) ) count += 1;
|
|
if (qrcode.isDark(row, col + 1) ) count += 1;
|
|
if (qrcode.isDark(row + 1, col + 1) ) count += 1;
|
|
if (count == 0 || count == 4) {
|
|
lostPoint += 3;
|
|
}
|
|
}
|
|
}
|
|
|
|
// LEVEL3
|
|
|
|
for (var row = 0; row < moduleCount; row += 1) {
|
|
for (var col = 0; col < moduleCount - 6; col += 1) {
|
|
if (qrcode.isDark(row, col)
|
|
&& !qrcode.isDark(row, col + 1)
|
|
&& qrcode.isDark(row, col + 2)
|
|
&& qrcode.isDark(row, col + 3)
|
|
&& qrcode.isDark(row, col + 4)
|
|
&& !qrcode.isDark(row, col + 5)
|
|
&& qrcode.isDark(row, col + 6) ) {
|
|
lostPoint += 40;
|
|
}
|
|
}
|
|
}
|
|
|
|
for (var col = 0; col < moduleCount; col += 1) {
|
|
for (var row = 0; row < moduleCount - 6; row += 1) {
|
|
if (qrcode.isDark(row, col)
|
|
&& !qrcode.isDark(row + 1, col)
|
|
&& qrcode.isDark(row + 2, col)
|
|
&& qrcode.isDark(row + 3, col)
|
|
&& qrcode.isDark(row + 4, col)
|
|
&& !qrcode.isDark(row + 5, col)
|
|
&& qrcode.isDark(row + 6, col) ) {
|
|
lostPoint += 40;
|
|
}
|
|
}
|
|
}
|
|
|
|
// LEVEL4
|
|
|
|
var darkCount = 0;
|
|
|
|
for (var col = 0; col < moduleCount; col += 1) {
|
|
for (var row = 0; row < moduleCount; row += 1) {
|
|
if (qrcode.isDark(row, col) ) {
|
|
darkCount += 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
|
|
lostPoint += ratio * 10;
|
|
|
|
return lostPoint;
|
|
};
|
|
|
|
return _this;
|
|
}();
|
|
|
|
//---------------------------------------------------------------------
|
|
// QRMath
|
|
//---------------------------------------------------------------------
|
|
|
|
var QRMath = function() {
|
|
|
|
var EXP_TABLE = new Array(256);
|
|
var LOG_TABLE = new Array(256);
|
|
|
|
// initialize tables
|
|
for (var i = 0; i < 8; i += 1) {
|
|
EXP_TABLE[i] = 1 << i;
|
|
}
|
|
for (var i = 8; i < 256; i += 1) {
|
|
EXP_TABLE[i] = EXP_TABLE[i - 4]
|
|
^ EXP_TABLE[i - 5]
|
|
^ EXP_TABLE[i - 6]
|
|
^ EXP_TABLE[i - 8];
|
|
}
|
|
for (var i = 0; i < 255; i += 1) {
|
|
LOG_TABLE[EXP_TABLE[i] ] = i;
|
|
}
|
|
|
|
var _this = {};
|
|
|
|
_this.glog = function(n) {
|
|
|
|
if (n < 1) {
|
|
throw new Error('glog(' + n + ')');
|
|
}
|
|
|
|
return LOG_TABLE[n];
|
|
};
|
|
|
|
_this.gexp = function(n) {
|
|
|
|
while (n < 0) {
|
|
n += 255;
|
|
}
|
|
|
|
while (n >= 256) {
|
|
n -= 255;
|
|
}
|
|
|
|
return EXP_TABLE[n];
|
|
};
|
|
|
|
return _this;
|
|
}();
|
|
|
|
//---------------------------------------------------------------------
|
|
// qrPolynomial
|
|
//---------------------------------------------------------------------
|
|
|
|
function qrPolynomial(num, shift) {
|
|
|
|
if (typeof num.length == 'undefined') {
|
|
throw new Error(num.length + '/' + shift);
|
|
}
|
|
|
|
var _num = function() {
|
|
var offset = 0;
|
|
while (offset < num.length && num[offset] == 0) {
|
|
offset += 1;
|
|
}
|
|
var _num = new Array(num.length - offset + shift);
|
|
for (var i = 0; i < num.length - offset; i += 1) {
|
|
_num[i] = num[i + offset];
|
|
}
|
|
return _num;
|
|
}();
|
|
|
|
var _this = {};
|
|
|
|
_this.getAt = function(index) {
|
|
return _num[index];
|
|
};
|
|
|
|
_this.getLength = function() {
|
|
return _num.length;
|
|
};
|
|
|
|
_this.multiply = function(e) {
|
|
|
|
var num = new Array(_this.getLength() + e.getLength() - 1);
|
|
|
|
for (var i = 0; i < _this.getLength(); i += 1) {
|
|
for (var j = 0; j < e.getLength(); j += 1) {
|
|
num[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i) ) + QRMath.glog(e.getAt(j) ) );
|
|
}
|
|
}
|
|
|
|
return qrPolynomial(num, 0);
|
|
};
|
|
|
|
_this.mod = function(e) {
|
|
|
|
if (_this.getLength() - e.getLength() < 0) {
|
|
return _this;
|
|
}
|
|
|
|
var ratio = QRMath.glog(_this.getAt(0) ) - QRMath.glog(e.getAt(0) );
|
|
|
|
var num = new Array(_this.getLength() );
|
|
for (var i = 0; i < _this.getLength(); i += 1) {
|
|
num[i] = _this.getAt(i);
|
|
}
|
|
|
|
for (var i = 0; i < e.getLength(); i += 1) {
|
|
num[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i) ) + ratio);
|
|
}
|
|
|
|
// recursive call
|
|
return qrPolynomial(num, 0).mod(e);
|
|
};
|
|
|
|
return _this;
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// QRRSBlock
|
|
//---------------------------------------------------------------------
|
|
|
|
var QRRSBlock = function() {
|
|
|
|
var RS_BLOCK_TABLE = [
|
|
|
|
// L
|
|
// M
|
|
// Q
|
|
// H
|
|
|
|
// 1
|
|
[1, 26, 19],
|
|
[1, 26, 16],
|
|
[1, 26, 13],
|
|
[1, 26, 9],
|
|
|
|
// 2
|
|
[1, 44, 34],
|
|
[1, 44, 28],
|
|
[1, 44, 22],
|
|
[1, 44, 16],
|
|
|
|
// 3
|
|
[1, 70, 55],
|
|
[1, 70, 44],
|
|
[2, 35, 17],
|
|
[2, 35, 13],
|
|
|
|
// 4
|
|
[1, 100, 80],
|
|
[2, 50, 32],
|
|
[2, 50, 24],
|
|
[4, 25, 9],
|
|
|
|
// 5
|
|
[1, 134, 108],
|
|
[2, 67, 43],
|
|
[2, 33, 15, 2, 34, 16],
|
|
[2, 33, 11, 2, 34, 12],
|
|
|
|
// 6
|
|
[2, 86, 68],
|
|
[4, 43, 27],
|
|
[4, 43, 19],
|
|
[4, 43, 15],
|
|
|
|
// 7
|
|
[2, 98, 78],
|
|
[4, 49, 31],
|
|
[2, 32, 14, 4, 33, 15],
|
|
[4, 39, 13, 1, 40, 14],
|
|
|
|
// 8
|
|
[2, 121, 97],
|
|
[2, 60, 38, 2, 61, 39],
|
|
[4, 40, 18, 2, 41, 19],
|
|
[4, 40, 14, 2, 41, 15],
|
|
|
|
// 9
|
|
[2, 146, 116],
|
|
[3, 58, 36, 2, 59, 37],
|
|
[4, 36, 16, 4, 37, 17],
|
|
[4, 36, 12, 4, 37, 13],
|
|
|
|
// 10
|
|
[2, 86, 68, 2, 87, 69],
|
|
[4, 69, 43, 1, 70, 44],
|
|
[6, 43, 19, 2, 44, 20],
|
|
[6, 43, 15, 2, 44, 16]
|
|
];
|
|
|
|
var qrRSBlock = function(totalCount, dataCount) {
|
|
var _this = {};
|
|
_this.totalCount = totalCount;
|
|
_this.dataCount = dataCount;
|
|
return _this;
|
|
};
|
|
|
|
var _this = {};
|
|
|
|
var getRsBlockTable = function(typeNumber, errorCorrectLevel) {
|
|
|
|
switch(errorCorrectLevel) {
|
|
case QRErrorCorrectLevel.L :
|
|
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
|
|
case QRErrorCorrectLevel.M :
|
|
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
|
|
case QRErrorCorrectLevel.Q :
|
|
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
|
|
case QRErrorCorrectLevel.H :
|
|
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
|
|
default :
|
|
return undefined;
|
|
}
|
|
};
|
|
|
|
_this.getRSBlocks = function(typeNumber, errorCorrectLevel) {
|
|
|
|
var rsBlock = getRsBlockTable(typeNumber, errorCorrectLevel);
|
|
|
|
if (typeof rsBlock == 'undefined') {
|
|
throw new Error('bad rs block @ typeNumber:' + typeNumber +
|
|
'/errorCorrectLevel:' + errorCorrectLevel);
|
|
}
|
|
|
|
var length = rsBlock.length / 3;
|
|
|
|
var list = new Array();
|
|
|
|
for (var i = 0; i < length; i += 1) {
|
|
|
|
var count = rsBlock[i * 3 + 0];
|
|
var totalCount = rsBlock[i * 3 + 1];
|
|
var dataCount = rsBlock[i * 3 + 2];
|
|
|
|
for (var j = 0; j < count; j += 1) {
|
|
list.push(qrRSBlock(totalCount, dataCount) );
|
|
}
|
|
}
|
|
|
|
return list;
|
|
};
|
|
|
|
return _this;
|
|
}();
|
|
|
|
//---------------------------------------------------------------------
|
|
// qrBitBuffer
|
|
//---------------------------------------------------------------------
|
|
|
|
var qrBitBuffer = function() {
|
|
|
|
var _buffer = new Array();
|
|
var _length = 0;
|
|
|
|
var _this = {};
|
|
|
|
_this.getBuffer = function() {
|
|
return _buffer;
|
|
};
|
|
|
|
_this.getAt = function(index) {
|
|
var bufIndex = Math.floor(index / 8);
|
|
return ( (_buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
|
|
};
|
|
|
|
_this.put = function(num, length) {
|
|
for (var i = 0; i < length; i += 1) {
|
|
_this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);
|
|
}
|
|
};
|
|
|
|
_this.getLengthInBits = function() {
|
|
return _length;
|
|
};
|
|
|
|
_this.putBit = function(bit) {
|
|
|
|
var bufIndex = Math.floor(_length / 8);
|
|
if (_buffer.length <= bufIndex) {
|
|
_buffer.push(0);
|
|
}
|
|
|
|
if (bit) {
|
|
_buffer[bufIndex] |= (0x80 >>> (_length % 8) );
|
|
}
|
|
|
|
_length += 1;
|
|
};
|
|
|
|
return _this;
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// qr8BitByte
|
|
//---------------------------------------------------------------------
|
|
|
|
var qr8BitByte = function(data) {
|
|
|
|
var _mode = QRMode.MODE_8BIT_BYTE;
|
|
var _data = data;
|
|
var _bytes = qrcode.stringToBytes(data);
|
|
|
|
var _this = {};
|
|
|
|
_this.getMode = function() {
|
|
return _mode;
|
|
};
|
|
|
|
_this.getLength = function(buffer) {
|
|
return _bytes.length;
|
|
};
|
|
|
|
_this.write = function(buffer) {
|
|
for (var i = 0; i < _bytes.length; i += 1) {
|
|
buffer.put(_bytes[i], 8);
|
|
}
|
|
};
|
|
|
|
return _this;
|
|
};
|
|
|
|
//=====================================================================
|
|
// GIF Support etc.
|
|
//
|
|
|
|
//---------------------------------------------------------------------
|
|
// byteArrayOutputStream
|
|
//---------------------------------------------------------------------
|
|
|
|
var byteArrayOutputStream = function() {
|
|
|
|
var _bytes = new Array();
|
|
|
|
var _this = {};
|
|
|
|
_this.writeByte = function(b) {
|
|
_bytes.push(b & 0xff);
|
|
};
|
|
|
|
_this.writeShort = function(i) {
|
|
_this.writeByte(i);
|
|
_this.writeByte(i >>> 8);
|
|
};
|
|
|
|
_this.writeBytes = function(b, off, len) {
|
|
off = off || 0;
|
|
len = len || b.length;
|
|
for (var i = 0; i < len; i += 1) {
|
|
_this.writeByte(b[i + off]);
|
|
}
|
|
};
|
|
|
|
_this.writeString = function(s) {
|
|
for (var i = 0; i < s.length; i += 1) {
|
|
_this.writeByte(s.charCodeAt(i) );
|
|
}
|
|
};
|
|
|
|
_this.toByteArray = function() {
|
|
return _bytes;
|
|
};
|
|
|
|
_this.toString = function() {
|
|
var s = '';
|
|
s += '[';
|
|
for (var i = 0; i < _bytes.length; i += 1) {
|
|
if (i > 0) {
|
|
s += ',';
|
|
}
|
|
s += _bytes[i];
|
|
}
|
|
s += ']';
|
|
return s;
|
|
};
|
|
|
|
return _this;
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// base64EncodeOutputStream
|
|
//---------------------------------------------------------------------
|
|
|
|
var base64EncodeOutputStream = function() {
|
|
|
|
var _buffer = 0;
|
|
var _buflen = 0;
|
|
var _length = 0;
|
|
var _base64 = '';
|
|
|
|
var _this = {};
|
|
|
|
var writeEncoded = function(b) {
|
|
_base64 += String.fromCharCode(encode(b & 0x3f) );
|
|
};
|
|
|
|
var encode = function(n) {
|
|
if (n < 0) {
|
|
// error.
|
|
} else if (n < 26) {
|
|
return 0x41 + n;
|
|
} else if (n < 52) {
|
|
return 0x61 + (n - 26);
|
|
} else if (n < 62) {
|
|
return 0x30 + (n - 52);
|
|
} else if (n == 62) {
|
|
return 0x2b;
|
|
} else if (n == 63) {
|
|
return 0x2f;
|
|
}
|
|
throw new Error('n:' + n);
|
|
};
|
|
|
|
_this.writeByte = function(n) {
|
|
|
|
_buffer = (_buffer << 8) | (n & 0xff);
|
|
_buflen += 8;
|
|
_length += 1;
|
|
|
|
while (_buflen >= 6) {
|
|
writeEncoded(_buffer >>> (_buflen - 6) );
|
|
_buflen -= 6;
|
|
}
|
|
};
|
|
|
|
_this.flush = function() {
|
|
|
|
if (_buflen > 0) {
|
|
writeEncoded(_buffer << (6 - _buflen) );
|
|
_buffer = 0;
|
|
_buflen = 0;
|
|
}
|
|
|
|
if (_length % 3 != 0) {
|
|
// padding
|
|
var padlen = 3 - _length % 3;
|
|
for (var i = 0; i < padlen; i += 1) {
|
|
_base64 += '=';
|
|
}
|
|
}
|
|
};
|
|
|
|
_this.toString = function() {
|
|
return _base64;
|
|
};
|
|
|
|
return _this;
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// base64DecodeInputStream
|
|
//---------------------------------------------------------------------
|
|
|
|
var base64DecodeInputStream = function(str) {
|
|
|
|
var _str = str;
|
|
var _pos = 0;
|
|
var _buffer = 0;
|
|
var _buflen = 0;
|
|
|
|
var _this = {};
|
|
|
|
_this.read = function() {
|
|
|
|
while (_buflen < 8) {
|
|
|
|
if (_pos >= _str.length) {
|
|
if (_buflen == 0) {
|
|
return -1;
|
|
}
|
|
throw new Error('unexpected end of file./' + _buflen);
|
|
}
|
|
|
|
var c = _str.charAt(_pos);
|
|
_pos += 1;
|
|
|
|
if (c == '=') {
|
|
_buflen = 0;
|
|
return -1;
|
|
} else if (c.match(/^\s$/) ) {
|
|
// ignore if whitespace.
|
|
continue;
|
|
}
|
|
|
|
_buffer = (_buffer << 6) | decode(c.charCodeAt(0) );
|
|
_buflen += 6;
|
|
}
|
|
|
|
var n = (_buffer >>> (_buflen - 8) ) & 0xff;
|
|
_buflen -= 8;
|
|
return n;
|
|
};
|
|
|
|
var decode = function(c) {
|
|
if (0x41 <= c && c <= 0x5a) {
|
|
return c - 0x41;
|
|
} else if (0x61 <= c && c <= 0x7a) {
|
|
return c - 0x61 + 26;
|
|
} else if (0x30 <= c && c <= 0x39) {
|
|
return c - 0x30 + 52;
|
|
} else if (c == 0x2b) {
|
|
return 62;
|
|
} else if (c == 0x2f) {
|
|
return 63;
|
|
} else {
|
|
throw new Error('c:' + c);
|
|
}
|
|
};
|
|
|
|
return _this;
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// gifImage (B/W)
|
|
//---------------------------------------------------------------------
|
|
|
|
var gifImage = function(width, height) {
|
|
|
|
var _width = width;
|
|
var _height = height;
|
|
var _data = new Array(width * height);
|
|
|
|
var _this = {};
|
|
|
|
_this.setPixel = function(x, y, pixel) {
|
|
_data[y * _width + x] = pixel;
|
|
};
|
|
|
|
_this.write = function(out) {
|
|
|
|
//---------------------------------
|
|
// GIF Signature
|
|
|
|
out.writeString('GIF87a');
|
|
|
|
//---------------------------------
|
|
// Screen Descriptor
|
|
|
|
out.writeShort(_width);
|
|
out.writeShort(_height);
|
|
|
|
out.writeByte(0x80); // 2bit
|
|
out.writeByte(0);
|
|
out.writeByte(0);
|
|
|
|
//---------------------------------
|
|
// Global Color Map
|
|
|
|
// black
|
|
out.writeByte(0x00);
|
|
out.writeByte(0x00);
|
|
out.writeByte(0x00);
|
|
|
|
// white
|
|
out.writeByte(0xff);
|
|
out.writeByte(0xff);
|
|
out.writeByte(0xff);
|
|
|
|
//---------------------------------
|
|
// Image Descriptor
|
|
|
|
out.writeString(',');
|
|
out.writeShort(0);
|
|
out.writeShort(0);
|
|
out.writeShort(_width);
|
|
out.writeShort(_height);
|
|
out.writeByte(0);
|
|
|
|
//---------------------------------
|
|
// Local Color Map
|
|
|
|
//---------------------------------
|
|
// Raster Data
|
|
|
|
var lzwMinCodeSize = 2;
|
|
var raster = getLZWRaster(lzwMinCodeSize);
|
|
|
|
out.writeByte(lzwMinCodeSize);
|
|
|
|
var offset = 0;
|
|
|
|
while (raster.length - offset > 255) {
|
|
out.writeByte(255);
|
|
out.writeBytes(raster, offset, 255);
|
|
offset += 255;
|
|
}
|
|
|
|
out.writeByte(raster.length - offset);
|
|
out.writeBytes(raster, offset, raster.length - offset);
|
|
out.writeByte(0x00);
|
|
|
|
//---------------------------------
|
|
// GIF Terminator
|
|
out.writeString(';');
|
|
};
|
|
|
|
var bitOutputStream = function(out) {
|
|
|
|
var _out = out;
|
|
var _bitLength = 0;
|
|
var _bitBuffer = 0;
|
|
|
|
var _this = {};
|
|
|
|
_this.write = function(data, length) {
|
|
|
|
if ( (data >>> length) != 0) {
|
|
throw new Error('length over');
|
|
}
|
|
|
|
while (_bitLength + length >= 8) {
|
|
_out.writeByte(0xff & ( (data << _bitLength) | _bitBuffer) );
|
|
length -= (8 - _bitLength);
|
|
data >>>= (8 - _bitLength);
|
|
_bitBuffer = 0;
|
|
_bitLength = 0;
|
|
}
|
|
|
|
_bitBuffer = (data << _bitLength) | _bitBuffer;
|
|
_bitLength = _bitLength + length;
|
|
};
|
|
|
|
_this.flush = function() {
|
|
if (_bitLength > 0) {
|
|
_out.writeByte(_bitBuffer);
|
|
}
|
|
};
|
|
|
|
return _this;
|
|
};
|
|
|
|
var getLZWRaster = function(lzwMinCodeSize) {
|
|
|
|
var clearCode = 1 << lzwMinCodeSize;
|
|
var endCode = (1 << lzwMinCodeSize) + 1;
|
|
var bitLength = lzwMinCodeSize + 1;
|
|
|
|
// Setup LZWTable
|
|
var table = lzwTable();
|
|
|
|
for (var i = 0; i < clearCode; i += 1) {
|
|
table.add(String.fromCharCode(i) );
|
|
}
|
|
table.add(String.fromCharCode(clearCode) );
|
|
table.add(String.fromCharCode(endCode) );
|
|
|
|
var byteOut = byteArrayOutputStream();
|
|
var bitOut = bitOutputStream(byteOut);
|
|
|
|
// clear code
|
|
bitOut.write(clearCode, bitLength);
|
|
|
|
var dataIndex = 0;
|
|
|
|
var s = String.fromCharCode(_data[dataIndex]);
|
|
dataIndex += 1;
|
|
|
|
while (dataIndex < _data.length) {
|
|
|
|
var c = String.fromCharCode(_data[dataIndex]);
|
|
dataIndex += 1;
|
|
|
|
if (table.contains(s + c) ) {
|
|
|
|
s = s + c;
|
|
|
|
} else {
|
|
|
|
bitOut.write(table.indexOf(s), bitLength);
|
|
|
|
if (table.size() < 0xfff) {
|
|
|
|
if (table.size() == (1 << bitLength) ) {
|
|
bitLength += 1;
|
|
}
|
|
|
|
table.add(s + c);
|
|
}
|
|
|
|
s = c;
|
|
}
|
|
}
|
|
|
|
bitOut.write(table.indexOf(s), bitLength);
|
|
|
|
// end code
|
|
bitOut.write(endCode, bitLength);
|
|
|
|
bitOut.flush();
|
|
|
|
return byteOut.toByteArray();
|
|
};
|
|
|
|
var lzwTable = function() {
|
|
|
|
var _map = {};
|
|
var _size = 0;
|
|
|
|
var _this = {};
|
|
|
|
_this.add = function(key) {
|
|
if (_this.contains(key) ) {
|
|
throw new Error('dup key:' + key);
|
|
}
|
|
_map[key] = _size;
|
|
_size += 1;
|
|
};
|
|
|
|
_this.size = function() {
|
|
return _size;
|
|
};
|
|
|
|
_this.indexOf = function(key) {
|
|
return _map[key];
|
|
};
|
|
|
|
_this.contains = function(key) {
|
|
return typeof _map[key] != 'undefined';
|
|
};
|
|
|
|
return _this;
|
|
};
|
|
|
|
return _this;
|
|
};
|
|
|
|
var createImgTag = function(width, height, getPixel, alt) {
|
|
|
|
var gif = gifImage(width, height);
|
|
for (var y = 0; y < height; y += 1) {
|
|
for (var x = 0; x < width; x += 1) {
|
|
gif.setPixel(x, y, getPixel(x, y) );
|
|
}
|
|
}
|
|
|
|
var b = byteArrayOutputStream();
|
|
gif.write(b);
|
|
|
|
var base64 = base64EncodeOutputStream();
|
|
var bytes = b.toByteArray();
|
|
for (var i = 0; i < bytes.length; i += 1) {
|
|
base64.writeByte(bytes[i]);
|
|
}
|
|
base64.flush();
|
|
|
|
var img = '';
|
|
img += '<img';
|
|
img += '\u0020src="';
|
|
img += 'data:image/gif;base64,';
|
|
img += base64;
|
|
img += '"';
|
|
img += '\u0020width="';
|
|
img += width;
|
|
img += '"';
|
|
img += '\u0020height="';
|
|
img += height;
|
|
img += '"';
|
|
if (alt) {
|
|
img += '\u0020alt="';
|
|
img += alt;
|
|
img += '"';
|
|
}
|
|
img += '/>';
|
|
|
|
return img;
|
|
};
|
|
|
|
//---------------------------------------------------------------------
|
|
// returns qrcode function.
|
|
|
|
return qrcode;
|
|
}();
|
|
|
|
// Source: public/lib/zeroclipboard/ZeroClipboard.min.js
|
|
/*!
|
|
* ZeroClipboard
|
|
* The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
|
|
* Copyright (c) 2014 Jon Rohan, James M. Greene
|
|
* Licensed MIT
|
|
* http://zeroclipboard.org/
|
|
* v1.3.2
|
|
*/
|
|
!function(){"use strict";function a(a){return a.replace(/,/g,".").replace(/[^0-9\.]/g,"")}function b(b){return parseFloat(a(b))>=10}var c,d={bridge:null,version:"0.0.0",disabled:null,outdated:null,ready:null},e={},f=0,g={},h=0,i={},j=null,k=null,l=function(){var a,b,c,d,e="ZeroClipboard.swf";if(document.currentScript&&(d=document.currentScript.src));else{var f=document.getElementsByTagName("script");if("readyState"in f[0])for(a=f.length;a--&&("interactive"!==f[a].readyState||!(d=f[a].src)););else if("loading"===document.readyState)d=f[f.length-1].src;else{for(a=f.length;a--;){if(c=f[a].src,!c){b=null;break}if(c=c.split("#")[0].split("?")[0],c=c.slice(0,c.lastIndexOf("/")+1),null==b)b=c;else if(b!==c){b=null;break}}null!==b&&(d=b)}}return d&&(d=d.split("#")[0].split("?")[0],e=d.slice(0,d.lastIndexOf("/")+1)+e),e}(),m=function(){var a=/\-([a-z])/g,b=function(a,b){return b.toUpperCase()};return function(c){return c.replace(a,b)}}(),n=function(a,b){var c,d,e;return window.getComputedStyle?c=window.getComputedStyle(a,null).getPropertyValue(b):(d=m(b),c=a.currentStyle?a.currentStyle[d]:a.style[d]),"cursor"!==b||c&&"auto"!==c||(e=a.tagName.toLowerCase(),"a"!==e)?c:"pointer"},o=function(a){a||(a=window.event);var b;this!==window?b=this:a.target?b=a.target:a.srcElement&&(b=a.srcElement),I.activate(b)},p=function(a,b,c){a&&1===a.nodeType&&(a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c))},q=function(a,b,c){a&&1===a.nodeType&&(a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c))},r=function(a,b){if(!a||1!==a.nodeType)return a;if(a.classList)return a.classList.contains(b)||a.classList.add(b),a;if(b&&"string"==typeof b){var c=(b||"").split(/\s+/);if(1===a.nodeType)if(a.className){for(var d=" "+a.className+" ",e=a.className,f=0,g=c.length;g>f;f++)d.indexOf(" "+c[f]+" ")<0&&(e+=" "+c[f]);a.className=e.replace(/^\s+|\s+$/g,"")}else a.className=b}return a},s=function(a,b){if(!a||1!==a.nodeType)return a;if(a.classList)return a.classList.contains(b)&&a.classList.remove(b),a;if(b&&"string"==typeof b||void 0===b){var c=(b||"").split(/\s+/);if(1===a.nodeType&&a.className)if(b){for(var d=(" "+a.className+" ").replace(/[\n\t]/g," "),e=0,f=c.length;f>e;e++)d=d.replace(" "+c[e]+" "," ");a.className=d.replace(/^\s+|\s+$/g,"")}else a.className=""}return a},t=function(){var a,b,c,d=1;return"function"==typeof document.body.getBoundingClientRect&&(a=document.body.getBoundingClientRect(),b=a.right-a.left,c=document.body.offsetWidth,d=Math.round(b/c*100)/100),d},u=function(a,b){var c={left:0,top:0,width:0,height:0,zIndex:A(b)-1};if(a.getBoundingClientRect){var d,e,f,g=a.getBoundingClientRect();"pageXOffset"in window&&"pageYOffset"in window?(d=window.pageXOffset,e=window.pageYOffset):(f=t(),d=Math.round(document.documentElement.scrollLeft/f),e=Math.round(document.documentElement.scrollTop/f));var h=document.documentElement.clientLeft||0,i=document.documentElement.clientTop||0;c.left=g.left+d-h,c.top=g.top+e-i,c.width="width"in g?g.width:g.right-g.left,c.height="height"in g?g.height:g.bottom-g.top}return c},v=function(a,b){var c=null==b||b&&b.cacheBust===!0&&b.useNoCache===!0;return c?(-1===a.indexOf("?")?"?":"&")+"noCache="+(new Date).getTime():""},w=function(a){var b,c,d,e=[],f=[],g=[];if(a.trustedOrigins&&("string"==typeof a.trustedOrigins?f.push(a.trustedOrigins):"object"==typeof a.trustedOrigins&&"length"in a.trustedOrigins&&(f=f.concat(a.trustedOrigins))),a.trustedDomains&&("string"==typeof a.trustedDomains?f.push(a.trustedDomains):"object"==typeof a.trustedDomains&&"length"in a.trustedDomains&&(f=f.concat(a.trustedDomains))),f.length)for(b=0,c=f.length;c>b;b++)if(f.hasOwnProperty(b)&&f[b]&&"string"==typeof f[b]){if(d=D(f[b]),!d)continue;if("*"===d){g=[d];break}g.push.apply(g,[d,"//"+d,window.location.protocol+"//"+d])}return g.length&&e.push("trustedOrigins="+encodeURIComponent(g.join(","))),"string"==typeof a.jsModuleId&&a.jsModuleId&&e.push("jsModuleId="+encodeURIComponent(a.jsModuleId)),e.join("&")},x=function(a,b,c){if("function"==typeof b.indexOf)return b.indexOf(a,c);var d,e=b.length;for("undefined"==typeof c?c=0:0>c&&(c=e+c),d=c;e>d;d++)if(b.hasOwnProperty(d)&&b[d]===a)return d;return-1},y=function(a){if("string"==typeof a)throw new TypeError("ZeroClipboard doesn't accept query strings.");return a.length?a:[a]},z=function(a,b,c,d){d?window.setTimeout(function(){a.apply(b,c)},0):a.apply(b,c)},A=function(a){var b,c;return a&&("number"==typeof a&&a>0?b=a:"string"==typeof a&&(c=parseInt(a,10))&&!isNaN(c)&&c>0&&(b=c)),b||("number"==typeof L.zIndex&&L.zIndex>0?b=L.zIndex:"string"==typeof L.zIndex&&(c=parseInt(L.zIndex,10))&&!isNaN(c)&&c>0&&(b=c)),b||0},B=function(a,b){if(a&&b!==!1&&"undefined"!=typeof console&&console&&(console.warn||console.log)){var c="`"+a+"` is deprecated. See docs for more info:\n https://github.com/zeroclipboard/zeroclipboard/blob/master/docs/instructions.md#deprecations";console.warn?console.warn(c):console.log(c)}},C=function(){var a,b,c,d,e,f,g=arguments[0]||{};for(a=1,b=arguments.length;b>a;a++)if(null!=(c=arguments[a]))for(d in c)if(c.hasOwnProperty(d)){if(e=g[d],f=c[d],g===f)continue;void 0!==f&&(g[d]=f)}return g},D=function(a){if(null==a||""===a)return null;if(a=a.replace(/^\s+|\s+$/g,""),""===a)return null;var b=a.indexOf("//");a=-1===b?a:a.slice(b+2);var c=a.indexOf("/");return a=-1===c?a:-1===b||0===c?null:a.slice(0,c),a&&".swf"===a.slice(-4).toLowerCase()?null:a||null},E=function(){var a=function(a,b){var c,d,e;if(null!=a&&"*"!==b[0]&&("string"==typeof a&&(a=[a]),"object"==typeof a&&"length"in a))for(c=0,d=a.length;d>c;c++)if(a.hasOwnProperty(c)&&(e=D(a[c]))){if("*"===e){b.length=0,b.push("*");break}-1===x(e,b)&&b.push(e)}},b={always:"always",samedomain:"sameDomain",never:"never"};return function(c,d){var e,f=d.allowScriptAccess;if("string"==typeof f&&(e=f.toLowerCase())&&/^always|samedomain|never$/.test(e))return b[e];var g=D(d.moviePath);null===g&&(g=c);var h=[];a(d.trustedOrigins,h),a(d.trustedDomains,h);var i=h.length;if(i>0){if(1===i&&"*"===h[0])return"always";if(-1!==x(c,h))return 1===i&&c===g?"sameDomain":"always"}return"never"}}(),F=function(a){if(null==a)return[];if(Object.keys)return Object.keys(a);var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b},G=function(a){if(a)for(var b in a)a.hasOwnProperty(b)&&delete a[b];return a},H=function(){var a=!1;if("boolean"==typeof d.disabled)a=d.disabled===!1;else{if("function"==typeof ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(a=!0)}catch(b){}!a&&navigator.mimeTypes["application/x-shockwave-flash"]&&(a=!0)}return a},I=function(a,b){return this instanceof I?(this.id=""+f++,g[this.id]={instance:this,elements:[],handlers:{}},a&&this.clip(a),"undefined"!=typeof b&&(B("new ZeroClipboard(elements, options)",L.debug),I.config(b)),this.options=I.config(),"boolean"!=typeof d.disabled&&(d.disabled=!H()),d.disabled===!1&&d.outdated!==!0&&null===d.bridge&&(d.outdated=!1,d.ready=!1,M()),void 0):new I(a,b)};I.prototype.setText=function(a){return a&&""!==a&&(e["text/plain"]=a,d.ready===!0&&d.bridge&&d.bridge.setText(a)),this},I.prototype.setSize=function(a,b){return d.ready===!0&&d.bridge&&d.bridge.setSize(a,b),this};var J=function(a){d.ready===!0&&d.bridge&&d.bridge.setHandCursor(a)};I.prototype.destroy=function(){this.unclip(),this.off(),delete g[this.id]};var K=function(){var a,b,c,d=[],e=F(g);for(a=0,b=e.length;b>a;a++)c=g[e[a]].instance,c&&c instanceof I&&d.push(c);return d};I.version="1.3.2";var L={swfPath:l,trustedDomains:window.location.host?[window.location.host]:[],cacheBust:!0,forceHandCursor:!1,zIndex:999999999,debug:!0,title:null,autoActivate:!0};I.config=function(a){"object"==typeof a&&null!==a&&C(L,a);{if("string"!=typeof a||!a){var b={};for(var c in L)L.hasOwnProperty(c)&&(b[c]="object"==typeof L[c]&&null!==L[c]?"length"in L[c]?L[c].slice(0):C({},L[c]):L[c]);return b}if(L.hasOwnProperty(a))return L[a]}},I.destroy=function(){I.deactivate();for(var a in g)if(g.hasOwnProperty(a)&&g[a]){var b=g[a].instance;b&&"function"==typeof b.destroy&&b.destroy()}var c=N(d.bridge);c&&c.parentNode&&(c.parentNode.removeChild(c),d.ready=null,d.bridge=null)},I.activate=function(a){c&&(s(c,L.hoverClass),s(c,L.activeClass)),c=a,r(a,L.hoverClass),O();var b=L.title||a.getAttribute("title");if(b){var e=N(d.bridge);e&&e.setAttribute("title",b)}var f=L.forceHandCursor===!0||"pointer"===n(a,"cursor");J(f)},I.deactivate=function(){var a=N(d.bridge);a&&(a.style.left="0px",a.style.top="-9999px",a.removeAttribute("title")),c&&(s(c,L.hoverClass),s(c,L.activeClass),c=null)};var M=function(){var a,b,c=document.getElementById("global-zeroclipboard-html-bridge");if(!c){var e=I.config();e.jsModuleId="string"==typeof j&&j||"string"==typeof k&&k||null;var f=E(window.location.host,L),g=w(e),h=L.moviePath+v(L.moviePath,L),i=' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="global-zeroclipboard-flash-bridge" width="100%" height="100%"> <param name="movie" value="'+h+'"/> <param name="allowScriptAccess" value="'+f+'"/> <param name="scale" value="exactfit"/> <param name="loop" value="false"/> <param name="menu" value="false"/> <param name="quality" value="best" /> <param name="bgcolor" value="#ffffff"/> <param name="wmode" value="transparent"/> <param name="flashvars" value="'+g+'"/> <embed src="'+h+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="100%" height="100%" name="global-zeroclipboard-flash-bridge" allowScriptAccess="'+f+'" allowFullScreen="false" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+g+'" scale="exactfit"> </embed> </object>';c=document.createElement("div"),c.id="global-zeroclipboard-html-bridge",c.setAttribute("class","global-zeroclipboard-container"),c.style.position="absolute",c.style.left="0px",c.style.top="-9999px",c.style.width="15px",c.style.height="15px",c.style.zIndex=""+A(L.zIndex),document.body.appendChild(c),c.innerHTML=i}a=document["global-zeroclipboard-flash-bridge"],a&&(b=a.length)&&(a=a[b-1]),d.bridge=a||c.children[0].lastElementChild},N=function(a){for(var b=/^OBJECT|EMBED$/,c=a&&a.parentNode;c&&b.test(c.nodeName)&&c.parentNode;)c=c.parentNode;return c||null},O=function(){if(c){var a=u(c,L.zIndex),b=N(d.bridge);b&&(b.style.top=a.top+"px",b.style.left=a.left+"px",b.style.width=a.width+"px",b.style.height=a.height+"px",b.style.zIndex=a.zIndex+1),d.ready===!0&&d.bridge&&d.bridge.setSize(a.width,a.height)}return this};I.prototype.on=function(a,b){var c,e,f,h={},i=g[this.id]&&g[this.id].handlers;if("string"==typeof a&&a)f=a.toLowerCase().split(/\s+/);else if("object"==typeof a&&a&&"undefined"==typeof b)for(c in a)a.hasOwnProperty(c)&&"string"==typeof c&&c&&"function"==typeof a[c]&&this.on(c,a[c]);if(f&&f.length){for(c=0,e=f.length;e>c;c++)a=f[c].replace(/^on/,""),h[a]=!0,i[a]||(i[a]=[]),i[a].push(b);h.noflash&&d.disabled&&R.call(this,"noflash",{}),h.wrongflash&&d.outdated&&R.call(this,"wrongflash",{flashVersion:d.version}),h.load&&d.ready&&R.call(this,"load",{flashVersion:d.version})}return this},I.prototype.off=function(a,b){var c,d,e,f,h,i=g[this.id]&&g[this.id].handlers;if(0===arguments.length)f=F(i);else if("string"==typeof a&&a)f=a.split(/\s+/);else if("object"==typeof a&&a&&"undefined"==typeof b)for(c in a)a.hasOwnProperty(c)&&"string"==typeof c&&c&&"function"==typeof a[c]&&this.off(c,a[c]);if(f&&f.length)for(c=0,d=f.length;d>c;c++)if(a=f[c].toLowerCase().replace(/^on/,""),h=i[a],h&&h.length)if(b)for(e=x(b,h);-1!==e;)h.splice(e,1),e=x(b,h,e);else i[a].length=0;return this},I.prototype.handlers=function(a){var b,c=null,d=g[this.id]&&g[this.id].handlers;if(d){if("string"==typeof a&&a)return d[a]?d[a].slice(0):null;c={};for(b in d)d.hasOwnProperty(b)&&d[b]&&(c[b]=d[b].slice(0))}return c};var P=function(a,b,c,d){var e=g[this.id]&&g[this.id].handlers[a];if(e&&e.length){var f,h,i,j=b||this;for(f=0,h=e.length;h>f;f++)i=e[f],b=j,"string"==typeof i&&"function"==typeof window[i]&&(i=window[i]),"object"==typeof i&&i&&"function"==typeof i.handleEvent&&(b=i,i=i.handleEvent),"function"==typeof i&&z(i,b,c,d)}return this};I.prototype.clip=function(a){a=y(a);for(var b=0;b<a.length;b++)if(a.hasOwnProperty(b)&&a[b]&&1===a[b].nodeType){a[b].zcClippingId?-1===x(this.id,i[a[b].zcClippingId])&&i[a[b].zcClippingId].push(this.id):(a[b].zcClippingId="zcClippingId_"+h++,i[a[b].zcClippingId]=[this.id],L.autoActivate===!0&&p(a[b],"mouseover",o));var c=g[this.id].elements;-1===x(a[b],c)&&c.push(a[b])}return this},I.prototype.unclip=function(a){var b=g[this.id];if(b){var c,d=b.elements;a="undefined"==typeof a?d.slice(0):y(a);for(var e=a.length;e--;)if(a.hasOwnProperty(e)&&a[e]&&1===a[e].nodeType){for(c=0;-1!==(c=x(a[e],d,c));)d.splice(c,1);var f=i[a[e].zcClippingId];if(f){for(c=0;-1!==(c=x(this.id,f,c));)f.splice(c,1);0===f.length&&(L.autoActivate===!0&&q(a[e],"mouseover",o),delete a[e].zcClippingId)}}}return this},I.prototype.elements=function(){var a=g[this.id];return a&&a.elements?a.elements.slice(0):[]};var Q=function(a){var b,c,d,e,f,h=[];if(a&&1===a.nodeType&&(b=a.zcClippingId)&&i.hasOwnProperty(b)&&(c=i[b],c&&c.length))for(d=0,e=c.length;e>d;d++)f=g[c[d]].instance,f&&f instanceof I&&h.push(f);return h};L.hoverClass="zeroclipboard-is-hover",L.activeClass="zeroclipboard-is-active",L.trustedOrigins=null,L.allowScriptAccess=null,L.useNoCache=!0,L.moviePath="ZeroClipboard.swf",I.detectFlashSupport=function(){return B("ZeroClipboard.detectFlashSupport",L.debug),H()},I.dispatch=function(a,b){if("string"==typeof a&&a){var d=a.toLowerCase().replace(/^on/,"");if(d)for(var e=c?Q(c):K(),f=0,g=e.length;g>f;f++)R.call(e[f],d,b)}},I.prototype.setHandCursor=function(a){return B("ZeroClipboard.prototype.setHandCursor",L.debug),a="boolean"==typeof a?a:!!a,J(a),L.forceHandCursor=a,this},I.prototype.reposition=function(){return B("ZeroClipboard.prototype.reposition",L.debug),O()},I.prototype.receiveEvent=function(a,b){if(B("ZeroClipboard.prototype.receiveEvent",L.debug),"string"==typeof a&&a){var c=a.toLowerCase().replace(/^on/,"");c&&R.call(this,c,b)}},I.prototype.setCurrent=function(a){return B("ZeroClipboard.prototype.setCurrent",L.debug),I.activate(a),this},I.prototype.resetBridge=function(){return B("ZeroClipboard.prototype.resetBridge",L.debug),I.deactivate(),this},I.prototype.setTitle=function(a){if(B("ZeroClipboard.prototype.setTitle",L.debug),a=a||L.title||c&&c.getAttribute("title")){var b=N(d.bridge);b&&b.setAttribute("title",a)}return this},I.setDefaults=function(a){B("ZeroClipboard.setDefaults",L.debug),I.config(a)},I.prototype.addEventListener=function(a,b){return B("ZeroClipboard.prototype.addEventListener",L.debug),this.on(a,b)},I.prototype.removeEventListener=function(a,b){return B("ZeroClipboard.prototype.removeEventListener",L.debug),this.off(a,b)},I.prototype.ready=function(){return B("ZeroClipboard.prototype.ready",L.debug),d.ready===!0};var R=function(f,g){f=f.toLowerCase().replace(/^on/,"");var h=g&&g.flashVersion&&a(g.flashVersion)||null,i=c,j=!0;switch(f){case"load":if(h){if(!b(h))return R.call(this,"onWrongFlash",{flashVersion:h}),void 0;d.outdated=!1,d.ready=!0,d.version=h}break;case"wrongflash":h&&!b(h)&&(d.outdated=!0,d.ready=!1,d.version=h);break;case"mouseover":r(i,L.hoverClass);break;case"mouseout":L.autoActivate===!0&&I.deactivate();break;case"mousedown":r(i,L.activeClass);break;case"mouseup":s(i,L.activeClass);break;case"datarequested":var k=i.getAttribute("data-clipboard-target"),l=k?document.getElementById(k):null;if(l){var m=l.value||l.textContent||l.innerText;m&&this.setText(m)}else{var n=i.getAttribute("data-clipboard-text");n&&this.setText(n)}j=!1;break;case"complete":G(e)}var o=i,p=[this,g];return P.call(this,f,o,p,j)};"function"==typeof define&&define.amd?define(["require","exports","module"],function(a,b,c){return j=c&&c.id||null,I}):"object"==typeof module&&module&&"object"==typeof module.exports&&module.exports?(k=module.id||null,module.exports=I):window.ZeroClipboard=I}(); |