Skip to content

Commit

Permalink
nullcheck fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Frooodle committed Feb 11, 2023
1 parent 54e1ced commit b40d324
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/resources/templates/security/change-metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ <h3 th:text="#{changeMetadata.selectText.4}"></h3>
var lastPDFFileMeta = null;
fileInput.addEventListener("change", async function() {



while (otherMetadataEntriesDiv.firstChild) {
otherMetadataEntriesDiv.removeChild(otherMetadataEntriesDiv.firstChild);
}
Expand All @@ -148,6 +150,12 @@ <h3 th:text="#{changeMetadata.selectText.4}"></h3>
const pdfMetadata = await pdf.getMetadata();
lastPDFFile = pdfMetadata?.info
console.log(pdfMetadata);
if(!pdfMetadata?.info?.Custom || pdfMetadata?.info?.Custom.size == 0) {
customModeCheckbox.disabled = true;
customModeCheckbox.checked = false;
} else {
customModeCheckbox.disabled = false;
}
authorInput.value = pdfMetadata?.info?.Author;
creationDateInput.value = convertDateFormat(pdfMetadata?.info?.CreationDate);
creatorInput.value = pdfMetadata?.info?.Creator;
Expand All @@ -171,15 +179,16 @@ <h3 th:text="#{changeMetadata.selectText.4}"></h3>
});

addMetadataBtn.addEventListener("click", () => {

const keyInput = document.createElement("input");
keyInput.type = "text";
keyInput.placeholder = "Key";
keyInput.placeholder = 'Key';
keyInput.className = "form-control";
keyInput.name = "customKey" + count;

const valueInput = document.createElement("input");
valueInput.type = "text";
valueInput.placeholder = "Value";
valueInput.placeholder = 'Value';
valueInput.className = "form-control";
valueInput.name = "customValue" + count;
count = count + 1;
Expand Down Expand Up @@ -211,7 +220,7 @@ <h3 th:text="#{changeMetadata.selectText.4}"></h3>
const event = document.getElementById("customModeCheckbox");


if (event.checked && lastPDFFile?.Custom) {
if (event.checked && lastPDFFile.Custom != null) {
customMetadataDiv.style.display = 'block';
for (const [key, value] of Object.entries(lastPDFFile.Custom)) {
if (key === 'Author' || key === 'CreationDate' || key === 'Creator' || key === 'Keywords' || key === 'ModDate' || key === 'Producer' || key === 'Subject' || key === 'Title' || key === 'Trapped') {
Expand Down

0 comments on commit b40d324

Please sign in to comment.