diff --git a/index.js b/index.js index 36c002f..f777c1a 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -(function () {function z(e,t){var a=(t=t||{}).debug,r=e.width,$=e.height,n=e.getContext("2d"),g=n.getImageData(0,0,r,$),i=n.createImageData(r,$);b([[0,-1,0],[-1,4,-1],[0,-1,0]]).width(r).height($).apply(g,i),a&&(e.width*=2,n.putImageData(i,0,0));var o=A(i.data,r,$);return a&&(q(o,n),n.translate(r,0),n.putImageData(g,r,0),q(o,n)),w(o).midpoint()}function q(e,t){for(var a=0;aa.intensity&&(a=t);return a}function A(e,t,a){var r=[],$=t/2,n=a/2;function g(e,t){return e=Math.abs(e-$)/$,t=Math.abs(t-n)/n,1-((e/=2)+(t/=2))}for(var i=0;ir.intensity&&(r=e);return r}function R(t,e,r){var a=[],i=20,n=e/2,h=r/2;function f(I,M){return I=Math.abs(I-n)/n,M=Math.abs(M-h)/h,I/=2,M/=2,1-(I+M)}for(var o=0;o!a.filter((o,s)=>o.filename==n.filename).length);if(!i.length)return!1;FileReader&&this.findFocus(i)}}},methods:{findFocus(r){r.forEach(a=>{let i=this;var n=new XMLHttpRequest;n.open("get",a.url),n.responseType="blob",n.onload=function(){var h=new FileReader;h.onload=function(){var f=document.createElement("canvas"),o=f.getContext("2d"),s=new Image;s.onload=function(){var p=s.width,g=s.height;f.width=p,f.height=g,o.drawImage(s,0,0);var v=P(f,{debug:!1}),l=v.x/p,u=v.y/g,l=(Math.round(l*100)/100).toFixed(2),u=(Math.round(u*100)/100).toFixed(2),c='{"x":'+l+',"y":'+u+"}";i.saveFocus(a,c)},s.src=h.result},h.readAsDataURL(n.response)},n.send()})},saveFocus(r,a){this.$api.post("autofocus/save-focus",{uri:r.parent,filename:r.filename,coords:a}).then(i=>{}).catch(i=>{console.log(i)})}}})}panel.plugin("sylvainjule/autofocus",{use:[C]})})(); diff --git a/package.json b/package.json index 65cbfdc..1380b76 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,17 @@ "author": "Sylvain Julé", "license": "MIT", "scripts": { - "dev": "parcel watch src/index.js --no-source-maps -d ./", - "build": "parcel build src/index.js --no-source-maps --experimental-scope-hoisting -d ./" + "dev": "kirbyup src/index.js --watch", + "build": "kirbyup src/index.js", + "lint": "eslint \"src/**/*.{js,vue}\"", + "lint:fix": "npm run lint -- --fix", + "format": "prettier --write \"src/**/*.{css,js,vue}\"" }, - "posthtml": { - "recognizeSelfClosing": true + "devDependencies": { + "eslint": "^8.2.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-vue": "^8.0.3", + "kirbyup": "^0.21.0", + "prettier": "^2.4.1" } }