diff options
author | Thomas <> | 2022-05-13 08:59:16 +0200 |
---|---|---|
committer | Thomas <> | 2022-05-13 08:59:16 +0200 |
commit | a11517f4d25f31e352a9665392ad000dff4a44c5 (patch) | |
tree | d9bbd0b09c68b0d86bd43ae5ccb5b277fd9c3fd3 /connector/src/main/webapp/js/js_country.js | |
parent | 9e3b78d931d220e1ed5ecbaadcb13df7cbe96e22 (diff) | |
parent | e412bda31b304821c08d8f8c7b2473d67246dba0 (diff) | |
download | National_eIDAS_Gateway-a11517f4d25f31e352a9665392ad000dff4a44c5.tar.gz National_eIDAS_Gateway-a11517f4d25f31e352a9665392ad000dff4a44c5.tar.bz2 National_eIDAS_Gateway-a11517f4d25f31e352a9665392ad000dff4a44c5.zip |
Merge branch 'nightlybuild' into feature/ms_proxy_before_refactoring
# Conflicts:
# basicConfig/templates/error_message.html
# connector/src/main/resources/specific_eIDAS_connector.beans.xml
# connector/src/test/resources/config/junit_config_1_springboot.properties
# connector/src/test/resources/config/junit_config_2_springboot.properties
# connector/src/test/resources/config/templates/countrySelection.html
# modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java
# modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java
# modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateAuthnRequestTask.java
# pom.xml
Diffstat (limited to 'connector/src/main/webapp/js/js_country.js')
-rw-r--r-- | connector/src/main/webapp/js/js_country.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/connector/src/main/webapp/js/js_country.js b/connector/src/main/webapp/js/js_country.js new file mode 100644 index 00000000..5dcea90e --- /dev/null +++ b/connector/src/main/webapp/js/js_country.js @@ -0,0 +1,42 @@ +function clickCountryFlag(element) { + if (!element) return false; + + var form = element.target.closest("form"); + + if (!form) return false; + + form.submit(); + return false; +} + + +/* Set JS events by EventListener to prevent problems with CSP*/ +document.addEventListener("DOMContentLoaded", function(event) { + + /* Element.closest polyfill - https://developer.mozilla.org/en-US/docs/Web/API/Element/closest License: public domain*/ + if (!Element.prototype.matches) + Element.prototype.matches = Element.prototype.msMatchesSelector || + Element.prototype.webkitMatchesSelector; + + if (!Element.prototype.closest) + Element.prototype.closest = function(s) { + var el = this; + if (!document.documentElement.contains(el)) return null; + do { + if (el.matches(s)) return el; + el = el.parentElement || el.parentNode; + } while (el !== null && el.nodeType === 1); + return null; + }; + + /* set Click events by EventListener to prevent JavaScript in HTML which can be a problem with CSP*/ + var allFlags = document.getElementsByClassName("countryimage"); + for (i=0;i<allFlags.length;i++) { + if(allFlags[i].getAttribute("disabled") == null) { + allFlags[i].closest("a").addEventListener('click', clickCountryFlag, false); + } + } +}); + + + |