1
0
Fork 0
mirror of https://github.com/24eme/signaturepdf synced 2024-05-17 21:26:34 +02:00

Managing page history and title

This commit is contained in:
Vincent LAURENT 2022-03-26 23:10:06 +01:00
parent 61fc267e93
commit 253cc31d73

View file

@ -890,6 +890,7 @@ async function getPDFBlobFromCache(cacheUrl) {
}
async function uploadFromUrl(url) {
history.replaceState({}, '', '/signature');
var response = await fetch(url);
if(response.status != 200) {
return;
@ -909,8 +910,6 @@ async function uploadFromUrl(url) {
}
var pageUpload = async function() {
history.replaceState({}, "Signature de PDF", "/signature");
document.getElementById('input_pdf_upload').value = '';
document.getElementById('page-upload').classList.remove('d-none');
document.getElementById('page-signature').classList.add('d-none');
@ -927,13 +926,14 @@ var pageUpload = async function() {
let response = new Response(document.getElementById('input_pdf_upload').files[0], { "status" : 200, "statusText" : "OK" });
let urlPdf = '/pdf/'+filename;
await cache.put(urlPdf, response);
history.replaceState({}, "Signature de PDF", '/signature#'+filename);
history.pushState({}, '', '/signature#'+filename);
pageSignature(urlPdf)
});
}
var pageSignature = async function(url) {
let filename = url.replace('/pdf/', '');
document.title = filename + ' - ' + document.title;
document.getElementById('page-upload').classList.add('d-none');
document.getElementById('page-signature').classList.remove('d-none');
fabric.Textbox.prototype._wordJoiners = /[]/;
@ -951,7 +951,6 @@ var pageSignature = async function(url) {
});
let pdfBlob = await getPDFBlobFromCache(url);
let filename = url.replace('/pdf/', '');
if(!pdfBlob) {
document.location = '/signature';
return;
@ -976,8 +975,6 @@ var pageSignature = async function(url) {
pageUpload();
}
window.addEventListener('hashchange', function() {
//window.location.href = window.location.href;
window.location.reload();
})
//pageSignature(url);
})();