summaryrefslogtreecommitdiffstats
path: root/_includes/cig_password.html
diff options
context:
space:
mode:
authorSimone <26844016+simonebortolin@users.noreply.github.com>2022-12-30 17:54:00 +0100
committerGitHub <noreply@github.com>2022-12-30 17:54:00 +0100
commit9b16504485a14b477aa00ae33a43d91e7e4ce9e6 (patch)
tree5e1d9aba2b5e70055ed96daba87786d80cc6085e /_includes/cig_password.html
parentHot fix pages.yml (#74) (diff)
downloadhack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar.gz
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar.bz2
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar.lz
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar.xz
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar.zst
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.zip
Diffstat (limited to '_includes/cig_password.html')
-rw-r--r--_includes/cig_password.html30
1 files changed, 19 insertions, 11 deletions
diff --git a/_includes/cig_password.html b/_includes/cig_password.html
index 5118a5c..e3be28b 100644
--- a/_includes/cig_password.html
+++ b/_includes/cig_password.html
@@ -1,32 +1,40 @@
<div>
- <form id="cig-password">
+ <form id="cig-password" novalidate>
<div class="form-floating mb-3">
<input type="text" class="form-control" placeholder="Serial Number" name="serial" id="serial" required pattern="[A-Z]{4}[0-9a-z]{8}">
- <label for="serial">GPON S/N in format GPONabc12345</label>
+ <label for="serial" class="form-label">GPON S/N in format GPONabc12345</label>
+ <div class="invalid-feedback">
+ Please provide a valid GPON S/N.
+ </div>
</div>
<div class="mb-3">
<input type="submit" class="btn btn-primary" value="Generate!" id="submit">
- <label for="submit">Warning: this script is hosted on a third-party server.</label>
+ <label for="submit" class="form-label">Warning: this script is hosted on a third-party server.</label>
</div>
<div class="form-floating mb-3">
<input readonly type="text" class="form-control" placeholder="Serial Number" name="username" id="username" value="{{include.username}}">
- <label for="username">Username</label>
+ <label for="username" class="form-label">Username</label>
</div>
<div class="form-floating mb-3">
<input readonly class="form-control" type="text" id="result" placeholder="Result">
- <label for="result">Password</label>
+ <label for="result" class="form-label">Password</label>
</div>
</form>
<script>
var cigPassword = document.getElementById('cig-password');
cigPassword.addEventListener('submit', (event) => {
event.preventDefault();
- const data = new URLSearchParams(new FormData(cigPassword));
- var url = new URL("https://cigpassword.ml/");
- url.search = data.toString();
- fetch(url, {mode: 'cors'}).then(response => response.json()).then(json => document.getElementById('result').value = json.password).catch((error) => {
- document.getElementById('result').value = "Error!"
- });
+ if (!cigPassword.checkValidity()) {
+ event.preventDefault();
+ } else {
+ const data = new URLSearchParams(new FormData(cigPassword));
+ var url = new URL("https://cigpassword.ml/");
+ url.search = data.toString();
+ fetch(url, {mode: 'cors'}).then(response => response.json()).then(json => document.getElementById('result').value = json.password).catch((error) => {
+ document.getElementById('result').value = "Error!"
+ });
+ }
+ [...cigPassword.elements].map(e => e.parentNode).forEach(e => e.classList.toggle('was-validated', true));
});
</script>
</div> \ No newline at end of file