Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sankeer28 committed Feb 5, 2024
1 parent 5082e50 commit 86d4353
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<title>PDF Generator</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="navbar">
Expand Down
9 changes: 5 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

function generateRandomFilename() {
var result = 'math';
var numbers = '0123456789';
Expand All @@ -14,13 +13,13 @@ function generateRandomFilename() {
return result;
}


function generatePDF(numPDFs=1, batchSize=20) {
var operators = ['+', '-', '*', '/'];
var zip = new JSZip();
var progressMessage = document.getElementById('progress-message');

function generateBatch(startIndex, endIndex) {
var startTime = Date.now();
for (var i = startIndex; i < endIndex; i++) {
var doc = new jsPDF();
var answers = [];
Expand Down Expand Up @@ -58,8 +57,10 @@ function generatePDF(numPDFs=1, batchSize=20) {
doc.text((idx + 1) + ") " + answers[idx], 10 + (idx % 3) * 60, 20 + Math.floor((idx % 78) / 3) * 10);
}
zip.file(generateRandomFilename() + '.pdf', doc.output('blob'));
progressMessage.textContent = 'Generated ' + (i + 1) + '/' + numPDFs + ' PDFs';
}
var endTime = Date.now();
var timeTaken = (endTime - startTime) / 1000;
progressMessage.textContent = 'Generated ' + numPDFs + ' PDFs';
}

var numBatches = Math.ceil(numPDFs / batchSize);
Expand All @@ -76,4 +77,4 @@ document.getElementById('generateButton').addEventListener('click', function(eve
event.preventDefault();
progressMessage.textContent = 'Starting PDF generation...';
generatePDF(100, 20);
});
});
14 changes: 14 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,17 @@ button:hover {
90% { transform: translate(1px, 2px) rotate(0deg); }
100% { transform: translate(1px, -2px) rotate(-1deg); }
}


.container {
width: 80%;
padding: 20px;
}


@media only screen and (max-width: 600px) {
.container {
width: 100%;
padding: 10px;
}
}

0 comments on commit 86d4353

Please sign in to comment.