Skip to content

Commit

Permalink
Merge pull request #28 from tvdijen/feature/no-unsafe-inline
Browse files Browse the repository at this point in the history
Offload inline javascript to file
  • Loading branch information
oharsta authored Dec 11, 2024
2 parents 2955cc0 + 59a224a commit 322fcb0
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 47 deletions.
5 changes: 5 additions & 0 deletions src/main/resources/public/lang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function switchLang(lang) {
const searchParams = new URLSearchParams(window.location.search);
searchParams.set("lang", lang);
window.location.search = searchParams.toString();
}
6 changes: 6 additions & 0 deletions src/main/resources/public/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
window.handleState = function handleState() {
if (document.readyState === 'interactive' || document.readyState === "complete") {
document.forms[0].submit();
}
};
document.onreadystatechange = window.handleState;
12 changes: 2 additions & 10 deletions src/main/resources/templates/consent.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,5 @@ <h1 th:text="#{footerTitle}"></h1>
</div>
</div>
</body>
<script>

function switchLang(lang) {
const searchParams = new URLSearchParams(window.location.search);
searchParams.set("lang", lang);
window.location.search = searchParams.toString();
}

</script>
</html>
<script th:src="@{/lang.js}"></script>
</html>
12 changes: 2 additions & 10 deletions src/main/resources/templates/device_continue.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,5 @@ <h1 th:text="#{authenticated}"></h1>

</div>
</body>
<script>

function switchLang(lang) {
const searchParams = new URLSearchParams(window.location.search);
searchParams.set("lang", lang);
window.location.search = searchParams.toString();
}

</script>
</html>
<script th:src="@{/lang.js}"></script>
</html>
12 changes: 2 additions & 10 deletions src/main/resources/templates/device_error.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,5 @@ <h1 th:text="#{notAuthenticated}"></h1>

</div>
</body>
<script>

function switchLang(lang) {
const searchParams = new URLSearchParams(window.location.search);
searchParams.set("lang", lang);
window.location.search = searchParams.toString();
}

</script>
</html>
<script th:src="@{/lang.js}"></script>
</html>
5 changes: 3 additions & 2 deletions src/main/resources/templates/form_post.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html xmlns:th="http://www.thymeleaf.org">
<head><title>Submit This Form</title></head>
<body onload="javascript:document.forms[0].submit()" enctype="application/x-www-form-urlencoded">
<body enctype="application/x-www-form-urlencoded">
<form method="post" th:action="${redirect_uri}">
<input th:if="${access_token != null}" type="hidden" name="access_token" th:value="${access_token}"/>
<input th:if="${code != null}" type="hidden" name="code" th:value="${code}"/>
Expand All @@ -10,4 +10,5 @@
<input th:if="${error_description != null}" type="hidden" name="error_description" th:value="${error_description}"/>
</form>
</body>
</html>
<script th:src="@{/post.js}"></script>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/no_session_found.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ <h1 class="error-title__heading">Error - No session found</h1>



<script src="/application.min.js" type="text/javascript"></script>
<script src="/application.min.js"></script>



</body></html>
</body></html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/no_session_found_nl.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ <h1 class="error-title__heading">Fout - Geen sessie gevonden</h1>



<script src="/application.min.js" type="text/javascript"></script>
<script src="/application.min.js"></script>



</body></html>
</body></html>
14 changes: 3 additions & 11 deletions src/main/resources/templates/verify.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ <h1 th:text="#{footerTitle}"></h1>
</div>
</div>
</body>
<script th:src="@{/main.js}" type="text/javascript"></script>
<script>

function switchLang(lang) {
const searchParams = new URLSearchParams(window.location.search);
searchParams.set("lang", lang);
window.location.search = searchParams.toString();
}

</script>
</html>
<script th:src="@{/main.js}"></script>
<script th:src="@{/lang.js}"></script>
</html>

0 comments on commit 322fcb0

Please sign in to comment.