tidying up javascript
This commit is contained in:
@ -304,9 +304,9 @@ $rating = passwordTest_strength($final);
|
||||
if ($passType === 0 || $passType === 1 || $passType === 2 || $passType === 3) {
|
||||
echo '<form action="#" method="GET">';
|
||||
// Password output
|
||||
echo '<input type="text" onClick="this.select();" style="font-size:20pt;border:none;" value="' . htmlspecialchars($final) . '" id="myInput"><br><p>';
|
||||
echo '<input type="text" onClick="this.select();" style="font-size:20pt;border:none;" value="' . htmlspecialchars($final) . '" id="result_password"><br><p>';
|
||||
echo 'Your password strength is: ' . $rating . '<br><p>';
|
||||
echo '<button onclick="myFunction()">Copy text</button>';
|
||||
echo '<button onclick="copyPassword()">Copy text</button>';
|
||||
echo '<input type="button" value="Generate Password" onClick="window.location.reload();">';
|
||||
|
||||
// Pass type selector
|
||||
@ -409,6 +409,8 @@ $rating = passwordTest_strength($final);
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
// Toggle the password description panel
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const panel = document.getElementById('info_panel');
|
||||
if (panel) {
|
||||
@ -423,8 +425,19 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
}
|
||||
});
|
||||
|
||||
function myFunction() {
|
||||
const copyText = document.getElementById("myInput");
|
||||
// oggle the API help panel
|
||||
document.getElementById('helpToggle').addEventListener('click', function () {
|
||||
const help = document.getElementById('helpText');
|
||||
if (help.style.display === 'none' || help.style.display === '') {
|
||||
help.style.display = 'block';
|
||||
} else {
|
||||
help.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Does what it says on the tin
|
||||
function copyPassword() {
|
||||
const copyText = document.getElementById("result_password");
|
||||
copyText.select();
|
||||
document.execCommand("copy");
|
||||
alert("Copied the text: " + copyText.value);
|
||||
@ -446,27 +459,11 @@ if (elX && elY) {
|
||||
elY.onchange = limit;
|
||||
}
|
||||
|
||||
// helper to sync range to number input (already done in form via oninput)
|
||||
// but keep for safety
|
||||
function updateTextInput1(val) { document.getElementById('wMin').value = val; }
|
||||
function updateTextInput2(val) { document.getElementById('wMax').value = val; }
|
||||
function updateTextInput3(val) { document.getElementById('wCount').value = val; }
|
||||
function updateTextInput4(val) { document.getElementById('sChar').value = val; }
|
||||
function updateTextInput5(val) { document.getElementById('numLen').value = val; }
|
||||
|
||||
//Toggle the help text when the link is clicked
|
||||
document.getElementById('helpToggle').addEventListener('click', function () {
|
||||
const help = document.getElementById('helpText');
|
||||
if (help.style.display === 'none' || help.style.display === '') {
|
||||
help.style.display = 'block';
|
||||
} else {
|
||||
help.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
ob_end_flush();
|
||||
?>
|
||||
Reference in New Issue
Block a user