From b6dad1dcf50a4eae3be746ce1062d8fd5307a8a7 Mon Sep 17 00:00:00 2001 From: Vincent LAURENT Date: Thu, 31 Mar 2022 11:53:55 +0200 Subject: [PATCH] Loading pdf from hash --- public/js/signature.js | 15 ++++++++++++++- templates/signature.html.php | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/public/js/signature.js b/public/js/signature.js index 262ee0e..d5fccb6 100644 --- a/public/js/signature.js +++ b/public/js/signature.js @@ -947,7 +947,15 @@ var pageSignature = async function(url) { fontCaveat = font; }); - let pdfBlob = await getPDFBlobFromCache(url); + if(hash) { + var response = await fetch(url); + if(response.status != 200) { + return; + } + let pdfBlob = await response.blob(); + } else { + let pdfBlob = await getPDFBlobFromCache(url); + } if(!pdfBlob) { document.location = '/signature'; return; @@ -962,6 +970,11 @@ var pageSignature = async function(url) { }; (function () { + if(hash) { + pageSignature('/signature/'+hash+'/pdf'); + return; + } + if(window.location.hash && window.location.hash.match(/^\#http/)) { let hashUrl = window.location.hash.replace(/^\#/, ''); pageUpload(); diff --git a/templates/signature.html.php b/templates/signature.html.php index 488fd17..b8d61a0 100644 --- a/templates/signature.html.php +++ b/templates/signature.html.php @@ -157,6 +157,10 @@