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) {
|
if ($passType === 0 || $passType === 1 || $passType === 2 || $passType === 3) {
|
||||||
echo '<form action="#" method="GET">';
|
echo '<form action="#" method="GET">';
|
||||||
// Password output
|
// 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 '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();">';
|
echo '<input type="button" value="Generate Password" onClick="window.location.reload();">';
|
||||||
|
|
||||||
// Pass type selector
|
// Pass type selector
|
||||||
@ -409,6 +409,8 @@ $rating = passwordTest_strength($final);
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
// Toggle the password description panel
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const panel = document.getElementById('info_panel');
|
const panel = document.getElementById('info_panel');
|
||||||
if (panel) {
|
if (panel) {
|
||||||
@ -423,8 +425,19 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function myFunction() {
|
// oggle the API help panel
|
||||||
const copyText = document.getElementById("myInput");
|
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();
|
copyText.select();
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
alert("Copied the text: " + copyText.value);
|
alert("Copied the text: " + copyText.value);
|
||||||
@ -446,27 +459,11 @@ if (elX && elY) {
|
|||||||
elY.onchange = limit;
|
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>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user