Added support for FQDNs in simpledemo.html
This commit is contained in:
parent
75e7d76d26
commit
cf0f5944ac
@ -530,8 +530,11 @@
|
|||||||
<script src='https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js'
|
<script src='https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js'
|
||||||
integrity='sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL' crossorigin='anonymous'></script>
|
integrity='sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL' crossorigin='anonymous'></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function isValidIP(ipaddress) {
|
function isValidIPorFQDN(address) {
|
||||||
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) {
|
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(address)) { // regex from https://www.w3resource.com/javascript/form/ip-address-validation.php
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (/^(?!:\/\/)(?!.{256,})(([a-z0-9][a-z0-9_-]*?\.)+?[a-z]{2,6}?)$/i.test(address)) { // regex from https://stackoverflow.com/questions/16463666/javascript-regex-to-match-fully-qualified-domain-name-without-protocol-optiona
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -774,7 +777,7 @@
|
|||||||
setInterval(updateStrings, 10000);
|
setInterval(updateStrings, 10000);
|
||||||
}
|
}
|
||||||
window.onload = function(e) {
|
window.onload = function(e) {
|
||||||
if (document.cookie == "" || !isValidIP(document.cookie)) {
|
if (document.cookie == "" || !isValidIPorFQDN(document.cookie)) {
|
||||||
var selectIPModal = new bootstrap.Modal(document.getElementById('selectIPAddressModal'), {});
|
var selectIPModal = new bootstrap.Modal(document.getElementById('selectIPAddressModal'), {});
|
||||||
selectIPModal.show();
|
selectIPModal.show();
|
||||||
|
|
||||||
@ -782,7 +785,7 @@
|
|||||||
|
|
||||||
function configButtonEventListener(hideModalOnSuccess) {
|
function configButtonEventListener(hideModalOnSuccess) {
|
||||||
var ipAddressEntered = document.getElementById('ipAdressInput').value;
|
var ipAddressEntered = document.getElementById('ipAdressInput').value;
|
||||||
if(isValidIP(ipAddressEntered)) {
|
if(isValidIPorFQDN(ipAddressEntered)) {
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
request.onreadystatechange = function() {
|
request.onreadystatechange = function() {
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
@ -811,7 +814,7 @@
|
|||||||
const ipAdressModalOkBtn = document.getElementById('ipAdressModalOkBtn');
|
const ipAdressModalOkBtn = document.getElementById('ipAdressModalOkBtn');
|
||||||
ipAdressModalOkBtn.addEventListener('click', () => { configButtonEventListener(true); });
|
ipAdressModalOkBtn.addEventListener('click', () => { configButtonEventListener(true); });
|
||||||
|
|
||||||
} else if (isValidIP(document.cookie)) setupSite();
|
} else if (isValidIPorFQDN(document.cookie)) setupSite();
|
||||||
} // end of onload function
|
} // end of onload function
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user