Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kompoth committed Apr 1, 2024
1 parent f22ab6a commit c1e3936
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
34 changes: 21 additions & 13 deletions static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ function updateImageList () {
});
}

function requestPDF() {
async function requestPDF() {
document.getElementById("print-button").disabled = true;

const requestBody = {
config: {
bg: "bashcorpo_v5_pale",
Expand All @@ -36,18 +38,24 @@ function requestPDF() {
},
body: document.getElementById("issue-body-textarea").value
}
fetch("/api/issue", {
method: "POST",
headers: {
"Content-Type": "application/json",
"accept": "application/json"
},
body: JSON.stringify(requestBody)
}).then((resp) => {

try {
const resp = await fetch("/api/issue", {
method: "POST",
headers: {
"Content-Type": "application/json",
"accept": "application/json"
},
body: JSON.stringify(requestBody)
});

if (resp.ok) {
resp.blob().then(blob => window.open(URL.createObjectURL(blob)));
} else {
resp.json().then(data => alert("Printing press says: " + data.detail[0].msg));
/* If everything is ok, open recieved PDF */
resp.blob().then(blob => window.open(URL.createObjectURL(blob)));
}
});
} catch {
console.error("Failed to get PDF");
}

document.getElementById("print-button").disabled = false;
}
8 changes: 4 additions & 4 deletions static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ header p {
#issue-body-textarea:focus {
border: 2px solid var(--fg);
}


/* File loading button */
input[type=file]::file-selector-button {
background-color: transparent;
color: var(--fg);
Expand All @@ -57,11 +58,10 @@ input[type=file]::file-selector-button {
border: 1px solid var(--fg);
cursor: pointer;
}

input[type=file]:disabled::file-selector-button {
opacity: 0.5;
border-style: dashed; /* 1 */
cursor: not-allowed; /* 2 */
border-style: dashed;
cursor: not-allowed;
text-decoration: line-through;
}
form input[type=file] {
Expand Down

0 comments on commit c1e3936

Please sign in to comment.