From 8d2aa68bc18c04c2b03cbdd01f008a89e4c8c1c6 Mon Sep 17 00:00:00 2001 From: Christian Kollmann Date: Tue, 7 Dec 2021 07:51:10 +0100 Subject: Unify HTML templates across test, main, basicConfig --- connector/src/main/webapp/css/basic.css | 4 --- connector/src/main/webapp/js/js_country.js | 42 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) delete mode 100644 connector/src/main/webapp/css/basic.css create mode 100644 connector/src/main/webapp/js/js_country.js (limited to 'connector/src/main/webapp') diff --git a/connector/src/main/webapp/css/basic.css b/connector/src/main/webapp/css/basic.css deleted file mode 100644 index 4bec163a..00000000 --- a/connector/src/main/webapp/css/basic.css +++ /dev/null @@ -1,4 +0,0 @@ -@charset "utf-8"; - .bgTrans { - background-color:transparent - } \ No newline at end of file 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