Adds requested changes
This commit is contained in:
parent
9a3bc839dd
commit
53a0291cc2
2 changed files with 17 additions and 9 deletions
|
@ -6,7 +6,6 @@ class PdfContainer {
|
||||||
downloadLink;
|
downloadLink;
|
||||||
|
|
||||||
constructor(id, wrapperId, pdfAdapters) {
|
constructor(id, wrapperId, pdfAdapters) {
|
||||||
this.fileName = null;
|
|
||||||
this.pagesContainer = document.getElementById(id)
|
this.pagesContainer = document.getElementById(id)
|
||||||
this.pagesContainerWrapper = document.getElementById(wrapperId);
|
this.pagesContainerWrapper = document.getElementById(wrapperId);
|
||||||
this.downloadLink = null;
|
this.downloadLink = null;
|
||||||
|
@ -34,13 +33,11 @@ class PdfContainer {
|
||||||
window.rotateAll = this.rotateAll;
|
window.rotateAll = this.rotateAll;
|
||||||
|
|
||||||
const filenameInput = document.getElementById('filename-input');
|
const filenameInput = document.getElementById('filename-input');
|
||||||
const filenameParagraph = document.getElementById('filename');
|
|
||||||
const downloadBtn = document.getElementById('export-button');
|
const downloadBtn = document.getElementById('export-button');
|
||||||
|
|
||||||
filenameInput.onkeyup = this.updateFilename;
|
filenameInput.onkeyup = this.updateFilename;
|
||||||
filenameInput.disabled = true;
|
filenameInput.disabled = true;
|
||||||
filenameInput.innerText = "";
|
filenameInput.innerText = "";
|
||||||
filenameParagraph.innerText = "";
|
|
||||||
downloadBtn.disabled = true;
|
downloadBtn.disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +80,18 @@ class PdfContainer {
|
||||||
|
|
||||||
if (pagesContainer.childElementCount === 0) {
|
if (pagesContainer.childElementCount === 0) {
|
||||||
filenameInput.value = "";
|
filenameInput.value = "";
|
||||||
|
this.filename = null;
|
||||||
downloadBtn.disabled = true;
|
downloadBtn.disabled = true;
|
||||||
|
} else {
|
||||||
|
this.filename = filenameInput.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.filename === null || this.filename === undefined) {
|
||||||
|
filenameInput.value = files[0].name;
|
||||||
|
} else {
|
||||||
|
filenameInput.value = this.filename;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addPdfsFromFiles(files, nextSiblingElement);
|
this.addPdfsFromFiles(files, nextSiblingElement);
|
||||||
|
@ -219,6 +226,12 @@ class PdfContainer {
|
||||||
const url = URL.createObjectURL(pdfBlob);
|
const url = URL.createObjectURL(pdfBlob);
|
||||||
const downloadOption = localStorage.getItem('downloadOption');
|
const downloadOption = localStorage.getItem('downloadOption');
|
||||||
|
|
||||||
|
const filenameInput = document.getElementById('filename-input');
|
||||||
|
|
||||||
|
if (!filenameInput.value.includes('.pdf')) {
|
||||||
|
filenameInput.value = filenameInput.value + '.pdf';
|
||||||
|
}
|
||||||
|
|
||||||
if (downloadOption === 'sameWindow') {
|
if (downloadOption === 'sameWindow') {
|
||||||
// Open the file in the same window
|
// Open the file in the same window
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
|
@ -245,11 +258,9 @@ class PdfContainer {
|
||||||
|
|
||||||
updateFilename() {
|
updateFilename() {
|
||||||
const filenameInput = document.getElementById('filename-input');
|
const filenameInput = document.getElementById('filename-input');
|
||||||
const filenameParagraph = document.getElementById('filename');
|
|
||||||
const downloadBtn = document.getElementById('export-button');
|
const downloadBtn = document.getElementById('export-button');
|
||||||
|
|
||||||
if (filenameInput.value === "") {
|
if (filenameInput.value === "") {
|
||||||
filenameParagraph.innerText = "";
|
|
||||||
downloadBtn.disabled = true;
|
downloadBtn.disabled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,7 @@
|
||||||
<div id="global-buttons-container" class="d-flex align-content-center justify-content-center">
|
<div id="global-buttons-container" class="d-flex align-content-center justify-content-center">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="filename-input">Filename</label>
|
<label for="filename-input">Filename</label>
|
||||||
<input type="text" class="form-control" id="filename-input" placeholder="filename" onkeyup="updateFilename()">
|
<input type="text" class="form-control" id="filename-input" placeholder="filename" >
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<p>Final name of file: </p><p id="filename"></p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="global-buttons-container">
|
<div id="global-buttons-container">
|
||||||
|
|
Loading…
Reference in a new issue