angular.module("alImageService",[]).factory("alPhotos",["$q","svcSettings","alImageUtil",function(a,b,c){var d=[],e=function(a){return angular.isArray(a)&&3==a.length?a[0].numerator/a[0].denominator+a[1].numerator/(60*a[1].denominator)+a[2].numerator/(3600*a[2].denominator):0},f=function(a,b,c,d){var e=b*c/a,f=Math.sqrt(d*e*4/3);return f},g=function(b,d,g,h){var i=a.defer(),j={file:null,blob:null,data:null,name:b.name,type:b.type,org_size:b.size+4e5,height:"*",width:"*",yoko:!0,position:{lat:null,lng:null},exif:null},k=new FileReader;return k.onload=function(){j.data=k.result;var a=new Image;a.onload=function(){EXIF.getData(a,function(){j.exif=EXIF.pretty(this);var b=g,k=EXIF.getTag(this,"PixelXDimension"),l=EXIF.getTag(this,"PixelYDimension");angular.isDefined(k)&&angular.isDefined(l)&&(b=f(j.org_size,k,l,d)),j.position.lat=0==j.exif.length?0:e(EXIF.getTag(this,"GPSLatitude")),j.position.lng=0==j.exif.length?0:e(EXIF.getTag(this,"GPSLongitude")),j.yoko=j.width>j.height,c.getResizedData(a.src,b,h,function(a){j.blob=a.blob,j.data=a.data,j.height=a.height,j.width=a.width,i.resolve(j)})})},a.src=k.result},k.readAsDataURL(b),i.promise};return{all:function(){return d},get:function(a){return a>=0&&a4){var r=g;g=h,h=r}if(n>g||p>h){var s=n/g;s<=p/h&&(s=p/h),n=Math.floor(i.width/s),p=Math.floor(i.height/s)}var t=$(""),u=t[0].getContext("2d");u.save(),m(t,n,p,q);var v=k(i);v&&(b/=2,e/=2);var w=1024,x=$("");x[0].width=x[0].height=w;for(var y=x[0].getContext("2d"),z=l(i,b,e),A=Math.ceil(w*n/b),B=Math.ceil(w*p/e/z),C=0,D=0;Ca.length)break}return c}var b=atob(a.split(",")[1]),c=d(b);return c},k=function(a){var b=a.naturalWidth,c=a.naturalHeight;if(b*c>1048576){var d=$("");d[0].width=d[0].height=1;var e=d[0].getContext("2d");return e.drawImage(a,-b+1,0),0===e.getImageData(0,0,1,1).data[3]}return!1},l=function(a,b,c){var d=$("");d[0].width=1,d[0].height=c;var e=d[0].getContext("2d");e.drawImage(a,0,0);for(var f=e.getImageData(0,0,1,c).data,g=0,h=c,i=c;i>g;){var j=f[4*(i-1)+3];0===j?h=i:g=i,i=h+g>>1}var k=i/c;return 0===k?1:k},m=function(a,b,c,d){d>4?(a[0].width=c,a[0].height=b):(a[0].width=b,a[0].height=c);var e=a[0].getContext("2d");switch(d){case 2:e.translate(b,0),e.scale(-1,1);break;case 3:e.translate(b,c),e.rotate(Math.PI);break;case 4:e.translate(0,c),e.scale(1,-1);break;case 5:e.rotate(.5*Math.PI),e.scale(1,-1);break;case 6:e.rotate(.5*Math.PI),e.translate(0,-c);break;case 7:e.rotate(.5*Math.PI),e.translate(b,-c),e.scale(-1,1);break;case 8:e.rotate(-.5*Math.PI),e.translate(-b,0)}},n=function(a){for(var b=atob(a.split(",")[1]),c=new ArrayBuffer(b.length),d=new Uint8Array(c),e=0;e

 '+b+'

',size:"sm"});return e.result.then(function(){e=null,d.resolve("success")},function(){e=null,d.reject("falt")}),d.promise}function j(b,c){a.open({animation:!0,backdrop:!0,templateUrl:"imageWindow.html",controller:["$scope",function(a){a.images=Lightbox,Lightbox.keyboardNavEnabled=!0}],size:"lg"});$scope.preveImage=function(){}}return{openLoading:e,closeLoading:f,openConfirm:g,openProgress:h,openWarning:i,openImage:j};var d}]).factory("alHistory",["$window",function(a){function b(a){var b=new Date,c={date:b.getFullYear()+"/"+("0"+(b.getMonth()+1)).slice(-2)+"/"+("0"+b.getDate()).slice(-2)+" "+["日","月","火","水","木","金","土"][b.getDay()],time:("0"+b.getHours()).slice(-2)+":"+("0"+b.getMinutes()).slice(-2)+":"+("0"+b.getSeconds()).slice(-2),location:{lat:a.lat,lng:a.lng},name:null,landId:null,landNumber:null,attachmentIds:[],success:!1};return c}function c(){return a.localStorage["al-history"]?JSON.parse(a.localStorage["al-history"]):[]}function d(b){var c=a.localStorage["al-history"]?JSON.parse(a.localStorage["al-history"]):[];c.length>99&&c.splice(0,1),c.push(b),a.localStorage["al-history"]=JSON.stringify(c)}function e(){window.localStorage.removeItem("al-history")}function f(){var b=a.localStorage["al-history"]?JSON.parse(a.localStorage["al-history"]):[];return b.sort(function(a,b){return b.date===a.date?b.time===a.time?0:b.time>a.time?1:-1:b.date>a.date?1:-1}),b}function g(){var b=a.localStorage["al-history"]?JSON.parse(a.localStorage["al-history"]):[];if(0===b.length)return[];b.sort(function(a,b){return b.date===a.date?b.time===a.time?0:b.time>a.time?1:-1:b.date>a.date?1:-1});for(var c=[],d="",e=0;e