Salve,
Capisco.....cercherò di darvi qualche informazione in più.
Vi allego:
1) Custom Function
2) risultato della custom nel DB originale
3) Risultato della custom nel mio B (Non funziona).
1) C.F.
Codice: Seleziona tutto
// FMEasySignature v1.0
// http://fmeasysignature.com/
// Developed by Tim Dietrich and provided under an open source license.
// Uses "Signature Pad v1.3.3" by Szymon Nowak. https://github.com/szimek/signature_pad
// Signature Pad is (c) 2014 Szymon Nowak. Released under the MIT license. http://opensource.org/licenses/MIT
Dichiara ( [
// Settings.
// backgroundColor: Color used for the background, as an RGB value. Example: rgb(255, 255, 255)
backgroundColor = "rgb(255, 255, 255)";
// minWidth: Minimum width of a line. Recommended: .5
minWidth = .5;
// maxWidth: Maximum width of a line. Recommended: 2.5
maxWidth = 2.5;
// penColor: Color used for the pen, as an RGB value. Example: rgb(0, 0, 255)
penColor = "rgb(0, 0, 255)"; // Color used for the pen, as an RGB value. Example: rgb(0, 0, 255)
// instructions: Optional instructions, displayed between the save and clear buttons.
instructions = "Please sign above.";
// fmpurl: FMP URL to use when the "Save" button is clicked. Example: fmp://$/FMEasySignature.fmp12?script=Example - Save Signature to Container
//fmpurl = "fmp://$/FMEasySignature.fmp12?script=FMP URL Handler - Save Signature to Container" // FMPURL to use when the "Save" button is clicked.
//Added to compute filename automatically
fmpurl = "fmp://$/"&Dashboard::NomeFileperfirma&"?script=FMP URL Handler - Save Signature to Container" // FMPURL to use when the "Save" button is clicked.
];
// HTML / Javascript template.
"data:text/html,<!doctype html>
¶<html lang=\"en\">
¶ <head>
¶ <meta charset=\"utf-8\">
¶ <title>FM EasySignature v1.0</title>
¶ <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no\">
¶ <meta name=\"apple-mobile-web-app-capable\" content=\"yes\">
¶ <meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black\">
¶ <script type=\"text/javascript\">
¶ // Signature Pad v1.3.3 | https://github.com/szimek/signature_pad
¶ // (c) 2014 Szymon Nowak | Released under the MIT license
¶ var SignaturePad=function(a){\"use strict\";var b=function(a,b){var c=b||{};this.velocityFilterWeight=c.velocityFilterWeight||.7,this.minWidth=c.minWidth||.5,this.maxWidth=c.maxWidth||2.5,this.dotSize=c.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=c.penColor||\"black\",this.backgroundColor=c.backgroundColor||\"rgba(0,0,0,0)\",this.onEnd=c.onEnd,this.onBegin=c.onBegin,this._canvas=a,this._ctx=a.getContext(\"2d\"),this.clear(),this._handleMouseEvents(),this._handleTouchEvents()};b.prototype.clear=function(){var a=this._ctx,b=this._canvas;a.fillStyle=this.backgroundColor,a.clearRect(0,0,b.width,b.height),a.fillRect(0,0,b.width,b.height),this._reset()},b.prototype.toDataURL=function(){var a=this._canvas;return a.toDataURL.apply(a,arguments)},b.prototype.fromDataURL=function(a){var b=this,c=new Image,d=window.devicePixelWidth||1,e=this._canvas.width/d,f=this._canvas.height/d;this._reset(),c.src=a,c.onload=function(){b._ctx.drawImage(c,0,0,e,f)},this._isEmpty=!1},b.prototype._strokeUpdate=function(a){var b=this._createPoint(a);this._addPoint(b)},b.prototype._strokeBegin=function(a){this._reset(),this._strokeUpdate(a),\"function\"==typeof this.onBegin&&this.onBegin(a)},b.prototype._strokeDraw=function(a){var b=this._ctx,c=\"function\"==typeof this.dotSize?this.dotSize():this.dotSize;b.beginPath(),this._drawPoint(a.x,a.y,c),b.closePath(),b.fill()},b.prototype._strokeEnd=function(a){var b=this.points.length>2,c=this.points[0];!b&&c&&this._strokeDraw(c),\"function\"==typeof this.onEnd&&this.onEnd(a)},b.prototype._handleMouseEvents=function(){var b=this;this._mouseButtonDown=!1,this._canvas.addEventListener(\"mousedown\",function(a){1===a.which&&(b._mouseButtonDown=!0,b._strokeBegin(a))}),this._canvas.addEventListener(\"mousemove\",function(a){b._mouseButtonDown&&b._strokeUpdate(a)}),a.addEventListener(\"mouseup\",function(a){1===a.which&&b._mouseButtonDown&&(b._mouseButtonDown=!1,b._strokeEnd(a))})},b.prototype._handleTouchEvents=function(){var b=this;this._canvas.style.msTouchAction=\"none\",this._canvas.addEventListener(\"touchstart\",function(a){var c=a.changedTouches[0];b._strokeBegin(c)}),this._canvas.addEventListener(\"touchmove\",function(a){a.preventDefault();var c=a.changedTouches[0];b._strokeUpdate(c)}),a.addEventListener(\"touchend\",function(a){var c=a.target===b._canvas;c&&b._strokeEnd(a)})},b.prototype.isEmpty=function(){return this._isEmpty},b.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._isEmpty=!0,this._ctx.fillStyle=this.penColor},b.prototype._createPoint=function(a){var b=this._canvas.getBoundingClientRect();return new c(a.clientX-b.left,a.clientY-b.top)},b.prototype._addPoint=function(a){var b,c,e,f,g=this.points;g.push(a),g.length>2&&(3===g.length&&g.unshift(g[0]),f=this._calculateCurveControlPoints(g[0],g[1],g[2]),b=f.c2,f=this._calculateCurveControlPoints(g[1],g[2],g[3]),c=f.c1,e=new d(g[1],b,c,g[2]),this._addCurve(e),g.shift())},b.prototype._calculateCurveControlPoints=function(a,b,d){var e=a.x-b.x,f=a.y-b.y,g=b.x-d.x,h=b.y-d.y,i={x:(a.x+b.x)/2,y:(a.y+b.y)/2},j={x:(b.x+d.x)/2,y:(b.y+d.y)/2},k=Math.sqrt(e*e+f*f),l=Math.sqrt(g*g+h*h),m=i.x-j.x,n=i.y-j.y,o=l/(k+l),p={x:j.x+m*o,y:j.y+n*o},q=b.x-p.x,r=b.y-p.y;return{c1:new c(i.x+q,i.y+r),c2:new c(j.x+q,j.y+r)}},b.prototype._addCurve=function(a){var b,c,d=a.startPoint,e=a.endPoint;b=e.velocityFrom(d),b=this.velocityFilterWeight*b+(1-this.velocityFilterWeight)*this._lastVelocity,c=this._strokeWidth(b),this._drawCurve(a,this._lastWidth,c),this._lastVelocity=b,this._lastWidth=c},b.prototype._drawPoint=function(a,b,c){var d=this._ctx;d.moveTo(a,b),d.arc(a,b,c,0,2*Math.PI,!1),this._isEmpty=!1},b.prototype._drawCurve=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o=this._ctx,p=c-b;for(d=Math.floor(a.length()),o.beginPath(),f=0;d>f;f++)g=f/d,h=g*g,i=h*g,j=1-g,k=j*j,l=k*j,m=l*a.startPoint.x,m+=3*k*g*a.control1.x,m+=3*j*h*a.control2.x,m+=i*a.endPoint.x,n=l*a.startPoint.y,n+=3*k*g*a.control1.y,n+=3*j*h*a.control2.y,n+=i*a.endPoint.y,e=b+i*p,this._drawPoint(m,n,e);o.closePath(),o.fill()},b.prototype._strokeWidth=function(a){return Math.max(this.maxWidth/(a+1),this.minWidth)};var c=function(a,b,c){this.x=a,this.y=b,this.time=c||(new Date).getTime()};c.prototype.velocityFrom=function(a){return this.time!==a.time?this.distanceTo(a)/(this.time-a.time):1},c.prototype.distanceTo=function(a){return Math.sqrt(Math.pow(this.x-a.x,2)+Math.pow(this.y-a.y,2))};var d=function(a,b,c,d){this.startPoint=a,this.control1=b,this.control2=c,this.endPoint=d};return d.prototype.length=function(){var a,b,c,d,e,f,g,h,i=10,j=0;for(a=0;i>=a;a++)b=a/i,c=this._point(b,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),d=this._point(b,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y),a>0&&(g=c-e,h=d-f,j+=Math.sqrt(g*g+h*h)),e=c,f=d;return j},d.prototype._point=function(a,b,c,d,e){return b*(1-a)*(1-a)*(1-a)+3*c*(1-a)*(1-a)*a+3*d*(1-a)*a*a+e*a*a*a},b}(document);
¶ </script>
¶ </head>
¶
¶ <body
¶ onselectstart=\"return false\"
¶ style=\"
¶ height:100%;
¶ background: #fff;
¶ margin: 0;
¶ text-align: center;
¶ font-family: Helvetica, Sans-Serif;
¶ -moz-user-select: none;
¶ -webkit-user-select: none;
¶ -ms-user-select: none;\">
¶
¶ <div style=\"height: 100vh; width: 100vw;\">
¶
¶ <!-- Signature canvas. -->
¶ <canvas
¶ id=\"easycanvas\"
¶ style=\"
¶ background : #fff;
¶ width: 98%;
¶ height: 70%;
¶ border: solid thin #ccc;
¶ border-radius: 8px;
¶ margin: 3px;\"></canvas>
¶
¶ <!-- Clear and Save buttons -->
¶ <div style=\"text-align: center; font-size: 9pt;\">
¶ <button id=\"clear-button\" data-action=\"clear\" style=\"margin-right: 20px; font-size: 9pt; padding: 4px;\">Clear</button>
¶ " & instructions & "
¶ <button id=\"save-button\" data-action=\"save\" style=\"margin-left: 20px; font-size: 9pt; padding: 4px;\">Save</button>
¶ </div>
¶
¶ </div>
¶
¶ <script type=\"text/javascript\">
¶
¶ // Get the canvas.
¶ var canvas = document.getElementById(\"easycanvas\");
¶
¶ // Adjust canvas coordinate space taking into account pixel ratio,
¶ // to make it look crisp on mobile devices.
¶ // This also causes canvas to be cleared.
¶ function resizeCanvas() {
¶ var ratio = window.devicePixelRatio || 1;
¶ canvas.width = canvas.offsetWidth * ratio;
¶ canvas.height = canvas.offsetHeight * ratio;
¶ canvas.getContext(\"2d\").scale(ratio, ratio);
¶ };
¶
¶
¶ // Resize the canvas at startup.
¶ resizeCanvas();
¶
¶
¶ // Also resize the canvas if the window is resized.
¶ window.onresize = resizeCanvas;
¶
¶
¶ // Init the signature pad.
¶ var signaturePad = new SignaturePad(canvas, {
¶ backgroundColor: \"" & backgroundColor & "\",
¶ minWidth: " & minWidth & ",
¶ maxWidth: " & maxWidth & ",
¶ penColor: \"" & penColor & "\"
¶ });
¶
¶
¶
¶ // Clear button.
¶ var clearButton = document.getElementById(\"clear-button\");
¶ clearButton.addEventListener(\"click\", function (event) {
¶ signaturePad.clear();
¶ });
¶
¶
¶
¶ // Save button.
¶ var saveButton = document.getElementById(\"save-button\");
¶ saveButton.addEventListener(\"click\", function (event) {
¶
¶ // If the signature pad isn't empty...
¶ if (! signaturePad.isEmpty() ) {
¶
¶ // Convert the canvas into a data URL.
¶ var dataURL = signaturePad.toDataURL();
¶
¶ // Encode the data.
¶ var_encoded = encodeURIComponent ( dataURL );
// Prep the URL to use for the hand-off to FM.
¶ var fullURL = '" & fmpurl & "¶m=' + var_encoded;
¶
¶ // Send the data to FM.
¶ window.location = fullURL;
¶
¶ };
¶
¶ });
¶
¶ </script>
¶
¶ </body>
¶
¶</html>"
)
2)
Risultato della custom nel DB Originale B (funziona).
Codice: Seleziona tutto
data:text/html,<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>FM EasySignature v1.0</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<script type="text/javascript">
// Signature Pad v1.3.3 | https://github.com/szimek/signature_pad
// (c) 2014 Szymon Nowak | Released under the MIT license
var SignaturePad=function(a){"use strict";var b=function(a,b){var c=b||{};this.velocityFilterWeight=c.velocityFilterWeight||.7,this.minWidth=c.minWidth||.5,this.maxWidth=c.maxWidth||2.5,this.dotSize=c.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=c.penColor||"black",this.backgroundColor=c.backgroundColor||"rgba(0,0,0,0)",this.onEnd=c.onEnd,this.onBegin=c.onBegin,this._canvas=a,this._ctx=a.getContext("2d"),this.clear(),this._handleMouseEvents(),this._handleTouchEvents()};b.prototype.clear=function(){var a=this._ctx,b=this._canvas;a.fillStyle=this.backgroundColor,a.clearRect(0,0,b.width,b.height),a.fillRect(0,0,b.width,b.height),this._reset()},b.prototype.toDataURL=function(){var a=this._canvas;return a.toDataURL.apply(a,arguments)},b.prototype.fromDataURL=function(a){var b=this,c=new Image,d=window.devicePixelWidth||1,e=this._canvas.width/d,f=this._canvas.height/d;this._reset(),c.src=a,c.onload=function(){b._ctx.drawImage(c,0,0,e,f)},this._isEmpty=!1},b.prototype._strokeUpdate=function(a){var b=this._createPoint(a);this._addPoint(b)},b.prototype._strokeBegin=function(a){this._reset(),this._strokeUpdate(a),"function"==typeof this.onBegin&&this.onBegin(a)},b.prototype._strokeDraw=function(a){var b=this._ctx,c="function"==typeof this.dotSize?this.dotSize():this.dotSize;b.beginPath(),this._drawPoint(a.x,a.y,c),b.closePath(),b.fill()},b.prototype._strokeEnd=function(a){var b=this.points.length>2,c=this.points[0];!b&&c&&this._strokeDraw(c),"function"==typeof this.onEnd&&this.onEnd(a)},b.prototype._handleMouseEvents=function(){var b=this;this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",function(a){1===a.which&&(b._mouseButtonDown=!0,b._strokeBegin(a))}),this._canvas.addEventListener("mousemove",function(a){b._mouseButtonDown&&b._strokeUpdate(a)}),a.addEventListener("mouseup",function(a){1===a.which&&b._mouseButtonDown&&(b._mouseButtonDown=!1,b._strokeEnd(a))})},b.prototype._handleTouchEvents=function(){var b=this;this._canvas.style.msTouchAction="none",this._canvas.addEventListener("touchstart",function(a){var c=a.changedTouches[0];b._strokeBegin(c)}),this._canvas.addEventListener("touchmove",function(a){a.preventDefault();var c=a.changedTouches[0];b._strokeUpdate(c)}),a.addEventListener("touchend",function(a){var c=a.target===b._canvas;c&&b._strokeEnd(a)})},b.prototype.isEmpty=function(){return this._isEmpty},b.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._isEmpty=!0,this._ctx.fillStyle=this.penColor},b.prototype._createPoint=function(a){var b=this._canvas.getBoundingClientRect();return new c(a.clientX-b.left,a.clientY-b.top)},b.prototype._addPoint=function(a){var b,c,e,f,g=this.points;g.push(a),g.length>2&&(3===g.length&&g.unshift(g[0]),f=this._calculateCurveControlPoints(g[0],g[1],g[2]),b=f.c2,f=this._calculateCurveControlPoints(g[1],g[2],g[3]),c=f.c1,e=new d(g[1],b,c,g[2]),this._addCurve(e),g.shift())},b.prototype._calculateCurveControlPoints=function(a,b,d){var e=a.x-b.x,f=a.y-b.y,g=b.x-d.x,h=b.y-d.y,i={x:(a.x+b.x)/2,y:(a.y+b.y)/2},j={x:(b.x+d.x)/2,y:(b.y+d.y)/2},k=Math.sqrt(e*e+f*f),l=Math.sqrt(g*g+h*h),m=i.x-j.x,n=i.y-j.y,o=l/(k+l),p={x:j.x+m*o,y:j.y+n*o},q=b.x-p.x,r=b.y-p.y;return{c1:new c(i.x+q,i.y+r),c2:new c(j.x+q,j.y+r)}},b.prototype._addCurve=function(a){var b,c,d=a.startPoint,e=a.endPoint;b=e.velocityFrom(d),b=this.velocityFilterWeight*b+(1-this.velocityFilterWeight)*this._lastVelocity,c=this._strokeWidth(b),this._drawCurve(a,this._lastWidth,c),this._lastVelocity=b,this._lastWidth=c},b.prototype._drawPoint=function(a,b,c){var d=this._ctx;d.moveTo(a,b),d.arc(a,b,c,0,2*Math.PI,!1),this._isEmpty=!1},b.prototype._drawCurve=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o=this._ctx,p=c-b;for(d=Math.floor(a.length()),o.beginPath(),f=0;d>f;f++)g=f/d,h=g*g,i=h*g,j=1-g,k=j*j,l=k*j,m=l*a.startPoint.x,m+=3*k*g*a.control1.x,m+=3*j*h*a.control2.x,m+=i*a.endPoint.x,n=l*a.startPoint.y,n+=3*k*g*a.control1.y,n+=3*j*h*a.control2.y,n+=i*a.endPoint.y,e=b+i*p,this._drawPoint(m,n,e);o.closePath(),o.fill()},b.prototype._strokeWidth=function(a){return Math.max(this.maxWidth/(a+1),this.minWidth)};var c=function(a,b,c){this.x=a,this.y=b,this.time=c||(new Date).getTime()};c.prototype.velocityFrom=function(a){return this.time!==a.time?this.distanceTo(a)/(this.time-a.time):1},c.prototype.distanceTo=function(a){return Math.sqrt(Math.pow(this.x-a.x,2)+Math.pow(this.y-a.y,2))};var d=function(a,b,c,d){this.startPoint=a,this.control1=b,this.control2=c,this.endPoint=d};return d.prototype.length=function(){var a,b,c,d,e,f,g,h,i=10,j=0;for(a=0;i>=a;a++)b=a/i,c=this._point(b,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),d=this._point(b,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y),a>0&&(g=c-e,h=d-f,j+=Math.sqrt(g*g+h*h)),e=c,f=d;return j},d.prototype._point=function(a,b,c,d,e){return b*(1-a)*(1-a)*(1-a)+3*c*(1-a)*(1-a)*a+3*d*(1-a)*a*a+e*a*a*a},b}(document);
</script>
</head>
<body
onselectstart="return false"
style="
height:100%;
background: #fff;
margin: 0;
text-align: center;
font-family: Helvetica, Sans-Serif;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;">
<div style="height: 100vh; width: 100vw;">
<!-- Signature canvas. -->
<canvas
id="easycanvas"
style="
background : #fff;
width: 98%;
height: 70%;
border: solid thin #ccc;
border-radius: 8px;
margin: 3px;"></canvas>
<!-- Clear and Save buttons -->
<div style="text-align: center; font-size: 9pt;">
<button id="clear-button" data-action="clear" style="margin-right: 20px; font-size: 9pt; padding: 4px;">Clear</button>
Please sign above.
<button id="save-button" data-action="save" style="margin-left: 20px; font-size: 9pt; padding: 4px;">Save</button>
</div>
</div>
<script type="text/javascript">
// Get the canvas.
var canvas = document.getElementById("easycanvas");
// Adjust canvas coordinate space taking into account pixel ratio,
// to make it look crisp on mobile devices.
// This also causes canvas to be cleared.
function resizeCanvas() {
var ratio = window.devicePixelRatio || 1;
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext("2d").scale(ratio, ratio);
};
// Resize the canvas at startup.
resizeCanvas();
// Also resize the canvas if the window is resized.
window.onresize = resizeCanvas;
// Init the signature pad.
var signaturePad = new SignaturePad(canvas, {
backgroundColor: "rgb(255, 255, 255)",
minWidth: .5,
maxWidth: 2.5,
penColor: "rgb(0, 0, 255)"
});
// Clear button.
var clearButton = document.getElementById("clear-button");
clearButton.addEventListener("click", function (event) {
signaturePad.clear();
});
// Save button.
var saveButton = document.getElementById("save-button");
saveButton.addEventListener("click", function (event) {
// If the signature pad isn't empty...
if (! signaturePad.isEmpty() ) {
// Convert the canvas into a data URL.
var dataURL = signaturePad.toDataURL();
// Encode the data.
var_encoded = encodeURIComponent ( dataURL ); // Prep the URL to use for the hand-off to FM.
var fullURL = 'fmp://$/FMEasySignature - Mac & Windows.fmp12?script=FMP URL Handler - Save Signature to Container¶m=' + var_encoded;
// Send the data to FM.
window.location = fullURL;
};
});
</script>
</body>
</html>
3)
Risultato della custom nel mio DB (Non funziona).
Codice: Seleziona tutto
data:text/html,<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>FM EasySignature v1.0</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<script type="text/javascript">
// Signature Pad v1.3.3 | https://github.com/szimek/signature_pad
// (c) 2014 Szymon Nowak | Released under the MIT license
var SignaturePad=function(a){"use strict";var b=function(a,b){var c=b||{};this.velocityFilterWeight=c.velocityFilterWeight||.7,this.minWidth=c.minWidth||.5,this.maxWidth=c.maxWidth||2.5,this.dotSize=c.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=c.penColor||"black",this.backgroundColor=c.backgroundColor||"rgba(0,0,0,0)",this.onEnd=c.onEnd,this.onBegin=c.onBegin,this._canvas=a,this._ctx=a.getContext("2d"),this.clear(),this._handleMouseEvents(),this._handleTouchEvents()};b.prototype.clear=function(){var a=this._ctx,b=this._canvas;a.fillStyle=this.backgroundColor,a.clearRect(0,0,b.width,b.height),a.fillRect(0,0,b.width,b.height),this._reset()},b.prototype.toDataURL=function(){var a=this._canvas;return a.toDataURL.apply(a,arguments)},b.prototype.fromDataURL=function(a){var b=this,c=new Image,d=window.devicePixelWidth||1,e=this._canvas.width/d,f=this._canvas.height/d;this._reset(),c.src=a,c.onload=function(){b._ctx.drawImage(c,0,0,e,f)},this._isEmpty=!1},b.prototype._strokeUpdate=function(a){var b=this._createPoint(a);this._addPoint(b)},b.prototype._strokeBegin=function(a){this._reset(),this._strokeUpdate(a),"function"==typeof this.onBegin&&this.onBegin(a)},b.prototype._strokeDraw=function(a){var b=this._ctx,c="function"==typeof this.dotSize?this.dotSize():this.dotSize;b.beginPath(),this._drawPoint(a.x,a.y,c),b.closePath(),b.fill()},b.prototype._strokeEnd=function(a){var b=this.points.length>2,c=this.points[0];!b&&c&&this._strokeDraw(c),"function"==typeof this.onEnd&&this.onEnd(a)},b.prototype._handleMouseEvents=function(){var b=this;this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",function(a){1===a.which&&(b._mouseButtonDown=!0,b._strokeBegin(a))}),this._canvas.addEventListener("mousemove",function(a){b._mouseButtonDown&&b._strokeUpdate(a)}),a.addEventListener("mouseup",function(a){1===a.which&&b._mouseButtonDown&&(b._mouseButtonDown=!1,b._strokeEnd(a))})},b.prototype._handleTouchEvents=function(){var b=this;this._canvas.style.msTouchAction="none",this._canvas.addEventListener("touchstart",function(a){var c=a.changedTouches[0];b._strokeBegin(c)}),this._canvas.addEventListener("touchmove",function(a){a.preventDefault();var c=a.changedTouches[0];b._strokeUpdate(c)}),a.addEventListener("touchend",function(a){var c=a.target===b._canvas;c&&b._strokeEnd(a)})},b.prototype.isEmpty=function(){return this._isEmpty},b.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._isEmpty=!0,this._ctx.fillStyle=this.penColor},b.prototype._createPoint=function(a){var b=this._canvas.getBoundingClientRect();return new c(a.clientX-b.left,a.clientY-b.top)},b.prototype._addPoint=function(a){var b,c,e,f,g=this.points;g.push(a),g.length>2&&(3===g.length&&g.unshift(g[0]),f=this._calculateCurveControlPoints(g[0],g[1],g[2]),b=f.c2,f=this._calculateCurveControlPoints(g[1],g[2],g[3]),c=f.c1,e=new d(g[1],b,c,g[2]),this._addCurve(e),g.shift())},b.prototype._calculateCurveControlPoints=function(a,b,d){var e=a.x-b.x,f=a.y-b.y,g=b.x-d.x,h=b.y-d.y,i={x:(a.x+b.x)/2,y:(a.y+b.y)/2},j={x:(b.x+d.x)/2,y:(b.y+d.y)/2},k=Math.sqrt(e*e+f*f),l=Math.sqrt(g*g+h*h),m=i.x-j.x,n=i.y-j.y,o=l/(k+l),p={x:j.x+m*o,y:j.y+n*o},q=b.x-p.x,r=b.y-p.y;return{c1:new c(i.x+q,i.y+r),c2:new c(j.x+q,j.y+r)}},b.prototype._addCurve=function(a){var b,c,d=a.startPoint,e=a.endPoint;b=e.velocityFrom(d),b=this.velocityFilterWeight*b+(1-this.velocityFilterWeight)*this._lastVelocity,c=this._strokeWidth(b),this._drawCurve(a,this._lastWidth,c),this._lastVelocity=b,this._lastWidth=c},b.prototype._drawPoint=function(a,b,c){var d=this._ctx;d.moveTo(a,b),d.arc(a,b,c,0,2*Math.PI,!1),this._isEmpty=!1},b.prototype._drawCurve=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o=this._ctx,p=c-b;for(d=Math.floor(a.length()),o.beginPath(),f=0;d>f;f++)g=f/d,h=g*g,i=h*g,j=1-g,k=j*j,l=k*j,m=l*a.startPoint.x,m+=3*k*g*a.control1.x,m+=3*j*h*a.control2.x,m+=i*a.endPoint.x,n=l*a.startPoint.y,n+=3*k*g*a.control1.y,n+=3*j*h*a.control2.y,n+=i*a.endPoint.y,e=b+i*p,this._drawPoint(m,n,e);o.closePath(),o.fill()},b.prototype._strokeWidth=function(a){return Math.max(this.maxWidth/(a+1),this.minWidth)};var c=function(a,b,c){this.x=a,this.y=b,this.time=c||(new Date).getTime()};c.prototype.velocityFrom=function(a){return this.time!==a.time?this.distanceTo(a)/(this.time-a.time):1},c.prototype.distanceTo=function(a){return Math.sqrt(Math.pow(this.x-a.x,2)+Math.pow(this.y-a.y,2))};var d=function(a,b,c,d){this.startPoint=a,this.control1=b,this.control2=c,this.endPoint=d};return d.prototype.length=function(){var a,b,c,d,e,f,g,h,i=10,j=0;for(a=0;i>=a;a++)b=a/i,c=this._point(b,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),d=this._point(b,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y),a>0&&(g=c-e,h=d-f,j+=Math.sqrt(g*g+h*h)),e=c,f=d;return j},d.prototype._point=function(a,b,c,d,e){return b*(1-a)*(1-a)*(1-a)+3*c*(1-a)*(1-a)*a+3*d*(1-a)*a*a+e*a*a*a},b}(document);
</script>
</head>
<body
onselectstart="return false"
style="
height:100%;
background: #fff;
margin: 0;
text-align: center;
font-family: Helvetica, Sans-Serif;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;">
<div style="height: 100vh; width: 100vw;">
<!-- Signature canvas. -->
<canvas
id="easycanvas"
style="
background : #fff;
width: 98%;
height: 70%;
border: solid thin #ccc;
border-radius: 8px;
margin: 3px;"></canvas>
<!-- Clear and Save buttons -->
<div style="text-align: center; font-size: 9pt;">
<button id="clear-button" data-action="clear" style="margin-right: 20px; font-size: 9pt; padding: 4px;">Clear</button>
Please sign above.
<button id="save-button" data-action="save" style="margin-left: 20px; font-size: 9pt; padding: 4px;">Save</button>
</div>
</div>
<script type="text/javascript">
// Get the canvas.
var canvas = document.getElementById("easycanvas");
// Adjust canvas coordinate space taking into account pixel ratio,
// to make it look crisp on mobile devices.
// This also causes canvas to be cleared.
function resizeCanvas() {
var ratio = window.devicePixelRatio || 1;
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext("2d").scale(ratio, ratio);
};
// Resize the canvas at startup.
resizeCanvas();
// Also resize the canvas if the window is resized.
window.onresize = resizeCanvas;
// Init the signature pad.
var signaturePad = new SignaturePad(canvas, {
backgroundColor: "rgb(255, 255, 255)",
minWidth: ,5,
maxWidth: 2,5,
penColor: "rgb(0, 0, 255)"
});
// Clear button.
var clearButton = document.getElementById("clear-button");
clearButton.addEventListener("click", function (event) {
signaturePad.clear();
});
// Save button.
var saveButton = document.getElementById("save-button");
saveButton.addEventListener("click", function (event) {
// If the signature pad isn't empty...
if (! signaturePad.isEmpty() ) {
// Convert the canvas into a data URL.
var dataURL = signaturePad.toDataURL();
// Encode the data.
var_encoded = encodeURIComponent ( dataURL ); // Prep the URL to use for the hand-off to FM.
var fullURL = 'fmp://$/Studio Privato 2.4 (Script Veloce).fmp12?script=FMP URL Handler - Save Signature to Container¶m=' + var_encoded;
// Send the data to FM.
window.location = fullURL;
};
});
</script>
</body>
</html>