Remove inline js

This commit is contained in:
Igor Scheller 2023-12-06 21:10:00 +01:00 committed by xuwhite
parent b76144b23d
commit 5fccc7e421
4 changed files with 29 additions and 20 deletions

View File

@ -423,7 +423,10 @@ return [
'X-Content-Type-Options' => 'nosniff', 'X-Content-Type-Options' => 'nosniff',
'X-Frame-Options' => 'sameorigin', 'X-Frame-Options' => 'sameorigin',
'Referrer-Policy' => 'strict-origin-when-cross-origin', 'Referrer-Policy' => 'strict-origin-when-cross-origin',
'Content-Security-Policy' => 'default-src \'self\' \'unsafe-inline\' \'unsafe-eval\'; img-src \'self\' data:;', 'Content-Security-Policy' =>
'default-src \'self\'; '
. ' style-src \'self\' \'unsafe-inline\'; '
. 'img-src \'self\' data:;',
'X-XSS-Protection' => '1; mode=block', 'X-XSS-Protection' => '1; mode=block',
'Feature-Policy' => 'autoplay \'none\'', 'Feature-Policy' => 'autoplay \'none\'',
//'Strict-Transport-Security' => 'max-age=7776000', //'Strict-Transport-Security' => 'max-age=7776000',

View File

@ -0,0 +1,13 @@
import { ready } from './ready';
ready(() => {
[...document.getElementsByClassName('prevent-default')].forEach((element) => {
let preventDefault = (e) => {
e.preventDefault();
return false;
};
element.addEventListener('submit', preventDefault);
element.addEventListener('click', preventDefault);
});
});

View File

@ -3,3 +3,4 @@ window.bootstrap = require('bootstrap');
import './forms'; import './forms';
import './countdown'; import './countdown';
import './dashboard'; import './dashboard';
import './design';

View File

@ -19,7 +19,7 @@
{% set types_buttons=['link']|merge(types) %} {% set types_buttons=['link']|merge(types) %}
{% set shortsum='Lorem ipsum dolor…' %} {% set shortsum='Lorem ipsum dolor…' %}
{% set lipsum='Lorem ipsum dolor sit amet, consectetur adipisici elit…' %} {% set lipsum='Lorem ipsum dolor sit amet, consectetur adipisici elit…' %}
{% set linksum='Lorem ipsum! Dolor <a href="#" onclick="return false">link</a> amet, consectetur adipisici elit!' %} {% set linksum='Lorem ipsum! Dolor <a href="#" class="prevent-default">link</a> amet, consectetur adipisici elit!' %}
{% block content %} {% block content %}
<div class="col-12"> <div class="col-12">
@ -94,13 +94,13 @@
<h3>Navigation Tabs</h3> <h3>Navigation Tabs</h3>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" href="#" onclick="return false">Lorem</a> <a class="nav-link active prevent-default" href="#">Lorem</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#" onclick="return false">Ipsum</a> <a class="nav-link prevent-default" href="#">Ipsum</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#" onclick="return false">Dolor</a> <a class="nav-link prevent-default" href="#">Dolor</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -108,13 +108,13 @@
<h3>Navigation Pills</h3> <h3>Navigation Pills</h3>
<ul class="nav nav-pills flex-column"> <ul class="nav nav-pills flex-column">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" href="#" onclick="return false">Some</a> <a class="nav-link active prevent-default" href="#">Some</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#" onclick="return false">Test</a> <a class="nav-link prevent-default" href="#">Test</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#" onclick="return false">Menu</a> <a class="nav-link prevent-default" href="#">Menu</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -250,7 +250,7 @@
<h4 class="card-header bg-{{ type }}">{{ type|capitalize }}</h4> <h4 class="card-header bg-{{ type }}">{{ type|capitalize }}</h4>
<div class="card-body"> <div class="card-body">
<p class="card-text">{{ shortsum }}</p> <p class="card-text">{{ shortsum }}</p>
<p class="card-text"><a href="#" onclick="return false" class="card-link">Some link</a></p> <p class="card-text"><a href="#" class="card-link prevent-default">Some link</a></p>
</div> </div>
<div class="card-footer text-muted"> <div class="card-footer text-muted">
Footer Footer
@ -525,13 +525,13 @@ Por scientie, musica, sport etc, litot Europa usa li sam vocabular.</code></pre>
<h4>Pagination</h4> <h4>Pagination</h4>
<ul class="pagination"> <ul class="pagination">
<li class="page-item active"> <li class="page-item active">
<a class="page-link" href="#" onclick="return false">1</a> <a class="page-link prevent-default" href="#">1</a>
</li> </li>
<li class="page-item"> <li class="page-item">
<a class="page-link" href="#" onclick="return false">2</a> <a class="page-link prevent-default" href="#">2</a>
</li> </li>
<li class="page-item"> <li class="page-item">
<a class="page-link" href="#" onclick="return false">3</a> <a class="page-link prevent-default" href="#">3</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -594,12 +594,4 @@ Por scientie, musica, sport etc, litot Europa usa li sam vocabular.</code></pre>
{{ bar_chart | raw }} {{ bar_chart | raw }}
</div> </div>
</div> </div>
<script>
[...document.getElementsByClassName('prevent-default')].forEach((element) => {
element.addEventListener('submit', (e) => {
e.preventDefault();
return false;
});
})
</script>
{% endblock %} {% endblock %}