mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-07 11:16:43 +08:00
32 lines
15 KiB
JavaScript
32 lines
15 KiB
JavaScript
var goog=goog||{};goog.global=this;goog.exportPath_=function(name,opt_object,opt_objectToExportTo){var parts=name.split(".");var cur=opt_objectToExportTo||goog.global;if(!(parts[0]in cur)&&cur.execScript)cur.execScript("var "+parts[0]);for(var part;parts.length&&(part=parts.shift());)if(!parts.length&&opt_object!==undefined)cur[part]=opt_object;else if(cur[part])cur=cur[part];else cur=cur[part]={}};
|
|
goog.exportSymbol=function(publicPath,object,opt_objectToExportTo){goog.exportPath_(publicPath,object,opt_objectToExportTo)};goog.exportProperty=function(object,publicName,symbol){object[publicName]=symbol};function aa(l){l&&l.preventDefault?l.preventDefault():window.event&&(window.event.returnValue=!1)}function ba(l){l&&l.stopPropagation?l.stopPropagation():window.event&&(window.event.cancelBubble=!0)}
|
|
function m(l){function L(){var a=n.getBoundingClientRect().width,b=n.getBoundingClientRect().height;n.width=a*p;n.height=b*p;f.scale(p,p);n.style.backgroundColor=n.style.backgroundColor}function I(a,b,c){window.getSelection()?window.getSelection().removeAllRanges():document.selection.empty();f.save();f.moveTo(a,b);F=G/2*(B/320);N&&(J(document,"mousemove",N),J(document,"touchmove",N),J(document,"mouseup",M),J(document,"touchend",M));"touchstart"==c?(O(document,"touchmove",N),O(document,"touchend",
|
|
M)):(O(document,"mousemove",N),O(document,"mouseup",M));x=null;R(a,b)}function R(a,b){var c,d;if(u.length&&(c=u[u.length-1],d=Math.sqrt((c.x-a)*(c.x-a)+(c.y-b)*(c.y-b)),!d))return;ka++;navigator.userAgent.match(/ OS (\d+).*? Mac OS/)&&!ca&&2==u.length&&4*c<u[1].a&&(u[0].x-=2/3*(u[0].x-u[1].x),u[0].y-=2/3*(u[0].y-u[1].y),u[1].a/=2/3*u[1].a);c={x:a,y:b,a:d};u.push(c);3<=u.length&&(c=u.shift(),la(c))}function la(a,b){var c=a.x,d=a.y,g=a.a;if(!x||0!==g){var H=u.length?u[0]:null;if(g&&x){f.moveTo(x.x,
|
|
x.y);var h;!ca&&H&&g>3*H.a&&(g/=4,h=1);ca=1;b||(b=ma(g));X=b;if(h)for(h=1;3>=h;h++)na(c+h/3*(x.x-c),d+h/3*(x.y-d),g)}na(c,d,g);x=a}}function ma(a){var b=B/320*G;return.65*(a<.003125*B?1.2*b:a<.00625*B?1.15*b:a<.009375*B?1.1*b:a<.015625*B?1.05*b:a<.021875*B?b:a<.028125*B?.95*b:a<.034375*B?.9*b:a<.046875*B?.85*b:a<.0625*B?.8*b:.75*b)}function na(a,b,c){var d={x:a,y:b},g=F;f.fillStyle=C;f.strokeStyle=C;if(x){a=Math.floor(Math.abs(c)/(F/3));if(1<a)for(g=F,c=0;c<a;c++)g-=(g-X)/(8<a?a:8);else Math.abs(F-
|
|
X)>B/320*G*.025&&(g=F-(F-X)/8);a=Math.abs(F-g);1<=a&&(g=F>g?g+.4*a:g-.4*a);a=null;if(0<u.length){a=u[0];b=ta;var H=a.x-x.x,h=a.y-x.y,e=oa(x,d),A=oa(d,a),k=e+A;a=0==e||0==A||(d.x-x.x)/(d.y-x.y)==(d.x-a.x)/(d.y-a.y)?null:[{x:d.x-H*b*e/k,y:d.y-h*b*e/k},{x:d.x+H*b*A/k,y:d.y+h*b*A/k}]}b=[x];if(P||a){H=a?a[0]:d;P=null==P?x:P;h=x;e=P;c/=2*g;A=[];for(k=0;k<c;k++){var n=(k+1)/(c+1),v,r,l,p,y,t,q,w;l=3*(e.x-h.x);r=3*(H.x-e.x)-l;v=d.x-h.x-l-r;t=3*(e.y-h.y);y=3*(H.y-e.y)-t;p=d.y-h.y-t-y;q=n*n;w=q*n;A.push({x:v*
|
|
w+r*q+l*n+h.x,y:p*w+y*q+t*n+h.y})}b=b.concat(A)}b.push(d);d=b;b=F;H=g;A=b;for(h=1;h<d.length;h++)e=(H-b)/(d.length-1)+A,y=d[h-1],c=d[h],k=e,l=A*Math.sin(Math.atan((c.y-y.y)/(c.x-y.x))),t=A*Math.cos(Math.atan((c.y-y.y)/(c.x-y.x))),p=k*Math.sin(Math.atan((c.y-y.y)/(c.x-y.x))),r=k*Math.cos(Math.atan((c.y-y.y)/(c.x-y.x))),n=y.x+l,v=y.y-t,l=y.x-l,y=y.y+t,t=c.x+p,q=c.y-r,p=c.x-p,r=c.y+r,f.beginPath(),f.moveTo(n,v),f.lineTo(t,q),f.lineTo(p,r),f.lineTo(l,y),f.lineTo(n,v),f.fill(),f.closePath(),f.lineWidth=
|
|
A,f.beginPath(),f.arc(c.x,c.y,k,0,2*Math.PI),f.fill(),f.closePath(),A=e;f.lineWidth=F=g;!a||1>=a.length?P=null:P=a[1]}else 2<=u.length&&((g=u[1].a)&&(F=ma(g)),F+=2),f.beginPath(),f.fillStyle=C,f.arc(a,b,F,0,2*Math.PI),f.fill(),f.closePath()}function oa(a,b){return Math.sqrt(Math.pow(b.x-a.x,2)+Math.pow(b.y-a.y,2))}function Q(){D&&M(null)}function da(a){aa(a);ba(a);Q();if("edit"===w){var b,c;if("touchstart"==a.type){if(2<=a.touches.length)return;b=a.touches[0].pageX;c=a.touches[0].pageY;J(n,"mousedown",
|
|
da)}else a.pageX?(b=a.pageX,c=a.pageY):(b=a.clientX,c=a.clientY);pa()||(canvasRect=n.getBoundingClientRect(),canvasRect={left:canvasRect.left+(window.scrollX||window.pageXOffset),top:canvasRect.top+(window.scrollY||window.pageYOffset)},b-=canvasRect.left,c-=canvasRect.top,D={time:new Date,points:[{x:b,y:c,t:0}],color:C,penSize:G},I(b,c,a.type))}}function N(a){aa(a);ba(a);if("edit"===w){var b;if("touchmove"==a.type){if(2<=a.touches.length)return;b=a.touches[0].pageX;a=a.touches[0].pageY}else a.pageX?
|
|
(b=a.pageX,a=a.pageY):(b=a.clientX,a=a.clientY);b-=canvasRect.left;a-=canvasRect.top;pa()?M(null):(D.points.push({x:b,y:a,t:new Date-D.time}),R(b,a))}}function M(a){aa(a);ba(a);"edit"===w&&(U(),k.length?D.time-=qa:(qa=D.time,D.time=D.time.getTime()),k.push(D),S=null,V=[],D=null)}function pa(){var a=0;D&&(a+=D.points.length);for(var b=0;b<k.length;b++)a+=k[b].points.length;return a>ua?!0:!1}function ea(){"play"==w&&(w=Y,clearTimeout(T),W());"edit"===w&&(x=null,e=[-1,-1,-1,-1],ka=0,k.length&&(S=k),
|
|
k=[],f.beginPath(),f.clearRect(0,0,n.width,n.height),f.closePath())}function U(){J(document,"mousemove",N);J(document,"touchmove",N);J(document,"mouseup",M);J(document,"touchend",M);for(var a;u.length;)a=u.shift(),la(a,B/320*G/8)}function ra(){function a(){C=b;G=c;K>=k.length?w=Y:(clearTimeout(T),T=setTimeout(function(){ra()},300))}var b=C,c=G,d=k[K];if(d&&"play"==w){C=d.color;G=d.penSize;I(d.points[0].x,d.points[0].y);1==d.points.length&&(U(),a());var g=1,e,h=0;e=d.points[g];(function(){e&&(R(e.x,
|
|
e.y),g>=d.points.length-1&&(U(),a()),g++,e=d.points[g])&&(clearTimeout(T),T=setTimeout(arguments.callee,e.t-h),h=e.t)})();K++}}function W(){function a(){C=b;G=c;K>=k.length&&(w="edit")}var b=C,c=G;f.clearRect(0,0,n.width,n.height);f.beginPath();K=0;for(var d=k[K];d;){C=d.color;G=d.penSize;I(d.points[0].x,d.points[0].y);1==d.points.length&&(U(),a());for(var g=1,e=1;g<d.points.length;g++){var h=d.points[e];e++;R(h.x,h.y);e>=d.points.length&&(U(),a())}K++;d=k[K]}}function fa(a,b,c,d){a.height=d;a.width=
|
|
c;a.style.height=d/p+"px";a.style.width=c/p+"px";b.scale(p,p)}function sa(a,b){q+="getWritingRect start \n";e=[-1,-1,-1,-1];for(var c=0;c<k.length;c++)for(var d=0;d<k[c].points.length;d++){var g=k[c].points[d],H=g.x,g=g.y,h=0>H-16?0:H-16,f=0>g-16?0:g-16;e[0]=0>e[0]?h:e[0];e[0]=e[0]>h?h:e[0];e[1]=e[1]<H+16?H+16:e[1];e[2]=0>e[2]?f:e[2];e[2]=e[2]>f?f:e[2];e[3]=e[3]<g+16?g+16:e[3]}q+="writingRect[0][1][2][3] = "+e[0]+"*"+e[1]+"*"+e[2]+"*"+e[3]+"*\n";e[1]=e[1]>a?a:e[1];e[3]=e[3]>b?b:e[3];for(c=0;c<e.length;c++)e[c]*=
|
|
p;q+="getWritingRect end \n"}function O(a,b,c){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener(b,c,{passive:!1})}function J(a,b,c){a.detachEvent?a.detachEvent("on"+b,c):a.removeEventListener(b,c,{passive:!1})}function ga(a){var b=[];if(!a)return b;for(var c=0;c<a.length;c++){var d=ha(a.charCodeAt(c));b.push.apply(b,d)}return b}function ha(a){if(0>a)return null;var b=Math.floor(a/4294967295);a%=4294967295;var c=[],d=[];if(b){do c.push(b&255),b>>>=8;while(b);d.push.apply(d,c.reverse())}c=
|
|
[];do c.push(a&255),a>>>=8;while(a);d.push.apply(d,c.reverse());return d}function t(a){if(!a||0==a.length)return null;var b=4<a.length?a.slice(0,a.length-4):[];a=4<a.length?a.slice(a.length-4,a.length):a;for(var c=0,d=b.length-1;0<=d;d--)c|=(b[d]&255)<<8*(b.length-1-d);b=0;for(d=a.length-1;0<=d;d--)b|=(a[d]&255)<<8*(a.length-1-d);return 4294967295*c+b}function ia(a){if(!a||0==a.length)return null;var b=a[0]&128;128==b&&(a[0]^=128);a=t(a);128==b&&(a=-a);return a}function Z(a){if(!a||4!=a.length)return null;
|
|
var b=new ArrayBuffer(4),c=new DataView(b);a.forEach(function(a,b){c.setUint8(b,a)});return c.getFloat32(0)}function ja(a){var b=new Float32Array(1);(new DataView(b.buffer)).setFloat32(0,a,!1);return new Int8Array(b.buffer)}function v(a,b,c){return!a||c>a.S||0>b?null:a.slice(b,c)}function z(a,b){var c=[],d=ha(a);if(null==d)return null;if(d.length>b){for(var g=0;g<b;g++)c.push(255);return c}for(g=d.length;g<b;g++)c.push(0);c.push.apply(c,d);return c}var n=null;if(l.nodeType)n=l;else if("string"==typeof l)n=
|
|
document.getElementById(l);else return;(function(a,b,c){document.addEventListener?a.addEventListener(b,c,!1):document.attachEvent&&a.attachEvent("on"+b,c)})(window,"resize",function(){q+="[window-resize function] start \n";var a=n.getBoundingClientRect().width*p/n.width,b=n.getBoundingClientRect().height*p/n.height;.9<=a&&1.1>=a&&.9<=b&&1.1>=b||(L(),q+="[window-resize canvas.width + canvas.height] ="+n.width/p+"_"+n.height/p,ea(),q+="[window-resize function] end \n")});var p=(window.devicePixelRatio||
|
|
1)/1,k=[],V=[],F=1,X=1,C="rgb(0,0,0)",G=8,B=320,ka=0,D=null,S=null,w="edit",e=[-1,-1,-1,-1],ta=.4,x=null,P=null,u=[],ca=0,qa=null,K=0,Y="edit",T=null,f=n.getContext("2d"),ua=5E4,q="";(function(){L();ea();n.getContext&&(f.strokeStyle=C,f.fillStyle=C,O(n,"selectstart",function(){return!1}),O(n,"touchstart",da),O(n,"mousedown",da))})();this.C=function(){for(var a="4.5.0.3";0<=a.indexOf(".");)a=a.replace(".","");return z(parseInt(a),2)};this.j=function(a){var b=a.match(/(\d+)/g);a=[];if(b)for(var c=0;c<
|
|
b.length;c++)a.push.apply(a,ha(b[c]));for(b=a.length;3>b;b++)a.push(0);return a};this.c=function(a){G=1==a&&18||2==a&&12||3==a&&8||4==a&&6||5==a&&3||8};this.R=function(a,b,c){C="rgb("+a+","+b+","+c+")"};this.g=function(){Q();return!!V.length};this.f=function(){Q();if("edit"===w)if(S&&S.length)k=S,S=null,W();else if(k.length){var a=k.pop();V.push([a]);W()}};this.L=function(){Q();"edit"===w&&V.length&&(k=k.concat(V.pop()),W())};this.O=function(){Q();0!=k.length&&("play"==w?(w=Y,clearTimeout(T),W()):
|
|
(Y=w,w="play",f.clearRect(0,0,n.width,n.height),f.beginPath(),K=0,ra()))};this.D=function(){return 0!=k.length&&"play"==w?!0:!1};this.h=function(){q+="_clear start \n";ea();q+="_clear end \n"};this.l=function(){Q();q+="_getHandWritingData start \n";if(0>=k.length)return null;var a=navigator.userAgent.match(/\([^\)]*\)[^\(]*\([^\)]*\)\s(.*)/);a&&0<a.length&&(a=a[1]);var b=navigator.userAgent.match(/\(([^\)]*)\)/);b&&0<b.length&&(b=b[1]);var c=[],d=this.C(),a=ga(a),g=ga(b),b=ga(""),e=6+a.length+
|
|
2+g.length+2+6+2+b.length;c.push.apply(c,d);c.push.apply(c,z(e,2));c.push.apply(c,z(a.length,2));c.push.apply(c,a);c.push.apply(c,z(g.length,2));c.push.apply(c,g);d=z(k.length,2);c.push.apply(c,d);d=z(0<k.length?k[0].time:0,6);c.push.apply(c,d);c.push.apply(c,z(b.length,2));c.push.apply(c,b);for(d=0;d<k.length;d++){a=[1,4,1,2,4,1,3,2,0];b=z(k[d].points.length,2);c.push.apply(c,z(a.length+9+b.length+4+4,1));c.push.apply(c,z(a.length,1));c.push.apply(c,a);a=d?z(k[d].time,3):z(0,3);c.push.apply(c,a);
|
|
a=this.j(k[d].color);c.push.apply(c,a);c.push.apply(c,z(b.length,1));c.push.apply(c,b);b=ja(parseFloat(k[d].penSize));c.push.apply(c,b);c.push.apply(c,b);b=[];a=[];g=[];for(e=0;e<k[d].points.length;e++){var h=k[d].points[e],f,A;f=h.x;A=h.y;h=h.t||0;f=ja(f);b.push.apply(b,f);A=ja(A);a.push.apply(a,A);A=h;(h=z(Math.abs(A),2))&&0!=h.length?(0>A&&(h[0]|=128),A=h):A=null;g.push.apply(g,A)}c.push.apply(c,b);c.push.apply(c,a);c.push.apply(c,g)}q+="_getHandWritingData end \n";return c};this.b=function(){Q();
|
|
q+="_getHandWritingPng start \n";if(0>=k.length)return null;sa(f.canvas.width,f.canvas.height);for(var a=f.getImageData(e[0],e[2],e[1]-e[0],e[3]-e[2]),b,c=b=0;c<a.data.length;c++)void 0!==a.data[c+3]&&0!==a.data[c+3]&&b++;q+="_getHandWritingPng imageLength \uff1a"+b;if(4>b)return null;q+="_getHandWritingPng end(callback == null) \n";q+="convertImgToBase64URL start \n";b=document.createElement("CANVAS");ctx=b.getContext("2d");fa(b,ctx,a.width,a.height);ctx.putImageData(a,0,0);dataURL=b.toDataURL("image/png");
|
|
q+="convertImgToBase64URL end \n";return dataURL};this.w=function(a,b,c){if(!(0>=a||0>=b)){var d=this.b();if(2!==(d?d.split(","):"").length)c?c(null):null;else{sa(f.canvas.width,f.canvas.height);var g=[e[1]-e[0],e[3]-e[2]],k=document.createElement("CANVAS"),h=k.getContext("2d");fa(k,h,a,b);var n=new Image;n.src=d;n.onload=function(){var d,e,f,l;g[0]>Math.round(a/b*g[1])?(f=a,l=Math.round(g[1]/g[0]*a),d=0,e=Math.round((b-l)/2)):(l=b,f=Math.round(g[0]/g[1]*b),d=Math.round((a-f)/2),e=0);h.drawImage(n,
|
|
d/p,e/p,f/p,l/p);d=k.toDataURL("image/png");c?c(d):null}}}};this.F=function(a,b,c,d){if(!(0>=a||0>=b||0>=c.length)){var e=document.createElement("CANVAS"),f=e.getContext("2d");fa(e,f,a,b);a=Math.floor(a/d);b=Math.floor(b/Math.ceil(c.length/d));for(var h=1;h<=c.length;h++)f.drawImage(c[h-1],(h-1)%d*a/p,(Math.ceil(h/d)*b-b)/p,a/p,b/p);return e.toDataURL("image/png")}};this.A=function(){var a=q+="userAgent \u4fe1\u606f:"+navigator.userAgent+"\n";q="";return a};this.H=function(a){if(a){var b=0,c=t(v(a,
|
|
b,2)),d=0;4101<c?(d=t(v(a,b+2,b+4)),b+=4):b+=2;var e=t(v(a,b,b+2)),b=b+2+e,f=t(v(a,b,b+2)),b=b+2+f,h=t(v(a,b,b+2)),n=t(v(a,b+2,b+2+6)),b=b+2+6;4101<c&&(b=d);if(null!==c&&null!==e&&null!==f&&null!==h&&null!==n&&0!=h){this.clear();for(d=0;d<h;d++){var l=0,e=[],f=[],p=[];if(4101<c){for(var u=b,l=t(v(a,b,b+1)),q=t(v(a,b+1,b+1+1)),b=b+1+1,r=0;r<Math.floor(q/3);r++)e.push(t(v(a,b+3*r,b+3*r+1))),f.push(t(v(a,b+3*r+1,b+3*r+2))),p.push(t(v(a,b+3*r+2,b+3*r+3)));b+=q}var q=t(v(a,b,b+3)),b=b+3,w=t(v(a,b,b+1)),
|
|
x=t(v(a,b+1,b+2)),y=t(v(a,b+2,b+3)),F="rgb("+w+","+x+","+y+")",b=b+3,z,B;4101<c?(z=t(v(a,b,b+1)),B=t(v(a,b+1,b+1+z)),b=b+1+z,z=Math.round(Z(v(a,b,b+4))),3>z?z=3:18<z&&(z=18),b=u+l):(e.push.apply(e,[1,2,3]),f.push.apply(f,[2,2,2]),p.push.apply(p,[0,0,0]),z=t(v(a,b,b+1)),B=t(v(a,b+1,b+3)),b+=3);for(var C=-1,D=-1,l=-1,r=0;r<e.length;r++)1==e[r]?C=r:2==e[r]?D=r:3==e[r]&&(l=r);if(null===q||null===w||null===x||null===y||null===B||-1==C||-1==D||-1==l)return;r||(q=n);for(var r=[],w=[],x=[],y=[],E=0;E<B;){var G=
|
|
v(a,b,b+f[C]);0==p[C]?w.push(ia(G)):w.push(Z(G));E++;b+=f[C]}for(E=0;E<B;)C=v(a,b,b+f[D]),0==p[D]?x.push(ia(C)):x.push(Z(C)),E++,b+=f[D];for(E=0;E<B;)D=v(a,b,b+f[l]),0==p[l]?y.push(ia(D)):y.push(Z(D)),E++,b+=f[l];for(E=0;E<e.length;E++)1!=e[E]&&2!=e[E]&&3!=e[E]&&(b+=f[E]*B);for(E=0;E<B;E++)r.push({x:w[E],y:x[E],t:y[E]});k.push({time:q,points:r,color:F,penSize:z})}replay()}}}}goog.exportSymbol("EPaper",m);m.prototype.N=function(l){this.c(l)};goog.exportProperty(m.prototype,"setPenSize",m.prototype.N);
|
|
m.prototype.M=function(l,L,I){this.R(l,L,I)};goog.exportProperty(m.prototype,"setPenColor",m.prototype.M);m.prototype.i=function(){return this.g()};goog.exportProperty(m.prototype,"canRedo",m.prototype.i);m.prototype.P=function(){this.f()};goog.exportProperty(m.prototype,"undo",m.prototype.P);m.prototype.J=function(){this.L()};goog.exportProperty(m.prototype,"redo",m.prototype.J);m.prototype.K=function(){this.O()};goog.exportProperty(m.prototype,"replay",m.prototype.K);m.prototype.B=function(){return this.D()};
|
|
goog.exportProperty(m.prototype,"isReplaying",m.prototype.B);m.prototype.clear=function(){this.h()};goog.exportProperty(m.prototype,"clear",m.prototype.clear);m.prototype.m=function(){return this.l()};goog.exportProperty(m.prototype,"getHandWritingData",m.prototype.m);m.prototype.s=function(){return this.b()};goog.exportProperty(m.prototype,"getHandWritingPng",m.prototype.s);m.prototype.o=function(l,L,I){this.w(l,L,I)};goog.exportProperty(m.prototype,"getHandWritingMaskedPng",m.prototype.o);
|
|
m.prototype.G=function(l,L,I,R){return this.F(l,L,I,R)};goog.exportProperty(m.prototype,"mergePngsInDesignatedSize",m.prototype.G);m.prototype.I=function(l){this.H(l)};goog.exportProperty(m.prototype,"playWithData",m.prototype.I);m.prototype.u=function(){return this.A()};goog.exportProperty(m.prototype,"getLogInfo",m.prototype.u);m.prototype.v=function(){return"4.5.0.3"};goog.exportProperty(m.prototype,"getVersion",m.prototype.v);
|