Skip to content

Commit

Permalink
✨ Support auto extract and auto generate
Browse files Browse the repository at this point in the history
New checkboxes allow to define to do this automatically after
the required step finishes.

Should help with batching.

Work towards #8
  • Loading branch information
foosel committed May 14, 2024
1 parent 6f6201d commit 0766559
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions assets/cardfoldr.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,10 @@ const onPdfChange = async (event) => {

document.getElementById('file').addEventListener('change', async (event) => {
await onPdfChange(event);

if (document.getElementById("autoExtract").checked) {
document.getElementById('extractCards').click();
}
});

const onBackgroundPdfChange = async (event) => {
Expand Down Expand Up @@ -891,6 +895,10 @@ document.getElementById('refresh').addEventListener('click', async () => {
clearCards();
clearOutput();
await refresh();

if (document.getElementById("autoExtract").checked) {
document.getElementById('extractCards').click();
}
});

document.getElementById('extractCards').addEventListener('click', async () => {
Expand Down Expand Up @@ -930,6 +938,10 @@ document.getElementById('extractCards').addEventListener('click', async () => {
await extractCards();
document.getElementById('generate').disabled = false;
document.getElementById("extractCards").getElementsByClassName("fa")[0].classList = "fa fa-gear";

if (document.getElementById("autoGenerate").checked) {
document.getElementById('generate').click();
}
}, 100);
});

Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ <h2>Step 3: Extract Cards</h2>
</div>

<div class="pure-controls">
<button id="extractCards" class="pure-button pure-button-primary"><i class="fa fa-gear"></i> Extract Cards</button>
<button id="extractCards" class="pure-button pure-button-primary"><i class="fa fa-gear"></i> Extract Cards</button> <input type="checkbox" id="autoExtract" /> <label for="autoExtract">Auto extract</label>
</div>
</form>

Expand Down Expand Up @@ -266,7 +266,7 @@ <h2>Step 4: Generate PDF</h2>
<div class="pure-controls">
<button id="generate" class="pure-button pure-button-primary" disabled>
<i class="fa fa-flag-checkered"></i> Generate PDF
</button>
</button> <input type="checkbox" id="autoGenerate" /> <label for="autoGenerate">Auto generate</label>
</div>
</form>

Expand Down

0 comments on commit 0766559

Please sign in to comment.