Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ <h4 id="how">How To Use:</h4>
<div id="random-password"></div>
</div>
<button class="copy button" type ="button" onClick="copyToClip()"> Copy to Clipboard </button>
<button class="download button" type="button" onClick="downloadPassword()">
Download Password
</button>
</div>

<div id="password-strength-container">
<div class="input-container">
<input type="password" id="password-test" placeholder="Type password here"><span id="password-toggle">show</span>
Expand All @@ -77,4 +81,6 @@ <h4 id="how">How To Use:</h4>
</div>
</body>
<script src="index.js"></script>
<!-- parallax/jsPDF -->
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js"></script>
</html>
23 changes: 23 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,26 @@ passwordToggle.onclick = function() {
//function strengthenPassword() {
// var value = passwordTest.value.trim();
//}


// use of jsPDF to generate a .pdf file with the
// generated password
function downloadPassword() {
window.jsPDF = window.jspdf.jsPDF;
var generatedPass = document.getElementById("random-password").innerHTML;
var pdfGenerator = new jsPDF();

if (generatedPass === "" || generatedPass === undefined) {
alert("Please Generate a Password!");
} else {
try {
pdfGenerator.setFontSize(12);
pdfGenerator.text("The generated password is:", 20, 20);
pdfGenerator.setFont("undefined", "bold");
pdfGenerator.text(generatedPass, 20, 30);
pdfGenerator.save("password.pdf");
} catch (err) {
alert("AN ERROR OCCURRED!");
}
}
}
8 changes: 8 additions & 0 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,11 @@ input[type="number"] {
width: 100%;
}
}

.button.download {
background-color: powderblue;
color: black;
}
.button.download:hover {
background-color: #b6e4eb;
}